Target directory in the final initramfs.
-I, --install [LIST] Install the space separated list of files into the
initramfs.
- --skip-missing Do not quit on missing module dependencies but skip
- these.
"
}
-H|--hostonly) hostonly="-h" ;;
-i|--include) include_src="$2"; include_target="$3"; shift 2;;
-I|--install) install_items="$2"; shift;;
- --skip-missing) skipmissing="yes" ;;
*) break ;;
esac
shift
case $dracutmodules in
""|auto)
dracutmodules="all"
- skipmissing="yes"
;;
hostonly)
dracutmodules="all"
- skipmissing="yes"
hostonly="-h"
;;
esac
-
[[ $2 ]] && kernel=$2 || kernel=$(uname -r)
[[ $1 ]] && outfile=$(readlink -f $1) || outfile="/boot/initrd-$kernel.img"
mkdir -p "$initdir/$d";
done
-# these bits are fugly, and need some cleanup.
-# Actually documenting how dracut modules work these days would be good.
-skip_missing() {
- # $1 = location of module
- [[ $skipmissing ]] || return 0
- [[ -x $1/check ]] || return 0
- "$1/check" $hostonly
-}
-
-can_source_module() {
- # $1 = location of module
- mod=${1##*/}; mod=${mod#[0-9][0-9]};
- if [[ $dracutmodules != all ]]; then
- strstr "$dracutmodules " "$mod " || return 1
- fi
- strstr "$omit_dracutmodules " "$mod " && return 1
- skip_missing "$1"
-}
-
-# source all our modules
-for moddir in "$dsrc/modules.d"/*; do
- [[ -d $moddir || -L $moddir ]] || continue
- can_source_module "$moddir" || continue
- dinfo "Using module: $moddir"
- [[ -x $moddir/install ]] && . "$moddir/install"
+# check all our modules to see if they should be sourced
+check_modules
+
+#source our modules.
+for moddir in "$dsrc/modules.d"/[0-9][0-9]*; do
+ mod=${moddir##*/}; mod=${mod#[0-9][0-9]}
+ strstr "$mods_to_load" "$mod" && . "$moddir/install"
done
unset moddir
( cd "$initdir"; find . |cpio -H newc -o |gzip -9 > "$outfile"; )
[[ "$beverbose" = "yes" ]] && ls -lh "$outfile"
-
-:
done
}
+memoize() {
+ local cmd=memoize_$@ ret
+ cmd=${cmd//[^[:alnum:]]/_}
+ [[ ${!cmd} ]] && return ${!cmd}
+ "$@"
+ ret=$?
+ eval "$cmd=$ret"
+ return $ret
+}
+
+check_module_deps() {
+ local moddir dep
+ # turn a module name into a directory, if we can.
+ moddir=$(echo ${dsrc}/modules.d/??${1})
+ [[ -d $moddir && -x $moddir/install ]] || return 1
+ # if we do not have a check script, we are unconditionally included
+ if [[ -x $moddir/check ]]; then
+ memoize "$moddir/check" || return 1
+ for dep in $("$moddir/check" -d); do
+ memoize check_module_deps "$dep" && continue
+ dwarning "Dependency $mod failed."
+ return 1
+ done
+ fi
+ mods_to_load+=" $1 "
+}
+
+should_source_module() {
+ local dep
+ [[ -x $1/install ]] || return 1
+ [[ -x $1/check ]] || return 0
+ "$1/check" $hostonly || return 1
+ for dep in $("$1/check" -d); do
+ memoize check_module_deps "$dep" && continue
+ dwarning "Cannot load $mod, dependencies failed."
+ return 1
+ done
+}
+
+check_modules() {
+ for moddir in "$dsrc/modules.d"/[0-9][0-9]*; do
+ local mod=${moddir##*/}; mod=${mod#[0-9][0-9]}
+ [[ -d $moddir ]] || continue
+ [[ $dracutmodules != all ]] && ! strstr "$dracutmodules" "$mod" && \
+ continue
+ strstr "$omit_dracutmodules" "$mod" && continue
+ should_source_module "$moddir" || continue
+ mods_to_load+=" $mod "
+ done
+}
+
# install modules, and handle installing all their dependencies as well.
instmods() {
local mod mpargs modpath modname cmd
+++ /dev/null
-#!/bin/bash
-exit 1
+++ /dev/null
-#!/bin/sh
-cp -a -t "$NEWROOT" /source/*
\ No newline at end of file
+++ /dev/null
-#!/bin/sh
-sfdisk -C 640 -H 2 -S 32 -L /dev/sda <<EOF
-,213
-,213
-,213
-;
-EOF
-mdadm --create /dev/md0 --run --auto=yes --level=5 --raid-devices=3 /dev/sda1 /dev/sda2 /dev/sda3
-echo -n test >keyfile
-cryptsetup -q luksFormat /dev/md0 /keyfile
-echo "The passphrase is test"
-cryptsetup luksOpen /dev/md0 dracut_crypt_test </keyfile
-lvm pvcreate -ff -y /dev/mapper/dracut_crypt_test
-lvm vgcreate dracut /dev/mapper/dracut_crypt_test
-lvm lvcreate -l 100%FREE -n root dracut
-udevadm settle --timeout=4
-[ -b /dev/dracut/root ] || emergency_shell
-mke2fs /dev/dracut/root
-e2mkdir /dev/dracut/root:/proc
+++ /dev/null
-#!/bin/sh
-umount "$NEWROOT"
-lvm lvchange -a n /dev/dracut/root
-cryptsetup luksClose /dev/mapper/dracut_crypt_test
-poweroff -f
\ No newline at end of file
#!/bin/sh
-[[ $dracutfunctions ]] && . $dracutfunctions
-
-find_binary cryptsetup >/dev/null || exit 1
+which cryptsetup >/dev/null 2>&1 || exit 1
if [ "$1" = "-h" ]; then
blkid | grep -q crypt_LUKS || exit 1
#!/bin/sh
-
-[[ $dracutfunctions ]] && . $dracutfunctions
-
-find_binary lvm >/dev/null || exit 1
+which lvm >/dev/null 2>&1 || exit 1
if [ "$1" = "-h" ]; then
blkid | grep -q lvm2pv || exit 1
#!/bin/sh
-
-[[ $dracutfunctions ]] && . $dracutfunctions
-
-find_binary mdadm >/dev/null || exit 1
+which mdadm >/dev/null 2>&1 || exit 1
if [ "$1" = "-h" ]; then
blkid | grep -q linux_raid || exit 1