From d7796a90aebc746593b99a40fce1e6192c9e1552 Mon Sep 17 00:00:00 2001
From: Helmut Grohne <helmut@subdivi.de>
Date: Sun, 5 Feb 2023 16:57:32 +0100
Subject: debvm-create: add --skip=initsystem

Closes: #1030254
---
 bin/debvm-create | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

(limited to 'bin/debvm-create')

diff --git a/bin/debvm-create b/bin/debvm-create
index 392b701..4d26ce9 100755
--- a/bin/debvm-create
+++ b/bin/debvm-create
@@ -75,6 +75,14 @@ Internally, B<mmdebstrap> creates a tar archive first and converts that to ext2,
 This option causes the conversion to ext2 and further steps to be skipped and the output image will be a tar archive instead.
 Such a tar archive is not suitable for being booted by B<debvm-run>.
 
+=item B<initsystem>
+
+skips installing an init system.
+When enabling this option, the resulting image will lack F</sbin/init> and the image will not be bootable by B<debvm-run> unless something else provides that path.
+One would specify this option when providing the init system via other means, such as passing C<--include=sysvinit-core> to B<mmdebstrap>.
+This option also implies disabling other integrations that depend on it.
+At present, this will also skip B<autologin> and B<systemdnetwork>.
+
 =item B<kernel>
 
 skips installing a linux kernel image.
@@ -231,6 +239,10 @@ check_skip() {
 	esac
 }
 
+if check_skip initsystem; then
+	SKIP="${SKIP}autologin,systemdnetwork,"
+fi
+
 if ! check_skip kernel; then
 	set -- "--customize-hook=$SHARE_DIR/customize-kernel.sh" "$@"
 fi
@@ -246,11 +258,14 @@ set -- \
 	--verbose \
 	--variant=apt \
 	"--format=$MMFORMAT" \
-	--include=systemd-sysv \
 	"--architecture=$ARCHITECTURE" \
 	'--customize-hook=echo "LABEL=debvm / ext4 defaults 0 1" >"$1/etc/fstab"' \
 	"$@"
 
+if ! check_skip initsystem; then
+	set -- --include=systemd-sysv "$@"
+fi
+
 # set up a hostname
 set -- \
 	"--customize-hook=echo $VMNAME >"'"$1/etc/hostname"' \
-- 
cgit v1.2.3