commit: 16d41fd6998e5ab8c9c2a4c050a9311c26ac3b6b
parent e7515905efa6cc0aed8b67ac815c9603384ba872
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue, 25 Jun 2024 11:59:55 +0200
Allow to disable extras with EXCLUDE_EXTRAS envvar
Diffstat:
3 files changed, 28 insertions(+), 15 deletions(-)
diff --git a/README.md b/README.md
@@ -149,6 +149,8 @@ Meanwhile:
 
 You can automatically build all of the above with `/build-extras.sh` but be warned that those aren't as curated and due to lack of deblob, they might contain binaries and some use autotools which harms reviewability.
 
+You can also exclude those tarballs from the initrd with setting the `EXCLUDE_EXTRAS` environment variable to any value.
+
 ## Launching in QEMU
 * You need a Linux kernel, so far no known version limitations
 * Combination of `panic=1` and `-no-reboot` allows to exit+relaunch
diff --git a/init.sh b/init.sh
@@ -185,10 +185,12 @@ build_bzip2 || die
 build_zlib_libs || die
 build_pigz || die
 
-mkdir -p /usr/share/cacert/ || die
-mv /cacert-*.pem /usr/share/cacert/cert.pem || die
-mkdir -p /etc/ssl || die
-ln -s /usr/share/cacert/cert.pem /etc/ssl/cert.pem || die
+test -f /cacert-*.pem && {
+	mkdir -p /usr/share/cacert/ || die
+	mv /cacert-*.pem /usr/share/cacert/cert.pem || die
+	mkdir -p /etc/ssl || die
+	ln -s /usr/share/cacert/cert.pem /etc/ssl/cert.pem || die
+}
 
 mkdir -p $HOME
 cd
diff --git a/make-root.sh b/make-root.sh
@@ -17,6 +17,14 @@ tarballs="
 	heirloom-devtools-070527.tar.bz2
 	sbase-b30fb568.tar.gz
 "
+local_files="
+	init.sh
+	ls-stub.c
+	grep-stub.c
+	cp-stub.c
+	getty-stub.c
+	mount-stub.c
+"
 distfiles="
 	make-4.4.1.tar.gz
 	xz-5.6.2.tar.gz
@@ -32,13 +40,7 @@ distfiles="
 	git-2.45.1.tar.gz
 	e2fsprogs-1.47.0.tar.gz
 "
-local_files="
-	init.sh
-	ls-stub.c
-	grep-stub.c
-	cp-stub.c
-	getty-stub.c
-	mount-stub.c
+local_distfiles="
 	bootstrap-make.sh
 	bootstrap-xz.sh
 	bootstrap-lua.sh
@@ -89,14 +91,21 @@ for i in $tarballs; do
 	tar xof "${WORKDIR}/distfiles/$i" || die "Failed extracting $i"
 done
 
-for i in $distfiles; do
-	cp "${WORKDIR}/distfiles/$i" ./ || die "Failed copying $i"
-done
-
 for i in $local_files; do
 	cp "${WORKDIR}/$i" ./ || die "Failed copying $i"
 done
 
+if ! test "${EXCLUDE_EXTRAS:+y}" = "y"; then
+	for i in $local_distfiles; do
+		cp "${WORKDIR}/$i" ./ || die "Failed copying $i"
+	done
+
+	for i in $distfiles
+	do
+		cp "${WORKDIR}/distfiles/$i" ./ || die "Failed copying $i"
+	done
+fi
+
 deblob
 
 mkdir -p dev proc sys etc usr/bin || die "Failed creating base directories"