]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
feat(systemd-repart): introducing systemd-repart module
authorJóhann B. Guðmundsson <johannbg@gmail.com>
Thu, 4 Feb 2021 18:19:02 +0000 (18:19 +0000)
committerJóhann B. Guðmundsson <johannbg@gmail.com>
Mon, 8 Feb 2021 20:32:16 +0000 (20:32 +0000)
This modules introduces systemd-repart which can be used
to generate partition(s), via a simple systemd-repart
drop-in(s), which can be useful in wide varity of usecase.

feat(systemd-repart): adding module to spec file

feat(systemd-repart): removing unessary requirement on type unit

fix: spelling error

dracut.spec
modules.d/01systemd-repart/module-setup.sh [new file with mode: 0755]

index 595da452e3a778bc6f2a4844f448003617889f35..3b37e8a620fdef583392fe4a59b273e1a0adeecf 100644 (file)
@@ -336,6 +336,7 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
 %{dracutlibdir}/modules.d/01systemd-sysusers
 %{dracutlibdir}/modules.d/01systemd-initrd
 %{dracutlibdir}/modules.d/01systemd-coredump
+%{dracutlibdir}/modules.d/01systemd-repart
 %{dracutlibdir}/modules.d/03modsign
 %{dracutlibdir}/modules.d/03rescue
 %{dracutlibdir}/modules.d/04watchdog
diff --git a/modules.d/01systemd-repart/module-setup.sh b/modules.d/01systemd-repart/module-setup.sh
new file mode 100755 (executable)
index 0000000..4b1c6ac
--- /dev/null
@@ -0,0 +1,55 @@
+#!/bin/sh
+# This file is part of dracut.
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+# Prerequisite check(s) for module.
+check() {
+
+    # If the binary(s) requirements are not fulfilled
+    # return 1 to not include the binary.
+    require_binaries systemd-repart || return 1
+
+    # If the module dependency requirements are not fulfilled
+    # return 1 to not include the required module(s).
+    if ! dracut_module_included "systemd"; then
+        derror "systemd-repart needs systemd in the initramfs."
+        return 1
+    fi
+
+    # Return 255 to only include the module, if another module requires it.
+    return 255
+
+}
+
+# Module dependency requirements.
+depends() {
+
+    # This module has external dependency on the systemd module.
+    echo systemd
+    # Return 0 to include the dependent systemd module in the initramfs.
+    return 0
+
+}
+
+# Install the required file(s) for the module in the initramfs.
+install() {
+
+    # Install the required file(s.
+    inst_multiple -o \
+        # Install vendor repartition configurations
+        $libdir/repart.d/*.conf
+        # Install the systemd type service unit for systemd repart.
+        $systemdsystemunitdir/systemd-repart.service \
+        $systemdsystemunitdir/initrd-root-fs.target.wants/systemd-repart.service
+        # Install the binary executable(s) for systemd repart.
+        systemd-repart
+
+    # Install the hosts local user configurations if enabled.
+    if [[ $hostonly ]]; then
+        inst_multiple -H -o \
+            /etc/repart.d/*.conf \
+            $systemdsystemconfdir/systemd-repart.service \
+            $systemdsystemconfdir/systemd-repart.service.d/*.conf
+            ${NULL}
+    fi
+}