summary refs log tree commit diff
path: root/vm
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2023-05-27 22:33:31 +0000
committerAlyssa Ross <hi@alyssa.is>2023-05-31 10:27:32 +0000
commit75a1ac3d62bf8c641e7145f46ebd6e9d01e6d3dc (patch)
treeed4888ea0aa2470ea99e5d9df2db85322a309285 /vm
parent997d39121cdb61bf2ba0852839e65f8adf633209 (diff)
downloadspectrum-75a1ac3d62bf8c641e7145f46ebd6e9d01e6d3dc.tar
spectrum-75a1ac3d62bf8c641e7145f46ebd6e9d01e6d3dc.tar.gz
spectrum-75a1ac3d62bf8c641e7145f46ebd6e9d01e6d3dc.tar.bz2
spectrum-75a1ac3d62bf8c641e7145f46ebd6e9d01e6d3dc.tar.lz
spectrum-75a1ac3d62bf8c641e7145f46ebd6e9d01e6d3dc.tar.xz
spectrum-75a1ac3d62bf8c641e7145f46ebd6e9d01e6d3dc.tar.zst
spectrum-75a1ac3d62bf8c641e7145f46ebd6e9d01e6d3dc.zip
vm: switch to EROFS
Diffstat (limited to 'vm')
-rw-r--r--vm/sys/net/Makefile17
-rw-r--r--vm/sys/net/default.nix22
2 files changed, 19 insertions, 20 deletions
diff --git a/vm/sys/net/Makefile b/vm/sys/net/Makefile
index 45d19d1..50c7b29 100644
--- a/vm/sys/net/Makefile
+++ b/vm/sys/net/Makefile
@@ -28,10 +28,10 @@ build/host/data/netvm/vmlinux: $(KERNEL)
 	mkdir -p $$(dirname $@)
 	cp $(KERNEL) $@
 
-build/host/data/netvm/blk/root.img: ../../../scripts/make-gpt.sh ../../../scripts/sfdisk-field.awk build/rootfs.ext4
+build/host/data/netvm/blk/root.img: ../../../scripts/make-gpt.sh ../../../scripts/sfdisk-field.awk build/rootfs.erofs
 	mkdir -p $$(dirname $@)
 	../../../scripts/make-gpt.sh $@.tmp \
-	    build/rootfs.ext4:4f68bce3-e8cd-4db1-96e7-fbcaf984b709:ea21da27-0391-48da-9235-9d2ab2ca7844:root
+	    build/rootfs.erofs:4f68bce3-e8cd-4db1-96e7-fbcaf984b709:ea21da27-0391-48da-9235-9d2ab2ca7844:root
 	mv $@.tmp $@
 
 VM_FILES = \
@@ -56,14 +56,11 @@ VM_BUILD_FILES = build/etc/s6-rc
 build/empty:
 	mkdir -p $@
 
-build/rootfs.tar: build/empty $(PACKAGES_TAR) $(VM_FILES) $(VM_BUILD_FILES)
-	cp --no-preserve=mode -f $(PACKAGES_TAR) $@
-	tar $(TARFLAGS) --append -f $@ $(VM_FILES) $(VM_LINKS)
-	echo $(VM_BUILD_FILES) | cut -d/ -f2 | \
-	    tar $(TARFLAGS) --append -f $@ -C build -T -
-	for m in $(VM_DIRS); do \
-	    tar $(TARFLAGS) --append -hf $@ --xform="s,.*,$$m," build/empty ; \
-	done
+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))
 
 VM_S6_RC_FILES = \
 	etc/s6-rc/connman/dependencies \
diff --git a/vm/sys/net/default.nix b/vm/sys/net/default.nix
index c43f347..98749d1 100644
--- a/vm/sys/net/default.nix
+++ b/vm/sys/net/default.nix
@@ -12,7 +12,7 @@ import ../../../lib/eval-config.nix (
 config.pkgs.pkgsStatic.callPackage (
 
 { lib, stdenvNoCC, runCommand, writeReferencesToFile, buildPackages
-, jq, s6-rc, tar2ext4, util-linux, xorg
+, erofs-utils, jq, s6-rc, util-linux, xorg
 , busybox, connmanMinimal, dbus, execline, kmod, mdevd, nftables, s6
 , s6-linux-init
 }:
@@ -54,12 +54,6 @@ let
     done
   '';
 
-  packagesTar = runCommand "packages.tar" {} ''
-    cd ${packagesSysroot}
-    tar -cf $out --verbatim-files-from \
-        -T ${writeReferencesToFile packagesSysroot} .
-  '';
-
   kernelTarget =
     if stdenvNoCC.hostPlatform.isx86 then
       # vmlinux.bin is the stripped version of vmlinux.
@@ -78,7 +72,7 @@ let
       VIRTIO_PCI = yes;
       VIRTIO_BLK = yes;
       VIRTIO_CONSOLE = yes;
-      EXT4_FS = yes;
+      EROFS_FS = yes;
       EXPERT = yes;
       FONTS = lib.mkForce unset;
       FONT_8x8 = lib.mkForce unset;
@@ -101,11 +95,19 @@ stdenvNoCC.mkDerivation {
   inherit src;
   sourceRoot = "source/vm/sys/net";
 
-  nativeBuildInputs = [ jq lseek s6-rc tar2ext4 util-linux ];
+  nativeBuildInputs = [ erofs-utils jq lseek s6-rc util-linux ];
 
-  PACKAGES_TAR = packagesTar;
+  PACKAGES = [ packagesSysroot "/" ];
   KERNEL = "${kernel}/${baseNameOf kernelTarget}";
 
+  shellHook = ''
+    PACKAGES+=" $(sed p ${writeReferencesToFile packagesSysroot} | tr '\n' ' ')"
+  '';
+
+  preBuild = ''
+    runHook shellHook
+  '';
+
   makeFlags = [ "prefix=$(out)" ];
 
   dontInstall = true;