patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: Alyssa Ross <hi@alyssa.is>
To: devel@spectrum-os.org
Cc: Ville Ilvonen <ville.ilvonen@unikie.com>
Subject: [PATCH] Don't assume /var/empty exists in Makefiles
Date: Wed,  6 Apr 2022 08:20:38 +0000	[thread overview]
Message-ID: <20220406082038.4012718-1-hi@alyssa.is> (raw)

It apparently doesn't on Ubuntu, and this way we also don't have to
hack around it being missing in the Nix sandbox.

Reported-by: Ville Ilvonen <ville.ilvonen@unikie.com>
---
 host/rootfs/Makefile       | 9 ++++++---
 host/rootfs/default.nix    | 5 -----
 vm/app/catgirl/Makefile    | 9 ++++++---
 vm/app/catgirl/default.nix | 5 -----
 vm/app/lynx/Makefile       | 9 ++++++---
 vm/app/lynx/default.nix    | 5 -----
 vm/sys/net/Makefile        | 9 ++++++---
 vm/sys/net/default.nix     | 5 -----
 8 files changed, 24 insertions(+), 32 deletions(-)

diff --git a/host/rootfs/Makefile b/host/rootfs/Makefile
index 87bc15e..d78cc4c 100644
--- a/host/rootfs/Makefile
+++ b/host/rootfs/Makefile
@@ -45,15 +45,18 @@ LINKS = bin sbin
 BUILD_FILES = build/etc/mdev/modalias.sh build/etc/s6-rc
 MOUNTPOINTS = dev ext run proc sys
 
-build/rootfs.tar: $(PACKAGES_TAR) $(FILES) $(BUILD_FILES)
+build/empty:
+	mkdir -p $@
+
+build/rootfs.tar: build/empty $(PACKAGES_TAR) $(FILES) $(BUILD_FILES)
 	cp --no-preserve=mode -f $(PACKAGES_TAR) $@
 	tar $(TARFLAGS) --append -f $@ $(FILES) $(LINKS)
 	echo $(BUILD_FILES) | cut -d/ -f2 | \
 	    tar $(TARFLAGS) --append -f $@ -C build -T -
 	for m in $(MOUNTPOINTS); do \
-	    tar $(TARFLAGS) --append -hf $@ --xform="s,.*,$$m," /var/empty ; \
+	    tar $(TARFLAGS) --append -hf $@ --xform="s,.*,$$m," build/empty ; \
 	done
-	tar $(TARFLAGS) --append -hf $@ --xform='s,.*,etc/service,' /var/empty
+	tar $(TARFLAGS) --append -hf $@ --xform='s,.*,etc/service,' build/empty
 
 build/etc/mdev/modules.map: scripts/modprobe/gen_modules.map.awk
 	mkdir -p $$(dirname $@)
diff --git a/host/rootfs/default.nix b/host/rootfs/default.nix
index cb02445..0bef7ba 100644
--- a/host/rootfs/default.nix
+++ b/host/rootfs/default.nix
@@ -94,11 +94,6 @@ stdenv.mkDerivation {
   MODULES_ORDER = "${kernel}/lib/modules/${kernel.modDirVersion}/modules.order";
   PACKAGES_TAR = packagesTar;
 
-  postPatch = ''
-    mkdir $NIX_BUILD_TOP/empty
-    substituteInPlace Makefile --replace /var/empty $NIX_BUILD_TOP/empty
-  '';
-
   installPhase = ''
     cp build/rootfs.ext4 $out
   '';
diff --git a/vm/app/catgirl/Makefile b/vm/app/catgirl/Makefile
index 5029bb4..3ee5842 100644
--- a/vm/app/catgirl/Makefile
+++ b/vm/app/catgirl/Makefile
@@ -55,15 +55,18 @@ VM_LINKS = bin etc/ssl/certs/ca-certificates.crt
 VM_BUILD_FILES = build/etc/s6-rc
 VM_MOUNTPOINTS = dev run proc sys
 
-build/rootfs.tar: $(PACKAGES_TAR) $(VM_FILES) $(VM_BUILD_FILES)
+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_MOUNTPOINTS); do \
-	    tar $(TARFLAGS) --append -hf $@ --xform="s,.*,$$m," /var/empty ; \
+	    tar $(TARFLAGS) --append -hf $@ --xform="s,.*,$$m," build/empty ; \
 	done
-	tar $(TARFLAGS) --append -hf $@ --xform='s,.*,etc/service,' /var/empty
+	tar $(TARFLAGS) --append -hf $@ --xform='s,.*,etc/service,' build/empty
 
 VM_S6_RC_FILES = \
 	etc/s6-rc/catgirl/run \
diff --git a/vm/app/catgirl/default.nix b/vm/app/catgirl/default.nix
index 230da00..bf35d04 100644
--- a/vm/app/catgirl/default.nix
+++ b/vm/app/catgirl/default.nix
@@ -74,11 +74,6 @@ stdenv.mkDerivation {
   PACKAGES_TAR = packagesTar;
   VMLINUX = "${kernel.dev}/vmlinux";
 
-  postPatch = ''
-    mkdir $NIX_BUILD_TOP/empty
-    substituteInPlace Makefile --replace /var/empty $NIX_BUILD_TOP/empty
-  '';
-
   installPhase = ''
     mv build/svc $out
   '';
diff --git a/vm/app/lynx/Makefile b/vm/app/lynx/Makefile
index f449d27..016b1f5 100644
--- a/vm/app/lynx/Makefile
+++ b/vm/app/lynx/Makefile
@@ -55,15 +55,18 @@ VM_LINKS = bin etc/ssl/certs/ca-certificates.crt
 VM_BUILD_FILES = build/etc/s6-rc
 VM_MOUNTPOINTS = dev run proc sys
 
-build/rootfs.tar: $(PACKAGES_TAR) $(VM_FILES) $(VM_BUILD_FILES)
+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_MOUNTPOINTS); do \
-	    tar $(TARFLAGS) --append -hf $@ --xform="s,.*,$$m," /var/empty ; \
+	    tar $(TARFLAGS) --append -hf $@ --xform="s,.*,$$m," build/empty ; \
 	done
-	tar $(TARFLAGS) --append -hf $@ --xform='s,.*,etc/service,' /var/empty
+	tar $(TARFLAGS) --append -hf $@ --xform='s,.*,etc/service,' build/empty
 
 VM_S6_RC_FILES = \
 	etc/s6-rc/lynx/run \
diff --git a/vm/app/lynx/default.nix b/vm/app/lynx/default.nix
index f7791d8..b188794 100644
--- a/vm/app/lynx/default.nix
+++ b/vm/app/lynx/default.nix
@@ -74,11 +74,6 @@ stdenv.mkDerivation {
   PACKAGES_TAR = packagesTar;
   VMLINUX = "${kernel.dev}/vmlinux";
 
-  postPatch = ''
-    mkdir $NIX_BUILD_TOP/empty
-    substituteInPlace Makefile --replace /var/empty $NIX_BUILD_TOP/empty
-  '';
-
   installPhase = ''
     mv build/svc $out
   '';
diff --git a/vm/sys/net/Makefile b/vm/sys/net/Makefile
index 642c815..7103c0e 100644
--- a/vm/sys/net/Makefile
+++ b/vm/sys/net/Makefile
@@ -55,15 +55,18 @@ VM_LINKS = bin var/run
 VM_BUILD_FILES = build/etc/s6-rc
 VM_MOUNTPOINTS = dev run proc sys var/lib/connman
 
-build/rootfs.tar: $(PACKAGES_TAR) $(VM_FILES) $(VM_BUILD_FILES)
+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_MOUNTPOINTS); do \
-	    tar $(TARFLAGS) --append -hf $@ --xform="s,.*,$$m," /var/empty ; \
+	    tar $(TARFLAGS) --append -hf $@ --xform="s,.*,$$m," build/empty ; \
 	done
-	tar $(TARFLAGS) --append -hf $@ --xform='s,.*,etc/service,' /var/empty
+	tar $(TARFLAGS) --append -hf $@ --xform='s,.*,etc/service,' build/empty
 
 VM_S6_RC_FILES = \
 	etc/s6-rc/connman/dependencies \
diff --git a/vm/sys/net/default.nix b/vm/sys/net/default.nix
index e3bd996..55ae9cb 100644
--- a/vm/sys/net/default.nix
+++ b/vm/sys/net/default.nix
@@ -83,11 +83,6 @@ stdenv.mkDerivation {
   PACKAGES_TAR = packagesTar;
   VMLINUX = "${kernel.dev}/vmlinux";
 
-  postPatch = ''
-    mkdir $NIX_BUILD_TOP/empty
-    substituteInPlace Makefile --replace /var/empty $NIX_BUILD_TOP/empty
-  '';
-
   installPhase = ''
     mv build/svc $out
   '';
-- 
2.35.1


             reply	other threads:[~2022-04-06  8:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-06  8:20 Alyssa Ross [this message]
2022-04-10  8:13 ` Alyssa Ross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220406082038.4012718-1-hi@alyssa.is \
    --to=hi@alyssa.is \
    --cc=devel@spectrum-os.org \
    --cc=ville.ilvonen@unikie.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).