summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--host/rootfs/Makefile12
-rw-r--r--img/app/Makefile12
-rwxr-xr-xscripts/make-erofs.sh42
-rw-r--r--vm-lib/make-vm.nix10
-rw-r--r--vm/sys/net/Makefile12
5 files changed, 38 insertions, 50 deletions
diff --git a/host/rootfs/Makefile b/host/rootfs/Makefile
index c5e467d..c6bd3be 100644
--- a/host/rootfs/Makefile
+++ b/host/rootfs/Makefile
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: EUPL-1.2+
-# SPDX-FileCopyrightText: 2021-2023 Alyssa Ross <hi@alyssa.is>
+# SPDX-FileCopyrightText: 2021-2024 Alyssa Ross <hi@alyssa.is>
 
 include ../../lib/common.mk
 
@@ -76,10 +76,12 @@ LINKS = \
 BUILD_FILES = build/etc/mdev/modalias.sh build/etc/s6-rc
 
 $(dest): ../../scripts/make-erofs.sh $(FILES) $(BUILD_FILES) build/empty
-	../../scripts/make-erofs.sh -- $@ $(PACKAGES) \
-	    $$(for file in $(FILES) $(LINKS); do printf '%s %s ' $$file $$file; done) \
-	    $$(for file in $(BUILD_FILES); do printf '%s %s ' $$file $${file#build/}; done) \
-	    $$(printf 'build/empty %s ' $(DIRS))
+	( \
+	    printf '%s\n' $(PACKAGES) ;\
+	    for file in $(FILES) $(LINKS); do printf '%s\n%s\n' $$file $$file; done ;\
+	    for file in $(BUILD_FILES); do printf '%s\n%s\n' $$file $${file#build/}; done ;\
+	    printf 'build/empty\n%s\n' $(DIRS) ;\
+	) | ../../scripts/make-erofs.sh $@
 
 build/empty:
 	mkdir -p $@
diff --git a/img/app/Makefile b/img/app/Makefile
index 95212b8..78f1a00 100644
--- a/img/app/Makefile
+++ b/img/app/Makefile
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: EUPL-1.2+
-# SPDX-FileCopyrightText: 2021-2023 Alyssa Ross <hi@alyssa.is>
+# SPDX-FileCopyrightText: 2021-2024 Alyssa Ross <hi@alyssa.is>
 # SPDX-FileCopyrightText: 2022 Unikie
 
 include ../../lib/common.mk
@@ -52,10 +52,12 @@ build/empty:
 	mkdir -p $@
 
 build/rootfs.erofs: ../../scripts/make-erofs.sh $(VM_FILES) $(VM_BUILD_FILES) build/empty
-	../../scripts/make-erofs.sh -- $@ $(PACKAGES) \
-	    $$(for file in $(VM_FILES) $(VM_LINKS); do printf '%s %s ' $$file $$file; done) \
-	    $$(for file in $(VM_BUILD_FILES); do printf '%s %s ' $$file $${file#build/}; done) \
-	    $$(printf 'build/empty %s ' $(VM_DIRS))
+	( \
+	    printf '%s\n' $(PACKAGES) ;\
+	    for file in $(VM_FILES) $(VM_LINKS); do printf '%s\n%s\n' $$file $$file; done ;\
+	    for file in $(VM_BUILD_FILES); do printf '%s\n%s\n' $$file $${file#build/}; done ;\
+	    printf 'build/empty\n%s\n' $(VM_DIRS) ;\
+	) | ../../scripts/make-erofs.sh $@
 
 VM_S6_RC_FILES = \
 	etc/s6-rc/app/run \
diff --git a/scripts/make-erofs.sh b/scripts/make-erofs.sh
index a289df7..4248360 100755
--- a/scripts/make-erofs.sh
+++ b/scripts/make-erofs.sh
@@ -1,6 +1,6 @@
 #!/bin/sh -eu
 #
-# SPDX-FileCopyrightText: 2023 Alyssa Ross <hi@alyssa.is>
+# SPDX-FileCopyrightText: 2023-2024 Alyssa Ross <hi@alyssa.is>
 # SPDX-License-Identifier: EUPL-1.2+
 #
 # FIXME: It would be nice to replace this script with a program that
@@ -9,36 +9,20 @@
 #        based on source:dest mappings directly.
 
 ex_usage() {
-	echo "Usage: make-erofs.sh [options]... -- img [source dest]..." >&2
+	echo "Usage: make-erofs.sh [options]... img < srcdest.txt" >&2
 	exit 1
 }
 
-opt_count=0
-while [ $# -gt $opt_count ]; do
-	arg1="$1"
-	shift
-
-	if [ -z "${img-}" ]; then
-		set -- "$@" "$arg1"
-		opt_count=$((opt_count + 1))
-
-		if [ "$arg1" = -- ]; then
-			img="$1"
-			shift
-
-			if [ $(($# % 2)) -eq 0 ]; then
-				ex_usage
-			fi
-
-			root="$(mktemp -d -- "$img.tmp.XXXXXXXXXX")"
-			trap 'chmod -R +w -- "$root" && rm -rf -- "$root"' EXIT
-		fi
+for img; do :; done
+if [ -z "${img-}" ]; then
+	ex_usage
+fi
 
-		continue
-	fi
+root="$(mktemp -d -- "$img.tmp.XXXXXXXXXX")"
+trap 'chmod -R +w -- "$root" && rm -rf -- "$root"' EXIT
 
-	arg2="$1"
-	shift
+while read -r arg1; do
+	read -r arg2 || ex_usage
 
 	printf "%s" "$arg1"
 	if [ "${arg1#/}" != "${arg2#/}" ]; then
@@ -52,8 +36,4 @@ while [ $# -gt $opt_count ]; do
 	cp -RT -- "$arg1" "$root/$arg2"
 done
 
-if [ -z "${img-}" ]; then
-	ex_usage
-fi
-
-mkfs.erofs -b4096 "$@" "$img" "$root"
+mkfs.erofs -b4096 "$@" "$root"
diff --git a/vm-lib/make-vm.nix b/vm-lib/make-vm.nix
index 82b1d03..f6234f1 100644
--- a/vm-lib/make-vm.nix
+++ b/vm-lib/make-vm.nix
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: MIT
-# SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>
+# SPDX-FileCopyrightText: 2022, 2024 Alyssa Ross <hi@alyssa.is>
 # SPDX-FileCopyrightText: 2022 Unikie
 
 { pkgs ? import <nixpkgs> {}
@@ -35,9 +35,11 @@ runCommand "spectrum-vm" {
 } ''
   mkdir -p "$out"/{blk,providers,shared-dirs}
 
-  ${../scripts/make-erofs.sh} -L ext -- "$out/blk/run.img" ${run} run \
-      $(comm -23 <(sort ${writeReferencesToFile run}) \
-          <(sort ${writeReferencesToFile basePaths}) | sed p)
+  (
+      printf "%s\nrun\n" ${run}
+      comm -23 <(sort ${writeReferencesToFile run}) \
+          <(sort ${writeReferencesToFile basePaths}) | sed p
+  ) | ${../scripts/make-erofs.sh} -L ext "$out/blk/run.img"
 
   pushd "$out"
 
diff --git a/vm/sys/net/Makefile b/vm/sys/net/Makefile
index 110372e..eb1af5b 100644
--- a/vm/sys/net/Makefile
+++ b/vm/sys/net/Makefile
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: EUPL-1.2+
-# SPDX-FileCopyrightText: 2021-2023 Alyssa Ross <hi@alyssa.is>
+# SPDX-FileCopyrightText: 2021-2024 Alyssa Ross <hi@alyssa.is>
 
 include ../../../lib/common.mk
 
@@ -57,10 +57,12 @@ build/empty:
 	mkdir -p $@
 
 build/rootfs.erofs: ../../../scripts/make-erofs.sh $(VM_FILES) $(VM_BUILD_FILES) build/empty
-	../../../scripts/make-erofs.sh -- $@ $(PACKAGES) \
-	    $$(for file in $(VM_FILES) $(VM_LINKS); do printf '%s %s ' $$file $$file; done) \
-	    $$(for file in $(VM_BUILD_FILES); do printf '%s %s ' $$file $${file#build/}; done) \
-	    $$(printf 'build/empty %s ' $(VM_DIRS))
+	( \
+	    printf '%s\n' $(PACKAGES) ;\
+	    for file in $(VM_FILES) $(VM_LINKS); do printf '%s\n%s\n' $$file $$file; done ;\
+	    for file in $(VM_BUILD_FILES); do printf '%s\n%s\n' $$file $${file#build/}; done ;\
+	    printf 'build/empty\n%s\n' $(VM_DIRS) ;\
+	) | ../../../scripts/make-erofs.sh $@
 
 VM_S6_RC_FILES = \
 	etc/s6-rc/connman/dependencies \