]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
feat(systemd-emergency): install rescue and emergency targets
authorJo Zzsi <jozzsicsataban@gmail.com>
Tue, 19 Nov 2024 13:35:30 +0000 (08:35 -0500)
committerLaszlo <laszlo.gombos@gmail.com>
Thu, 21 Nov 2024 11:49:47 +0000 (06:49 -0500)
Systemd upstream natively provides emergency and rescue services.
Give an option to install them instead of dracut provided versions.

Both mkinitcpio and mkosi installs these into the initrd.

.github/labeler.yml
modules.d/97systemd-emergency/module-setup.sh [new file with mode: 0755]
test/TEST-41-FULL-SYSTEMD/test.sh

index de20d8480aac4f0dde81cac746016f9f2570bed5..7f7669b5d10ef293d6e154826c50c127a737c607 100644 (file)
@@ -187,6 +187,10 @@ systemd-veritysetup:
   - changed-files:
       - any-glob-to-any-file: 'modules.d/[0-9][0-9]systemd-veritysetup/*'
 
+systemd-emergency:
+  - changed-files:
+    - any-glob-to-any-file: 'modules.d/[0-9][0-9]systemd-emergency/*'
+
 caps:
   - changed-files:
       - any-glob-to-any-file: 'modules.d/[0-9][0-9]caps/*'
diff --git a/modules.d/97systemd-emergency/module-setup.sh b/modules.d/97systemd-emergency/module-setup.sh
new file mode 100755 (executable)
index 0000000..83c1cec
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/bash
+# This file is part of dracut.
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+check() {
+    require_binaries "$systemdutildir"/systemd-sulogin-shell || return 1
+
+    return 255
+}
+
+depends() {
+    echo systemd
+}
+
+install() {
+    inst_multiple -o \
+        "$systemdsystemunitdir"/emergency.target \
+        "$systemdsystemunitdir"/emergency.service \
+        "$systemdsystemunitdir"/rescue.target \
+        "$systemdsystemunitdir"/rescue.service \
+        "$systemdutildir"/systemd-sulogin-shell
+}
index e58fb576a64be1285adf6798b8d36b6785babea1..cc9f586f57130caf5193b672446ec464fef700f5 100755 (executable)
@@ -143,7 +143,7 @@ EOF
         optional_modules="$optional_modules systemd-pcrphase"
     fi
     test_dracut \
-        -a "resume dracut-systemd systemd-ac-power systemd-coredump systemd-creds systemd-cryptsetup systemd-integritysetup systemd-ldconfig systemd-pstore systemd-repart systemd-sysext systemd-veritysetup $optional_modules" \
+        -a "resume dracut-systemd systemd-emergency systemd-ac-power systemd-coredump systemd-creds systemd-cryptsetup systemd-integritysetup systemd-ldconfig systemd-pstore systemd-repart systemd-sysext systemd-veritysetup $optional_modules" \
         --add-drivers "btrfs" \
         "$TESTDIR"/initramfs.testing
 
@@ -158,6 +158,16 @@ EOF
             printf "\n *** systemd units included in initrd from mkinitcpio but not from dracut:%s\n\n" "${mkinitcpio_units}"
             exit 1
         fi
+
+        # verify that in this configuration, dracut does not modify any native systemd service files and ensures compatibility with mkinitcpio
+        (cd "$TESTDIR"/mkinitcpio.*/root/usr/lib/systemd/system/ && find . -type f > /tmp/systemd-mkinitcpio)
+
+        while read -r unit; do
+            if ! diff -q "$TESTDIR"/mkinitcpio.*/root/usr/lib/systemd/system/"$unit" "$TESTDIR"/initrd/dracut.*/initramfs/usr/lib/systemd/system/"$unit"; then
+                exit 1
+            fi
+        done < /tmp/systemd-mkinitcpio
+
     fi
 }