]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
[PATCH 49/50] Modify hook loading to make it slightly easier to script.
authorVictor Lowther <victor.lowther@gmail.com>
Fri, 13 Feb 2009 12:43:29 +0000 (04:43 -0800)
committerDave Jones <davej@redhat.com>
Mon, 16 Feb 2009 18:56:51 +0000 (13:56 -0500)
Modules are now responsible for loading their hooks into the initrd.

This should be all the structure we need to make it easy for things
to integrate with dracut -- now to document and test it all.

Makefile
dracut-functions
hooks/cryptroot [moved from pre-mount/50cryptroot with 100% similarity]
hooks/resume [moved from pre-mount/99resume with 100% similarity]
hooks/selinux-loadpolicy [moved from pre-pivot/50selinux-loadpolicy with 100% similarity]
modules/90crypt
modules/99base

index 365cdf1e7c62b6580791b935d1809e87b7b3f1f7..5d48a5f1cb75fbf96c2fc8183d32f8432199486d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -4,16 +4,16 @@ all:
 install:
        mkdir -p $(DESTDIR)/usr/libexec/dracut
        mkdir -p $(DESTDIR)/sbin
-       mkdir -p $(DESTDIR)/usr/libexec/dracut/pre-mount
-       mkdir -p $(DESTDIR)/usr/libexec/dracut/pre-udev
-       mkdir -p $(DESTDIR)/usr/libexec/dracut/pre-pivot
+       mkdir -p $(DESTDIR)/usr/libexec/dracut/hooks
+       mkdir -p $(DESTDIR)/usr/libexec/dracut/modules
        install -m 0755 dracut $(DESTDIR)/sbin/dracut
        install -m 0755 init $(DESTDIR)/usr/libexec/dracut/init
        install -m 0755 switch_root $(DESTDIR)/usr/libexec/dracut/switch_root
        install -m 0755 dracut-functions $(DESTDIR)/usr/libexec/dracut/functions
        mkdir $(DESTDIR)/usr/libexec/dracut/rules.d
        for rule in rules.d/*.rules ; do install -m 0644 $$rule $(DESTDIR)/usr/libexec/dracut ; done
-       for hooks in pre-*/* ; do install -m 0755 $$hook $(DESTDIR/usr/libexec/dracut ; done
+       for hooks in hooks/* ; do install -m 0755 $$hook $(DESTDIR)/usr/libexec/dracut ; done
+       for module in modules/*; do install -m 0755 $$module $(DESTDIR)/usr/libexec/dracut ; done
 clean:
        rm -f *~
 
index 1923b26bbb8035cb36a205cf43ec30bfb8daf08c..852ce3673c21fe19c8242385462139044157ed2e 100755 (executable)
@@ -145,6 +145,22 @@ inst() {
     return 1
 }
 
+# install function specialized for hooks
+# $1 = type of hook, $2 = hook priority (lower runs first), $3 = hook
+# All hooks should be POSIX/SuS compliant, they will be sourced by init.
+inst_hook() {
+    [[ -f $3 ]] || {
+       echo "Cannot install a hook ($3) that does not exist." >&2
+       echo "Aborting initrd creation." >&2
+       exit 1
+    }
+    strstr "$hookdirs" "$1" || {
+       echo "No such hook type $1. Aborting initrd creation." >&2
+       exit 1
+    }
+    inst_simple "$3" "/${1}/${2}${3##*/}"
+}
+
 dracut_install() {
     while (($# > 0)); do
        inst "$1" && shift
similarity index 100%
rename from pre-mount/50cryptroot
rename to hooks/cryptroot
similarity index 100%
rename from pre-mount/99resume
rename to hooks/resume
index e8f92693dedf5413bf3dbc8d05f67c7ccff4da89..66d7e708a99d218fb1fc95f7ab5be6ce813ebad3 100755 (executable)
@@ -1,3 +1,4 @@
 #!/bin/bash
 inst cryptsetup
-inst_rules "$dsrc/rules.d/63-luks.rules"
\ No newline at end of file
+inst_rules "$dsrc/rules.d/63-luks.rules"
+inst_hook pre-mount 50 "$dsrc/hooks/cryptroot"
\ No newline at end of file
index e1c699b159f6f775c45d5706f3ed9f7ab69ca1b2..c746abce0b5263aba3669681fed26fd9a3863450 100755 (executable)
@@ -4,9 +4,6 @@ dracut_install mount mknod mkdir modprobe pidof sleep chroot echo sed sh ls
 # install our scripts and hooks
 inst "$initfile" "/init"
 inst "$switchroot" "/sbin/switch_root"
-for hookdir in $hookdirs; do
-    for hook in "$dsrc/$hookdir"/*; do
-       [[ -f $hook ]] && inst "$hook" "/$hookdir/${hook##*/}"
-    done
-done
+inst_hook pre-pivot 50 "$dsrc/hooks/selinux-loadpolicy"
+inst_hook pre-mount 99 "$dsrc/hooks/resume"