diff -Naur dracut-010/dracut dracut-0e6a94b/dracut --- dracut-010/dracut 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/dracut 2011-05-31 16:34:37.000000000 +0200 @@ -1,7 +1,7 @@ #!/bin/bash # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh -# +# # Generator script for a dracut initramfs # Tries to retain some degree of compatibility with the command line # of the various mkinitrd implementations out there @@ -40,19 +40,21 @@ -a, --add [LIST] Add a space-separated list of dracut modules. -d, --drivers [LIST] Specify a space-separated list of kernel modules to exclusively include in the initramfs. - --add-drivers [LIST] Specify a space-separated list of kernel + --add-drivers [LIST] Specify a space-separated list of kernel modules to add to the initramfs. --filesystems [LIST] Specify a space-separated list of kernel filesystem modules to exclusively include in the generic initramfs. - -k, --kmoddir [DIR] Specify the directory, where to look for kernel + -k, --kmoddir [DIR] Specify the directory, where to look for kernel modules - --fwdir [DIR] Specify additional directories, where to look for + --fwdir [DIR] Specify additional directories, where to look for firmwares, separated by : --kernel-only Only install kernel drivers and firmware files --no-kernel Do not install kernel drivers and firmware files --strip Strip binaries in the initramfs --nostrip Do not strip binaries in the initramfs (default) + --prefix [DIR] Prefix initramfs files with [DIR] + --noprefix Do not prefix initramfs files (default) --mdadmconf Include local /etc/mdadm.conf --nomdadmconf Do not include local /etc/mdadm.conf --lvmconf Include local /etc/lvm/lvm.conf @@ -71,7 +73,7 @@ -q, --quiet Decrease verbosity level (default is info(4)) -c, --conf [FILE] Specify configuration file to use. Default: /etc/dracut.conf - --confdir [DIR] Specify configuration directory to use *.conf files + --confdir [DIR] Specify configuration directory to use *.conf files from. Default: /etc/dracut.conf.d -l, --local Local mode. Use modules from the current working directory instead of the system-wide installed in @@ -83,7 +85,7 @@ -i, --include [SOURCE] [TARGET] Include the files in the SOURCE directory into the Target directory in the final initramfs. - If SOURCE is a file, it will be installed to TARGET + If SOURCE is a file, it will be installed to TARGET in the final initramfs. -I, --install [LIST] Install the space separated list of files into the initramfs. @@ -94,20 +96,21 @@ Make sure your kernel has bzip2 decompression support compiled in, otherwise you will not be able to boot. --lzma Compress the generated initramfs using lzma. - Make sure your kernel has lzma support compiled in, + Make sure your kernel has lzma support compiled in, otherwise you will not be able to boot. --xz Compress the generated initramfs using xz. Make sure that your kernel has xz support compiled in, otherwise you will not be able to boot. --compress [COMPRESSION] Compress the generated initramfs with the passed compression program. Make sure your kernel - knows how to decompress the generated initramfs, + knows how to decompress the generated initramfs, otherwise you will not be able to boot. --no-compress Do not compress the generated initramfs. This will override any other compression options. --list-modules List all available dracut modules. -M, --show-modules Print included module's name to standard output during build. + --keep Keep the temporary initramfs for debugging purposes EOF } @@ -135,7 +138,7 @@ # val=$(pop stack) pop() { local __stack=$1; shift - local __resultvar=$1 + local __resultvar=$1 local myresult; # check for empty stack eval '[[ ${#'${__stack}'[@]} -eq 0 ]] && return 1' @@ -206,11 +209,13 @@ -I|--install) read_arg install_items "$@" || shift;; --fwdir) read_arg fw_dir_l "$@" || shift;; --compress) read_arg compress_l "$@" || shift;; + --prefix) read_arg prefix_l "$@" || shift;; -f|--force) force=yes;; --kernel-only) kernel_only="yes"; no_kernel="no";; --no-kernel) kernel_only="no"; no_kernel="yes";; --strip) do_strip_l="yes";; --nostrip) do_strip_l="no";; + --noprefix) prefix_l="/";; --mdadmconf) mdadmconf_l="yes";; --nomdadmconf) mdadmconf_l="no";; --lvmconf) lvmconf_l="yes";; @@ -236,8 +241,9 @@ -M|--show-modules) show_modules_l="yes" ;; + --keep) keep="yes";; -*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;; - *) + *) if ! [[ ${outfile+x} ]]; then outfile=$1 elif ! [[ ${kernel+x} ]]; then @@ -257,7 +263,7 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin export PATH -[[ $debug ]] && { +[[ $debug ]] && { export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): '; set -x } @@ -265,7 +271,7 @@ [[ $dracutbasedir ]] || dracutbasedir=/usr/share/dracut [[ $allowlocal && -f "$(readlink -f ${0%/*})/dracut-functions" ]] && \ - dracutbasedir="$(readlink -f ${0%/*})" + dracutbasedir="$(readlink -f ${0%/*})" # if we were not passed a config file, try the default one if [[ ! -f $conffile ]]; then @@ -283,7 +289,7 @@ # source our config dir if [[ $confdir && -d $confdir ]]; then - for f in "$confdir"/*.conf; do + for f in "$confdir"/*.conf; do [[ -e $f ]] && . "$f" done fi @@ -345,6 +351,8 @@ [[ $drivers_dir_l ]] && drivers_dir=$drivers_dir_l [[ $do_strip_l ]] && do_strip=$do_strip_l +[[ $prefix_l ]] && prefix=$prefix_l +[[ $prefix = "/" ]] && unset prefix [[ $hostonly_l ]] && hostonly=$hostonly_l [[ $use_fstab_l ]] && use_fstab=$use_fstab_l [[ $mdadmconf_l ]] && mdadmconf=$mdadmconf_l @@ -358,11 +366,12 @@ fw_dir=${fw_dir//:/ } # handle compression options. +[[ $compress ]] || compress="gzip" case $compress in - bzip2) compress="bzip -9";; + bzip2) compress="bzip2 -9";; lzma) compress="lzma -9";; xz) compress="xz --check=crc32 --lzma2=dict=1MiB";; - gzip) type pigz > /dev/null 2>&1 && compress="pigz -9" || \ + gzip) command -v pigz > /dev/null 2>&1 && compress="pigz -9" || \ compress="gzip -9";; esac if [[ $_no_compress_l = "cat" ]]; then @@ -371,7 +380,6 @@ [[ $hostonly = yes ]] && hostonly="-h" [[ $hostonly != "-h" ]] && unset hostonly -[[ $compress ]] || compress="gzip -9" if [[ -f $dracutbasedir/dracut-functions ]]; then . $dracutbasedir/dracut-functions @@ -445,13 +453,13 @@ exit 1 fi -[[ $TMPDIR && ! -w $TMPDIR ]] && unset TMPDIR -readonly initdir=$(mktemp -d -t initramfs.XXXXXX) +readonly TMPDIR=/var/tmp +readonly initdir=$(mktemp --tmpdir=/var/tmp/ -d -t initramfs.XXXXXX) # clean up after ourselves no matter how we die. -trap 'ret=$?;rm -rf "$initdir";exit $ret;' EXIT +trap 'ret=$?;[[ $keep ]] && echo "Not removing $initdir." >&2 || rm -rf "$initdir";exit $ret;' EXIT # clean up after ourselves no matter how we die. -trap 'exit 1;' SIGINT +trap 'exit 1;' SIGINT # Need to be able to have non-root users read stuff (rpcbind etc) chmod 755 "$initdir" @@ -463,33 +471,60 @@ stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \ debug +# Create some directory structure first +[[ $prefix ]] && mkdir -m 0755 -p "${initdir}${prefix}" + +[[ -h /lib ]] || mkdir -m 0755 -p "${initdir}${prefix}/lib" +[[ $prefix ]] && ln -sfn "${prefix#/}/lib" "$initdir/lib" + +if [[ $prefix ]]; then + for d in bin etc lib "$libdir" sbin tmp usr var; do + ln -sfn "${prefix#/}/${d#/}" "$initdir/$d" + done +fi + if [[ $kernel_only != yes ]]; then - # Create some directory structure first - for d in bin sbin usr/bin usr/sbin usr/lib etc \ - proc sys sysroot tmp dev/pts var/run; do - inst_dir "/$d"; + for d in bin etc lib "$libdir" sbin tmp usr var usr/bin usr/sbin; do + [[ -e "${initdir}${prefix}/$d" ]] && continue + if [ -h "/$d" ]; then + inst "/$d" "${prefix}/$d" + else + mkdir -m 0755 -p "${initdir}${prefix}/$d" + fi + done + + for d in proc sys sysroot root run run/lock run/initramfs; do + if [ -h "/$d" ]; then + inst "/$d" + else + mkdir -m 0755 -p "$initdir/$d" + fi done + + ln -sfn /run "$initdir/var/run" + ln -sfn /run/lock "$initdir/var/lock" fi # check all our modules to see if they should be sourced. # This builds a list of modules that we will install next. check_module_dir - +modules_loaded=" " # source our modules. for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do - mod=${moddir##*/}; mod=${mod#[0-9][0-9]} - if strstr "$mods_to_load" " $mod "; then - [[ $show_modules = yes ]] && echo "$mod" || \ - dinfo "*** Including module: $mod ***" + _d_mod=${moddir##*/}; _d_mod=${_d_mod#[0-9][0-9]} + if strstr "$mods_to_load" " $_d_mod "; then + [[ $show_modules = yes ]] && echo "$_d_mod" || \ + dinfo "*** Including module: $_d_mod ***" if [[ $kernel_only = yes ]]; then - module_installkernel $mod + module_installkernel $_d_mod else - module_install $mod + module_install $_d_mod if [[ $no_kernel != yes ]]; then - module_installkernel $mod + module_installkernel $_d_mod fi fi - mods_to_load=${mods_to_load// $mod /} + mods_to_load=${mods_to_load// $_d_mod /} + modules_loaded+="$_d_mod " fi done unset moddir @@ -511,7 +546,21 @@ else ddebug "Including directory: $src" mkdir -p "${initdir}/${tgt}" - cp -a -t "${initdir}/${tgt}" "$src"/* + # check for preexisting symlinks, so we can cope with the + # symlinks to $prefix + for i in "$src"/*; do + [[ -e "$i" || -h "$i" ]] || continue + s=${initdir}/${tgt}/${i#$src/} + if [[ -d "$i" ]]; then + if ! [[ -e "$s" ]]; then + mkdir -m 0755 -p "$s" + chmod --reference="$i" "$s" + fi + cp -a -t "$s" "$i"/* + else + cp -a -t "$s" "$i" + fi + done fi fi done @@ -523,13 +572,18 @@ done unset item -# make sure that library links are correct and up to date -dracut_install /etc/ld.so.conf /etc/ld.so.conf.d/* -if ! ldconfig -r "$initdir"; then - if [[ $UID = 0 ]]; then - derror "ldconfig exited ungracefully" - else - derror "ldconfig might need uid=0 (root) for chroot()" + +if [[ $kernel_only != yes ]]; then + # make sure that library links are correct and up to date + for f in /etc/ld.so.conf /etc/ld.so.conf.d/*; do + [[ -e $f ]] && dracut_install "$f" + done + if ! ldconfig -r "$initdir"; then + if [[ $UID = 0 ]]; then + derror "ldconfig exited ungracefully" + else + derror "ldconfig might need uid=0 (root) for chroot()" + fi fi fi @@ -538,9 +592,9 @@ du -c "$initdir" | sort -n | ddebug fi -# strip binaries +# strip binaries if [[ $do_strip = yes ]] ; then - for p in strip grep find; do + for p in strip grep find; do if ! type -P $p >/dev/null; then derror "Could not find '$p'. You should run $0 with '--nostrip'." do_strip=no @@ -561,11 +615,20 @@ hardlink "$initdir" 2>&1 } +if strstr "$modules_loaded" " fips " && command -v prelink >/dev/null; then + for i in $initdir/bin/* \ + $initdir/bin/* \ + $initdir/usr/bin/* \ + $initdir/usr/sbin/*; do + [ -x $i ] && prelink -u $i &>/dev/null + done +fi + if ! ( cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet | \ - $compress > "$outfile"; ); then + $compress > "$outfile"; ); then dfatal "dracut: creation of $outfile failed" exit 1 -fi +fi dinfo "Wrote $outfile:" dinfo "$(ls -l "$outfile")" diff -Naur dracut-010/dracut.8.xml dracut-0e6a94b/dracut.8.xml --- dracut-010/dracut.8.xml 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/dracut.8.xml 2011-05-31 16:34:37.000000000 +0200 @@ -108,9 +108,9 @@ - specify a space-separated list of dracut modules to call -when building the initramfs. -Modules are located in + specify a space-separated list of dracut modules to call +when building the initramfs. +Modules are located in /usr/share/dracut/modules.d. This parameter can be specified multiple times. @@ -163,7 +163,7 @@ - specify a space-separated list of kernel filesystem modules to exclusively + specify a space-separated list of kernel filesystem modules to exclusively include in the generic initramfs. This parameter can be specified multiple times. @@ -236,6 +236,22 @@ + + + + prefix initramfs files with /run/initramfs/ + + + + + + + + do not prefix initramfs files with /run/initramfs/ (default) + + + + @@ -284,7 +300,7 @@ specify configuration file to use. -Default: +Default: /etc/dracut.conf @@ -294,7 +310,7 @@ specify configuration directory to use. -Default: +Default: /etc/dracut.conf.d @@ -320,8 +336,8 @@ - Host-Only mode: Install only what is needed for booting -the local host instead of a generic host. + Host-Only mode: Install only what is needed for booting +the local host instead of a generic host. If chrooted to another root other than the real root device, use "--fstab" and provide a valid /etc/fstab. @@ -435,6 +451,14 @@ Print included module's name to standard output during build. + + + + + + Keep the initramfs temporary directory for debugging purposes. + + @@ -489,7 +513,7 @@ Any files found in /etc/conf.d/ will be sourced in the initramfs to -set initial values. Command line options will override these values +set initial values. Command line options will override these values set in the configuration files. @@ -507,7 +531,7 @@ Availability The dracut command is part of the dracut package and is available from -http://sourceforge.net/apps/trac/dracut/wiki +https://dracut.wiki.kernel.org See Also diff -Naur dracut-010/dracut-catimages dracut-0e6a94b/dracut-catimages --- dracut-010/dracut-catimages 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/dracut-catimages 2011-05-31 16:34:37.000000000 +0200 @@ -39,7 +39,7 @@ line and /boot/dracut/ -f, --force Overwrite existing initramfs file. - -i, --imagedir Directory with additional images to add + -i, --imagedir Directory with additional images to add (default: /boot/dracut/) -o, --overlaydir Overlay directory, which contains files that will be used to create an additional image @@ -120,7 +120,7 @@ dinfo "Using base image $baseimage" cat "$baseimage" > "$outfile" -for i in "${images[@]}"; do +for i in "${images[@]}"; do dinfo "Appending $i" cat "$i" >> "$outfile" done diff -Naur dracut-010/dracut-catimages.8.xml dracut-0e6a94b/dracut-catimages.8.xml --- dracut-010/dracut-catimages.8.xml 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/dracut-catimages.8.xml 2011-05-31 16:34:37.000000000 +0200 @@ -67,7 +67,7 @@ , -display help text and exit. +display help text and exit. @@ -105,7 +105,7 @@ AVAILABILITY The dracut-catimages command is part of the dracut package and is available from -http://sourceforge.net/apps/trac/dracut/wiki +https://dracut.wiki.kernel.org diff -Naur dracut-010/dracut.conf dracut-0e6a94b/dracut.conf --- dracut-010/dracut.conf 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/dracut.conf 2011-05-31 16:34:37.000000000 +0200 @@ -3,7 +3,9 @@ logfile=/var/log/dracut.log fileloglvl=6 -# Specific list of dracut modules to use +# Exact list of dracut modules to use. Modules not listed here are not going +# to be included. If you only want to add some optional modules use +# add_dracutmodules option instead. #dracutmodules+="" # Dracut modules to omit diff -Naur dracut-010/dracut.conf.5.xml dracut-0e6a94b/dracut.conf.5.xml --- dracut-010/dracut.conf.5.xml 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/dracut.conf.5.xml 2011-05-31 16:34:37.000000000 +0200 @@ -79,7 +79,7 @@ add_drivers+=" <kernel modules> " - Specify a space-separated list of kernel + Specify a space-separated list of kernel modules to add to the initramfs. The kernel modules have to be specified without the ".ko" suffix. @@ -123,7 +123,7 @@ hostonly="{yes|no}" - Host-Only mode: Install only what is needed for booting + Host-Only mode: Install only what is needed for booting the local host instead of a generic host. If chrooted to another root other than the real root device, use and provide a valid /etc/fstab. diff -Naur dracut-010/dracut.conf.d/fedora.conf.example dracut-0e6a94b/dracut.conf.d/fedora.conf.example --- dracut-010/dracut.conf.d/fedora.conf.example 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/dracut.conf.d/fedora.conf.example 2011-05-31 16:34:37.000000000 +0200 @@ -1,7 +1,7 @@ -# /etc/dracut.conf.d/redhat.conf # Dracut config file customized for RedHat/Fedora. # i18n i18n_vars="/etc/sysconfig/keyboard:KEYTABLE-KEYMAP /etc/sysconfig/i18n:SYSFONT-FONT,FONTACM-FONT_MAP,FONT_UNIMAP" -add_dracutmodules+=" rpmversion " +add_dracutmodules+=" rpmversion shutdown " stdloglvl=3 +prefix=/run/initramfs diff -Naur dracut-010/dracut-functions dracut-0e6a94b/dracut-functions --- dracut-010/dracut-functions 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/dracut-functions 2011-05-31 16:34:37.000000000 +0200 @@ -32,9 +32,6 @@ dlog_init fi -IF_RTLD="" -IF_dynamic="" - # Generic substring function. If $2 is in $1, return 0. strstr() { [[ $1 =~ $2 ]]; } @@ -47,25 +44,25 @@ # $2 = comparision op (gt, ge, eq, le, lt, ne) # $3 = version b vercmp() { - local n1=(${1//./ }) op=$2 n2=(${3//./ }) i res + local _n1=(${1//./ }) _op=$2 _n2=(${3//./ }) _i _res - for ((i=0; ; i++)) + for ((_i=0; ; _i++)) do - if [[ ! ${n1[i]}${n2[i]} ]]; then res=0 - elif ((${n1[i]:-0} > ${n2[i]:-0})); then res=1 - elif ((${n1[i]:-0} < ${n2[i]:-0})); then res=2 + if [[ ! ${_n1[_i]}${_n2[_i]} ]]; then _res=0 + elif ((${_n1[_i]:-0} > ${_n2[_i]:-0})); then _res=1 + elif ((${_n1[_i]:-0} < ${_n2[_i]:-0})); then _res=2 else continue fi break done - case $op in - gt) ((res == 1));; - ge) ((res != 2));; - eq) ((res == 0));; - le) ((res != 1));; - lt) ((res == 2));; - ne) ((res != 0));; + case $_op in + gt) ((_res == 1));; + ge) ((_res != 2));; + eq) ((_res == 0));; + le) ((_res != 1));; + lt) ((_res == 2));; + ne) ((_res != 0));; esac } @@ -76,17 +73,19 @@ # Function prints global variables in format name=value line by line. # $@ = list of global variables' name print_vars() { - local var value + local _var _value - for var in $@ + for _var in $@ do - value=$(eval echo \$$var) - [[ ${value} ]] && echo "${var}=\"${value}\"" + _value=$(eval echo \$$_var) + [[ ${_value} ]] && echo "${_var}=\"${_value}\"" done } get_fs_env() { [[ $1 ]] || return + unset ID_FS_TYPE + unset ID_FS_UUID eval $(udevadm info --query=env --name=$1|egrep 'ID_FS_(TYPE|UUID)=') [[ $ID_FS_TYPE ]] && return @@ -118,38 +117,38 @@ # finds the major:minor of the block device backing the root filesystem. find_block_device() { - local x mpt majmin dev fs misc maj min + local _x _mpt _majmin _dev _fs _maj _min if [[ $use_fstab != yes ]]; then - while read x x majmin x mpt x x fs dev misc; do - [[ $fs = nfs ]] && { echo $dev; return 0;} - [[ $fs = nfs3 ]] && { echo $dev; return 0;} - [[ $fs = nfs4 ]] && { echo $dev; return 0;} - [[ $fs = btrfs ]] && { - ls -nLl "$dev" | { - read x x x x maj min x - maj=${maj//,/} - echo $maj:$min + while read _x _x _majmin _x _mpt _x _x _fs _dev _x; do + [[ $_fs = nfs ]] && { echo $_dev; return 0;} + [[ $_fs = nfs3 ]] && { echo $_dev; return 0;} + [[ $_fs = nfs4 ]] && { echo $_dev; return 0;} + [[ $_fs = btrfs ]] && { + ls -nLl "$_dev" | { + read _x _x _x _x _maj _min _x + _maj=${_maj//,/} + echo $_maj:$_min } && return 0 } - if [[ $mpt = $1 ]] && [[ ${majmin#0:} = $majmin ]]; then - echo $majmin + if [[ $_mpt = $1 ]] && [[ ${_majmin#0:} = $_majmin ]]; then + echo $_majmin return 0 # we have a winner! fi done < /proc/self/mountinfo fi # fall back to /etc/fstab - while read dev mpt fs misc; do - if [[ $mpt = $1 ]]; then - [[ $fs = nfs ]] && { echo $dev; return 0;} - [[ $fs = nfs3 ]] && { echo $dev; return 0;} - [[ $fs = nfs4 ]] && { echo $dev; return 0;} - [[ $dev != ${dev#UUID=} ]] && dev=/dev/disk/by-uuid/${dev#UUID=} - [[ $dev != ${dev#LABEL=} ]] && dev=/dev/disk/by-label/${dev#LABEL=} - [[ -b $dev ]] || return 1 # oops, not a block device. - ls -nLl "$dev" | { - read x x x x maj min x - maj=${maj//,/} - echo $maj:$min + while read _dev _mpt _fs _x; do + if [[ $_mpt = $1 ]]; then + [[ $_fs = nfs ]] && { echo $_dev; return 0;} + [[ $_fs = nfs3 ]] && { echo $_dev; return 0;} + [[ $_fs = nfs4 ]] && { echo $_dev; return 0;} + [[ $_dev != ${_dev#UUID=} ]] && _dev=/dev/disk/by-uuid/${_dev#UUID=} + [[ $_dev != ${_dev#LABEL=} ]] && _dev=/dev/disk/by-label/${_dev#LABEL=} + [[ -b $_dev ]] || return 1 # oops, not a block device. + ls -nLl "$_dev" | { + read _x _x _x _x _maj _min _x + _maj=${_maj//,/} + echo $_maj:$_min } && return 0 fi done < /etc/fstab @@ -164,7 +163,7 @@ # $1 = function to call on every found block device # $2 = block device in major:minor format check_block_and_slaves() { - local x + local _x [[ -b /dev/block/$2 ]] || return 1 # Not a block device? So sorry. "$1" $2 && return check_vol_slaves "$@" && return 0 @@ -172,15 +171,16 @@ check_block_and_slaves $1 $(cat "/sys/dev/block/$2/../dev") && return 0 fi [[ -d /sys/dev/block/$2/slaves ]] || return 1 - for x in /sys/dev/block/$2/slaves/*/dev; do - [[ -f $x ]] || continue - check_block_and_slaves $1 $(cat "$x") && return 0 + for _x in /sys/dev/block/$2/slaves/*/dev; do + [[ -f $_x ]] || continue + check_block_and_slaves $1 $(cat "$_x") && return 0 done return 1 } get_numeric_dev() { - ls -lH "$1" | { read a b c d maj min rest; printf "%d:%d" ${maj%%,} $min; } + local _x _maj _min + ls -lH "$1" | { read _x _x _x _x _maj _min _x; printf "%d:%d" ${_maj%%,} $_min; } } # ugly workaround for the lvm design @@ -190,16 +190,17 @@ # but you cannot create the logical volume without the volume group. # And the volume group might be bigger than the devices the LV needs. check_vol_slaves() { + local _lv _vg _pv for i in /dev/mapper/*; do - lv=$(get_numeric_dev $i) - if [[ $lv = $2 ]]; then - vg=$(lvm lvs --noheadings -o vg_name $i 2>/dev/null) + _lv=$(get_numeric_dev $i) + if [[ $_lv = $2 ]]; then + _vg=$(lvm lvs --noheadings -o vg_name $i 2>/dev/null) # strip space - vg=$(echo $vg) - if [[ $vg ]]; then - for pv in $(lvm vgs --noheadings -o pv_name "$vg" 2>/dev/null) + _vg=$(echo $_vg) + if [[ $_vg ]]; then + for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null) do - check_block_and_slaves $1 $(get_numeric_dev $pv) && return 0 + check_block_and_slaves $1 $(get_numeric_dev $_pv) && return 0 done fi fi @@ -212,27 +213,33 @@ # will create ${initdir}/lib64, ${initdir}/lib64/file, # and a symlink ${initdir}/lib -> lib64. inst_dir() { - local dir="$1" - [[ -e ${initdir}$dir ]] && return 0 + local _dir="$1" + local _file="" + local IFS="/" + local _part + [[ -e ${initdir}$_dir ]] && return 0 # iterate over parent directories - local file="" - local IFS="/" - for part in $dir; do - [[ $part ]] || continue - file="$file/$part" - [[ -e ${initdir}$file ]] && continue + for _part in $_dir; do + [[ $_part ]] || continue + _file="$_file/$_part" + [[ -e ${initdir}$_file ]] && continue - if [[ -L $file ]]; then + if [[ -L $_file ]]; then # create link as the original - local target=$(readlink "$file") - ln -sfn "$target" "${initdir}$file" || return 1 + local target=$(readlink "$_file") + ln -sfn "$target" "${initdir}$_file" || return 1 # resolve relative path and recursively install destination - [[ $target == ${target#/} ]] && target="$(dirname "$file")/$target" + [[ $target == ${target#/} ]] && target="$(dirname "$_file")/$target" inst_dir "$target" else + [[ -h ${initdir}$_file ]] && _file=$(readlink "${initdir}$_file") # create directory - mkdir -m 0755 -p "${initdir}$file" || return 1 + mkdir -m 0755 -p "${initdir}$_file" || return 1 + if [[ -d "$_file" ]]; then + chmod --reference="$_file" "${initdir}$_file" + chmod u+w "${initdir}$_file" + fi fi done } @@ -242,19 +249,20 @@ # Location of the image dir is assumed to be $initdir # We never overwrite the target if it exists. inst_simple() { - local src target + local _src target [[ -f $1 ]] || return 1 - src=$1 target="${2:-$1}" + _src=$1 target="${2:-$1}" if ! [[ -d ${initdir}$target ]]; then [[ -e ${initdir}$target ]] && return 0 + [[ -h ${initdir}$target ]] && return 0 inst_dir "${target%/*}" fi # install checksum files also - if [[ -e "${src%/*}/.${src##*/}.hmac" ]]; then - inst "${src%/*}/.${src##*/}.hmac" "${target%/*}/.${target##*/}.hmac" + if [[ -e "${_src%/*}/.${_src##*/}.hmac" ]]; then + inst "${_src%/*}/.${_src##*/}.hmac" "${target%/*}/.${target##*/}.hmac" fi - ddebug "Installing $src" - cp -pfL "$src" "${initdir}$target" + ddebug "Installing $_src" + cp -pfL "$_src" "${initdir}$target" } # find symlinks linked to given library file @@ -286,27 +294,27 @@ # It handles making symlinks according to how the original library # is referenced. inst_library() { - local src=$1 dest=${2:-$1} lib reallib symlink - [[ -e $initdir$dest ]] && return 0 - if [[ -L $src ]]; then + local _src=$1 _dest=${2:-$1} _lib _reallib _symlink + [[ -e $initdir$_dest ]] && return 0 + if [[ -L $_src ]]; then # install checksum files also - if [[ -e "${src%/*}/.${src##*/}.hmac" ]]; then - inst "${src%/*}/.${src##*/}.hmac" "${dest%/*}/.${dest##*/}.hmac" + if [[ -e "${_src%/*}/.${_src##*/}.hmac" ]]; then + inst "${_src%/*}/.${_src##*/}.hmac" "${_dest%/*}/.${_dest##*/}.hmac" fi - reallib=$(readlink -f "$src") - lib=${src##*/} - inst_simple "$reallib" "$reallib" - inst_dir "${dest%/*}" - (cd "${initdir}${dest%/*}" && ln -s "$reallib" "$lib") + _reallib=$(readlink -f "$_src") + _lib=${_src##*/} + inst_simple "$_reallib" "$_reallib" + inst_dir "${_dest%/*}" + (cd "${initdir}${_dest%/*}" && ln -sfn "$_reallib" "$_lib") else - inst_simple "$src" "$dest" + inst_simple "$_src" "$_dest" fi # Create additional symlinks. See rev_symlinks description. - for symlink in $(rev_lib_symlinks $src) $(rev_lib_symlinks $reallib); do - [[ ! -e $initdir$symlink ]] && { - ddebug "Creating extra symlink: $symlink" - inst_symlink $symlink + for _symlink in $(rev_lib_symlinks $_src) $(rev_lib_symlinks $_reallib); do + [[ ! -e $initdir$_symlink ]] && { + ddebug "Creating extra symlink: $_symlink" + inst_symlink $_symlink } done } @@ -314,15 +322,15 @@ # find a binary. If we were not passed the full path directly, # search in the usual places to find the binary. find_binary() { - local binpath="/bin /sbin /usr/bin /usr/sbin" p + local _binpath="/usr/sbin /sbin /usr/bin /bin" _p if [[ -z ${1##/*} ]]; then if [[ -x $1 ]] || ldd $1 &>/dev/null; then echo $1 return 0 fi fi - for p in $binpath; do - [[ -x $p/$1 ]] && { echo "$p/$1"; return 0; } + for _p in $_binpath; do + [[ -x $_p/$1 ]] && { echo "$_p/$1"; return 0; } done return 1 } @@ -330,105 +338,112 @@ # Same as above, but specialized to install binary executables. # Install binary executable, and all shared library dependencies, if any. inst_binary() { - local bin target - bin=$(find_binary "$1") || return 1 - target=${2:-$bin} - inst_symlink $bin $target && return 0 - local LDSO NAME IO FILE ADDR I1 n f TLIBDIR - [[ -e $initdir$target ]] && return 0 + local _bin _target _f _self _so_regex _lib_regex _tlibdir _base _file _line + + _bin=$(find_binary "$1") || return 1 + _target=${2:-$_bin} + inst_symlink $_bin $_target && return 0 + [[ -e $initdir$_target ]] && return 0 + + # If the binary being installed is also a library, add it to the loop. + _so_regex='([^ ]*/lib[^/]*/[^ ]*\.so[^ ]*)' + [[ $_bin =~ $_so_regex ]] && _self="\t${_bin##*/} => ${_bin} (0x0)\n" + + _lib_regex='^(/lib[^/]*).*' # I love bash! - LC_ALL=C ldd $bin 2>/dev/null | while read line; do - [[ $line = 'not a dynamic executable' ]] && return 1 - if [[ $line =~ not\ found ]]; then - dfatal "Missing a shared library required by $bin." - dfatal "Run \"ldd $bin\" to find out what it is." + { LC_ALL=C ldd $_bin 2>/dev/null; echo -en "$_self"; } | while read _line; do + [[ $_line = 'not a dynamic executable' ]] && return 1 + if [[ $_line =~ not\ found ]]; then + dfatal "Missing a shared library required by $_bin." + dfatal "Run \"ldd $_bin\" to find out what it is." dfatal "dracut cannot create an initrd." exit 1 fi - so_regex='([^ ]*/lib[^/]*/[^ ]*\.so[^ ]*)' - [[ $line =~ $so_regex ]] || continue - FILE=${BASH_REMATCH[1]} - [[ -e ${initdir}$FILE ]] && continue - # see if we are loading an optimized version of a shared lib. - lib_regex='^(/lib[^/]*).*' - if [[ $FILE =~ $lib_regex ]]; then - TLIBDIR=${BASH_REMATCH[1]} - BASE=${FILE##*/} - # prefer nosegneg libs, then unoptimized ones. - for f in "$TLIBDIR/i686/nosegneg" "$TLIBDIR"; do - [[ -e $f/$BASE ]] || continue - FILE=$f/$BASE + [[ $_line =~ $_so_regex ]] || continue + _file=${BASH_REMATCH[1]} + [[ -e ${initdir}$_file ]] && continue + + # See if we are loading an optimized version of a shared lib. + if [[ $_file =~ $_lib_regex ]]; then + _tlibdir=${BASH_REMATCH[1]} + _base=${_file##*/} + # Prefer nosegneg libs to unoptimized ones. + for _f in "$_tlibdir/i686/nosegneg" "$_tlibdir"; do + [[ -e $_f/$_base ]] || continue + _file=$_f/$_base break done - inst_library "$FILE" "$TLIBDIR/$BASE" - IF_dynamic=yes - continue - fi - inst_library "$FILE" + inst_library "$_file" "$_tlibdir/$_base" + else + inst_library "$_file" + fi done - inst_simple "$bin" "$target" + + # Install the binary if it wasn't handled in the above loop. + [[ -z $_self ]] && inst_simple "$_bin" "$_target" } # same as above, except for shell scripts. # If your shell script does not start with shebang, it is not a shell script. inst_script() { [[ -f $1 ]] || return 1 - local line - read -r -n 80 line <"$1" + local _line _shebang_regex + read -r -n 80 _line <"$1" # If debug is set, clean unprintable chars to prevent messing up the term - [[ $debug ]] && line=$(echo -n "$line" | tr -c -d '[:print:][:space:]') - shebang_regex='(#! *)(/[^ ]+).*' - [[ $line =~ $shebang_regex ]] || return 1 + [[ $debug ]] && _line=$(echo -n "$_line" | tr -c -d '[:print:][:space:]') + _shebang_regex='(#! *)(/[^ ]+).*' + [[ $_line =~ $_shebang_regex ]] || return 1 inst "${BASH_REMATCH[2]}" && inst_simple "$@" } # same as above, but specialized for symlinks inst_symlink() { - local src=$1 target=$initdir${2:-$1} realsrc + local _src=$1 _target=$initdir${2:-$1} _realsrc [[ -L $1 ]] || return 1 - [[ -L $target ]] && return 0 - realsrc=$(readlink -f "$src") - [[ $realsrc = ${realsrc##*/} ]] && realsrc=${src%/*}/$realsrc - inst "$realsrc" && mkdir -m 0755 -p "${target%/*}" && \ - ln -s "$realsrc" "$target" -} - -# find a udev rule in the usual places. -find_rule() { - [[ -f $1 ]] && { echo "$1"; return 0; } - for r in . /lib/udev/rules.d /etc/udev/rules.d $dracutbasedir/rules.d; do - [[ -f $r/$1 ]] && { echo "$r/$1"; return 0; } - done - return 1 + [[ -L $_target ]] && return 0 + _realsrc=$(readlink -f "$_src") + [[ $_realsrc = ${_realsrc##*/} ]] && _realsrc=${_src%/*}/$_realsrc + if [[ -d $_realsrc ]]; then + inst_dir "$_realsrc" + else + inst "$_realsrc" && mkdir -m 0755 -p "${_target%/*}" + fi + if [[ -e "${_src}" ]]; then + cp -aP "${_src}" "$_target" + else + ln -sfn "$_realsrc" "$_target" + fi } # udev rules always get installed in the same place, so # create a function to install them to make life simpler. inst_rules() { - local target=/etc/udev/rules.d rule found + local _target=/etc/udev/rules.d _rule _found inst_dir "/lib/udev/rules.d" - inst_dir "$target" - for rule in "$@"; do + inst_dir "$_target" + for _rule in "$@"; do for r in /lib/udev/rules.d /etc/udev/rules.d; do - if [[ -f $r/$rule ]]; then - found="$r/$rule" - inst_simple "$found" + if [[ -f $r/$_rule ]]; then + _found="$r/$_rule" + inst_simple "$_found" fi - done + done for r in '' ./ $dracutbasedir/rules.d/; do - if [[ -f ${r}$rule ]]; then - found="${r}$rule" - inst_simple "$found" "$target/${found##*/}" + if [[ -f ${r}$_rule ]]; then + _found="${r}$_rule" + inst_simple "$_found" "$_target/${_found##*/}" fi done - [[ $found ]] || dinfo "Skipping udev rule: $rule" + [[ $_found ]] || dinfo "Skipping udev rule: $_rule" done } # general purpose installation function # Same args as above. inst() { + local _x + case $# in 1) ;; 2) [[ ! $initdir && -d $2 ]] && export initdir=$2 @@ -438,15 +453,15 @@ *) dfatal "inst only takes 1 or 2 or 3 arguments" exit 1;; esac - for x in inst_symlink inst_script inst_binary inst_simple; do - $x "$@" && return 0 + for _x in inst_symlink inst_script inst_binary inst_simple; do + $_x "$@" && return 0 done return 1 } [[ $hookdirs ]] || { hookdirs="cmdline pre-udev pre-trigger netroot initqueue pre-mount" - hookdirs+=" pre-pivot mount emergency" + hookdirs+=" pre-pivot mount emergency emergency-shutdown shutdown" export hookdirs } @@ -459,20 +474,21 @@ dfatal "Aborting initrd creation." exit 1 elif ! strstr "$hookdirs" "$1"; then - dfatal "No such hook type $1. Aborting initrd creation." + dfatal "No such hook type $1. Aborting initrd creation." exit 1 fi inst_simple "$3" "/lib/dracut/hooks/${1}/${2}${3##*/}" } dracut_install() { + local _optional=no if [[ $1 = '-o' ]]; then - local optional=yes + _optional=yes shift fi while (($# > 0)); do if ! inst "$1" ; then - if [[ $optional = yes ]]; then + if [[ $_optional = yes ]]; then dwarn "Skipping program $1 as it cannot be found and is" \ "flagged to be optional" else @@ -490,32 +506,32 @@ # Function install targets in the same paths inside overlay but decompressed # and without extensions (.gz, .bz2). inst_decompress() { - local src dst realsrc realdst cmd + local _src _dst _realsrc _realdst _cmd - for src in $@ + for _src in $@ do - case ${src} in - *.gz) cmd='gzip -d' ;; - *.bz2) cmd='bzip2 -d' ;; + case ${_src} in + *.gz) _cmd='gzip -d' ;; + *.bz2) _cmd='bzip2 -d' ;; *) return 1 ;; esac - if [[ -L ${src} ]] + if [[ -L ${_src} ]] then - realsrc="$(readlink -f ${src})" # symlink target with extension - dst="${src%.*}" # symlink without extension - realdst="${realsrc%.*}" # symlink target without extension - mksubdirs "${initdir}/${src}" + _realsrc="$(readlink -f ${_src})" # symlink target with extension + _dst="${_src%.*}" # symlink without extension + _realdst="${_realsrc%.*}" # symlink target without extension + mksubdirs "${initdir}/${_src}" # Create symlink without extension to target without extension. - ln -s "${realdst}" "${initdir}/${dst}" + ln -sfn "${_realdst}" "${initdir}/${_dst}" fi # If the source is symlink we operate on its target. - [[ ${realsrc} ]] && src=${realsrc} - inst ${src} + [[ ${_realsrc} ]] && _src=${_realsrc} + inst ${_src} # Decompress with chosen tool. We assume that tool changes name e.g. # from 'name.gz' to 'name'. - ${cmd} "${initdir}${src}" + ${_cmd} "${initdir}${_src}" done } @@ -523,170 +539,181 @@ # install. # $@ = list of files inst_opt_decompress() { - local src + local _src - for src in $@ + for _src in $@ do - inst_decompress "${src}" || inst "${src}" + inst_decompress "${_src}" || inst "${_src}" done } module_check() { - local moddir=$(echo ${dracutbasedir}/modules.d/??${1}) - [[ -d $moddir ]] || return 1 - if [[ ! -f $moddir/module-setup.sh ]]; then + local _moddir=$(echo ${dracutbasedir}/modules.d/??${1}) + local _ret + [[ -d $_moddir ]] || return 1 + if [[ ! -f $_moddir/module-setup.sh ]]; then # if we do not have a check script, we are unconditionally included - [[ -x $moddir/check ]] || return 0 - $moddir/check $hostonly + [[ -x $_moddir/check ]] || return 0 + $_moddir/check $hostonly return $? else unset check depends install installkernel - . $moddir/module-setup.sh + . $_moddir/module-setup.sh is_func check || return 0 check - ret=$? + _ret=$? unset check depends install installkernel - return $ret + return $_ret fi } module_depends() { - local moddir=$(echo ${dracutbasedir}/modules.d/??${1}) - [[ -d $moddir ]] || return 1 - if [[ ! -f $moddir/module-setup.sh ]]; then + local _moddir=$(echo ${dracutbasedir}/modules.d/??${1}) + local _ret + [[ -d $_moddir ]] || return 1 + if [[ ! -f $_moddir/module-setup.sh ]]; then # if we do not have a check script, we have no deps - [[ -x $moddir/check ]] || return 0 - $moddir/check -d + [[ -x $_moddir/check ]] || return 0 + $_moddir/check -d return $? else unset check depends install installkernel - . $moddir/module-setup.sh + . $_moddir/module-setup.sh is_func depends || return 0 depends - ret=$? + _ret=$? unset check depends install installkernel - return $ret + return $_ret fi } module_install() { - local moddir=$(echo ${dracutbasedir}/modules.d/??${1}) - [[ -d $moddir ]] || return 1 - if [[ ! -f $moddir/module-setup.sh ]]; then - [[ -x $moddir/install ]] && . "$moddir/install" + local _moddir=$(echo ${dracutbasedir}/modules.d/??${1}) + local _ret + [[ -d $_moddir ]] || return 1 + if [[ ! -f $_moddir/module-setup.sh ]]; then + [[ -x $_moddir/install ]] && . "$_moddir/install" return $? else unset check depends install installkernel - . $moddir/module-setup.sh + . $_moddir/module-setup.sh is_func install || return 0 install - ret=$? + _ret=$? unset check depends install installkernel - return $ret + return $_ret fi } module_installkernel() { - local moddir=$(echo ${dracutbasedir}/modules.d/??${1}) - [[ -d $moddir ]] || return 1 - if [[ ! -f $moddir/module-setup.sh ]]; then - [[ -x $moddir/installkernel ]] && . "$moddir/installkernel" + local _moddir=$(echo ${dracutbasedir}/modules.d/??${1}) + local _ret + [[ -d $_moddir ]] || return 1 + if [[ ! -f $_moddir/module-setup.sh ]]; then + [[ -x $_moddir/installkernel ]] && . "$_moddir/installkernel" return $? else unset check depends install installkernel - . $moddir/module-setup.sh + . $_moddir/module-setup.sh is_func installkernel || return 0 installkernel - ret=$? + _ret=$? unset check depends install installkernel - return $ret + return $_ret fi } check_module() { - local mod=$1; - local moddir=$(echo ${dracutbasedir}/modules.d/??${1}) - local moddep; + local _mod=$1 + local _moddir=$(echo ${dracutbasedir}/modules.d/??${1}) + local _ret + local _moddep # If we are already scheduled to be loaded, no need to check again. - strstr " $mods_to_load " " $mod " && return 0 - strstr " $mods_checked_as_dep " " $mod " && return 1 + strstr " $mods_to_load " " $_mod " && return 0 + strstr " $mods_checked_as_dep " " $_mod " && return 1 # This should never happen, but... - [[ -d $moddir ]] || return 1 + [[ -d $_moddir ]] || return 1 - [[ $2 ]] || mods_checked_as_dep+=" $mod " + [[ $2 ]] || mods_checked_as_dep+=" $_mod " - strstr " $omit_dracutmodules " " $mod " && return 1 + strstr " $omit_dracutmodules " " $_mod " && return 1 - if strstr " $dracutmodules $add_dracutmodules " " $mod "; then - module_check $mod; ret=$? + if strstr " $dracutmodules $add_dracutmodules " " $_mod "; then + module_check $_mod; ret=$? # explicit module, so also accept ret=255 [[ $ret = 0 || $ret = 255 ]] || return 1 else # module not in our list if [[ $dracutmodules = all ]]; then # check, if we can and should install this module - module_check $mod || return 1 + module_check $_mod || return 1 else # skip this module return 1 fi fi - for moddep in $(module_depends $mod); do + for _moddep in $(module_depends $_mod); do # handle deps as if they were manually added - strstr " $add_dracutmodules " " $moddep " || \ - add_dracutmodules+=" $moddep " + strstr " $add_dracutmodules " " $_moddep " || \ + add_dracutmodules+=" $_moddep " # if a module we depend on fail, fail also - check_module $moddep || return 1 + check_module $_moddep || return 1 done - strstr " $mods_to_load " " $mod " || \ - mods_to_load+=" $mod " + strstr " $mods_to_load " " $_mod " || \ + mods_to_load+=" $_mod " return 0 } check_module_dir() { - local modcheck; - local mod; + local _modcheck + local _mod + local _moddir mods_to_load="" - for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do - local mod=${moddir##*/}; mod=${mod#[0-9][0-9]} - check_module $mod 1 + for _moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do + _mod=${_moddir##*/}; _mod=${_mod#[0-9][0-9]} + check_module $_mod 1 done # Report any missing dracut modules, the user has specified - modcheck=$add_dracutmodules - [[ $dracutmodules != all ]] && modcheck="$m $dracutmodules" - for mod in $modcheck; do - strstr "$mods_to_load" "$mod" && continue - strstr "$omit_dracutmodules" "$mod" && continue - derror "Dracut module \"$mod\" cannot be found." + _modcheck=$add_dracutmodules + [[ $dracutmodules != all ]] && _modcheck="$m $dracutmodules" + for _mod in $_modcheck; do + strstr "$mods_to_load" "$_mod" && continue + strstr "$omit_dracutmodules" "$_mod" && continue + derror "Dracut module \"$_mod\" cannot be found." done } # Install a single kernel module along with any firmware it may require. # $1 = full path to kernel module to install install_kmod_with_fw() { - local modname=${1##*/} fwdir found - modname=${modname%.ko*} + local _modname=${1##*/} _fwdir _found _fw + _modname=${_modname%.ko*} # no need to go further if the module is already installed [[ -e "${initdir}/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" ]] \ && return 0 inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" \ || return $? - for fw in $(modinfo -k $kernel -F firmware $1 2>/dev/null); do - found='' - for fwdir in $fw_dir; do - if [[ -d $fwdir && -f $fwdir/$fw ]]; then - inst_simple "$fwdir/$fw" "/lib/firmware/$fw" - found=yes + for _fw in $(modinfo -k $kernel -F firmware $1 2>/dev/null); do + _found='' + for _fwdir in $fw_dir; do + if [[ -d $_fwdir && -f $_fwdir/$_fw ]]; then + inst_simple "$_fwdir/$_fw" "/lib/firmware/$_fw" + _found=yes fi done - if [[ $found != yes ]]; then - dwarn "Possible missing firmware \"${fw}\" for kernel module" \ - "\"${mod}.ko\"" + if [[ $_found != yes ]]; then + if ! grep -qe "\<${_modname//-/_}\>" /proc/modules; then + dinfo "Possible missing firmware \"${_fw}\" for kernel module" \ + "\"${_modname}.ko\"" + else + dwarn "Possible missing firmware \"${_fw}\" for kernel module" \ + "\"${_modname}.ko\"" + fi fi done return 0 @@ -699,18 +726,19 @@ # $2 = module to get dependencies for # rest of args = arguments to modprobe for_each_kmod_dep() { - local func=$1 kmod=$2 cmd modpapth options + local _func=$1 _kmod=$2 _cmd _modpath _options _found=0 shift 2 - modprobe "$@" --ignore-install --show-depends $kmod 2>/dev/null | ( - local found=0 - while read cmd modpath options; do - [[ $cmd = insmod ]] || continue - $func ${modpath} || exit $? - found=1 + modprobe "$@" --ignore-install --show-depends $_kmod 2>"$initdir/modprobe.err" | ( + while read _cmd _modpath _options; do + [[ $_cmd = insmod ]] || continue + $_func ${_modpath} || exit $? + _found=1 done - [[ $found -eq 0 ]] && exit 1 + [[ $_found -eq 0 ]] && exit 1 exit 0 ) + egrep -v 'FATAL: Module .* not found.' "$initdir/modprobe.err" | derror + rm -f "$initdir/modprobe.err" return $? } @@ -723,19 +751,20 @@ # If it is not, we will look at all kernel modules # This function returns the full filenames of modules that match $1 filter_kernel_modules () ( + local _modname _filtercmd if ! [[ $hostonly ]]; then - filtercmd='find "$srcmods/kernel/drivers" "$srcmods/extra"' - filtercmd+=' "$srcmods/weak-updates" -name "*.ko" -o -name "*.ko.gz"' - filtercmd+=' 2>/dev/null' + _filtercmd='find "$srcmods/kernel/drivers" "$srcmods/extra"' + _filtercmd+=' "$srcmods/weak-updates" -name "*.ko" -o -name "*.ko.gz"' + _filtercmd+=' 2>/dev/null' else - filtercmd='cut -d " " -f 1 $initdir/$$.ko - $1 $initdir/$$.ko && echo "$modname" + for _modname in $(eval $_filtercmd); do + case $_modname in + *.ko) "$1" "$_modname" && echo "$_modname";; + *.ko.gz) gzip -dc "$_modname" > $initdir/$$.ko + $1 $initdir/$$.ko && echo "$_modname" rm -f $initdir/$$.ko ;; esac @@ -745,52 +774,52 @@ # install kernel modules along with all their dependencies. instmods() { [[ $no_kernel = yes ]] && return - local mod mpargs modpath modname cmd moddirname - local ret=0 + local _mod _mpargs _moddirname + local _ret=0 while (($# > 0)); do - mod=${1%.ko*} - case $mod in + _mod=${1%.ko*} + case $_mod in =*) # This introduces 2 incompatible meanings for =* arguments # to instmods. We need to decide which one to keep. - if [[ $mod = =ata && -f $srcmods/modules.block ]]; then - instmods $mpargs \ + if [[ $_mod = =ata && -f $srcmods/modules.block ]]; then + instmods $_mpargs \ $(egrep 'ata|ahci' "${srcmods}/modules.block") - elif [ -f $srcmods/modules.${mod#=} ]; then - instmods $mpargs $(cat ${srcmods}/modules.${mod#=} ) + elif [ -f $srcmods/modules.${_mod#=} ]; then + instmods $_mpargs $(cat ${srcmods}/modules.${_mod#=} ) else - instmods $mpargs $(find "$srcmods" -path "*/${mod#=}/*") + instmods $_mpargs $(find "$srcmods" -path "*/${_mod#=}/*") fi ;; --*) - mod=${mod##*/} - mpargs+=" $mod";; + _mod=${_mod##*/} + _mpargs+=" $_mod";; i2o_scsi) shift; continue;; # Do not load this diagnostic-only module - *) mod=${mod##*/} + *) _mod=${_mod##*/} # if we are already installed, skip this module and go on # to the next one. [[ -f $initdir/$1 ]] && { shift; continue; } # If we are building a host-specific initramfs and this # module is not already loaded, move on to the next one. - [[ $hostonly ]] && ! grep -qe "\<${mod//-/_}\>" /proc/modules \ - && ! echo $add_drivers | grep -qe "\<${mod}\>" && { + [[ $hostonly ]] && ! grep -qe "\<${_mod//-/_}\>" /proc/modules \ + && ! echo $add_drivers | grep -qe "\<${_mod}\>" && { shift; continue } # We use '-d' option in modprobe only if modules prefix path # differs from default '/'. This allows us to use Dracut with # old version of modprobe which doesn't have '-d' option. - moddirname=${srcmods%%/lib/modules/*} - [[ -n ${moddirname} ]] && moddirname="-d ${moddirname}/" + _moddirname=${srcmods%%/lib/modules/*} + [[ -n ${_moddirname} ]] && _moddirname="-d ${_moddirname}/" # ok, load the module, all its dependencies, and any firmware # it may require - for_each_kmod_dep install_kmod_with_fw $mod \ - --set-version $kernel ${moddirname} - ((ret+=$?)) + for_each_kmod_dep install_kmod_with_fw $_mod \ + --set-version $kernel ${_moddirname} + ((_ret+=$?)) ;; esac shift done - return $ret + return $_ret } diff -Naur dracut-010/dracut-gencmdline dracut-0e6a94b/dracut-gencmdline --- dracut-010/dracut-gencmdline 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/dracut-gencmdline 2011-05-31 16:34:37.000000000 +0200 @@ -168,7 +168,7 @@ real=$(freadlink /dev/disk/by-label/${1##LABEL=}) [ -b $real ] && { echo $real; return; } fi - echo "$1" + echo "$1" } finddevnoinsys() { @@ -308,7 +308,7 @@ chap=${result} if [ -n "${chap}" -a "${chap}" != "" ]; then chap="-u ${chap}" - iscsi_get_rec_val $tmpfile "node.session.auth.password" + iscsi_get_rec_val $tmpfile "node.session.auth.password" chap_pw="-w ${result}" else chap="" @@ -318,7 +318,7 @@ chap_in=${result} if [ -n "${chap_in}" -a "${chap_in}" != "" ]; then chap_in="-U ${chap_in}" - iscsi_get_rec_val $tmpfile "node.session.auth.password_in" + iscsi_get_rec_val $tmpfile "node.session.auth.password_in" chap_in_pw="-W ${result}" else chap_in="" @@ -343,7 +343,7 @@ path=$1 if echo $path | grep -q "/platform/host[0-9]*/session[0-9]*/target[0-9]*:[0-9]*:[0-9]*/[0-9]*:[0-9]*:[0-9]*:[0-9]*"; then return 0 - else + else return 1 fi } @@ -399,7 +399,7 @@ EOF local name=$(dmsetup info --noheadings -c -j $major -m $minor -o name) local vg=$(lvshow "/dev/mapper/$name") - local raids=$(/sbin/dmraid -s -craidname 2>/dev/null | grep -vi "no raid disks") + local raids=$(/sbin/dmraid -s -craidname 2>/dev/null | grep -vi "no raid disks") if [ -n "$vg" ]; then vg=`echo $vg` # strip whitespace case " $vg_list " in @@ -630,7 +630,7 @@ cemit() { - cat + cat } emit() @@ -640,7 +640,7 @@ NONL="-n" shift fi - echo $NONL "$@" + echo $NONL "$@" } emitdmraids() @@ -678,8 +678,8 @@ echo -n "rd_NO_MD " fi -if [ -z "$nolvm" -a -n "$vg_list" ]; then - for vg in $vg_list; do +if [ -z "$nolvm" -a -n "$vg_list" ]; then + for vg in $vg_list; do echo -n "rd_LVM_VG=$vg " done else diff -Naur dracut-010/dracut-gencmdline.8.xml dracut-0e6a94b/dracut-gencmdline.8.xml --- dracut-010/dracut-gencmdline.8.xml 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/dracut-gencmdline.8.xml 2011-05-31 16:34:37.000000000 +0200 @@ -15,7 +15,7 @@ - dracut-gencmdline + dracut-gencmdline @@ -35,7 +35,7 @@ AVAILABILITY The dracut-gencmdline command is part of the dracut package and is available from -http://sourceforge.net/apps/trac/dracut/wiki +https://dracut.wiki.kernel.org diff -Naur dracut-010/dracut.kernel.7.xml dracut-0e6a94b/dracut.kernel.7.xml --- dracut-010/dracut.kernel.7.xml 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/dracut.kernel.7.xml 2011-05-31 16:34:37.000000000 +0200 @@ -25,11 +25,11 @@ Description The root filesystem used by the kernel is specified in the boot configuration -file, as always. The traditional root=/dev/hda1 style device +file, as always. The traditional root=/dev/hda1 style device specification is allowed. If a label is used, as in root=LABEL=rootPart the initramfs will search all available devices for an ext2 or ext3 filesystem with the appropriate label, and mount that device as the root filesystem. -root=UUID=uuidnumber will mount the partition with that UUID as the +root=UUID=uuidnumber will mount the partition with that UUID as the root filesystem. Standard @@ -47,7 +47,7 @@ root=<path to blockdevice> - specify blockdevice to use as root filesystem. + specify blockdevice to use as root filesystem. e.g.: root=/dev/sda1 root=/dev/disk/by-path/pci-0000:00:1f.1-scsi-0:0:1:0-part1 @@ -66,14 +66,14 @@ specify additional mount options for the root filesystem. If not set, /etc/fstab -of the real root will be parsed for special mount options and mounted +of the real root will be parsed for special mount options and mounted accordingly. rd.fstab=0 - do not honor special mount options for the root filesystem found in + do not honor special mount options for the root filesystem found in /etc/fstab of the real root. @@ -169,14 +169,6 @@ set udev to loglevel debug - - - rd.timestamp - - - export RDTIMESTAMP environment variable to init, which is set to the uptime of the dracut start. - - @@ -302,7 +294,7 @@ only activate the LUKS partitions with the given UUID Any "luks-" of the LUKS UUID is removed before comparing to <luks uuid>. -The comparisons also matches, if <luks uuid> is only the beginning of the +The comparisons also matches, if <luks uuid> is only the beginning of the LUKS UUID, so you don't have to specify the full UUID. This parameter can be specified multiple times. @@ -325,7 +317,7 @@ rd.luks.key=<keypath>:<keydev>:<luksdev> - keypath is a path to key file to look for. It's REQUIRED. + keypath is a path to key file to look for. It's REQUIRED. When keypath ends with '.gpg' it's considered to be key encrypted symmetrically with GPG. You will be prompted for password on boot. GPG support comes with 'crypt-gpg' module which needs to be added explicitly. keydev is a device on which key file resides. It might be kernel name of devices (should start with "/dev/"), UUID (prefixed with "UUID=") or label (prefix with "LABEL="). You don't have to specify full UUID. Just its beginning will suffice, even if its ambiguous. All matching devices will be probed. This parameter is recommended, but not required. If not present, all block devices will be probed, which may significantly increase boot time. If luksdev is given, the specified key will only be applied for that LUKS device. Possible values are the same as for keydev. Unless you have several LUKS devices, you don't have to specify this parameter. The simplest usage is: @@ -390,6 +382,37 @@ + FIPS + + + rd.fips + + enable FIPS + + + + + boot=<boot device> + + + specify the device, where /boot is located. +e.g. + boot=/dev/sda1 + boot=/dev/disk/by-path/pci-0000:00:1f.1-scsi-0:0:1:0-part1 + boot=UUID=<uuid> + boot=LABEL=<label> + + + + + rd.fips.skipkernel + + skip checksum check of the kernel image. Useful, if the kernel image is not in a separate boot partition. + + + + + Network @@ -397,8 +420,8 @@ ip={dhcp|on|any|dhcp6|auto6|ibft} - dhcp|on|any: get ip from dhcp server from all interfaces. If root=dhcp, -loop sequentially through all interfaces (eth0, eth1, ...) and use the first + dhcp|on|any: get ip from dhcp server from all interfaces. If root=dhcp, +loop sequentially through all interfaces (eth0, eth1, ...) and use the first with a valid DHCP root-path. auto6: IPv6 autoconfiguration dhcp6: IPv6 DHCP @@ -436,7 +459,7 @@ bootdev=<interface> - specify network interface to use routing and netroot information from. + specify network interface to use routing and netroot information from. Required if multiple ip= lines are used. @@ -478,7 +501,7 @@ root={dhcp|dhcp6} - root=dhcp alone directs initrd to look at the DHCP root-path where NFS + root=dhcp alone directs initrd to look at the DHCP root-path where NFS options can be specified. root-path=<server-ip>:<root-dir>[,<nfs-options>] root-path=nfs:<server-ip>:<root-dir>[,<nfs-options>] @@ -491,8 +514,8 @@ nfsroot=<server-ip>:<root-dir>:<nfs-options> - Deprecated! kernel Documentation/filesystems/nfsroot.txt defines -this method. + Deprecated! kernel Documentation/filesystems/nfsroot.txt defines +this method. This is supported by dracut, but not recommended. @@ -530,7 +553,7 @@ associated fields. See http://tools.ietf.org/html/rfc4173. e.g.:root=iscsi:192.168.50.1::::iqn.2009-06.dracut:target0 - If servername is an IPv6 address, it has to be put in brackets. e.g.: + If servername is an IPv6 address, it has to be put in brackets. e.g.: root=iscsi:[2001:DB8::1]::::iqn.2009-06.dracut:target0 @@ -545,7 +568,7 @@ <LUN> :<targetname> ... - multiple netroot options allow setting up multiple iscsi disks. e.g.: + multiple netroot options allow setting up multiple iscsi disks. e.g.: root=UUID=12424547 netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target0 netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target1 @@ -573,7 +596,7 @@ - root=??? rd.iscsi.firmware=1 + root=??? netroot=iscsi rd.iscsi.firmware=1 will read the iscsi parameter from the BIOS firmware @@ -608,9 +631,9 @@ with dhcp root-path=nbd:<server>:<port>[:<fstype>][:<mountopts>] -root=dhcp alone directs initrd to look at the DHCP root-path where NBD +root=dhcp alone directs initrd to look at the DHCP root-path where NBD options can be specified. -This syntax is only usable in cases where you are directly mounting the volume +This syntax is only usable in cases where you are directly mounting the volume as the rootfs. @@ -702,14 +725,6 @@ - rdcopystate - - - rd.copystate - - - - rd_DASD_MOD @@ -1200,7 +1215,7 @@ Any files found in /etc/conf.d/ will be sourced in the initramfs to -set initial values. Command line options will override these values +set initial values. Command line options will override these values set in the configuration files. diff -Naur dracut-010/dracut.spec dracut-0e6a94b/dracut.spec --- dracut-010/dracut.spec 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/dracut.spec 2011-05-31 16:34:37.000000000 +0200 @@ -6,33 +6,25 @@ %define with_nbd 0 %endif -%if %{defined gittag} -%define rdist .git%{gittag}%{?dist} -%define dashgittag -%{gittag} -%else -%define rdist %{?dist} -%endif - Name: dracut -Version: 010 -%define release_prefix 0%{?rdist} -Release: %{release_prefix} +Version: xxx +Release: xxx Summary: Initramfs generator using udev %if 0%{?fedora} -Group: System Environment/Base +Group: System Environment/Base %endif %if 0%{?suse_version} Group: System/Base %endif -License: GPLv2+ +License: GPLv2+ URL: https://dracut.wiki.kernel.org/ -# Source can be generated by -# http://git.kernel.org/?p=boot/dracut/dracut.git;a=snapshot;h=%{?dashgittag};sf=tgz -Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}%{?dashgittag}.tar.bz2 +# Source can be generated by +# http://git.kernel.org/?p=boot/dracut/dracut.git;a=snapshot;h=%{version};sf=tgz +Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}.tar.bz2 BuildArch: noarch - +BuildRequires: dash bash %if 0%{?fedora} BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) %endif @@ -93,16 +85,16 @@ %description -Dracut contains tools to create a bootable initramfs for 2.6 Linux kernels. -Unlike existing implementations, dracut does hard-code as little as possible -into the initramfs. Dracut contains various modules which are driven by the -event-based udev. Having root on MD, DM, LVM2, LUKS is supported as well as +Dracut contains tools to create a bootable initramfs for 2.6 Linux kernels. +Unlike existing implementations, dracut does hard-code as little as possible +into the initramfs. Dracut contains various modules which are driven by the +event-based udev. Having root on MD, DM, LVM2, LUKS is supported as well as NFS, iSCSI, NBD, FCoE with the dracut-network package. %package network Summary: Dracut modules to build a dracut initramfs with network support Requires: %{name} = %{version}-%{release} -Requires: rpcbind +Requires: rpcbind %if %{with_nbd} Requires: nbd %endif @@ -111,7 +103,7 @@ %if 0%{?fedora} Requires: iscsi-initiator-utils -Requires: nfs-utils +Requires: nfs-utils Requires: dhclient %endif @@ -162,17 +154,17 @@ This package contains tools to assemble the local initrd and host configuration. %prep -%setup -q -n %{name}-%{version}%{?dashgittag} +%setup -q -n %{name}-%{version} %build -make WITH_SWITCH_ROOT=0%{?with_switch_root} +make %install %if 0%{?fedora} rm -rf $RPM_BUILD_ROOT %endif make install DESTDIR=$RPM_BUILD_ROOT sbindir=/sbin \ - sysconfdir=/etc mandir=%{_mandir} WITH_SWITCH_ROOT=0%{?with_switch_root} + sysconfdir=/etc mandir=%{_mandir} echo %{name}-%{version}-%{release} > $RPM_BUILD_ROOT/%{_datadir}/dracut/modules.d/10rpmversion/dracut-version @@ -213,9 +205,6 @@ %defattr(-,root,root,0755) %doc README HACKING TODO COPYING AUTHORS NEWS dracut.html dracut.png dracut.svg /sbin/dracut -%if 0%{?with_switch_root} -/sbin/switch_root -%endif %if 0%{?fedora} > 12 || 0%{?rhel} >= 6 || 0%{?suse_version} > 9999 /sbin/mkinitrd /sbin/lsinitrd @@ -249,6 +238,7 @@ %{_datadir}/dracut/modules.d/90lvm %{_datadir}/dracut/modules.d/90mdraid %{_datadir}/dracut/modules.d/90multipath +%{_datadir}/dracut/modules.d/91crypt-gpg %{_datadir}/dracut/modules.d/95debug %{_datadir}/dracut/modules.d/95resume %{_datadir}/dracut/modules.d/95rootfs-block @@ -262,6 +252,7 @@ %{_datadir}/dracut/modules.d/98selinux %{_datadir}/dracut/modules.d/98syslog %{_datadir}/dracut/modules.d/99base +%{_datadir}/dracut/modules.d/99shutdown # logfile needs no logrotate, because it gets overwritten # for every dracut run %attr(0644,root,root) %ghost %config(missingok,noreplace) %{_localstatedir}/log/dracut.log @@ -288,7 +279,7 @@ %defattr(-,root,root,0755) %{_datadir}/dracut/modules.d/02caps -%files tools +%files tools %defattr(-,root,root,0755) %{_mandir}/man8/dracut-gencmdline.8* %{_mandir}/man8/dracut-catimages.8* diff -Naur dracut-010/dracut.xml dracut-0e6a94b/dracut.xml --- dracut-010/dracut.xml 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/dracut.xml 2011-05-31 16:34:37.000000000 +0200 @@ -74,7 +74,7 @@ A TFTP server (on systems that can boot from Ethernet) - The bootloader will load the kernel and initial root file system image into memory and then start the kernel, passing in the memory address of the image. + The bootloader will load the kernel and initial root file system image into memory and then start the kernel, passing in the memory address of the image. Depending on which algorithms were compiled statically into it, the kernel can currently unpack initrd/initramfs images compressed with gzip, bzip2 and LZMA. @@ -431,7 +431,7 @@ Remove the boot arguments ''rhgb'' and ''quiet'' -A sample /etc/grub.conf bootloader configuration file is listed below. +A sample /etc/grub.conf bootloader configuration file is listed below. default=0 timeout=5 @@ -439,12 +439,12 @@ terminal --timeout=5 serial console title Fedora (2.6.29.5-191.fc11.x86_64) root (hd0,0) - kernel /vmlinuz-2.6.29.5-191.fc11.x86_64 ro root=/dev/mapper/vg_uc1-lv_root console=tty0 rd.shell + kernel /vmlinuz-2.6.29.5-191.fc11.x86_64 ro root=/dev/mapper/vg_uc1-lv_root console=tty0 rd.shell initrd /dracut-2.6.29.5-191.fc11.x86_64.img If system boot fails, you will be dropped into a shell as seen in the example below. -No root device found +No root device found Dropping to debug shell. sh: can't access tty; job control turned off @@ -623,7 +623,7 @@ inst_simple "$moddir/insmodpost.sh" /sbin/insmodpost.sh The pase-instmodpost.sh parses the kernel command line for a argument rd.driver.post, blacklists the module from being autoloaded and installs the hook insmodpost.sh in the initqueue-settled. parse-insmodpost.sh: - for p in $(getargs rd.driver.post=); do + for p in $(getargs rd.driver.post=); do echo "blacklist $p" >> /etc/modprobe.d/initramfsblacklist.conf _do_insmodpost=1 done @@ -635,7 +635,7 @@ insmodpost.sh: . /lib/dracut-lib.sh -for p in $(getargs rd.driver.post=); do +for p in $(getargs rd.driver.post=); do modprobe $p done diff -Naur dracut-010/git2spec.pl dracut-0e6a94b/git2spec.pl --- dracut-010/git2spec.pl 1970-01-01 01:00:00.000000000 +0100 +++ dracut-0e6a94b/git2spec.pl 2011-05-31 16:34:37.000000000 +0200 @@ -0,0 +1,66 @@ +#!/usr/bin/perl + +sub last_tag { + open( GIT, 'git log --pretty=format:%H |'); + LINE: while( ) { + open( GIT2, "git tag --contains $_ |"); + while( ) { + chomp; + last LINE if /..*/; + } + close GIT2; + } + $tag=$_; + close GIT2; + close GIT; # be done + return $tag; +}; + +sub create_patches { + my $tag=shift; + my $num=0; + open( GIT, 'git format-patch -M -N --no-signature '.$tag.' |'); + @lines=; + close GIT; # be done + return @lines; +}; +use POSIX qw(strftime); +my $datestr = strftime "%Y%m%d", gmtime; + +my $tag=shift; +$tag=&last_tag if not defined $tag; +my @patches=&create_patches($tag); +my $num=$#patches + 2; +$tag=~s/[^0-9]+?([0-9]+)/$1/; +my $release="$num.git$datestr"; +$release="1" if $num == 1; + +while(<>) { + if (/^Version:/) { + print "Version: $tag\n"; + } + elsif (/^Release:/) { + print "Release: $release\n"; + } + elsif ((/^Source0:/) || (/^Source:/)) { + print $_; + $num=1; + for(@patches) { + print "Patch$num: $_"; + $num++; + } + print "\n"; + } + elsif (/^%setup/) { + print $_; + $num=1; + for(@patches) { + print "%patch$num -p1\n"; + $num++; + } + print "\n"; + } + else { + print $_; + } +} diff -Naur dracut-010/.gitignore dracut-0e6a94b/.gitignore --- dracut-010/.gitignore 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/.gitignore 2011-05-31 16:34:37.000000000 +0200 @@ -1,8 +1,10 @@ +/dracut.8 +/dracut-catimages.8 +/dracut.conf.5 +/dracut.conf.d/*.conf +/dracut-gencmdline.8 +/dracut.html +/dracut.kernel.7 +/modules.d/99base/switch_root +/test/*/test.log test*.img -modules.d/99base/switch_root -*~ -dracut.kernel.7 -dracut.conf.5 -dracut.8 -dracut-catimages.8 -dracut-gencmdline.8 diff -Naur dracut-010/HACKING dracut-0e6a94b/HACKING --- dracut-010/HACKING 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/HACKING 2011-05-31 16:34:37.000000000 +0200 @@ -1,11 +1,11 @@ Right now, most of the testing is done using a qemu/kvm guest and generating the initramfs on another box but the support is all present to build for the "running" machine. For the former, you can boot the guest -using qemu's -kernel and -initrd options. +using qemu's -kernel and -initrd options. dracut exists and will build an image. It is command-line equivalent to most mkinitrd implementations and should be pretty straight-forward -to use. +to use. To use, just run dracut with an output file name and, optionally, a kernel version (it defaults to using the current). The appropriate @@ -14,7 +14,7 @@ and set dracutmodules="foo bar baz" -Note that dracut calls functional components in modules.d "modules" +Note that dracut calls functional components in modules.d "modules" while kernel modules are called "drivers". Requirements: diff -Naur dracut-010/lsinitrd dracut-0e6a94b/lsinitrd --- dracut-010/lsinitrd 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/lsinitrd 2011-05-31 16:34:37.000000000 +0200 @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # @@ -30,6 +30,8 @@ CAT=zcat elif [[ "$FILE_T" =~ ": xz compressed data" ]]; then CAT=xzcat +elif [[ "$FILE_T" =~ ": XZ compressed data" ]]; then + CAT=xzcat elif [[ "$FILE_T" =~ ": data" ]]; then CAT=lzcat fi @@ -41,7 +43,7 @@ echo "$image:" echo "========================================================================" -$CAT "$image" | cpio --extract --verbose --quiet --to-stdout 'lib/dracut/dracut-*' 2>/dev/null +$CAT "$image" | cpio --extract --verbose --quiet --to-stdout 'lib/dracut/dracut-*' 2>/dev/null echo "========================================================================" $CAT "$image" | cpio --extract --verbose --quiet --list echo "========================================================================" diff -Naur dracut-010/Makefile dracut-0e6a94b/Makefile --- dracut-010/Makefile 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/Makefile 2011-05-31 16:34:37.000000000 +0200 @@ -10,15 +10,10 @@ manpages = dracut.8 dracut.kernel.7 dracut.conf.5 dracut-catimages.8 dracut-gencmdline.8 -.PHONY: install clean archive rpm testimage test all check AUTHORS +.PHONY: install clean archive rpm testimage test all check AUTHORS doc -ifeq (1,${WITH_SWITCH_ROOT}) -targets = modules.d/99base/switch_root -else -targets = -endif - -all: $(targets) $(manpages) dracut.html +doc: $(manpages) dracut.html +all: syncheck %: %.xml xsltproc -o $@ -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $< @@ -29,10 +24,7 @@ --stringparam html.stylesheet http://docs.redhat.com/docs/en-US/Common_Content/css/default.css \ http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl dracut.xml -modules.d/99base/switch_root: switch_root.c - gcc -D _GNU_SOURCE -D 'PACKAGE_STRING="dracut"' -std=gnu99 -fsigned-char -g -O2 -o modules.d/99base/switch_root switch_root.c - -install: +install: doc mkdir -p $(DESTDIR)$(pkglibdir) mkdir -p $(DESTDIR)$(sbindir) mkdir -p $(DESTDIR)$(sysconfdir) @@ -43,9 +35,6 @@ install -m 0755 dracut-catimages $(DESTDIR)$(sbindir)/dracut-catimages install -m 0755 mkinitrd-dracut.sh $(DESTDIR)$(sbindir)/mkinitrd install -m 0755 lsinitrd $(DESTDIR)$(sbindir)/lsinitrd -ifeq (1,${WITH_SWITCH_ROOT}) - install -m 0755 modules.d/99base/switch_root $(DESTDIR)$(sbindir)/switch_root -endif install -m 0644 dracut.conf $(DESTDIR)$(sysconfdir)/dracut.conf mkdir -p $(DESTDIR)$(sysconfdir)/dracut.conf.d install -m 0755 dracut-functions $(DESTDIR)$(pkglibdir)/dracut-functions @@ -56,15 +45,11 @@ install -m 0644 dracut-gencmdline.8 $(DESTDIR)$(mandir)/man8 install -m 0644 dracut.conf.5 $(DESTDIR)$(mandir)/man5 install -m 0644 dracut.kernel.7 $(DESTDIR)$(mandir)/man7 -ifeq (1,${WITH_SWITCH_ROOT}) - rm $(DESTDIR)$(pkglibdir)/modules.d/99base/switch_root -endif clean: $(RM) *~ $(RM) */*~ $(RM) */*/*~ - $(RM) modules.d/99base/switch_root $(RM) test-*.img $(RM) dracut-*.rpm dracut-*.tar.bz2 $(RM) $(manpages) dracut.html @@ -80,22 +65,15 @@ dracut-$(VERSION).tar.gz: git archive --format=tar $(VERSION) --prefix=dracut-$(VERSION)/ |gzip > dracut-$(VERSION).tar.gz -dracut-$(VERSION)-$(GITVERSION).tar.bz2: - git archive --format=tar HEAD --prefix=dracut-$(VERSION)-$(GITVERSION)/ |bzip2 > dracut-$(VERSION)-$(GITVERSION).tar.bz2 - - -rpm: clean dracut-$(VERSION).tar.bz2 - rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" --define "_specdir $$PWD" --define "_srcrpmdir $$PWD" --define "_rpmdir $$PWD" -ba dracut.spec - rm -fr BUILD BUILDROOT - -gitrpm: dracut-$(VERSION)-$(GITVERSION).tar.bz2 - echo "%define gittag $(GITVERSION)" > dracut.spec.git - cat dracut.spec >> dracut.spec.git - mv dracut.spec dracut.spec.bak - mv dracut.spec.git dracut.spec - rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" --define "_specdir $$PWD" --define "_srcrpmdir $$PWD" --define "_rpmdir $$PWD" --define "gittag $(GITVERSION)" -ba dracut.spec || : - mv dracut.spec.bak dracut.spec - rm -fr BUILD BUILDROOT +rpm: dracut-$(VERSION).tar.bz2 + mkdir -p rpmbuild + cp dracut-$(VERSION).tar.bz2 rpmbuild + cd rpmbuild; ../git2spec.pl $(VERSION) < ../dracut.spec > dracut.spec; \ + rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" \ + --define "_specdir $$PWD" --define "_srcrpmdir $$PWD" \ + --define "_rpmdir $$PWD" -ba dracut.spec || :; \ + cd ..; + rm -fr rpmbuild syncheck: @ret=0;for i in dracut-logger modules.d/99base/init modules.d/*/*.sh; do \ diff -Naur dracut-010/modules.d/00bootchart/module-setup.sh dracut-0e6a94b/modules.d/00bootchart/module-setup.sh --- dracut-010/modules.d/00bootchart/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/00bootchart/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -12,16 +12,16 @@ } install() { - inst /sbin/bootchartd - inst /bin/bash + inst /sbin/bootchartd + inst /bin/bash inst_symlink /init /sbin/init inst_dir /lib/bootchart/tmpfs - inst /lib/bootchart/bootchart-collector - inst /etc/bootchartd.conf - inst /sbin/accton + inst /lib/bootchart/bootchart-collector + inst /etc/bootchartd.conf + inst /sbin/accton inst /usr/bin/pkill /bin/pkill inst /bin/echo - inst /bin/grep + inst /bin/grep inst /bin/usleep inst /usr/bin/[ /bin/[ diff -Naur dracut-010/modules.d/01fips/fips-boot.sh dracut-0e6a94b/modules.d/01fips/fips-boot.sh --- dracut-010/modules.d/01fips/fips-boot.sh 1970-01-01 01:00:00.000000000 +0100 +++ dracut-0e6a94b/modules.d/01fips/fips-boot.sh 2011-05-31 16:34:37.000000000 +0200 @@ -0,0 +1,12 @@ +#!/bin/sh +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ex: ts=8 sw=4 sts=4 et filetype=sh + +if ! fipsmode=$(getarg fips) || [ $fipsmode = "0" ]; then + rm -f /etc/modprobe.d/fips.conf >/dev/null 2>&1 +elif getarg boot= >/dev/null; then + . /sbin/fips.sh + if mount_boot; then + do_fips || die "FIPS integrity test failed" + fi +fi diff -Naur dracut-010/modules.d/01fips/fips-noboot.sh dracut-0e6a94b/modules.d/01fips/fips-noboot.sh --- dracut-010/modules.d/01fips/fips-noboot.sh 1970-01-01 01:00:00.000000000 +0100 +++ dracut-0e6a94b/modules.d/01fips/fips-noboot.sh 2011-05-31 16:34:37.000000000 +0200 @@ -0,0 +1,11 @@ +#!/bin/sh +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ex: ts=8 sw=4 sts=4 et filetype=sh + +if ! fipsmode=$(getarg fips) || [ $fipsmode = "0" ]; then + rm -f /etc/modprobe.d/fips.conf >/dev/null 2>&1 +elif ! [ -f /tmp/fipsdone ]; then + . /sbin/fips.sh + mount_boot + do_fips || die "FIPS integrity test failed" +fi diff -Naur dracut-010/modules.d/01fips/fips.sh dracut-0e6a94b/modules.d/01fips/fips.sh --- dracut-010/modules.d/01fips/fips.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/01fips/fips.sh 2011-05-31 16:34:37.000000000 +0200 @@ -1,12 +1,13 @@ #!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh -do_fips() + +mount_boot() { - FIPSMODULES=$(cat /etc/fipsmodules) boot=$(getarg boot=) - KERNEL=$(uname -r) - case "$boot" in + + if [ -n "$boot" ]; then + case "$boot" in LABEL=*) boot="$(echo $boot | sed 's,/,\\x2f,g')" boot="/dev/disk/by-label/${boot#LABEL=}" @@ -18,36 +19,51 @@ ;; *) die "You have to specify boot= as a boot option for fips=1" ;; - esac + esac - if ! [ -e "$boot" ]; then - udevadm trigger --action=add >/dev/null 2>&1 - [ -z "$UDEVVERSION" ] && UDEVVERSION=$(udevadm --version) - - if [ $UDEVVERSION -ge 143 ]; then - udevadm settle --exit-if-exists=$boot - else - udevadm settle --timeout=30 + if ! [ -e "$boot" ]; then + udevadm trigger --action=add >/dev/null 2>&1 + [ -z "$UDEVVERSION" ] && UDEVVERSION=$(udevadm --version) + i=0 + while ! [ -e $boot ]; do + if [ $UDEVVERSION -ge 143 ]; then + udevadm settle --exit-if-exists=$boot + else + udevadm settle --timeout=30 + fi + [ -e $boot ] && break + modprobe scsi_wait_scan && rmmod scsi_wait_scan + [ -e $boot ] && break + sleep 0.5 + i=$(($i+1)) + [ $i -gt 40 ] && break + done fi - fi - [ -e "$boot" ] + [ -e "$boot" ] || return 1 - mkdir /boot - info "Mounting $boot as /boot" - mount -oro "$boot" /boot + mkdir /boot + info "Mounting $boot as /boot" + mount -oro "$boot" /boot || return 1 + fi +} +do_fips() +{ info "Checking integrity of kernel" + newroot=$NEWROOT + KERNEL=$(uname -r) + + [ -e "$newroot/boot/.vmlinuz-${KERNEL}.hmac" ] || unset newroot - if ! [ -e "/boot/.vmlinuz-${KERNEL}.hmac" ]; then - warn "/boot/.vmlinuz-${KERNEL}.hmac does not exist" + if ! [ -e "$newroot/boot/.vmlinuz-${KERNEL}.hmac" ]; then + warn "$newroot/boot/.vmlinuz-${KERNEL}.hmac does not exist" return 1 fi - sha512hmac -c "/boot/.vmlinuz-${KERNEL}.hmac" || return 1 + sha512hmac -c "$newroot/boot/.vmlinuz-${KERNEL}.hmac" || return 1 - info "Umounting /boot" - umount /boot + FIPSMODULES=$(cat /etc/fipsmodules) info "Loading and integrity checking all crypto modules" for module in $FIPSMODULES; do @@ -58,15 +74,11 @@ info "Self testing crypto algorithms" modprobe tcrypt || return 1 rmmod tcrypt - info "All initrd crypto checks done" + info "All initrd crypto checks done" + + > /tmp/fipsdone + + umount /boot >/dev/null 2>&1 return 0 } - -if ! fipsmode=$(getarg fips) || [ $fipsmode = "0" ]; then - rm -f /etc/modprobe.d/fips.conf >/dev/null 2>&1 -else - set -e - do_fips || die "FIPS integrity test failed" - set +e -fi diff -Naur dracut-010/modules.d/01fips/module-setup.sh dracut-0e6a94b/modules.d/01fips/module-setup.sh --- dracut-010/modules.d/01fips/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/01fips/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -11,31 +11,39 @@ } installkernel() { - FIPSMODULES="aead aes_generici aes-xts aes-x86_64 ansi_cprng cbc ccm chainiv ctr" - FIPSMODULES="$FIPSMODULES des deflate ecb eseqiv hmac seqiv sha256 sha512" - FIPSMODULES="$FIPSMODULES cryptomgr crypto_null tcrypt" - - mkdir -p "${initdir}/etc/modprobe.d" - - for mod in $FIPSMODULES; do - if instmods $mod; then - echo $mod >> "${initdir}/etc/fipsmodules" - echo "blacklist $mod" >> "${initdir}/etc/modprobe.d/fips.conf" + local _fipsmodules _mod + _fipsmodules="aead aes_generici aes-xts aes-x86_64 ansi_cprng cbc ccm chainiv ctr" + _fipsmodules+=" des deflate ecb eseqiv hmac seqiv sha256 sha512" + _fipsmodules+=" cryptomgr crypto_null tcrypt" + + mkdir -m 0755 -p "${initdir}/etc/modprobe.d" + + for _mod in $_fipsmodules; do + if instmods $_mod; then + echo $_mod >> "${initdir}/etc/fipsmodules" + echo "blacklist $_mod" >> "${initdir}/etc/modprobe.d/fips.conf" fi done } install() { - inst_hook pre-trigger 01 "$moddir/fips.sh" + local _dir + inst_hook pre-trigger 01 "$moddir/fips-boot.sh" + inst_hook pre-pivot 01 "$moddir/fips-noboot.sh" + inst "$moddir/fips.sh" /sbin/fips.sh + dracut_install sha512hmac rmmod insmod mount uname umount - for dir in "$usrlibdir" "$libdir"; do - [[ -e $dir/libsoftokn3.so ]] && \ - dracut_install $dir/libsoftokn3.so $dir/libsoftokn3.chk \ - $dir/libfreebl3.so $dir/libfreebl3.chk && \ + for _dir in "$usrlibdir" "$libdir"; do + [[ -e $_dir/libsoftokn3.so ]] && \ + dracut_install $_dir/libsoftokn3.so $_dir/libsoftokn3.chk \ + $_dir/libfreebl3.so $_dir/libfreebl3.chk && \ break done dracut_install $usrlibdir/hmaccalc/sha512hmac.hmac + if command -v prelink >/dev/null; then + dracut_install prelink + fi } diff -Naur dracut-010/modules.d/02caps/caps.sh dracut-0e6a94b/modules.d/02caps/caps.sh --- dracut-010/modules.d/02caps/caps.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/02caps/caps.sh 2011-05-31 16:34:37.000000000 +0200 @@ -12,7 +12,7 @@ info "Loading CAPS_MODULES $CAPS_MODULES" for i in $CAPS_MODULES;do modprobe $i 2>&1 >/dev/null | vinfo; done - + if [ "$CAPS_MODULES_DISABLED" = "1" -a -e /proc/sys/kernel/modules_disabled ]; then info "Disabling module loading." echo $CAPS_MODULES_DISABLED > /proc/sys/kernel/modules_disabled @@ -29,7 +29,7 @@ echo $CAPS_USERMODEHELPER_BSET > /proc/sys/kernel/usermodehelper/bset echo $CAPS_USERMODEHELPER_BSET > /proc/sys/kernel/usermodehelper/inheritable fi - + echo "CAPS_INIT_DROP=\"$CAPS_INIT_DROP\"" > /etc/capsdrop info "Will drop capabilities $CAPS_INIT_DROP from init." fi diff -Naur dracut-010/modules.d/05busybox/module-setup.sh dracut-0e6a94b/modules.d/05busybox/module-setup.sh --- dracut-010/modules.d/05busybox/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/05busybox/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -13,18 +13,23 @@ } install() { - inst busybox /sbin/busybox + local _i _progs _path + inst busybox /usr/bin/busybox # List of shell programs that we use in other official dracut modules, that # must be supported by the busybox installed on the host system - progs="echo grep usleep [ rmmod insmod mount uname umount setfont kbd_mode stty gzip bzip2 chvt readlink blkid dd losetup tr sed seq ps more cat rm free ping netstat vi ping6 fsck ip hostname basename mknod mkdir pidof sleep chroot ls cp mv dmesg mkfifo less ln modprobe" + _progs="echo grep usleep [ rmmod insmod mount uname umount setfont kbd_mode stty gzip bzip2 chvt readlink blkid dd losetup tr sed seq ps more cat rm free ping netstat vi ping6 fsck ip hostname basename mknod mkdir pidof sleep chroot ls cp mv dmesg mkfifo less ln modprobe" # FIXME: switch_root should be in the above list, but busybox version hangs # (using busybox-1.15.1-7.fc14.i686 at the time of writing) - for i in $progs; do - path=$(find_binary "$i") - ln -s /sbin/busybox "$initdir/$path" + for _i in $_progs; do + _path=$(find_binary "$_i") + if [[ $_path != ${_path#/usr} ]]; then + ln -s ../../usr/bin/busybox "$initdir/$_path" + else + ln -s ../usr/bin/busybox "$initdir/$_path" + fi done } diff -Naur dracut-010/modules.d/10i18n/console_init dracut-0e6a94b/modules.d/10i18n/console_init --- dracut-010/modules.d/10i18n/console_init 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/10i18n/console_init 2011-05-31 16:34:37.000000000 +0200 @@ -61,7 +61,6 @@ exec 7>>${dev} } - dev=/dev/${1#/dev/} devname=${dev#/dev/} @@ -70,8 +69,6 @@ exit 1 } -[ -e /tmp/console_init.${devname} ] && exit 0 - dev_open ${dev} for fd in 6 7; do @@ -88,4 +85,4 @@ set_keymap dev_close ->/tmp/console_init.${devname} + diff -Naur dracut-010/modules.d/10i18n/module-setup.sh dracut-0e6a94b/modules.d/10i18n/module-setup.sh --- dracut-010/modules.d/10i18n/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/10i18n/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -11,6 +11,7 @@ } install() { + [ -x /lib/systemd/systemd-vconsole-setup ] && dracut_install /lib/systemd/systemd-vconsole-setup KBDSUBDIRS=consolefonts,consoletrans,keymaps,unimaps DEFAULT_FONT=LatArCyrHeb-16 I18N_CONF="/etc/locale.conf" @@ -177,12 +178,12 @@ for kbddir in ${kbddir} /usr/lib/kbd /lib/kbd /usr/share /usr/share/kbd do [[ -d "${kbddir}" ]] && \ - for dir in ${KBDSUBDIRS//,/ } + for dir in ${KBDSUBDIRS//,/ } do [[ -d "${kbddir}/${dir}" ]] && continue false done && break - kbddir='' + kbddir='' done [[ ${kbddir} ]] || { diff -Naur dracut-010/modules.d/10i18n/parse-i18n.sh dracut-0e6a94b/modules.d/10i18n/parse-i18n.sh --- dracut-010/modules.d/10i18n/parse-i18n.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/10i18n/parse-i18n.sh 2011-05-31 16:34:37.000000000 +0200 @@ -20,9 +20,9 @@ } inst_key_val '' /etc/vconsole.conf KEYMAP vconsole.keymap KEYTABLE -inst_key_val '' /etc/vconsole.conf FONT vconsole.font SYSFONT -inst_key_val '' /etc/vconsole.conf FONT_MAP vconsole.font.map CONTRANS -inst_key_val '' /etc/vconsole.conf FONT_UNIMAP vconsole.font.unimap UNIMAP +inst_key_val '' /etc/vconsole.conf FONT vconsole.font SYSFONT +inst_key_val '' /etc/vconsole.conf FONT_MAP vconsole.font.map CONTRANS +inst_key_val '' /etc/vconsole.conf FONT_UNIMAP vconsole.font.unimap UNIMAP inst_key_val 1 /etc/vconsole.conf UNICODE vconsole.unicode vconsole.font.unicode inst_key_val '' /etc/vconsole.conf EXT_KEYMAP vconsole.keymap.ext @@ -35,3 +35,10 @@ export LC_ALL fi +# FIXME: fix systemd-vconsole-setup +#if [ -x /lib/systemd/systemd-vconsole-setup ]; then +# /lib/systemd/systemd-vconsole-setup +# rm -f /{etc,lib}/udev/rules.d/10-console.rules +# rm -f /lib/udev/console_init +# ln -s /lib/systemd/systemd-vconsole-setup /lib/udev/console_init +#fi diff -Naur dracut-010/modules.d/10i18n/README dracut-0e6a94b/modules.d/10i18n/README --- dracut-010/modules.d/10i18n/README 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/10i18n/README 2011-05-31 16:34:37.000000000 +0200 @@ -23,7 +23,7 @@ the installation script we handle it by mappings between variables used by Dracut and the ones in the system. Package maintainer is expected to create those for his/her distribution and it's appreciated to share it -with us, so we can include it in source package. +with us, so we can include it in source package. 1. Hostonly vs Generic diff -Naur dracut-010/modules.d/10rpmversion/module-setup.sh dracut-0e6a94b/modules.d/10rpmversion/module-setup.sh --- dracut-010/modules.d/10rpmversion/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/10rpmversion/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -11,14 +11,16 @@ } install() { + local _line + local _dracut_rpm_version if [ -e "$moddir/dracut-version" ]; then - dracut_rpm_version=$(cat "$moddir/dracut-version") - inst "$moddir/dracut-version" /lib/dracut/$dracut_rpm_version + _dracut_rpm_version=$(cat "$moddir/dracut-version") + inst "$moddir/dracut-version" /lib/dracut/$_dracut_rpm_version else if rpm -qf $(type -P $0) &>/dev/null; then - dracut_rpm_version=$(rpm -qf --qf '%{name}-%{version}-%{release}\n' $(type -P $0) | { ver="";while read line;do ver=$line;done;echo $ver;} ) - mkdir -m 0755 -p $initdir/lib $initdir/lib/dracut - echo $dracut_rpm_version > $initdir/lib/dracut/$dracut_rpm_version + _dracut_rpm_version=$(rpm -qf --qf '%{name}-%{version}-%{release}\n' $(type -P $0) | { ver="";while read _line;do ver=$_line;done;echo $ver;} ) + mkdir -m 0755 -p $initdir/lib/dracut + echo $_dracut_rpm_version > $initdir/lib/dracut/$_dracut_rpm_version fi fi inst_hook cmdline 01 "$moddir/version.sh" diff -Naur dracut-010/modules.d/40network/dhclient.conf dracut-0e6a94b/modules.d/40network/dhclient.conf --- dracut-010/modules.d/40network/dhclient.conf 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/40network/dhclient.conf 2011-05-31 16:34:37.000000000 +0200 @@ -1,3 +1,3 @@ request subnet-mask, broadcast-address, time-offset, routers, domain-name, domain-name-servers, domain-search, host-name, - root-path, interface-mtu; + root-path, interface-mtu; diff -Naur dracut-010/modules.d/40network/dhclient-script dracut-0e6a94b/modules.d/40network/dhclient-script --- dracut-010/modules.d/40network/dhclient-script 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/40network/dhclient-script 2011-05-31 16:34:37.000000000 +0200 @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh @@ -37,17 +37,17 @@ [ -n "${search}${domain}" ] && echo "search $search $domain" > /tmp/net.$netif.resolv.conf if [ -n "$namesrv" ] ; then for s in $namesrv; do - echo nameserver $s + echo nameserver $s done fi >> /tmp/net.$netif.resolv.conf [ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname } -PATH=$PATH:/sbin:/usr/sbin +PATH=/usr/sbin:/usr/bin:/sbin:/bin export PS4="dhclient.$interface.$$ + " -exec >>/run/initramfs/initlog.pipe 2>>/run/initramfs/initlog.pipe +exec >>/run/initramfs/loginit.pipe 2>>/run/initramfs/loginit.pipe type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh # We already need a set netif here @@ -68,13 +68,13 @@ warn "Duplicate address detected for $new_ip_address while doing dhcp. retrying" exit 1 fi - setup_interface + setup_interface set | while read line; do [ "${line#new_}" = "$line" ] && continue - echo "$line" + echo "$line" done >/tmp/dhclient.$netif.dhcpopts echo online > /sys/class/net/$netif/uevent - /sbin/initqueue --onetime --name netroot-$netif /sbin/netroot $netif + initqueue --onetime --name netroot-$netif netroot $netif ;; *) echo "dhcp: $reason";; esac diff -Naur dracut-010/modules.d/40network/ifup dracut-0e6a94b/modules.d/40network/ifup --- dracut-010/modules.d/40network/ifup 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/40network/ifup 2011-05-31 16:34:37.000000000 +0200 @@ -5,13 +5,13 @@ # We don't need to check for ip= errors here, that is handled by the # cmdline parser script # -PATH=$PATH:/sbin:/usr/sbin +PATH=/usr/sbin:/usr/bin:/sbin:/bin type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh # Run dhclient do_dhcp() { - # /sbin/dhclient-script will mark the netif up and generate the online + # dhclient-script will mark the netif up and generate the online # event for nfsroot # XXX add -V vendor class and option parsing per kernel echo "Starting dhcp for interface $netif" @@ -32,10 +32,10 @@ do_ipv6auto() { load_ipv6 { - echo 0 > /proc/sys/net/ipv6/conf/$netif/forwarding + echo 0 > /proc/sys/net/ipv6/conf/$netif/forwarding echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_ra echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_redirects - echo ip link set $netif up + echo ip link set $netif up echo wait_for_if_up $netif } > /tmp/net.$netif.up @@ -44,13 +44,13 @@ namesrv=$(getargs nameserver) if [ -n "$namesrv" ] ; then for s in $namesrv; do - echo nameserver $s + echo nameserver $s done fi >> /tmp/net.$netif.resolv.conf echo online > /sys/class/net/$netif/uevent - /sbin/initqueue --onetime --name netroot-$netif /sbin/netroot $netif + initqueue --onetime --name netroot-$netif netroot $netif } # Handle static ip configuration @@ -58,7 +58,7 @@ strstr $ip '*:*:*' && load_ipv6 { - echo ip link set $netif up + echo ip link set $netif up echo wait_for_if_up $netif # do not flush addr for ipv6 strstr $ip '*:*:*' || \ @@ -72,18 +72,16 @@ namesrv=$(getargs nameserver) if [ -n "$namesrv" ] ; then for s in $namesrv; do - echo nameserver $s + echo nameserver $s done fi >> /tmp/net.$netif.resolv.conf echo online > /sys/class/net/$netif/uevent - /sbin/initqueue --onetime --name netroot-$netif /sbin/netroot $netif + initqueue --onetime --name netroot-$netif netroot $netif } -PATH=$PATH:/sbin:/usr/sbin - export PS4="ifup.$1.$$ + " -exec >>/run/initramfs/initlog.pipe 2>>/run/initramfs/initlog.pipe +exec >>/run/initramfs/loginit.pipe 2>>/run/initramfs/loginit.pipe type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh # Huh? No $1? @@ -181,7 +179,7 @@ # start bridge if necessary if [ "$netif" = "$bridgename" ] && [ ! -e /tmp/net.$bridgename.up ]; then if [ "$ethname" = "$bondname" ] ; then - DO_BOND_SETUP=yes /sbin/ifup $bondname + DO_BOND_SETUP=yes ifup $bondname else ip link set $ethname up fi @@ -225,7 +223,7 @@ do_dhcp -6 ;; auto6) do_ipv6auto ;; - *) + *) do_static ;; esac break diff -Naur dracut-010/modules.d/40network/module-setup.sh dracut-0e6a94b/modules.d/40network/module-setup.sh --- dracut-010/modules.d/40network/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/40network/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -3,11 +3,12 @@ # ex: ts=8 sw=4 sts=4 et filetype=sh check() { + local _program . $dracutfunctions - for program in ip arping dhclient ; do - if ! type -P $program >/dev/null; then - derror "Could not find program \"$program\" required by network." + for _program in ip arping dhclient ; do + if ! type -P $_program >/dev/null; then + derror "Could not find program \"$_program\" required by network." return 1 fi done @@ -24,11 +25,11 @@ # Include wired net drivers, excluding wireless net_module_test() { - local net_drivers='eth_type_trans|register_virtio_device' - local unwanted_drivers='/(wireless|isdn|uwb)/' - egrep -q $net_drivers "$1" && \ + local _net_drivers='eth_type_trans|register_virtio_device' + local _unwanted_drivers='/(wireless|isdn|uwb)/' + egrep -q $_net_drivers "$1" && \ egrep -qv 'iw_handler_get_spy' "$1" && \ - [[ ! $1 =~ $unwanted_drivers ]] + [[ ! $1 =~ $_unwanted_drivers ]] } instmods $(filter_kernel_modules net_module_test) @@ -42,12 +43,13 @@ } install() { - dracut_install ip arping tr dhclient + local _arch _i _dir + dracut_install ip arping tr dhclient dracut_install -o brctl ifenslave inst "$moddir/ifup" "/sbin/ifup" inst "$moddir/netroot" "/sbin/netroot" inst "$moddir/dhclient-script" "/sbin/dhclient-script" - inst "$moddir/dhclient.conf" "/etc/dhclient.conf" + inst "$moddir/dhclient.conf" "/etc/dhclient.conf" inst_hook pre-udev 50 "$moddir/ifname-genrules.sh" inst_hook pre-udev 60 "$moddir/net-genrules.sh" inst_hook cmdline 91 "$moddir/dhcp-root.sh" @@ -57,12 +59,12 @@ inst_hook cmdline 99 "$moddir/parse-ifname.sh" inst_hook pre-pivot 10 "$moddir/kill-dhclient.sh" - arch=$(uname -m) + _arch=$(uname -m) - for dir in "$usrlibdir/tls/$arch" "$usrlibdir/tls" "$usrlibdir/$arch" \ + for _dir in "$usrlibdir/tls/$_arch" "$usrlibdir/tls" "$usrlibdir/$_arch" \ "$usrlibdir" "$libdir"; do - for i in "$dir"/libnss_dns.so.* "$dir"/libnss_mdns4_minimal.so.*; do - [ -e "$i" ] && dracut_install "$i" + for _i in "$_dir"/libnss_dns.so.* "$_dir"/libnss_mdns4_minimal.so.*; do + [ -e "$_i" ] && dracut_install "$_i" done done diff -Naur dracut-010/modules.d/40network/net-genrules.sh dracut-0e6a94b/modules.d/40network/net-genrules.sh --- dracut-010/modules.d/40network/net-genrules.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/40network/net-genrules.sh 2011-05-31 16:34:37.000000000 +0200 @@ -40,12 +40,12 @@ # If we have to handle multiple interfaces, handle only them. elif [ -n "$IFACES" ] ; then for iface in $IFACES ; do - printf 'ACTION=="add", SUBSYSTEM=="net", ENV{INTERFACE}=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$iface" + printf 'SUBSYSTEM=="net", ENV{INTERFACE}=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$iface" done # Default: We don't know the interface to use, handle all else - printf 'ACTION=="add", SUBSYSTEM=="net", RUN+="/sbin/ifup $env{INTERFACE}"\n' + printf 'SUBSYSTEM=="net", RUN+="/sbin/ifup $env{INTERFACE}"\n' fi } > /etc/udev/rules.d/60-net.rules diff -Naur dracut-010/modules.d/40network/netroot dracut-0e6a94b/modules.d/40network/netroot --- dracut-010/modules.d/40network/netroot 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/40network/netroot 2011-05-31 16:34:37.000000000 +0200 @@ -2,7 +2,7 @@ # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh -PATH=$PATH:/sbin:/usr/sbin +PATH=/usr/sbin:/usr/bin:/sbin:/bin type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh @@ -20,18 +20,18 @@ [ -z "$netroot" ] && exit 1 # Let's see if we have to wait for other interfaces -# Note: exit works just fine, since the last interface to be +# Note: exit works just fine, since the last interface to be # online'd should see all files [ -e "/tmp/net.ifaces" ] && read IFACES < /tmp/net.ifaces for iface in $IFACES ; do [ -e /tmp/net.$iface.up ] || exit 1 done -# Set or override primary interface +# Set or override primary interface netif=$1 [ -e "/tmp/net.bootdev" ] && read netif < /tmp/net.bootdev -# Figure out the handler for root=dhcp by recalling all netroot cmdline +# Figure out the handler for root=dhcp by recalling all netroot cmdline # handlers if [ "$netroot" = "dhcp" ] || [ "$netroot" = "dhcp6" ] ; then # Unset root so we can check later @@ -40,7 +40,7 @@ # Load dhcp options [ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts - # If we have a specific bootdev with no dhcpoptions or empty root-path, + # If we have a specific bootdev with no dhcpoptions or empty root-path, # we die. Otherwise we just warn if [ -z "$new_root_path" ] ; then [ -n "$BOOTDEV" ] && die "No dhcp root-path received for '$BOOTDEV'" @@ -55,7 +55,7 @@ for f in $hookdir/cmdline/90*.sh; do [ -f "$f" ] && . "$f"; done -else +else rootok="1" fi @@ -65,7 +65,7 @@ handler=${netroot%%:*} handler=${handler%%4} -handler="/sbin/${handler}root" +handler=$(command -v ${handler}root) if [ -z "$netroot" ] || [ ! -e "$handler" ] ; then die "No handler for netroot type '$netroot'" fi @@ -89,7 +89,7 @@ # Note: This assumes that if no router is present the # root server is on the same subnet. # -# TODO There's some netroot variants that don't (yet) have their +# TODO There's some netroot variants that don't (yet) have their # server-ip netroot # Get router IP if set @@ -136,7 +136,7 @@ # Save used netif for later use [ ! -f /tmp/net.ifaces ] && echo $netif > /tmp/net.ifaces -else +else warn "Mounting root via '$netif' failed" # If we're trying with multiple interfaces, put that one down. # ip down/flush ensures that routeing info goes away as well diff -Naur dracut-010/modules.d/40network/parse-bond.sh dracut-0e6a94b/modules.d/40network/parse-bond.sh --- dracut-010/modules.d/40network/parse-bond.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/40network/parse-bond.sh 2011-05-31 16:34:37.000000000 +0200 @@ -13,7 +13,7 @@ # return if bond already parsed [ -n "$bondname" ] && return -# Check if bond parameter is valid +# Check if bond parameter is valid if getarg bond= >/dev/null ; then if [ -z "$netroot" ] ; then die "No netboot configured, bond is invalid" @@ -46,7 +46,7 @@ if getarg bond >/dev/null; then # Read bond= parameters if they exist bond="$(getarg bond=)" - if [ ! "$bond" = "bond" ]; then + if [ ! "$bond" = "bond" ]; then parsebond "$(getarg bond=)" fi # Simple default bond diff -Naur dracut-010/modules.d/40network/parse-bridge.sh dracut-0e6a94b/modules.d/40network/parse-bridge.sh --- dracut-010/modules.d/40network/parse-bridge.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/40network/parse-bridge.sh 2011-05-31 16:34:37.000000000 +0200 @@ -11,7 +11,7 @@ # return if bridge already parsed [ -n "$bridgename" ] && return -# Check if bridge parameter is valid +# Check if bridge parameter is valid if getarg bridge= >/dev/null ; then if [ -z "$netroot" ] ; then die "No netboot configured, bridge is invalid" @@ -49,7 +49,7 @@ if getarg bridge >/dev/null; then # Read bridge= parameters if they exist bridge="$(getarg bridge=)" - if [ ! "$bridge" = "bridge" ]; then + if [ ! "$bridge" = "bridge" ]; then parsebridge "$(getarg bridge=)" fi # Simple default bridge diff -Naur dracut-010/modules.d/40network/parse-ip-opts.sh dracut-0e6a94b/modules.d/40network/parse-ip-opts.sh --- dracut-010/modules.d/40network/parse-ip-opts.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/40network/parse-ip-opts.sh 2011-05-31 16:34:37.000000000 +0200 @@ -52,17 +52,26 @@ fi if [ "ibft" = "$(getarg ip=)" ]; then - modprobe ibft + modprobe iscsi_ibft num=0 - ( + ( for iface in /sys/firmware/ibft/ethernet*; do [ -e ${iface}/mac ] || continue ifname_mac=$(read a < ${iface}/mac; echo $a) - [ -z "$ifname_mac" ] || continue - ifname_if=ibft$num - num=$(( $num + 1 )) - echo "ifname=$ifname_if:$ifname_mac" - dev=$ifname_if + [ -z "$ifname_mac" ] && continue + unset dev + for ifname in $(getargs ifname=); do + if strstr "$ifname" "$ifname_mac"; then + dev=${ifname%%:*} + break + fi + done + if [ -z "$dev" ]; then + ifname_if=ibft$num + num=$(( $num + 1 )) + echo "ifname=$ifname_if:$ifname_mac" + dev=$ifname_if + fi dhcp=$(read a < ${iface}/dhcp; echo $a) if [ -n "$dhcp" ]; then @@ -147,7 +156,7 @@ done # This ensures that BOOTDEV is always first in IFACES -if [ -n "$BOOTDEV" ] && [ -n "$IFACES" ] ; then +if [ -n "$BOOTDEV" ] && [ -n "$IFACES" ] ; then IFACES="${IFACES%$BOOTDEV*} ${IFACES#*$BOOTDEV}" IFACES="$BOOTDEV $IFACES" fi @@ -156,5 +165,5 @@ [ -n "$BOOTDEV" ] && echo $BOOTDEV > /tmp/net.bootdev [ -n "$IFACES" ] && echo $IFACES > /tmp/net.ifaces -# We need a ip= line for the configured bootdev= +# We need a ip= line for the configured bootdev= [ -n "$NEEDBOOTDEV" ] && [ -z "$BOOTDEVOK" ] && die "Bootdev Argument '$BOOTDEV' not found" diff -Naur dracut-010/modules.d/45ifcfg/write-ifcfg.sh dracut-0e6a94b/modules.d/45ifcfg/write-ifcfg.sh --- dracut-010/modules.d/45ifcfg/write-ifcfg.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/45ifcfg/write-ifcfg.sh 2011-05-31 16:34:37.000000000 +0200 @@ -17,7 +17,7 @@ . /tmp/bridge.info fi -mkdir -p /tmp/ifcfg/ +mkdir -m 0755 -p /tmp/ifcfg/ for netif in $IFACES ; do # bridge? @@ -31,18 +31,18 @@ fi cat /sys/class/net/$netif/address > /tmp/net.$netif.hwaddr { - echo "# Generated by dracut initrd" + echo "# Generated by dracut initrd" echo "DEVICE=$netif" echo "ONBOOT=yes" echo "NETBOOT=yes" if [ -f /tmp/net.$netif.lease ]; then strstr "$ip" '*:*:*' && - echo "DHCPV6C=yes" - echo "BOOTPROTO=dhcp" + echo "DHCPV6C=yes" + echo "BOOTPROTO=dhcp" else - echo "BOOTPROTO=none" + echo "BOOTPROTO=none" # If we've booted with static ip= lines, the override file is there - . /tmp/net.$netif.override + [ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override echo "IPADDR=$ip" echo "NETMASK=$mask" [ -n "$gw" ] && echo "GATEWAY=$gw" @@ -55,7 +55,7 @@ { echo "HWADDR=$(cat /sys/class/net/$netif/address)" echo "TYPE=Ethernet" - echo "NAME=\"Boot Disk\"" + echo "NAME=\"Boot Disk\"" } >> /tmp/ifcfg/ifcfg-$netif fi @@ -88,7 +88,7 @@ # bridge { echo "TYPE=Bridge" - echo "NAME=\"Boot Disk\"" + echo "NAME=\"Boot Disk\"" } >> /tmp/ifcfg/ifcfg-$netif if [ "$ethname" = "$bondname" ] ; then { @@ -100,7 +100,7 @@ # This variable is an indicator of a bond interface for initscripts echo "BONDING_OPTS=\"$bondoptions\"" echo "BRIDGE=$netif" - echo "NAME=\"$bondname\"" + echo "NAME=\"$bondname\"" } >> /tmp/ifcfg/ifcfg-$bondname for slave in $bondslaves ; do # write separate ifcfg file for the raw eth interface @@ -134,9 +134,11 @@ done # Pass network opts -mkdir -p /run/initramfs +[ -d /run/initramfs ] || mkdir -m 0755 -p /run/initramfs cp /tmp/net.* /run/initramfs/ >/dev/null 2>&1 -mkdir -p /run/initramfs/state/etc/sysconfig/network-scripts/ +for i in /run/initramfs/state /run/initramfs/state/etc/ /run/initramfs/state/etc/sysconfig /run/initramfs/state/etc/sysconfig/network-scripts; do + [ -d $i ] || mkdir -m 0755 -p $i +done cp /tmp/net.$netif.resolv.conf /run/initramfs/state/etc/ >/dev/null 2>&1 echo "files /etc/sysconfig/network-scripts" > /run/initramfs/rwtab -cp -a /tmp/ifcfg/* /run/initramfs/state/etc/sysconfig/network-scripts/ >/dev/null 2>&1 +cp -a -t /run/initramfs/state/etc/sysconfig/network-scripts/ /tmp/ifcfg/* >/dev/null 2>&1 diff -Naur dracut-010/modules.d/50gensplash/gensplash-pretrigger.sh dracut-0e6a94b/modules.d/50gensplash/gensplash-pretrigger.sh --- dracut-010/modules.d/50gensplash/gensplash-pretrigger.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/50gensplash/gensplash-pretrigger.sh 2011-05-31 16:34:37.000000000 +0200 @@ -9,8 +9,9 @@ info "Starting Gentoo Splash" - [ -x /lib/udev/console_init ] && /lib/udev/console_init tty0 + [ -x /lib/udev/console_init ] && /lib/udev/console_init /dev/tty0 CDROOT=0 . /lib/gensplash-lib.sh splash init + [ -x /lib/udev/console_init ] && /lib/udev/console_init /dev/tty0 fi diff -Naur dracut-010/modules.d/50gensplash/module-setup.sh dracut-0e6a94b/modules.d/50gensplash/module-setup.sh --- dracut-010/modules.d/50gensplash/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/50gensplash/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -13,55 +13,57 @@ } install() { + local _opts + local _splash_theme + local _splash_res + call_splash_geninitramfs() { - local out ret + local _out _ret - out=$(splash_geninitramfs -c "$1" ${@:2} 2>&1) - ret=$? + _out=$(splash_geninitramfs -c "$1" ${@:2} 2>&1) + _ret=$? - if [[ ${out} ]]; then + if [[ ${_out} ]]; then local IFS=' ' - for line in ${out}; do + for line in ${_out}; do if [[ ${line} =~ ^Warning ]]; then dwarn "${line}" else derror "${line}" - (( ret == 0 )) && ret=1 + (( $_ret == 0 )) && _ret=1 fi done fi - return ${ret} + return ${_ret} } - type -P splash_geninitramfs >/dev/null || return 1 - opts='' - + _opts='' if [[ ${DRACUT_GENSPLASH_THEME} ]]; then # Variables from the environment # They're supposed to be set up by e.g. Genkernel in basis of cmdline args. # If user set them he/she would expect to be included only given theme # rather then all even if we're building generic initramfs. - SPLASH_THEME=${DRACUT_GENSPLASH_THEME} - SPLASH_RES=${DRACUT_GENSPLASH_RES} + _splash_theme=${DRACUT_GENSPLASH_THEME} + _splash_res=${DRACUT_GENSPLASH_RES} elif [[ ${hostonly} ]]; then # Settings from config only in hostonly [[ -e /etc/conf.d/splash ]] && source /etc/conf.d/splash - [[ ! ${SPLASH_THEME} ]] && SPLASH_THEME=default - [[ ${SPLASH_RES} ]] && opts+=" -r ${SPLASH_RES}" + [[ ! ${_splash_theme} ]] && _splash_theme=default + [[ ${_splash_res} ]] && _opts+=" -r ${_splash_res}" else # generic - SPLASH_THEME=--all + _splash_theme=--all fi - dinfo "Installing Gentoo Splash (using the ${SPLASH_THEME} theme)" + dinfo "Installing Gentoo Splash (using the ${_splash_theme} theme)" pushd "${initdir}" >/dev/null mv dev dev.old - call_splash_geninitramfs "${initdir}" ${opts} ${SPLASH_THEME} || { + call_splash_geninitramfs "${initdir}" ${_opts} ${_splash_theme} || { derror "Could not build splash" return 1 } diff -Naur dracut-010/modules.d/50plymouth/module-setup.sh dracut-0e6a94b/modules.d/50plymouth/module-setup.sh --- dracut-010/modules.d/50plymouth/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/50plymouth/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -11,9 +11,10 @@ } installkernel() { + local _modname # Include KMS capable drm drivers - for modname in $(find "$srcmods/kernel/drivers/gpu/drm" "$srcmods/extra" -name '*.ko' 2>/dev/null); do - grep -q drm_crtc_init $modname && instmods $modname + for _modname in $(find "$srcmods/kernel/drivers/gpu/drm" "$srcmods/extra" -name '*.ko' 2>/dev/null); do + grep -q drm_crtc_init $_modname && instmods $_modname done } diff -Naur dracut-010/modules.d/50plymouth/plymouth-populate-initrd dracut-0e6a94b/modules.d/50plymouth/plymouth-populate-initrd --- dracut-010/modules.d/50plymouth/plymouth-populate-initrd 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/50plymouth/plymouth-populate-initrd 2011-05-31 16:34:37.000000000 +0200 @@ -7,11 +7,11 @@ inst /sbin/plymouthd /bin/plymouthd dracut_install /bin/plymouth \ "${PLYMOUTH_LOGO_FILE}" \ - /etc/system-release + /etc/system-release -mkdir -p "${initdir}/usr/share/plymouth" +mkdir -m 0755 -p "${initdir}/usr/share/plymouth" -if [[ $hostonly ]]; then +if [[ $hostonly ]]; then dracut_install "${usrlibdir}/plymouth/text.so" \ "${usrlibdir}/plymouth/details.so" \ "/usr/share/plymouth/themes/details/details.plymouth" \ @@ -34,7 +34,7 @@ for x in /usr/share/plymouth/themes/{text,details}/* ; do [[ -f "$x" ]] || continue THEME_DIR=$(dirname "$x") - mkdir -p "${initdir}/$THEME_DIR" + mkdir -m 0755 -p "${initdir}/$THEME_DIR" dracut_install "$x" done for x in "${usrlibdir}"/plymouth/{text,details}.so ; do @@ -44,6 +44,6 @@ done ( cd ${initdir}/usr/share/plymouth/themes; - ln -s text/text.plymouth default.plymouth 2>&1; + ln -s text/text.plymouth default.plymouth 2>&1; ) fi diff -Naur dracut-010/modules.d/50plymouth/plymouth-pretrigger.sh dracut-0e6a94b/modules.d/50plymouth/plymouth-pretrigger.sh --- dracut-010/modules.d/50plymouth/plymouth-pretrigger.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/50plymouth/plymouth-pretrigger.sh 2011-05-31 16:34:37.000000000 +0200 @@ -17,8 +17,10 @@ [ -e /dev/fb ] || ln -s fb0 /dev/fb info "Starting plymouth daemon" - mkdir -m 0755 -p /run/plymouth + mkdir -m 0755 /run/plymouth + [ -x /lib/udev/console_init ] && /lib/udev/console_init /dev/tty0 [ -x /bin/plymouthd ] && /bin/plymouthd --attach-to-session --pid-file /run/plymouth/pid - [ -x /lib/udev/console_init ] && /lib/udev/console_init tty0 /bin/plymouth --show-splash 2>&1 | vinfo + # reset tty after plymouth messed with it + [ -x /lib/udev/console_init ] && /lib/udev/console_init /dev/tty0 fi diff -Naur dracut-010/modules.d/60xen/module-setup.sh dracut-0e6a94b/modules.d/60xen/module-setup.sh --- dracut-010/modules.d/60xen/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/60xen/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -23,11 +23,12 @@ } installkernel() { - for i in \ + local _i + for _i in \ xenbus_probe_frontend xen-pcifront \ xen-fbfront xen-kbdfront xen-blkfront xen-netfront \ ; do - modinfo -k $kernel $i >/dev/null 2>&1 && instmods $i + modinfo -k $kernel $_i >/dev/null 2>&1 && instmods $_i done } diff -Naur dracut-010/modules.d/90btrfs/module-setup.sh dracut-0e6a94b/modules.d/90btrfs/module-setup.sh --- dracut-010/modules.d/90btrfs/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90btrfs/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -3,6 +3,7 @@ # ex: ts=8 sw=4 sts=4 et filetype=sh check() { + local _rootdev # if we don't have btrfs installed on the host system, # no point in trying to support it in the initramfs. type -P btrfs >/dev/null || return 1 @@ -13,9 +14,9 @@ is_btrfs() { get_fs_type /dev/block/$1 | grep -q btrfs; } if [[ $hostonly ]]; then - rootdev=$(find_root_block_device) - if [[ $rootdev ]]; then - is_btrfs "$rootdev" || return 1 + _rootdev=$(find_root_block_device) + if [[ $_rootdev ]]; then + is_btrfs "$_rootdev" || return 1 fi fi diff -Naur dracut-010/modules.d/90crypt/crypt-lib.sh dracut-0e6a94b/modules.d/90crypt/crypt-lib.sh --- dracut-010/modules.d/90crypt/crypt-lib.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90crypt/crypt-lib.sh 2011-05-31 16:34:37.000000000 +0200 @@ -2,7 +2,79 @@ # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh -type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh +command -v getarg >/dev/null || . /lib/dracut-lib.sh + +# ask_for_password +# +# Wraps around plymouth ask-for-password and adds fallback to tty password ask +# if plymouth is not present. +# +# --cmd command +# Command to execute. Required. +# --prompt prompt +# Password prompt. Note that function already adds ':' at the end. +# Recommended. +# --tries n +# How many times repeat command on its failure. Default is 3. +# --ply-[cmd|prompt|tries] +# Command/prompt/tries specific for plymouth password ask only. +# --tty-[cmd|prompt|tries] +# Command/prompt/tries specific for tty password ask only. +# --tty-echo-off +# Turn off input echo before tty command is executed and turn on after. +# It's useful when password is read from stdin. +ask_for_password() { + local cmd; local prompt; local tries=3 + local ply_cmd; local ply_prompt; local ply_tries=3 + local tty_cmd; local tty_prompt; local tty_tries=3 + local ret + + while [ $# -gt 0 ]; do + case "$1" in + --cmd) ply_cmd="$2"; tty_cmd="$2" shift;; + --ply-cmd) ply_cmd="$2"; shift;; + --tty-cmd) tty_cmd="$2"; shift;; + --prompt) ply_prompt="$2"; tty_prompt="$2" shift;; + --ply-prompt) ply_prompt="$2"; shift;; + --tty-prompt) tty_prompt="$2"; shift;; + --tries) ply_tries="$2"; tty_tries="$2"; shift;; + --ply-tries) ply_tries="$2"; shift;; + --tty-tries) tty_tries="$2"; shift;; + --tty-echo-off) tty_echo_off=yes;; + esac + shift + done + + { flock -s 9; + # Prompt for password with plymouth, if installed and running. + if [ -x /bin/plymouth ] && /bin/plymouth --has-active-vt; then + /bin/plymouth ask-for-password \ + --prompt "$ply_prompt" --number-of-tries=$ply_tries \ + --command="$ply_cmd" + ret=$? + else + if [ "$tty_echo_off" = yes ]; then + stty_orig="$(stty -g)" + stty -echo + fi + + local i=1 + while [ $i -le $tty_tries ]; do + [ -n "$tty_prompt" ] && \ + printf "$tty_prompt [$i/$tty_tries]:" >&2 + eval "$tty_cmd" && ret=0 && break + ret=$? + i=$(($i+1)) + [ -n "$tty_prompt" ] && printf '\n' >&2 + done + + [ "$tty_echo_off" = yes ] && stty $stty_orig + fi + } 9>/.console.lock + + [ $ret -ne 0 ] && echo "Wrong password" >&2 + return $ret +} # Try to mount specified device (by path, by UUID or by label) and check # the path with 'test'. @@ -118,3 +190,33 @@ return 1 } + +# readkey keypath keydev device +# +# Mounts , reads key from file , optionally processes it (e.g. +# if encrypted with GPG) and prints to standard output which is supposed to be +# read by cryptsetup. is just passed to helper function for +# informational purpose. +readkey() { + local keypath="$1" + local keydev="$2" + local device="$3" + + local mntp=$(mkuniqdir /mnt keydev) + mount -r "$keydev" "$mntp" || die 'Mounting rem. dev. failed!' + + case "${keypath##*.}" in + gpg) + if [ -f /lib/dracut-crypt-gpg-lib.sh ]; then + . /lib/dracut-crypt-gpg-lib.sh + gpg_decrypt "$mntp" "$keypath" "$keydev" "$device" + else + die "No GPG support to decrypt '$keypath' on '$keydev'." + fi + ;; + *) cat "$mntp/$keypath" ;; + esac + + umount "$mntp" + rmdir "$mntp" +} diff -Naur dracut-010/modules.d/90crypt/cryptroot-ask.sh dracut-0e6a94b/modules.d/90crypt/cryptroot-ask.sh --- dracut-010/modules.d/90crypt/cryptroot-ask.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90crypt/cryptroot-ask.sh 2011-05-31 16:34:37.000000000 +0200 @@ -2,8 +2,11 @@ # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh +PATH=/usr/sbin:/usr/bin:/sbin:/bin +NEWROOT=${NEWROOT:-"/sysroot"} + # do not ask, if we already have root -[ -f /sysroot/proc ] && exit 0 +[ -f $NEWROOT/proc ] && exit 0 # check if destination already exists [ -b /dev/mapper/$2 ] && exit 0 @@ -40,7 +43,7 @@ luksname="$name" break fi - + # path used in crypttab else cdev=$(readlink -f $dev) @@ -66,45 +69,25 @@ keypath="${tmp#*:}" else info "No key found for $device. Will try later." - /sbin/initqueue --unique --onetime --settled \ + initqueue --unique --onetime --settled \ --name cryptroot-ask-$luksname \ - /sbin/cryptroot-ask "$@" + $(command -v cryptroot-ask) "$@" exit 0 fi unset tmp - mntp=$(mkuniqdir /mnt keydev) - mount -r "$keydev" "$mntp" || die 'Mounting rem. dev. failed!' - cryptsetup -d "$mntp/$keypath" luksOpen "$device" "$luksname" - umount "$mntp" - rmdir "$mntp" - unset mntp keypath keydev + info "Using '$keypath' on '$keydev'" + readkey "$keypath" "$keydev" "$device" \ + | cryptsetup -d - luksOpen "$device" "$luksname" + unset keypath keydev else - # Prompt for password with plymouth, if installed and running. - if [ -x /bin/plymouth ] && /bin/plymouth --has-active-vt; then - prompt="Password [$device ($luksname)]:" - if [ ${#luksname} -gt 8 ]; then - sluksname=${sluksname##luks-} - sluksname=${luksname%%${luksname##????????}} - prompt="Password for $device ($sluksname...)" - fi - - # flock against other interactive activities - { flock -s 9; - /bin/plymouth ask-for-password \ - --prompt "$prompt" --number-of-tries=5 \ - --command="/sbin/cryptsetup luksOpen -T1 $device $luksname" - } 9>/.console.lock - - unset sluksname prompt - - else - # flock against other interactive activities - { flock -s 9; - echo "$device ($luksname) is password protected" - cryptsetup luksOpen -T5 $device $luksname - } 9>/.console.lock - fi + luks_open="$(command -v cryptsetup) luksOpen" + ask_for_password --ply-tries 5 \ + --ply-cmd "$luks_open -T1 $device $luksname" \ + --ply-prompt "Password ($device)" \ + --tty-tries 1 \ + --tty-cmd "$luks_open -T5 $device $luksname" + unset luks_open fi unset device luksname diff -Naur dracut-010/modules.d/90crypt/module-setup.sh dracut-0e6a94b/modules.d/90crypt/module-setup.sh --- dracut-010/modules.d/90crypt/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90crypt/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -3,6 +3,7 @@ # ex: ts=8 sw=4 sts=4 et filetype=sh check() { + local _rootdev # if cryptsetup is not installed, then we cannot support encrypted devices. type -P cryptsetup >/dev/null || return 1 @@ -11,11 +12,11 @@ is_crypt() { [[ $(get_fs_type /dev/block/$1) = crypto_LUKS ]]; } [[ $hostonly ]] && { - rootdev=$(find_root_block_device) - if [[ $rootdev ]]; then - # root lives on a block device, so we can be more precise about + _rootdev=$(find_root_block_device) + if [[ $_rootdev ]]; then + # root lives on a block device, so we can be more precise about # hostonly checking - check_block_and_slaves is_crypt "$rootdev" || return 1 + check_block_and_slaves is_crypt "$_rootdev" || return 1 else # root is not on a block device, use the shotgun approach blkid | grep -q crypto\?_LUKS || return 1 @@ -35,9 +36,7 @@ } install() { - inst cryptsetup - inst rmdir - inst readlink + dracut_install cryptsetup rmdir readlink umount inst "$moddir"/cryptroot-ask.sh /sbin/cryptroot-ask inst "$moddir"/probe-keydev.sh /sbin/probe-keydev inst_hook cmdline 10 "$moddir/parse-keydev.sh" diff -Naur dracut-010/modules.d/90crypt/parse-crypt.sh dracut-0e6a94b/modules.d/90crypt/parse-crypt.sh --- dracut-010/modules.d/90crypt/parse-crypt.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90crypt/parse-crypt.sh 2011-05-31 16:34:37.000000000 +0200 @@ -8,34 +8,36 @@ { echo 'SUBSYSTEM!="block", GOTO="luks_end"' echo 'ACTION!="add|change", GOTO="luks_end"' - } > /etc/udev/rules.d/70-luks.rules + } > /etc/udev/rules.d/70-luks.rules.new LUKS=$(getargs rd.luks.uuid rd_LUKS_UUID) if [ -n "$LUKS" ]; then - for luksid in $LUKS; do + for luksid in $LUKS; do luksid=${luksid##luks-} { - printf 'ENV{ID_FS_TYPE}=="crypto_LUKS", ' - printf 'ENV{ID_FS_UUID}=="*%s*", ' $luksid - printf 'RUN+="/sbin/initqueue --unique --onetime ' - printf -- '--name cryptroot-ask-%%k /sbin/cryptroot-ask ' - printf '$env{DEVNAME} luks-$env{ID_FS_UUID}"\n' - } >> /etc/udev/rules.d/70-luks.rules + printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", ' + printf -- 'ENV{ID_FS_UUID}=="*%s*", ' $luksid + printf -- 'RUN+="%s --unique --onetime ' $(command -v initqueue) + printf -- '--name cryptroot-ask-%%k %s ' $(command -v cryptroot-ask) + printf -- '$env{DEVNAME} luks-$env{ID_FS_UUID}"\n' + } >> /etc/udev/rules.d/70-luks.rules.new - printf '[ -e /dev/disk/by-uuid/*%s* ] || exit 1\n' $luksid \ + printf -- '[ -e /dev/disk/by-uuid/*%s* ]\n' $luksid \ >> $hookdir/initqueue/finished/90-crypt.sh { - printf '[ -e /dev/disk/by-uuid/*%s* ] || ' $luksid - printf 'warn "crypto LUKS UUID "%s" not found"\n' $luksid + printf -- '[ -e /dev/disk/by-uuid/*%s* ] || ' $luksid + printf -- 'warn "crypto LUKS UUID "%s" not found"\n' $luksid } >> $hookdir/emergency/90-crypt.sh done else - echo 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="/sbin/initqueue' \ - '--unique --onetime --name cryptroot-ask-%k' \ - '/sbin/cryptroot-ask $env{DEVNAME} luks-$env{ID_FS_UUID}"' \ - >> /etc/udev/rules.d/70-luks.rules + { + printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", RUN+="%s ' $(command -v initqueue) + printf -- '--unique --onetime --name cryptroot-ask-%%k ' + printf -- '%s $env{DEVNAME} luks-$env{ID_FS_UUID}"\n' $(command -v cryptroot-ask) + } >> /etc/udev/rules.d/70-luks.rules.new fi - echo 'LABEL="luks_end"' >> /etc/udev/rules.d/70-luks.rules + echo 'LABEL="luks_end"' >> /etc/udev/rules.d/70-luks.rules.new + mv /etc/udev/rules.d/70-luks.rules.new /etc/udev/rules.d/70-luks.rules fi diff -Naur dracut-010/modules.d/90crypt/parse-keydev.sh dracut-0e6a94b/modules.d/90crypt/parse-keydev.sh --- dracut-010/modules.d/90crypt/parse-keydev.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90crypt/parse-keydev.sh 2011-05-31 16:34:37.000000000 +0200 @@ -28,10 +28,10 @@ fi { - printf 'RUN+="/sbin/initqueue --unique --onetime ' + printf -- 'RUN+="%s --unique --onetime ' $(command -v initqueue) printf -- '--name probe-keydev-%%k ' - printf '/sbin/probe-keydev /dev/%%k %s %s"\n' \ - "${keypath}" "${luksdev}" + printf -- '%s /dev/%%k %s %s"\n' \ + $(command -v probe-keydev) "${keypath}" "${luksdev}" } >&7 done unset arg keypath keydev luksdev diff -Naur dracut-010/modules.d/90dm/11-dm.rules dracut-0e6a94b/modules.d/90dm/11-dm.rules --- dracut-010/modules.d/90dm/11-dm.rules 1970-01-01 01:00:00.000000000 +0100 +++ dracut-0e6a94b/modules.d/90dm/11-dm.rules 2011-05-31 16:34:37.000000000 +0200 @@ -0,0 +1,5 @@ +SUBSYSTEM!="block", GOTO="dm_end" +KERNEL!="dm-[0-9]*", GOTO="dm_end" +ACTION!="add|change", GOTO="dm_end" +OPTIONS+="db_persist" +LABEL="dm_end" diff -Naur dracut-010/modules.d/90dm/dm-pre-udev.sh dracut-0e6a94b/modules.d/90dm/dm-pre-udev.sh --- dracut-010/modules.d/90dm/dm-pre-udev.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90dm/dm-pre-udev.sh 2011-05-31 16:34:37.000000000 +0200 @@ -1,4 +1,4 @@ #!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh -strstr "$(cat /proc/misc)" device-mapper || modprobe dm_mod +strstr "$(cat /proc/misc)" device-mapper || modprobe dm_mod diff -Naur dracut-010/modules.d/90dm/dm-shutdown.sh dracut-0e6a94b/modules.d/90dm/dm-shutdown.sh --- dracut-010/modules.d/90dm/dm-shutdown.sh 1970-01-01 01:00:00.000000000 +0100 +++ dracut-0e6a94b/modules.d/90dm/dm-shutdown.sh 2011-05-31 16:34:37.000000000 +0200 @@ -0,0 +1,2 @@ +echo "Disassembling device-mapper devices" +dmsetup -v remove_all diff -Naur dracut-010/modules.d/90dm/module-setup.sh dracut-0e6a94b/modules.d/90dm/module-setup.sh --- dracut-010/modules.d/90dm/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90dm/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -25,5 +25,8 @@ # Gentoo ebuild for LVM2 prior to 2.02.63-r1 doesn't install above rules # files, but provides the one below: inst_rules 64-device-mapper.rules + inst_rules "$moddir/11-dm.rules" + + inst_hook shutdown 30 "$moddir/dm-shutdown.sh" } diff -Naur dracut-010/modules.d/90dmraid/dmraid.sh dracut-0e6a94b/modules.d/90dmraid/dmraid.sh --- dracut-010/modules.d/90dmraid/dmraid.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90dmraid/dmraid.sh 2011-05-31 16:34:37.000000000 +0200 @@ -21,8 +21,8 @@ if [ -n "$DM_RAIDS" ]; then # only activate specified DM RAIDS - for r in $DM_RAIDS; do - for s in $SETS; do + for r in $DM_RAIDS; do + for s in $SETS; do if [ "${s##$r}" != "$s" ]; then info "Activating $s" dmraid -ay -i -p --rm_partitions "$s" 2>&1 | vinfo @@ -31,7 +31,7 @@ fi done done -else +else # scan and activate all DM RAIDS for s in $SETS; do info "Activating $s" diff -Naur dracut-010/modules.d/90dmraid/module-setup.sh dracut-0e6a94b/modules.d/90dmraid/module-setup.sh --- dracut-010/modules.d/90dmraid/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90dmraid/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -3,6 +3,7 @@ # ex: ts=8 sw=4 sts=4 et filetype=sh check() { + local _rootdev # if we don't have dmraid installed on the host system, no point # in trying to support it in the initramfs. type -P dmraid >/dev/null || return 1 @@ -14,11 +15,11 @@ grep -q _raid_member; } [[ $hostonly ]] && { - rootdev=$(find_root_block_device) - if [[ $rootdev ]]; then - # root lives on a block device, so we can be more precise about + _rootdev=$(find_root_block_device) + if [[ $_rootdev ]]; then + # root lives on a block device, so we can be more precise about # hostonly checking - check_block_and_slaves is_dmraid "$rootdev" || return 1 + check_block_and_slaves is_dmraid "$_rootdev" || return 1 else # root is not on a block device, use the shotgun approach dmraid -r | grep -q ok || return 1 @@ -34,15 +35,16 @@ } install() { - dracut_install dmraid partx kpartx + local _i + dracut_install dmraid partx kpartx inst dmeventd - for i in {"$libdir","$usrlibdir"}/libdmraid-events*.so; do - [ -e "$i" ] && dracut_install "$i" + for _i in {"$libdir","$usrlibdir"}/libdmraid-events*.so; do + [ -e "$_i" ] && dracut_install "$_i" done - inst_rules 10-dm.rules 13-dm-disk.rules 95-dm-notify.rules + inst_rules 10-dm.rules 13-dm-disk.rules 95-dm-notify.rules # Gentoo ebuild for LVM2 prior to 2.02.63-r1 doesn't install above rules # files, but provides the one below: inst_rules 64-device-mapper.rules diff -Naur dracut-010/modules.d/90dmraid/parse-dm.sh dracut-0e6a94b/modules.d/90dmraid/parse-dm.sh --- dracut-010/modules.d/90dmraid/parse-dm.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90dmraid/parse-dm.sh 2011-05-31 16:34:37.000000000 +0200 @@ -7,7 +7,7 @@ udevproperty rd_NO_DM=1 fi -if [ ! -x /sbin/mdadm ] || ! getargbool 1 rd.md.imsm -n rd_NO_MDIMSM || getarg noiswmd; then +if ! command -v mdadm >/dev/null || ! getargbool 1 rd.md.imsm -n rd_NO_MDIMSM || getarg noiswmd; then info "rd.md.imsm=0: no MD RAID for imsm/isw raids" udevproperty rd_NO_MDIMSM=1 fi diff -Naur dracut-010/modules.d/90dmsquash-live/dmsquash-live-genrules.sh dracut-0e6a94b/modules.d/90dmsquash-live/dmsquash-live-genrules.sh --- dracut-010/modules.d/90dmsquash-live/dmsquash-live-genrules.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90dmsquash-live/dmsquash-live-genrules.sh 2011-05-31 16:34:37.000000000 +0200 @@ -5,15 +5,15 @@ live:/dev/*) { printf 'KERNEL=="%s", SYMLINK+="live"\n' \ - ${root#live:/dev/} + ${root#live:/dev/} printf 'SYMLINK=="%s", SYMLINK+="live"\n' \ - ${root#live:/dev/} + ${root#live:/dev/} } >> $UDEVRULESD/99-live-mount.rules { printf 'KERNEL=="%s", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root $env{DEVNAME}"\n' \ - ${root#live:/dev/} + ${root#live:/dev/} printf 'SYMLINK=="%s", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root $env{DEVNAME}"\n' \ - ${root#live:/dev/} + ${root#live:/dev/} } >> $UDEVRULESD/99-live-squash.rules echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/dmsquash.sh ;; diff -Naur dracut-010/modules.d/90dmsquash-live/dmsquash-live-root dracut-0e6a94b/modules.d/90dmsquash-live/dmsquash-live-root --- dracut-010/modules.d/90dmsquash-live/dmsquash-live-root 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90dmsquash-live/dmsquash-live-root 2011-05-31 16:34:37.000000000 +0200 @@ -5,7 +5,7 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh [ -f /tmp/root.info ] && . /tmp/root.info -PATH=$PATH:/sbin:/usr/sbin +PATH=/usr/sbin:/usr/bin:/sbin:/bin if getargbool 0 rd.live.debug -y rdlivedebug; then exec > /tmp/liveroot.$$.out @@ -25,25 +25,26 @@ getargbool 0 rd.live.overlay.readonly -y readonly_overlay && readonly_overlay="--readonly" || readonly_overlay="" overlay=$(getarg rd.live.overlay overlay) -# FIXME: we need to be able to hide the plymouth splash for the check really [ -e $livedev ] && fs=$(blkid -s TYPE -o value $livedev) if [ "$fs" = "iso9660" -o "$fs" = "udf" ]; then check="yes" fi getarg rd.live.check check || check="" if [ -n "$check" ]; then + [ -x /bin/plymouth ] && /bin/plymouth --hide-splash checkisomd5 --verbose $livedev || : if [ $? -ne 0 ]; then die "CD check failed!" exit 1 fi + [ -x /bin/plymouth ] && /bin/plymouth --show-splash fi getarg ro && liverw=ro getarg rw && liverw=rw [ -z "$liverw" ] && liverw=ro # mount the backing of the live image first -mkdir -p /run/initramfs/live +mkdir -m 0755 -p /run/initramfs/live if [ -f $livedev ]; then # no mount needed - we've already got the LiveOS image in initramfs case $livedev in @@ -84,16 +85,16 @@ # need to know where to look for the overlay setup="" if [ -n "$devspec" -a -n "$pathspec" -a -n "$overlay" ]; then - mkdir /overlayfs - mount -n -t auto $devspec /overlayfs || : - if [ -f /overlayfs$pathspec -a -w /overlayfs$pathspec ]; then - losetup $OVERLAY_LOOPDEV /overlayfs$pathspec + mkdir -m 0755 /run/initramfs/overlayfs + mount -n -t auto $devspec /run/initramfs/overlayfs || : + if [ -f /run/initramfs/overlayfs$pathspec -a -w /run/initramfs/overlayfs$pathspec ]; then + losetup $OVERLAY_LOOPDEV /run/initramfs/overlayfs$pathspec if [ -n "$reset_overlay" ]; then dd if=/dev/zero of=$OVERLAY_LOOPDEV bs=64k count=1 2>/dev/null fi setup="yes" fi - umount -l /overlayfs || : + umount -l /run/initramfs/overlayfs || : fi if [ -z "$setup" ]; then @@ -125,11 +126,11 @@ dd if=$OSMINSQFS of=/osmin.img 2> /dev/null OSMIN_SQUASHED_LOOPDEV=$( losetup -f ) losetup -r $OSMIN_SQUASHED_LOOPDEV /osmin.img - mkdir -p /squashfs.osmin - mount -n -t squashfs -o ro $OSMIN_SQUASHED_LOOPDEV /squashfs.osmin + mkdir -m 0755 -p /run/initramfs/squashfs.osmin + mount -n -t squashfs -o ro $OSMIN_SQUASHED_LOOPDEV /run/initramfs/squashfs.osmin OSMIN_LOOPDEV=$( losetup -f ) - losetup -r $OSMIN_LOOPDEV /squashfs.osmin/osmin - umount -l /squashfs.osmin + losetup -r $OSMIN_LOOPDEV /run/initramfs/squashfs.osmin/osmin + umount -l /run/initramfs/squashfs.osmin fi # we might have an embedded fs image to use as rootfs (uncompressed live) @@ -164,17 +165,17 @@ SQUASHED_LOOPDEV=$( losetup -f ) losetup -r $SQUASHED_LOOPDEV $SQUASHED - mkdir -p /squashfs - mount -n -t squashfs -o ro $SQUASHED_LOOPDEV /squashfs + mkdir -m 0755 -p /run/initramfs/squashfs + mount -n -t squashfs -o ro $SQUASHED_LOOPDEV /run/initramfs/squashfs BASE_LOOPDEV=$( losetup -f ) - if [ -f /squashfs/LiveOS/ext3fs.img ]; then - losetup -r $BASE_LOOPDEV /squashfs/LiveOS/ext3fs.img - elif [ -f /squashfs/LiveOS/rootfs.img ]; then - losetup -r $BASE_LOOPDEV /squashfs/LiveOS/rootfs.img + if [ -f /run/initramfs/squashfs/LiveOS/ext3fs.img ]; then + losetup -r $BASE_LOOPDEV /run/initramfs/squashfs/LiveOS/ext3fs.img + elif [ -f /run/initramfs/squashfs/LiveOS/rootfs.img ]; then + losetup -r $BASE_LOOPDEV /run/initramfs/squashfs/LiveOS/rootfs.img fi - umount -l /squashfs + umount -l /run/initramfs/squashfs do_live_from_base_loop fi diff -Naur dracut-010/modules.d/90dmsquash-live/module-setup.sh dracut-0e6a94b/modules.d/90dmsquash-live/module-setup.sh --- dracut-010/modules.d/90dmsquash-live/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90dmsquash-live/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -9,7 +9,7 @@ } depends() { - # if dmsetup is not installed, then we cannot support fedora/red hat + # if dmsetup is not installed, then we cannot support fedora/red hat # style live images echo dm rootfs-block return 0 diff -Naur dracut-010/modules.d/90kernel-modules/insmodpost.sh dracut-0e6a94b/modules.d/90kernel-modules/insmodpost.sh --- dracut-010/modules.d/90kernel-modules/insmodpost.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90kernel-modules/insmodpost.sh 2011-05-31 16:34:37.000000000 +0200 @@ -2,10 +2,10 @@ # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh -for p in $(getargs rd.driver.post rdinsmodpost=); do +for p in $(getargs rd.driver.post rdinsmodpost=); do ( IFS=, - for p in $i; do + for p in $i; do modprobe $p done ) diff -Naur dracut-010/modules.d/90kernel-modules/module-setup.sh dracut-0e6a94b/modules.d/90kernel-modules/module-setup.sh --- dracut-010/modules.d/90kernel-modules/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90kernel-modules/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -17,7 +17,7 @@ hostonly='' instmods atkbd i8042 usbhid hid-apple hid-sunplus hid-cherry hid-logitech hid-microsoft ehci-hcd ohci-hcd uhci-hcd instmods "=drivers/pcmcia" =ide "=drivers/usb/storage" - instmods $(filter_kernel_modules block_module_test) + instmods $(filter_kernel_modules block_module_test) # if not on hostonly mode, install all known filesystems, # if the required list is not set via the filesystems variable if ! [[ $hostonly ]]; then @@ -42,9 +42,19 @@ } install() { + local _f [ -f /etc/modprobe.conf ] && dracut_install /etc/modprobe.conf dracut_install $(find /etc/modprobe.d/ -type f -name '*.conf') inst_hook cmdline 01 "$moddir/parse-kernel.sh" inst_simple "$moddir/insmodpost.sh" /sbin/insmodpost.sh - inst "$srcmods/modules.builtin.bin" "/lib/modules/$kernel/modules.builtin.bin" + + local f + + for _f in modules.builtin.bin modules.builtin; do + [[ $srcmods/$_f ]] && inst "$srcmods/$_f" "/lib/modules/$kernel/$_f" \ + && break + done || { + dfatal "No modules.builtin.bin and modules.builtin found!" + return 1 + } } diff -Naur dracut-010/modules.d/90kernel-modules/parse-kernel.sh dracut-0e6a94b/modules.d/90kernel-modules/parse-kernel.sh --- dracut-010/modules.d/90kernel-modules/parse-kernel.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90kernel-modules/parse-kernel.sh 2011-05-31 16:34:37.000000000 +0200 @@ -2,28 +2,28 @@ # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh -for p in $(getargs rd.driver.pre rdloaddriver=); do - ( +for i in $(getargs rd.driver.pre rdloaddriver=); do + ( IFS=, - for p in $i; do + for p in $i; do modprobe $p 2>&1 | vinfo done ) done -for p in $(getargs rd.driver.blacklist rdblacklist=); do +for i in $(getargs rd.driver.blacklist rdblacklist=); do ( IFS=, - for p in $i; do + for p in $i; do echo "blacklist $p" >> /etc/modprobe.d/initramfsblacklist.conf done ) done -for p in $(getargs rd.driver.post rdinsmodpost=); do +for p in $(getargs rd.driver.post rdinsmodpost=); do echo "blacklist $p" >> /etc/modprobe.d/initramfsblacklist.conf _do_insmodpost=1 done -[ -n "$_do_insmodpost" ] && /sbin/initqueue --settled --unique --onetime /sbin/insmodpost.sh +[ -n "$_do_insmodpost" ] && initqueue --settled --unique --onetime insmodpost.sh unset _do_insmodpost diff -Naur dracut-010/modules.d/90lvm/lvm_scan.sh dracut-0e6a94b/modules.d/90lvm/lvm_scan.sh --- dracut-010/modules.d/90lvm/lvm_scan.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90lvm/lvm_scan.sh 2011-05-31 16:34:37.000000000 +0200 @@ -11,7 +11,7 @@ SNAPSHOT=$(getargs rd.lvm.snapshot rd_LVM_SNAPSHOT=) SNAPSIZE=$(getargs rd.lvm.snapsize rd_LVM_SNAPSIZE=) -[ -d /etc/lvm ] || mkdir -p /etc/lvm +[ -d /etc/lvm ] || mkdir -m 0755 -p /etc/lvm # build a list of devices to scan lvmdevs=$( for f in /tmp/.lvm_scan-*; do @@ -20,7 +20,7 @@ done ) -if [ ! -e /etc/lvm/lvm.conf ]; then +if [ ! -e /etc/lvm/lvm.conf ]; then { echo 'devices {'; echo -n ' filter = [ ' @@ -28,7 +28,7 @@ printf '"a|^/dev/%s$|", ' $dev; done; echo '"r/.*/" ]'; - echo '}'; + echo '}'; # establish LVM locking if [ -n $SNAPSHOT ]; then @@ -66,7 +66,7 @@ maj=${1##*:} min=$2 sub=${3%% *} -sub=${sub%%\(*}; +sub=${sub%%\(*}; check_lvm_ver 2 2 57 $maj $min $sub && \ nopoll="--poll n" @@ -120,7 +120,5 @@ if [ "$lvmwritten" ]; then rm -f /etc/lvm/lvm.conf - ln -s /sbin/lvm-cleanup $hookdir/pre-pivot/30-lvm-cleanup.sh 2>/dev/null - ln -s /sbin/lvm-cleanup $hookdir/pre-pivot/31-lvm-cleanup.sh 2>/dev/null fi unset lvmwritten diff -Naur dracut-010/modules.d/90lvm/module-setup.sh dracut-0e6a94b/modules.d/90lvm/module-setup.sh --- dracut-010/modules.d/90lvm/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90lvm/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -3,6 +3,7 @@ # ex: ts=8 sw=4 sts=4 et filetype=sh check() { + local _rootdev # No point trying to support lvm if the binaries are missing type -P lvm >/dev/null || return 1 @@ -12,11 +13,11 @@ is_lvm() { [[ $(get_fs_type /dev/block/$1) = LVM2_member ]]; } [[ $hostonly ]] && { - rootdev=$(find_root_block_device) - if [[ $rootdev ]]; then - # root lives on a block device, so we can be more precise about + _rootdev=$(find_root_block_device) + if [[ $_rootdev ]]; then + # root lives on a block device, so we can be more precise about # hostonly checking - check_block_and_slaves is_lvm "$rootdev" || return 1 + check_block_and_slaves is_lvm "$_rootdev" || return 1 else # root is not on a block device, use the shotgun approach blkid | grep -q LVM2_member || return 1 @@ -33,11 +34,12 @@ } install() { + local _i inst lvm - inst_rules "$moddir/64-lvm.rules" + inst_rules "$moddir/64-lvm.rules" - if [[ $hostonly ]] || [[ $lvmconf = "yes" ]]; then + if [[ $hostonly ]] || [[ $lvmconf = "yes" ]]; then if [ -f /etc/lvm/lvm.conf ]; then inst /etc/lvm/lvm.conf # FIXME: near-term hack to establish read-only locking; @@ -54,8 +56,8 @@ inst "$moddir/lvm_scan.sh" /sbin/lvm_scan inst_hook cmdline 30 "$moddir/parse-lvm.sh" - for i in {"$libdir","$usrlibdir"}/libdevmapper-event-lvm*.so; do - [ -e "$i" ] && dracut_install "$i" + for _i in {"$libdir","$usrlibdir"}/libdevmapper-event-lvm*.so; do + [ -e "$_i" ] && dracut_install "$_i" done } diff -Naur dracut-010/modules.d/90lvm/parse-lvm.sh dracut-0e6a94b/modules.d/90lvm/parse-lvm.sh --- dracut-010/modules.d/90lvm/parse-lvm.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90lvm/parse-lvm.sh 2011-05-31 16:34:37.000000000 +0200 @@ -10,7 +10,7 @@ rm -f /etc/udev/rules.d/64-lvm*.rules else for dev in $(getargs rd.lvm.vg rd_LVM_VG=) $(getargs rd.lvm.lv rd_LVM_LV=); do - printf '[ -e "/dev/%s" ] || exit 1\n' $dev \ + printf '[ -e "/dev/%s" ]\n' $dev \ >> $hookdir/initqueue/finished/lvm.sh { printf '[ -e "/dev/%s" ] || ' $dev diff -Naur dracut-010/modules.d/90mdraid/65-md-incremental-imsm.rules dracut-0e6a94b/modules.d/90mdraid/65-md-incremental-imsm.rules --- dracut-010/modules.d/90mdraid/65-md-incremental-imsm.rules 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90mdraid/65-md-incremental-imsm.rules 2011-05-31 16:34:37.000000000 +0200 @@ -22,10 +22,10 @@ LABEL="do_md_inc" -# +# # if rd_MDADMCONF do not assemble incrementally # defer auto assembly until the udev queue is settled -# +# ENV{rd_MDADMCONF}!="?*", GOTO="md_auto_end" RUN+="/bin/sh -c 'ln -s /sbin/md_finished.sh $hookdir/initqueue/finished/md_finished.sh;/sbin/initqueue --settled --onetime --unique /sbin/mdadm_auto'" diff -Naur dracut-010/modules.d/90mdraid/mdadm_auto.sh dracut-0e6a94b/modules.d/90mdraid/mdadm_auto.sh --- dracut-010/modules.d/90mdraid/mdadm_auto.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90mdraid/mdadm_auto.sh 2011-05-31 16:34:37.000000000 +0200 @@ -3,5 +3,5 @@ # ex: ts=8 sw=4 sts=4 et filetype=sh type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh -info "Autoassembling MD Raid" -/sbin/mdadm -As --auto=yes --run 2>&1 | vinfo +info "Autoassembling MD Raid" +mdadm -As --auto=yes --run 2>&1 | vinfo diff -Naur dracut-010/modules.d/90mdraid/mdcontainer_start.sh dracut-0e6a94b/modules.d/90mdraid/mdcontainer_start.sh --- dracut-010/modules.d/90mdraid/mdcontainer_start.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90mdraid/mdcontainer_start.sh 2011-05-31 16:34:37.000000000 +0200 @@ -7,6 +7,6 @@ udevadm control --stop-exec-queue # and activate any containers mdadm -IR $md 2>&1 | vinfo -ln -s /sbin/mdraid-cleanup $hookdir/pre-pivot/30-mdraid-cleanup.sh 2>/dev/null -ln -s /sbin/mdraid-cleanup $hookdir/pre-pivot/31-mdraid-cleanup.sh 2>/dev/null +ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/30-mdraid-cleanup.sh 2>/dev/null +ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/31-mdraid-cleanup.sh 2>/dev/null udevadm control --start-exec-queue diff -Naur dracut-010/modules.d/90mdraid/mdmon-pre-udev.sh dracut-0e6a94b/modules.d/90mdraid/mdmon-pre-udev.sh --- dracut-010/modules.d/90mdraid/mdmon-pre-udev.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90mdraid/mdmon-pre-udev.sh 2011-05-31 16:34:37.000000000 +0200 @@ -2,5 +2,5 @@ # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # save state dir for mdmon/mdadm for the real root -mkdir -m 0755 /run/mdadm +[ -d /run/mdadm ] || mkdir -m 0755 /run/mdadm # backward compat link diff -Naur dracut-010/modules.d/90mdraid/mdraid-cleanup.sh dracut-0e6a94b/modules.d/90mdraid/mdraid-cleanup.sh --- dracut-010/modules.d/90mdraid/mdraid-cleanup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90mdraid/mdraid-cleanup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -7,8 +7,8 @@ [ -b $i ] || continue mddetail=$(udevadm info --query=property --name=$i) - case "$mddetail" in - *MD_LEVEL=container*) + case "$mddetail" in + *MD_LEVEL=container*) ;; *DEVTYPE=partition*) ;; diff -Naur dracut-010/modules.d/90mdraid/mdraid_start.sh dracut-0e6a94b/modules.d/90mdraid/mdraid_start.sh --- dracut-010/modules.d/90mdraid/mdraid_start.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90mdraid/mdraid_start.sh 2011-05-31 16:34:37.000000000 +0200 @@ -11,7 +11,7 @@ # there could still be some leftover devices # which have had a container added -for md in /dev/md[0-9]* /dev/md/*; do +for md in /dev/md[0-9]* /dev/md/*; do [ -b "$md" ] || continue udevinfo="$(udevadm info --query=env --name=$md)" strstr "$udevinfo" "MD_UUID=" && continue @@ -21,6 +21,6 @@ done unset udevinfo -ln -s /sbin/mdraid-cleanup $hookdir/pre-pivot/30-mdraid-cleanup.sh 2>/dev/null -ln -s /sbin/mdraid-cleanup $hookdir/pre-pivot/31-mdraid-cleanup.sh 2>/dev/null +ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/30-mdraid-cleanup.sh 2>/dev/null +ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/31-mdraid-cleanup.sh 2>/dev/null udevadm control --start-exec-queue diff -Naur dracut-010/modules.d/90mdraid/md-shutdown.sh dracut-0e6a94b/modules.d/90mdraid/md-shutdown.sh --- dracut-010/modules.d/90mdraid/md-shutdown.sh 1970-01-01 01:00:00.000000000 +0100 +++ dracut-0e6a94b/modules.d/90mdraid/md-shutdown.sh 2011-05-31 16:34:37.000000000 +0200 @@ -0,0 +1,2 @@ +echo "Disassembling mdraid devices." +mdadm -v --stop --scan diff -Naur dracut-010/modules.d/90mdraid/module-setup.sh dracut-0e6a94b/modules.d/90mdraid/module-setup.sh --- dracut-010/modules.d/90mdraid/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90mdraid/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -3,6 +3,7 @@ # ex: ts=8 sw=4 sts=4 et filetype=sh check() { + local _rootdev # No mdadm? No mdraid support. type -P mdadm >/dev/null || return 1 @@ -12,11 +13,11 @@ is_mdraid() { [[ -d "/sys/dev/block/$1/md" ]]; } [[ $hostonly ]] && { - rootdev=$(find_root_block_device) - if [[ $rootdev ]]; then - # root lives on a block device, so we can be more precise about + _rootdev=$(find_root_block_device) + if [[ $_rootdev ]]; then + # root lives on a block device, so we can be more precise about # hostonly checking - check_block_and_slaves is_mdraid "$rootdev" || return 1 + check_block_and_slaves is_mdraid "$_rootdev" || return 1 else # root is not on a block device, use the shotgun approach blkid | egrep -q '(linux|isw)_raid' || return 1 @@ -36,12 +37,12 @@ } install() { - dracut_install mdadm partx + dracut_install mdadm partx # XXX: mdmon really needs to run as non-root? # If so, write only the user it needs in the initrd's /etc/passwd (and maybe /etc/group) - # in a similar fashion to modules.d/95nfs. Do not copy /etc/passwd and /etc/group from + # in a similar fashion to modules.d/95nfs. Do not copy /etc/passwd and /etc/group from # the system into the initrd. # dledford has hardware to test this, so he should be able to clean this up. # inst /etc/passwd @@ -53,11 +54,11 @@ inst_rules "$moddir/65-md-incremental-imsm.rules" - if ! mdadm -Q -e imsm /dev/null &> /dev/null; then + if ! mdadm -Q -e imsm /dev/null &> /dev/null; then inst_hook pre-trigger 30 "$moddir/md-noimsm.sh" fi - if [[ $hostonly ]] || [[ $mdadmconf = "yes" ]]; then + if [[ $hostonly ]] || [[ $mdadmconf = "yes" ]]; then if [ -f /etc/mdadm.conf ]; then inst /etc/mdadm.conf else @@ -67,7 +68,7 @@ if [ -x /sbin/mdmon ] ; then dracut_install mdmon - fi + fi inst_hook pre-udev 30 "$moddir/mdmon-pre-udev.sh" inst "$moddir/mdraid_start.sh" /sbin/mdraid_start @@ -76,5 +77,6 @@ inst "$moddir/md_finished.sh" /sbin/md_finished.sh inst_hook pre-trigger 30 "$moddir/parse-md.sh" inst "$moddir/mdraid-cleanup.sh" /sbin/mdraid-cleanup + inst_hook shutdown 30 "$moddir/md-shutdown.sh" } diff -Naur dracut-010/modules.d/90mdraid/parse-md.sh dracut-0e6a94b/modules.d/90mdraid/parse-md.sh --- dracut-010/modules.d/90mdraid/parse-md.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90mdraid/parse-md.sh 2011-05-31 16:34:37.000000000 +0200 @@ -11,17 +11,17 @@ if [ -n "$MD_UUID" ]; then for f in /etc/udev/rules.d/65-md-incremental*.rules; do [ -e "$f" ] || continue - while read line; do + while read line; do if [ "${line%%UUID CHECK}" != "$line" ]; then for uuid in $MD_UUID; do printf 'ENV{MD_UUID}=="%s", GOTO="do_md_inc"\n' $uuid done; - printf 'GOTO="md_inc_end"\n'; + printf 'GOTO="md_inc_end"\n'; else - echo $line; + echo $line; fi done < "${f}" > "${f}.new" - mv "${f}.new" "$f" + mv "${f}.new" "$f" done fi fi diff -Naur dracut-010/modules.d/90multipath/module-setup.sh dracut-0e6a94b/modules.d/90multipath/module-setup.sh --- dracut-010/modules.d/90multipath/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90multipath/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -3,6 +3,7 @@ # ex: ts=8 sw=4 sts=4 et filetype=sh check() { + local _rootdev # if there's no multipath binary, no go. type -P multipath >/dev/null || return 1 @@ -16,9 +17,9 @@ } if [[ $hostonly ]]; then - rootdev=$(find_root_block_device) - if [[ $rootdev ]]; then - check_block_and_slaves is_mpath "$rootdev" && return 0 + _rootdev=$(find_root_block_device) + if [[ $_rootdev ]]; then + check_block_and_slaves is_mpath "$_rootdev" && return 0 fi return 1 fi @@ -41,7 +42,8 @@ } install() { - for f in \ + local _f + for _f in \ /sbin/dmsetup \ /sbin/kpartx \ /sbin/mpath_wait \ @@ -53,7 +55,7 @@ /etc/multipath.conf \ /etc/multipath/* \ "$libdir"/libmultipath* "$libdir"/multipath/*; do - [ -e "$f" ] && inst "$f" + [ -e "$_f" ] && inst "$_f" done inst_hook pre-trigger 02 "$moddir/multipathd.sh" diff -Naur dracut-010/modules.d/90multipath/multipathd.sh dracut-0e6a94b/modules.d/90multipath/multipathd.sh --- dracut-010/modules.d/90multipath/multipathd.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90multipath/multipathd.sh 2011-05-31 16:34:37.000000000 +0200 @@ -6,6 +6,6 @@ modprobe dm-multipath multipathd -B || multipathd else - rm /etc/udev/rules.d/??-multipath.rules 2>/dev/null + rm /etc/udev/rules.d/??-multipath.rules 2>/dev/null fi diff -Naur dracut-010/modules.d/90multipath/multipathd-stop.sh dracut-0e6a94b/modules.d/90multipath/multipathd-stop.sh --- dracut-010/modules.d/90multipath/multipathd-stop.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/90multipath/multipathd-stop.sh 2011-05-31 16:34:37.000000000 +0200 @@ -4,7 +4,7 @@ if [ -e /etc/multipath.conf ]; then HARD="" - while pidof multipathd >/dev/null 2>&1; do + while pidof multipathd >/dev/null 2>&1; do for pid in $(pidof multipathd); do kill $HARD $pid >/dev/null 2>&1 done diff -Naur dracut-010/modules.d/91crypt-gpg/crypt-gpg-lib.sh dracut-0e6a94b/modules.d/91crypt-gpg/crypt-gpg-lib.sh --- dracut-010/modules.d/91crypt-gpg/crypt-gpg-lib.sh 1970-01-01 01:00:00.000000000 +0100 +++ dracut-0e6a94b/modules.d/91crypt-gpg/crypt-gpg-lib.sh 2011-05-31 16:34:37.000000000 +0200 @@ -0,0 +1,33 @@ +#!/bin/sh +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ex: ts=4 sw=4 sts=0 et filetype=sh + +command -v ask_for_password >/dev/null || . /lib/dracut-crypt-lib.sh + +# gpg_decrypt mnt_point keypath keydev device +# +# Decrypts encrypted symmetrically key to standard output. +# +# mnt_point - mount point where is already mounted +# keypath - GPG encrypted key path relative to +# keydev - device on which key resides; only to display in prompt +# device - device to be opened by cryptsetup; only to display in prompt +gpg_decrypt() { + local mntp="$1" + local keypath="$2" + local keydev="$3" + local device="$4" + + local gpghome=/tmp/gnupg + local opts="--homedir $gpghome --no-mdc-warning --skip-verify --quiet" + opts="$opts --logger-file /dev/null --batch --no-tty --passphrase-fd 0" + + mkdir -m 0700 -p "$gpghome" + + ask_for_password \ + --cmd "gpg $opts --decrypt $mntp/$keypath" \ + --prompt "Password ($keypath on $keydev for $device)" \ + --tries 3 --tty-echo-off + + rm -rf -- "$gpghome" +} diff -Naur dracut-010/modules.d/91crypt-gpg/module-setup.sh dracut-0e6a94b/modules.d/91crypt-gpg/module-setup.sh --- dracut-010/modules.d/91crypt-gpg/module-setup.sh 1970-01-01 01:00:00.000000000 +0100 +++ dracut-0e6a94b/modules.d/91crypt-gpg/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -0,0 +1,19 @@ +#!/bin/bash +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ex: ts=8 sw=4 sts=4 et filetype=sh + +# GPG support is optional +check() { + type -P gpg >/dev/null || return 1 + + return 255 +} + +depends() { + echo crypt +} + +install() { + dracut_install gpg + inst "$moddir/crypt-gpg-lib.sh" "/lib/dracut-crypt-gpg-lib.sh" +} diff -Naur dracut-010/modules.d/95dasd/module-setup.sh dracut-0e6a94b/modules.d/95dasd/module-setup.sh --- dracut-010/modules.d/95dasd/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95dasd/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -3,8 +3,8 @@ # ex: ts=8 sw=4 sts=4 et filetype=sh check() { - arch=$(uname -m) - [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 + local _arch=$(uname -m) + [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 return 0 } diff -Naur dracut-010/modules.d/95dasd_mod/module-setup.sh dracut-0e6a94b/modules.d/95dasd_mod/module-setup.sh --- dracut-010/modules.d/95dasd_mod/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95dasd_mod/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -3,8 +3,8 @@ # ex: ts=8 sw=4 sts=4 et filetype=sh check() { - arch=$(uname -m) - [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 + local _arch=$(uname -m) + [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1 return 0 } diff -Naur dracut-010/modules.d/95dasd_mod/parse-dasd-mod.sh dracut-0e6a94b/modules.d/95dasd_mod/parse-dasd-mod.sh --- dracut-010/modules.d/95dasd_mod/parse-dasd-mod.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95dasd_mod/parse-dasd-mod.sh 2011-05-31 16:34:37.000000000 +0200 @@ -1,7 +1,7 @@ #!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh -[ -d /etc/modprobe.d ] || mkdir /etc/modprobe.d +[ -d /etc/modprobe.d ] || mkdir -m 0755 -p /etc/modprobe.d dasd_arg=$(getarg rd.dasd_mod.dasd rd_DASD_MOD=) if [ -n "$dasd_arg" ]; then diff -Naur dracut-010/modules.d/95debug/module-setup.sh dracut-0e6a94b/modules.d/95debug/module-setup.sh --- dracut-010/modules.d/95debug/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95debug/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -12,7 +12,7 @@ } install() { - dracut_install -o ps grep more cat rm strace free showmount + dracut_install -o ps grep more cat rm strace free showmount dracut_install -o ping netstat rpcinfo vi scp ping6 ssh dracut_install -o fsck fsck.ext2 fsck.ext4 fsck.ext3 fsck.ext4dev fsck.vfat e2fsck diff -Naur dracut-010/modules.d/95fcoe/fcoe-edd.sh dracut-0e6a94b/modules.d/95fcoe/fcoe-edd.sh --- dracut-010/modules.d/95fcoe/fcoe-edd.sh 1970-01-01 01:00:00.000000000 +0100 +++ dracut-0e6a94b/modules.d/95fcoe/fcoe-edd.sh 2011-05-31 16:34:37.000000000 +0200 @@ -0,0 +1,25 @@ +#!/bin/sh +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ex: ts=8 sw=4 sts=4 et filetype=sh + +dcb=$1 + +if ! [ -d /sys/firmware/edd ]; then + modprobe edd + while ! [ -d /sys/firmware/edd ]; do sleep 0.1; done +fi + +for disk in /sys/firmware/edd/int13_*; do + [ -d $disk ] || continue + for nic in ${disk}/pci_dev/net/*; do + [ -d $nic ] || continue + if [ -e ${nic}/address ]; then + fcoe_interface=${nic##*/} + if ! [ -e "/tmp/.fcoe-$fcoe_interface" ]; then + /sbin/fcoe-up $fcoe_interface $dcb + > "/tmp/.fcoe-$fcoe_interface" + fi + fi + done +done +modprobe -r edd diff -Naur dracut-010/modules.d/95fcoe/fcoe-up dracut-0e6a94b/modules.d/95fcoe/fcoe-up --- dracut-010/modules.d/95fcoe/fcoe-up 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95fcoe/fcoe-up 2011-05-31 16:34:37.000000000 +0200 @@ -3,24 +3,24 @@ # ex: ts=8 sw=4 sts=4 et filetype=sh # # We get called like this: -# /sbin/fcoe-up +# fcoe-up # # Note currently only nodcb is supported, the dcb option is reserved for # future use. -PATH=$PATH:/sbin:/usr/sbin +PATH=/usr/sbin:/usr/bin:/sbin:/bin # Huh? Missing arguments ?? [ -z "$1" -o -z "$2" ] && exit 1 export PS4="fcoe-up.$1.$$ + " -exec >>/run/initramfs/initlog.pipe 2>>/run/initramfs/initlog.pipe +exec >>/run/initramfs/loginit.pipe 2>>/run/initramfs/loginit.pipe type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh netif=$1 dcb=$2 -/sbin/ip link set "$netif" up +ip link set "$netif" up wait_for_if_up "$netif" if [ "$dcb" = "dcb" ]; then diff -Naur dracut-010/modules.d/95fcoe/module-setup.sh dracut-0e6a94b/modules.d/95fcoe/module-setup.sh --- dracut-010/modules.d/95fcoe/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95fcoe/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -21,16 +21,16 @@ } install() { - dracut_install ip - inst dcbtool + dracut_install ip + inst dcbtool inst fipvlan inst lldpad - mkdir -p "$initdir/var/lib/lldpad" + mkdir -m 0755 -p "$initdir/var/lib/lldpad" inst "$moddir/fcoe-up" "/sbin/fcoe-up" + inst "$moddir/fcoe-edd.sh" "/sbin/fcoe-edd" inst "$moddir/fcoe-genrules.sh" "/sbin/fcoe-genrules.sh" - inst_hook pre-udev 60 "$moddir/fcoe-genrules.sh" inst_hook cmdline 99 "$moddir/parse-fcoe.sh" } diff -Naur dracut-010/modules.d/95fcoe/parse-fcoe.sh dracut-0e6a94b/modules.d/95fcoe/parse-fcoe.sh --- dracut-010/modules.d/95fcoe/parse-fcoe.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95fcoe/parse-fcoe.sh 2011-05-31 16:34:37.000000000 +0200 @@ -51,20 +51,7 @@ if [ "$fcoe_dcb" != "nodcb" -a "$fcoe_dcb" != "dcb" ] ; then warn "Invalid FCoE DCB option: $fcoe_dcb" fi - [ -d /sys/firmware/edd ] || modprobe edd - # parse edd interfaces - for disk in /sys/firmware/edd/int13_*; do - [ -d $disk ] || continue - for nic in ${disk}/pci_dev/net/*; do - [ -d $nic ] || continue - if [ -e ${nic}/address ]; then - unset fcoe_mac - unset fcoe_interface - fcoe_mac=$(cat ${nic}/address) - [ -n "$fcoe_mac" ] && source /sbin/fcoe-genrules.sh - fi - done - done + /sbin/initqueue --settled --unique /sbin/fcoe-edd $fcoe_dcb else for fcoe in $(getargs fcoe=); do unset fcoe_mac @@ -73,6 +60,6 @@ if [ "$fcoe_dcb" != "nodcb" -a "$fcoe_dcb" != "dcb" ] ; then warn "Invalid FCoE DCB option: $fcoe_dcb" fi - source /sbin/fcoe-genrules.sh + . $(command -v fcoe-genrules.sh) done -fi \ Kein Zeilenumbruch am Dateiende. +fi diff -Naur dracut-010/modules.d/95fstab-sys/module-setup.sh dracut-0e6a94b/modules.d/95fstab-sys/module-setup.sh --- dracut-010/modules.d/95fstab-sys/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95fstab-sys/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -12,5 +12,7 @@ install() { dracut_install /etc/fstab.sys + dracut_install /sbin/fsck* + type -P e2fsck >/dev/null && dracut_install e2fsck inst_hook pre-pivot 00 "$moddir/mount-sys.sh" } diff -Naur dracut-010/modules.d/95fstab-sys/mount-sys.sh dracut-0e6a94b/modules.d/95fstab-sys/mount-sys.sh --- dracut-010/modules.d/95fstab-sys/mount-sys.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95fstab-sys/mount-sys.sh 2011-05-31 16:34:37.000000000 +0200 @@ -2,14 +2,25 @@ # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh -fstab_mount(){ - local dev mp type opts rest +type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh + +fstab_mount() { + local _dev _mp _fs _opts _dump _pass _rest test -e "$1" || return 1 info "Mounting from $1" - while read dev mp type opts rest; do - [ -z "${dev%%#*}" ]&& continue # Skip comment lines - mount -v -t $type -o $opts $dev $NEWROOT/$mp - done < $1 | vinfo + while read _dev _mp _fs _opts _dump _pass _rest; do + [ -z "${_dev%%#*}" ] && continue # Skip comment lines + if [ ! -e "$_dev" ]; then + warn "Device $_dev doesn't exist, skipping mount." + continue + fi + if [ "$_pass" -gt 0 ] && ! strstr "$_opts" _netdev; then + wrap_fsck "$_dev" + fi + _fs=$(det_fs "$_dev" "$_fs" /etc/fstab.sys) + info "Mounting $_dev" + mount -v -t $_fs -o $_opts $_dev $NEWROOT/$_mp 2>&1 | vinfo + done < $1 return 0 } diff -Naur dracut-010/modules.d/95iscsi/iscsiroot dracut-0e6a94b/modules.d/95iscsi/iscsiroot --- dracut-010/modules.d/95iscsi/iscsiroot 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95iscsi/iscsiroot 2011-05-31 16:34:37.000000000 +0200 @@ -4,13 +4,13 @@ # # This implementation is incomplete: Discovery mode is not implemented and # the argument handling doesn't follow currently agreed formats. This is mainly -# because rfc4173 does not say anything about iscsi_initiator but open-iscsi's +# because rfc4173 does not say anything about iscsi_initiator but open-iscsi's # iscsistart needs this. # type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh -PATH=$PATH:/sbin:/usr/sbin +PATH=/usr/sbin:/usr/bin:/sbin:/bin # Huh? Empty $1? [ -z "$1" ] && exit 1 @@ -18,7 +18,7 @@ # Huh? Empty $2? [ -z "$2" ] && exit 1 -# Huh? Empty $3? This isn't really necessary, since NEWROOT isn't +# Huh? Empty $3? This isn't really necessary, since NEWROOT isn't # used here. But let's be consistent [ -z "$3" ] && exit 1 @@ -69,7 +69,7 @@ arg=$(getargs rd.iscsi.in.password iscsi_in_password=) [ -n "$arg" ] && iscsi_in_password=$arg -handle_netroot() +handle_netroot() { iroot=$1 # override conf/commandline options by dhcp root_path @@ -78,7 +78,7 @@ IFS=@ set $iroot if [ $# -gt 1 ]; then - authinfo=$1; shift + authinfo=$1; shift iroot=$* # allow empty authinfo to allow having an @ in iscsi_target_name like this: # netroot=iscsi:@192.168.1.100::3260::iqn.2009-01.com.example:testdi@sk @@ -92,13 +92,13 @@ iscsi_in_password=$4 fi fi - fi + fi IFS="$OLDIFS" local v=${iroot}: local i - set -- + set -- while [ -n "$v" ]; do if [ "${v#\[*:*:*\]:}" != "$v" ]; then # handle IPv6 address @@ -106,7 +106,7 @@ i="${i##\[}" set -- "$@" "$i" v=${v#\[$i\]:} - else + else set -- "$@" "${v%%:*}" v=${v#*:} fi @@ -183,8 +183,8 @@ } # loop over all netroot parameter -if getarg netroot; then - for nroot in $(getargs netroot); do +if getarg netroot; then + for nroot in $(getargs netroot); do [ "${netroot%%:*}" = "iscsi" ] || continue handle_netroot ${nroot##iscsi:} done diff -Naur dracut-010/modules.d/95iscsi/module-setup.sh dracut-0e6a94b/modules.d/95iscsi/module-setup.sh --- dracut-010/modules.d/95iscsi/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95iscsi/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -3,6 +3,7 @@ # ex: ts=8 sw=4 sts=4 et filetype=sh check() { + local _rootdev # If our prerequisites are not met, fail anyways. type -P iscsistart hostname iscsi-iname >/dev/null || return 1 @@ -13,7 +14,7 @@ [[ $debug ]] && set -x - is_iscsi() ( + is_iscsi() ( [[ -L /sys/dev/block/$1 ]] || return cd "$(readlink -f /sys/dev/block/$1)" until [[ -d sys || -d iscsi_session ]]; do @@ -23,11 +24,11 @@ ) [[ $hostonly ]] && { - rootdev=$(find_root_block_device) - if [[ $rootdev ]]; then - # root lives on a block device, so we can be more precise about + _rootdev=$(find_root_block_device) + if [[ $_rootdev ]]; then + # root lives on a block device, so we can be more precise about # hostonly checking - check_block_and_slaves is_iscsi "$rootdev" || return 1 + check_block_and_slaves is_iscsi "$_rootdev" || return 1 else return 1 fi @@ -40,12 +41,17 @@ } installkernel() { - instmods iscsi_tcp crc32c iscsi_ibft + instmods iscsi_tcp iscsi_ibft crc32c + iscsi_module_test() { + local _iscsifuncs='iscsi_register_transport' + fgrep -q "$_iscsifuncs" "$1" + } + instmods $(filter_kernel_modules iscsi_module_test) } install() { dracut_install umount - inst iscsistart + inst iscsistart inst hostname inst iscsi-iname inst_hook cmdline 90 "$moddir/parse-iscsiroot.sh" diff -Naur dracut-010/modules.d/95iscsi/mount-lun.sh dracut-0e6a94b/modules.d/95iscsi/mount-lun.sh --- dracut-010/modules.d/95iscsi/mount-lun.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95iscsi/mount-lun.sh 2011-05-31 16:34:37.000000000 +0200 @@ -8,7 +8,7 @@ for disk in /dev/disk/by-path/*-iscsi-*-$iscsi_lun; do if mount -t ${fstype:-auto} -o "$rflags" $disk $NEWROOT; then - if [ ! -d /sysroot/proc ]; then + if [ ! -d $NEWROOT/proc ]; then umount $disk continue fi diff -Naur dracut-010/modules.d/95nbd/module-setup.sh dracut-0e6a94b/modules.d/95nbd/module-setup.sh --- dracut-010/modules.d/95nbd/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95nbd/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -3,18 +3,19 @@ # ex: ts=8 sw=4 sts=4 et filetype=sh check() { + local _rootdev # If our prerequisites are not met, fail. type -P nbd-client >/dev/null || return 1 - # if an nbd device is not somewhere in the chain of devices root is + # if an nbd device is not somewhere in the chain of devices root is # mounted on, fail the hostonly check. [[ $hostonly ]] && { is_nbd() { [[ -b /dev/block/$1 && $1 == 43:* ]] ;} . $dracutfunctions - rootdev=$(find_root_block_device) - [[ -b /dev/block/$rootdev ]] || return 1 - check_block_and_slaves is_nbd "$rootdev" || return 1 + _rootdev=$(find_root_block_device) + [[ -b /dev/block/$_rootdev ]] || return 1 + check_block_and_slaves is_nbd "$_rootdev" || return 1 } return 0 diff -Naur dracut-010/modules.d/95nbd/nbdroot dracut-0e6a94b/modules.d/95nbd/nbdroot --- dracut-010/modules.d/95nbd/nbdroot 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95nbd/nbdroot 2011-05-31 16:34:37.000000000 +0200 @@ -4,7 +4,7 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh -PATH=$PATH:/sbin:/usr/sbin +PATH=/usr/sbin:/usr/bin:/sbin:/bin # Huh? Empty $1? [ -z "$1" ] && exit 1 diff -Naur dracut-010/modules.d/95nbd/parse-nbdroot.sh dracut-0e6a94b/modules.d/95nbd/parse-nbdroot.sh --- dracut-010/modules.d/95nbd/parse-nbdroot.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95nbd/parse-nbdroot.sh 2011-05-31 16:34:37.000000000 +0200 @@ -20,7 +20,7 @@ v=${v#*:} done - unset server port + unset server port server=$2; port=$3; } diff -Naur dracut-010/modules.d/95nfs/module-setup.sh dracut-0e6a94b/modules.d/95nfs/module-setup.sh --- dracut-010/modules.d/95nfs/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95nfs/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -23,35 +23,37 @@ } install() { + local _i + local _nsslibs type -P portmap >/dev/null && dracut_install portmap type -P rpcbind >/dev/null && dracut_install rpcbind - dracut_install rpc.statd mount.nfs mount.nfs4 umount - [ -f /etc/netconfig ] && dracut_install /etc/netconfig - dracut_install /etc/services + dracut_install rpc.statd mount.nfs mount.nfs4 umount + [ -f /etc/netconfig ] && dracut_install /etc/netconfig + dracut_install /etc/services dracut_install /etc/nsswitch.conf /etc/rpc /etc/protocols dracut_install rpc.idmapd /etc/idmapd.conf dracut_install sed - for i in {"$libdir","$usrlibdir"}/libnfsidmap_nsswitch.so* \ + for _i in {"$libdir","$usrlibdir"}/libnfsidmap_nsswitch.so* \ {"$libdir","$usrlibdir"}/libnfsidmap/*.so \ {"$libdir","$usrlibdir"}/libnfsidmap*.so*; do - [ -e "$i" ] && dracut_install "$i" + [ -e "$_i" ] && dracut_install "$_i" done - nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \ + _nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \ | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|') - nsslibs=${nsslibs#|} - nsslibs=${nsslibs%|} + _nsslibs=${_nsslibs#|} + _nsslibs=${_nsslibs%|} - dracut_install $(for i in $(ls {/usr,}$libdir/libnss*.so 2>/dev/null); do echo $i;done | egrep "$nsslibs") + dracut_install $(for _i in $(ls {/usr,}$libdir/libnss*.so 2>/dev/null); do echo $_i;done | egrep "$_nsslibs") inst_hook cmdline 90 "$moddir/parse-nfsroot.sh" inst_hook pre-pivot 99 "$moddir/nfsroot-cleanup.sh" inst "$moddir/nfsroot" "/sbin/nfsroot" - mkdir -p "$initdir/var/lib/nfs/rpc_pipefs" - mkdir -p "$initdir/var/lib/rpcbind" - mkdir -p "$initdir/var/lib/nfs/statd/sm" + mkdir -m 0755 -p "$initdir/var/lib/nfs/rpc_pipefs" + mkdir -m 0755 -p "$initdir/var/lib/rpcbind" + mkdir -m 0755 -p "$initdir/var/lib/nfs/statd/sm" # Rather than copy the passwd file in, just set a user for rpcbind # We'll save the state and restart the daemon from the root anyway @@ -61,9 +63,11 @@ egrep '^rpc:' /etc/passwd >> "$initdir/etc/passwd" egrep '^rpcuser:' /etc/passwd >> "$initdir/etc/passwd" #type -P nologin >/dev/null && dracut_install nologin + egrep '^rpc:' /etc/group >> "$initdir/etc/group" # rpc user needs to be able to write to this directory to save the warmstart # file - chmod 777 "$initdir/var/lib/rpcbind" + chmod 770 "$initdir/var/lib/rpcbind" + chown rpc.rpc "$initdir/var/lib/rpcbind" } diff -Naur dracut-010/modules.d/95nfs/nfsroot dracut-0e6a94b/modules.d/95nfs/nfsroot --- dracut-010/modules.d/95nfs/nfsroot 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95nfs/nfsroot 2011-05-31 16:34:37.000000000 +0200 @@ -4,7 +4,7 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh -PATH=$PATH:/sbin:/usr/sbin +PATH=/usr/sbin:/usr/bin:/sbin:/bin # Huh? Empty $1? [ -z "$1" ] && exit 1 @@ -46,7 +46,7 @@ [ -n "$var" ] && server=$var && break; done - # XXX This blindly assumes that if new_root_path has to used that + # XXX This blindly assumes that if new_root_path has to used that # XXX it really can be used as server server=${server%%:*} fi @@ -86,8 +86,8 @@ # Start rpcbind or rpcbind # FIXME occasionally saw 'rpcbind: fork failed: No such device' -- why? -[ -x /sbin/portmap ] && [ -z "$(pidof portmap)" ] && portmap -[ -x /sbin/rpcbind ] && [ -z "$(pidof rpcbind)" ] && rpcbind +command -v portmap >/dev/null && [ -z "$(pidof portmap)" ] && portmap +command -v rpcbind >/dev/null && [ -z "$(pidof rpcbind)" ] && rpcbind if [ "$nfs" = "nfs4" ]; then [ ! -d /var/lib/nfs/rpc_pipefs/nfs ] && \ @@ -113,7 +113,7 @@ # XXX Should we loop here? { mount -t nfs -o$options${options:+,}nolock,nfsvers=3 $server:$path $NEWROOT || \ mount -t nfs -o$options${options:+,}nolock,nfsvers=2 $server:$path $NEWROOT ; } \ - && { [ -e /dev/root ] || >/dev/root ; } + && { [ -e /dev/root ] || >/dev/root ; } fi # inject new exit_if_exists diff -Naur dracut-010/modules.d/95nfs/nfsroot-cleanup.sh dracut-0e6a94b/modules.d/95nfs/nfsroot-cleanup.sh --- dracut-010/modules.d/95nfs/nfsroot-cleanup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95nfs/nfsroot-cleanup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -14,9 +14,10 @@ pid=$(pidof rpcbind) [ -n "$pid" ] && kill $pid -if incol2 /proc/mounts /var/lib/nfs/rpc_pipefs; then +if incol2 /proc/mounts /var/lib/nfs/rpc_pipefs; then # try to create the destination directory - [ -d $NEWROOT/$rpcpipefspath ] || mkdir -p $NEWROOT/$rpcpipefspath 2>/dev/null + [ -d $NEWROOT/$rpcpipefspath ] || \ + mkdir -m 0755 -p $NEWROOT/$rpcpipefspath 2>/dev/null if [ -d $NEWROOT/$rpcpipefspath ]; then mount --move /var/lib/nfs/rpc_pipefs $NEWROOT/$rpcpipefspath diff -Naur dracut-010/modules.d/95nfs/parse-nfsroot.sh dracut-0e6a94b/modules.d/95nfs/parse-nfsroot.sh --- dracut-010/modules.d/95nfs/parse-nfsroot.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95nfs/parse-nfsroot.sh 2011-05-31 16:34:37.000000000 +0200 @@ -11,7 +11,7 @@ # root=/dev/nfs nfsroot=[server:]path[,options] # # In Legacy root=/dev/nfs mode, if the 'nfsroot' parameter is not given -# on the command line or is empty, the dhcp root-path is used as +# on the command line or is empty, the dhcp root-path is used as # [server:]path[:options] or the default "/tftpboot/%s" will be used. # # If server is unspecified it will be pulled from one of the following @@ -44,7 +44,7 @@ fi else netroot=$root; -fi +fi # LEGACY: nfsroot= is valid only if root=/dev/nfs if [ -n "$nfsroot" ] ; then @@ -106,7 +106,7 @@ # Done, all good! rootok=1 -# Shut up init error check or make sure that block parser wont get +# Shut up init error check or make sure that block parser wont get # confused by having /dev/nfs[4] root="$fstype" diff -Naur dracut-010/modules.d/95resume/module-setup.sh dracut-0e6a94b/modules.d/95resume/module-setup.sh --- dracut-010/modules.d/95resume/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95resume/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -3,13 +3,14 @@ # ex: ts=8 sw=4 sts=4 et filetype=sh install() { + local _bin # Optional uswsusp support - for bin in /usr/sbin/resume /usr/lib/suspend/resume + for _bin in /usr/sbin/resume /usr/lib/suspend/resume do - [[ -x "${bin}" ]] && { - inst "${bin}" /usr/sbin/resume + [[ -x "${_bin}" ]] && { + inst "${_bin}" /usr/sbin/resume [[ -f /etc/suspend.conf ]] && inst /etc/suspend.conf - break + break } done diff -Naur dracut-010/modules.d/95resume/parse-resume.sh dracut-0e6a94b/modules.d/95resume/parse-resume.sh --- dracut-010/modules.d/95resume/parse-resume.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95resume/parse-resume.sh 2011-05-31 16:34:37.000000000 +0200 @@ -2,7 +2,7 @@ # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh -if resume=$(getarg resume=) && ! getarg noresume; then +if resume=$(getarg resume=) && ! getarg noresume; then export resume echo "$resume" >/.resume else diff -Naur dracut-010/modules.d/95resume/resume.sh dracut-0e6a94b/modules.d/95resume/resume.sh --- dracut-010/modules.d/95resume/resume.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95resume/resume.sh 2011-05-31 16:34:37.000000000 +0200 @@ -2,6 +2,8 @@ # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh +PATH=/usr/sbin:/usr/bin:/sbin:/bin + [ -s /.resume -a -b "$resume" ] && { # First try user level resume; it offers splash etc case "$splash" in @@ -12,10 +14,10 @@ a_splash="-P splash=n" ;; esac - [ -x /usr/sbin/resume ] && /usr/sbin/resume $a_splash "$resume" + [ -x $(command -v resume) ] && command resume $a_splash "$resume" # parsing the output of ls is Bad, but until there is a better way... - ls -lH "$resume" | ( + ls -lH "$resume" | ( read x x x x maj min x; echo "${maj%,}:$min"> /sys/power/resume) >/.resume diff -Naur dracut-010/modules.d/95rootfs-block/block-genrules.sh dracut-0e6a94b/modules.d/95rootfs-block/block-genrules.sh --- dracut-010/modules.d/95rootfs-block/block-genrules.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95rootfs-block/block-genrules.sh 2011-05-31 16:34:37.000000000 +0200 @@ -5,13 +5,13 @@ if [ "${root%%:*}" = "block" ]; then { printf 'KERNEL=="%s", SYMLINK+="root"\n' \ - ${root#block:/dev/} + ${root#block:/dev/} printf 'SYMLINK=="%s", SYMLINK+="root"\n' \ - ${root#block:/dev/} + ${root#block:/dev/} } >> $UDEVRULESD/99-root.rules - + printf '[ -e "%s" ] && { ln -s "%s" /dev/root 2>/dev/null; rm "$job"; }\n' \ - "${root#block:}" "${root#block:}" >> $hookdir/initqueue/settled/blocksymlink.sh + "${root#block:}" "${root#block:}" > $hookdir/initqueue/settled/blocksymlink.sh echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/block.sh fi diff -Naur dracut-010/modules.d/95rootfs-block/mount-root.sh dracut-0e6a94b/modules.d/95rootfs-block/mount-root.sh --- dracut-010/modules.d/95rootfs-block/mount-root.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95rootfs-block/mount-root.sh 2011-05-31 16:34:37.000000000 +0200 @@ -26,8 +26,10 @@ } if [ -n "$root" -a -z "${root%%block:*}" ]; then - mount -t ${fstype:-auto} -o "$rflags",ro "${root#block:}" "$NEWROOT" \ - && ROOTFS_MOUNTED=yes + + # sanity - determine/fix fstype + rootfs=$(det_fs "${root#block:}" "$fstype" "cmdline") + mount -t ${rootfs} -o "$rflags",ro "${root#block:}" "$NEWROOT" READONLY= fsckoptions= @@ -67,26 +69,26 @@ fsckoptions="$AUTOFSCK_OPT $fsckoptions" fi - if ! strstr " $fsckoptions" " -y"; then + if ! strstr " $fsckoptions" " -y" && strstr "$rootfs" ext; then fsckoptions="-a $fsckoptions" fi - rootfs=${fstype:-auto} rootopts= if getargbool 1 rd.fstab -n rd_NO_FSTAB \ && ! getarg rootflags \ && [ -f "$NEWROOT/etc/fstab" ] \ && ! [ -L "$NEWROOT/etc/fstab" ]; then - # if $NEWROOT/etc/fstab contains special mount options for + # if $NEWROOT/etc/fstab contains special mount options for # the root filesystem, # remount it with the proper options rootopts="defaults" - while read dev mp fs opts rest; do + while read dev mp fs opts rest; do # skip comments [ "${dev%%#*}" != "$dev" ] && continue - + if [ "$mp" = "/" ]; then - rootfs=$fs + # sanity - determine/fix fstype + rootfs=$(det_fs "${root#block:}" "$fs" "$NEWROOT/etc/fstab") rootopts=$opts break fi @@ -96,41 +98,14 @@ fi umount "$NEWROOT" - if [ "$rootfs" = "auto" ]; then - rootfs=$(udevadm info --query=env --name=${root#block:} | \ - while read line; do - if strstr $line ID_FS_TYPE; then - eval $line - echo $ID_FS_TYPE - break - fi - done) - rootfs=${rootfs:-auto} - fi # backslashes are treated as escape character in fstab esc_root=$(echo ${root#block:} | sed 's,\\,\\\\,g') printf '%s %s %s %s,%s 1 1 \n' "$esc_root" "$NEWROOT" "$rootfs" "$rflags" "$rootopts" > /etc/fstab - if [ -z "$fastboot" -a "$READONLY" != "yes" ]; then - info "Checking filesystems" - info fsck -T -t noopts=_netdev -A $fsckoptions - out=$(fsck -T -t noopts=_netdev -A $fsckoptions) - export RD_ROOTFS_FSCK=$? - echo $RD_ROOTFS_FSCK > /run/initramfs/root-fsck - - # A return of 4 or higher means there were serious problems. - if [ $RD_ROOTFS_FSCK -gt 3 ]; then - warn $out - warn "fsck returned with error code $RD_ROOTFS_FSCK" - warn "*** An error occurred during the file system check." - warn "*** Dropping you to a shell; the system will retry" - warn "*** to mount the system, when you leave the shell." - emergency_shell -n "(Repair filesystem)" - else - echo $out|vinfo - [ $RD_ROOTFS_FSCK -gt 0 ] && warn "fsck returned with $RD_ROOTFS_FSCK" - fi + if [ -x "/sbin/fsck.$rootfs" -a -z "$fastboot" -a "$READONLY" != "yes" ] && ! strstr "${rflags},${rootopts}" _netdev; then + wrap_fsck "${root#block:}" "$fsckoptions" + echo $? >/run/initramfs/root-fsck fi info "Remounting ${root#block:} with -o ${rflags},${rootopts}" diff -Naur dracut-010/modules.d/95terminfo/module-setup.sh dracut-0e6a94b/modules.d/95terminfo/module-setup.sh --- dracut-010/modules.d/95terminfo/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95terminfo/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -3,12 +3,13 @@ # ex: ts=8 sw=4 sts=4 et filetype=sh install() { + local _terminfodir # terminfo bits make things work better if you fall into interactive mode - for TERMINFODIR in /lib/terminfo /etc/terminfo /usr/share/terminfo; do - [ -d ${TERMINFODIR} ] && break + for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do + [ -d ${_terminfodir} ] && break done - - [ -d ${TERMINFODIR} ] && \ - dracut_install $(find ${TERMINFODIR} -type f) + + [ -d ${_terminfodir} ] && \ + dracut_install $(find ${_terminfodir} -type f) } diff -Naur dracut-010/modules.d/95udev-rules/module-setup.sh dracut-0e6a94b/modules.d/95udev-rules/module-setup.sh --- dracut-010/modules.d/95udev-rules/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95udev-rules/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -3,6 +3,7 @@ # ex: ts=8 sw=4 sts=4 et filetype=sh install() { + local _i # FIXME: would be nice if we didn't have to know which rules to grab.... # ultimately, /lib/initramfs/rules.d or somesuch which includes links/copies # of the rules we want so that we just copy those in would be best @@ -10,7 +11,7 @@ dracut_install basename inst_rules 50-udev-default.rules 60-persistent-storage.rules \ 61-persistent-storage-edd.rules 80-drivers.rules 95-udev-late.rules \ - 60-pcmcia.rules + 60-pcmcia.rules #Some debian udev rules are named differently inst_rules 50-udev.rules 95-late.rules @@ -21,6 +22,10 @@ inst_rules 50-firmware.rules dracut_install cat uname + + inst_dir /run/udev + inst_dir /run/udev/rules.d + if [ ! -x /lib/udev/vol_id ]; then dracut_install blkid inst_rules "$moddir/59-persistent-storage.rules" @@ -29,7 +34,7 @@ fi inst_rules "$moddir/61-persistent-storage.rules" - for i in \ + for _i in \ ata_id \ cdrom_id \ create_floppy_devices \ @@ -47,14 +52,14 @@ pcmcia-socket-startup \ pcmcia-check-broken-cis \ ; do - [ -e /lib/udev/$i ] && dracut_install /lib/udev/$i + [ -e /lib/udev/$_i ] && dracut_install /lib/udev/$_i done [ -f /etc/arch-release ] && \ inst "$moddir/load-modules.sh" /lib/udev/load-modules.sh - for i in {"$libdir","$usrlibdir"}/libnss_files*; do - [ -e "$i" ] && dracut_install "$i" + for _i in {"$libdir","$usrlibdir"}/libnss_files*; do + [ -e "$_i" ] && dracut_install "$_i" done } diff -Naur dracut-010/modules.d/95zfcp/module-setup.sh dracut-0e6a94b/modules.d/95zfcp/module-setup.sh --- dracut-010/modules.d/95zfcp/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95zfcp/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -4,14 +4,14 @@ check() { arch=$(uname -m) - [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 + [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 return 0 } depends() { arch=$(uname -m) - [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 + [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 return 0 } diff -Naur dracut-010/modules.d/95zfcp/parse-zfcp.sh dracut-0e6a94b/modules.d/95zfcp/parse-zfcp.sh --- dracut-010/modules.d/95zfcp/parse-zfcp.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95zfcp/parse-zfcp.sh 2011-05-31 16:34:37.000000000 +0200 @@ -5,7 +5,7 @@ getargbool 1 rd.zfcp.conf -n rd_NO_ZFCPCONF || rm /etc/zfcp.conf for zfcp_arg in $(getargs rd.zfcp 'rd_ZFCP='); do - ( + ( IFS="," set $zfcp_arg echo "$@" >> /etc/zfcp.conf diff -Naur dracut-010/modules.d/95zfcp/zfcpconf.sh dracut-0e6a94b/modules.d/95zfcp/zfcpconf.sh --- dracut-010/modules.d/95zfcp/zfcpconf.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95zfcp/zfcpconf.sh 2011-05-31 16:34:37.000000000 +0200 @@ -6,22 +6,22 @@ # deviceno WWPN FCPLUN # # Example: -# 0.0.4000 0x5005076300C213e9 0x5022000000000000 -# 0.0.4001 0x5005076300c213e9 0x5023000000000000 +# 0.0.4000 0x5005076300C213e9 0x5022000000000000 +# 0.0.4001 0x5005076300c213e9 0x5023000000000000 # # # manual setup: # modprobe zfcp # echo 1 > /sys/bus/ccw/drivers/zfcp/0.0.4000/online # echo LUN > /sys/bus/ccw/drivers/zfcp/0.0.4000/WWPN/unit_add -# +# # Example: # modprobe zfcp # echo 1 > /sys/bus/ccw/drivers/zfcp/0.0.4000/online # echo 0x5022000000000000 > /sys/bus/ccw/drivers/zfcp/0.0.4000/0x5005076300c213e9/unit_add CONFIG=/etc/zfcp.conf -PATH=/bin:/usr/bin:/sbin:/usr/sbin +PATH=/usr/sbin:/usr/bin:/sbin:/bin if [ -f "$CONFIG" ]; then if [ ! -d /sys/bus/ccw/drivers/zfcp ]; then diff -Naur dracut-010/modules.d/95znet/module-setup.sh dracut-0e6a94b/modules.d/95znet/module-setup.sh --- dracut-010/modules.d/95znet/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/95znet/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -4,7 +4,7 @@ check() { arch=$(uname -m) - [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 + [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1 return 0 } diff -Naur dracut-010/modules.d/98selinux/selinux-loadpolicy.sh dracut-0e6a94b/modules.d/98selinux/selinux-loadpolicy.sh --- dracut-010/modules.d/98selinux/selinux-loadpolicy.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/98selinux/selinux-loadpolicy.sh 2011-05-31 16:34:37.000000000 +0200 @@ -2,11 +2,11 @@ # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh -# FIXME: load selinux policy. this should really be done after we switchroot +# FIXME: load selinux policy. this should really be done after we switchroot rd_load_policy() { - # If SELinux is disabled exit now + # If SELinux is disabled exit now getarg "selinux=0" > /dev/null && return 0 SELINUX="enforcing" @@ -14,7 +14,7 @@ # Check whether SELinux is in permissive mode permissive=0 - getarg "enforcing=0" > /dev/null + getarg "enforcing=0" > /dev/null if [ $? -eq 0 -o "$SELINUX" = "permissive" ]; then permissive=1 fi @@ -24,7 +24,7 @@ local ret=0 local out info "Loading SELinux policy" - # load_policy does mount /proc and /selinux in + # load_policy does mount /proc and /selinux in # libselinux,selinux_init_load_policy() if [ -x "$NEWROOT/sbin/load_policy" ]; then out=$(chroot "$NEWROOT" /sbin/load_policy -i 2>&1) diff -Naur dracut-010/modules.d/98syslog/module-setup.sh dracut-0e6a94b/modules.d/98syslog/module-setup.sh --- dracut-010/modules.d/98syslog/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/98syslog/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -12,30 +12,32 @@ } install() { + local _i + local _installs if type -P rsyslogd >/dev/null; then - installs="rsyslogd" - for i in {"$libdir","$usrlibdir"}/rsyslog/lmnet.so \ + _installs="rsyslogd" + for _i in {"$libdir","$usrlibdir"}/rsyslog/lmnet.so \ {"$libdir","$usrlibdir"}/rsyslog/imklog.so \ {"$libdir","$usrlibdir"}/rsyslog/imuxsock.so ; do - [ -e "$i" ] && installs="$installs $i" + [ -e "$_i" ] && _installs="$_installs $_i" done elif type -P syslogd >/dev/null; then - installs="syslogd" + _installs="syslogd" elif type -P syslog-ng >/dev/null; then - installs="syslog-ng" + _installs="syslog-ng" else derror "Could not find any syslog binary although the syslogmodule" \ "is selected to be installed. Please check." fi - if [ -n "$installs" ]; then + if [ -n "$_installs" ]; then dracut_install cat - dracut_install $installs + dracut_install $_installs inst_hook cmdline 90 "$moddir/parse-syslog-opts.sh" inst_hook pre-udev 61 "$moddir/syslog-genrules.sh" inst_hook pre-pivot 99 "$moddir/syslog-cleanup.sh" inst_simple "$moddir/rsyslogd-start.sh" /sbin/rsyslogd-start inst_simple "$moddir/rsyslogd-stop.sh" /sbin/rsyslogd-stop - mkdir -p ${initdir}/etc/templates + mkdir -m 0755 -p ${initdir}/etc/templates inst_simple "${moddir}/rsyslog.conf" /etc/templates fi } diff -Naur dracut-010/modules.d/98syslog/parse-syslog-opts.sh dracut-0e6a94b/modules.d/98syslog/parse-syslog-opts.sh --- dracut-010/modules.d/98syslog/parse-syslog-opts.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/98syslog/parse-syslog-opts.sh 2011-05-31 16:34:37.000000000 +0200 @@ -7,7 +7,7 @@ #Bootparameters: #syslogserver=ip Where to syslog to #sysloglevel=level What level has to be logged -#syslogtype=rsyslog|syslog|syslogng +#syslogtype=rsyslog|syslog|syslogng # Don't auto detect syslog but set it type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh diff -Naur dracut-010/modules.d/98syslog/README dracut-0e6a94b/modules.d/98syslog/README --- dracut-010/modules.d/98syslog/README 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/98syslog/README 2011-05-31 16:34:37.000000000 +0200 @@ -1,16 +1,16 @@ Syslog support for dracut This module provides syslog functionality in the initrd. -This is especially interesting when complex configuration being +This is especially interesting when complex configuration being used to provide access to the device the rootfs resides on. -When this module is installed into the ramfs it is triggered by +When this module is installed into the ramfs it is triggered by the udev event from the nic being setup (online). Then if syslog is configured it is started and will forward all kernel messages to the given syslog server. -The syslog implementation is detected automatically by finding the +The syslog implementation is detected automatically by finding the apropriate binary with the following order: rsyslogd syslogd @@ -20,5 +20,5 @@ Bootparameters: syslogserver=ip Where to syslog to sysloglevel=level What level has to be logged -syslogtype=rsyslog|syslog|syslogng - Don't auto detect syslog but set it +syslogtype=rsyslog|syslog|syslogng + Don't auto detect syslog but set it diff -Naur dracut-010/modules.d/98syslog/rsyslogd-start.sh dracut-0e6a94b/modules.d/98syslog/rsyslogd-start.sh --- dracut-010/modules.d/98syslog/rsyslogd-start.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/98syslog/rsyslogd-start.sh 2011-05-31 16:34:37.000000000 +0200 @@ -13,7 +13,7 @@ shift local filters=$* local filter= - + cat $syslog_template for filter in $filters; do @@ -31,5 +31,5 @@ template=/etc/templates/rsyslog.conf if [ -n "$server" ]; then rsyslog_config "$server" "$template" "$filters" > $conf - /sbin/rsyslogd -c3 -fi + rsyslogd -c3 +fi diff -Naur dracut-010/modules.d/98syslog/syslog-cleanup.sh dracut-0e6a94b/modules.d/98syslog/syslog-cleanup.sh --- dracut-010/modules.d/98syslog/syslog-cleanup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/98syslog/syslog-cleanup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -8,7 +8,7 @@ if [ -f /tmp/syslog.server ]; then read syslogtype < /tmp/syslog.type - if [ -e "/sbin/${syslogtype}-stop" ]; then + if command -v "${syslogtype}-stop" >/dev/null; then ${syslogtype}-stop else warn "syslog-cleanup: Could not find script to stop syslog of type \"$syslogtype\". Syslog will not be stopped." diff -Naur dracut-010/modules.d/98syslog/syslog-genrules.sh dracut-0e6a94b/modules.d/98syslog/syslog-genrules.sh --- dracut-010/modules.d/98syslog/syslog-genrules.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/98syslog/syslog-genrules.sh 2011-05-31 16:34:37.000000000 +0200 @@ -18,7 +18,7 @@ fi echo "$syslogtype" [ -n "$syslogtype" ] -} +} read syslogtype < /tmp/syslog.type if [ -z "$syslogtype" ]; then diff -Naur dracut-010/modules.d/99base/dracut-lib.sh dracut-0e6a94b/modules.d/99base/dracut-lib.sh --- dracut-010/modules.d/99base/dracut-lib.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/99base/dracut-lib.sh 2011-05-31 16:34:37.000000000 +0200 @@ -52,12 +52,12 @@ for _o in $CMDLINE; do if [ "$_o" = "$1" ]; then - return 0; + return 0; fi [ "${_o%%=*}" = "${1%=}" ] && _val=${_o#*=}; done if [ -n "$_val" ]; then - echo $_val; + echo $_val; return 0; fi return 1; @@ -86,7 +86,7 @@ shift;; esac done - [ "$RD_DEBUG" = "yes" ] && set -x + [ "$RD_DEBUG" = "yes" ] && set -x return 1 } @@ -105,7 +105,7 @@ } _dogetargs() { - set +x + set +x local _o _found unset _o unset _found @@ -116,7 +116,7 @@ return 0; fi if [ "${_o%%=*}" = "${1%=}" ]; then - echo -n "${_o#*=} "; + echo -n "${_o#*=} "; _found=1; fi done @@ -134,10 +134,10 @@ done if [ -n "$_val" ]; then echo -n $_val - [ "$RD_DEBUG" = "yes" ] && set -x + [ "$RD_DEBUG" = "yes" ] && set -x return 0 fi - [ "$RD_DEBUG" = "yes" ] && set -x + [ "$RD_DEBUG" = "yes" ] && set -x return 1; } @@ -146,7 +146,7 @@ # it just returns 0. Otherwise 1 is returned. # $1 = options separated by commas # $2 = option we are interested in -# +# # Example: # $1 = cipher=aes-cbc-essiv:sha256,hash=sha256,verify # $2 = hash @@ -199,12 +199,14 @@ if [ -e /proc/cmdline ]; then RD_DEBUG=no if getargbool 0 rd.debug -y rdinitdebug -y rdnetdebug; then - RD_DEBUG=yes - fi + RD_DEBUG=yes + [ -n "$BASH" ] && \ + export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): '; + fi fi export RD_DEBUG fi - [ "$RD_DEBUG" = "yes" ] && set -x + [ "$RD_DEBUG" = "yes" ] && set -x } setdebug @@ -240,13 +242,12 @@ echo "<24>dracut: Refusing to continue"; } > /dev/kmsg - { + { echo "warn dracut: FATAL: \"$@\""; echo "warn dracut: Refusing to continue"; - echo "exit 1" } >> $hookdir/emergency/01-die.sh - > /.die + > /run/initramfs/.die exit 1 } @@ -261,19 +262,24 @@ warn() { check_quiet echo "<28>dracut Warning: $@" > /dev/kmsg - [ "$DRACUT_QUIET" != "yes" ] && \ - echo "dracut Warning: $@" >&2 + echo "dracut Warning: $@" >&2 } info() { check_quiet echo "<30>dracut: $@" > /dev/kmsg [ "$DRACUT_QUIET" != "yes" ] && \ - echo "dracut: $@" + echo "dracut: $@" +} + +vwarn() { + while read line; do + warn $line; + done } vinfo() { - while read line; do + while read line; do info $line; done } @@ -299,8 +305,8 @@ local file="$1"; local str="$2"; - [ -z "$file" ] && return; - [ -z "$str" ] && return; + [ -z "$file" ] && return 1; + [ -z "$str" ] && return 1; while read dummy check restofline; do [ "$check" = "$str" ] && return 0 @@ -328,18 +334,25 @@ fi } +ismounted() { + while read a m a; do + [ "$m" = "$1" ] && return 0 + done < /proc/mounts + return 1 +} + wait_for_if_up() { local cnt=0 - while [ $cnt -lt 20 ]; do + while [ $cnt -lt 20 ]; do li=$(ip link show $1) [ -z "${li##*state UP*}" ] && return 0 sleep 0.1 cnt=$(($cnt+1)) - done + done return 1 } -# root=nfs:[:][:] +# root=nfs:[:][:] # root=nfs4:[:][:] nfsroot_to_var() { # strip nfs[4]: @@ -361,10 +374,10 @@ options="${options##:}" # strip ":" options="${options%%:}" - + # Does it really start with '/'? [ -n "${path%%/*}" ] && path="error"; - + #Fix kernel legacy style separating path and options with ',' if [ "$path" != "${path#*,}" ] ; then options=${path#*,} @@ -375,7 +388,7 @@ ip_to_var() { local v=${1}: local i - set -- + set -- while [ -n "$v" ]; do if [ "${v#\[*:*:*\]:}" != "$v" ]; then # handle IPv6 address @@ -383,7 +396,7 @@ i="${i##\[}" set -- "$@" "$i" v=${v#\[$i\]:} - else + else set -- "$@" "${v%%:*}" v=${v#*:} fi @@ -453,10 +466,10 @@ local dir="$1"; local prefix="$2" local retdir; local retdir_new - [ -d "${dir}" ] || mkdir -p "${dir}" || return 1 + [ -d "${dir}" ] || mkdir -m 0755 -p "${dir}" || return 1 retdir=$(funiq "${dir}" "${prefix}") || return 1 - until mkdir "${retdir}" 2>/dev/null; do + until mkdir -m 0755 "${retdir}" 2>/dev/null; do retdir_new=$(funiq "${dir}" "${prefix}") || return 1 [ "$retdir_new" = "$retdir" ] && return 1 retdir="$retdir_new" @@ -502,3 +515,50 @@ return 1 ) + +# Wrap fsck call for device _dev with additional fsck options _fsckopts return +# fsck's return code +wrap_fsck() { + local _ret _out _dev="$1" _fsckopts="$2" + + info "Checking filesystem." + info fsck -T $_fsckopts "$_dev" + _out=$(fsck -T $_fsckopts "$_dev") ; _ret=$? + + # A return of 4 or higher means there were serious problems. + if [ $_ret -gt 3 ]; then + echo $_out|vwarn + warn "fsck returned with error code $_ret" + warn "*** An error occurred during the file system check." + warn "*** Dropping you to a shell; the system will try" + warn "*** to mount the filesystem, when you leave the shell." + emergency_shell -n "(Repair filesystem)" + else + echo $_out|vinfo + [ $_ret -gt 0 ] && warn "fsck returned with $_ret" + fi + + return $_ret +} + +# Verify supplied filesystem type, fix if it's invalid, warn user if +# appropriate +det_fs() { + local _dev="$1" _fs="${2:-auto}" _inf="$3" _orig + + _orig="$_fs" + _fs=$(udevadm info --query=env --name="$_dev" | \ + while read line; do + if str_starts $line "ID_FS_TYPE="; then + echo ${line#ID_FS_TYPE=} + break + fi + done) + _fs=${_fs:-auto} + if [ "$_fs" = "auto" ]; then + warn "Cannon detect filesystem type for device $_dev" + elif [ "$_orig" != "auto" -a "$_fs" != "$_orig" ]; then + warn "$_inf: detected filesystem '$_fs' instead of '$_orig' for device: $_dev" + fi + echo "$_fs" +} diff -Naur dracut-010/modules.d/99base/init dracut-0e6a94b/modules.d/99base/init --- dracut-010/modules.d/99base/init 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/99base/init 2011-05-31 16:34:37.000000000 +0200 @@ -10,32 +10,30 @@ wait_for_loginit() { - if getargbool 0 rd.debug -y rdinitdebug -y rdnetdebug; then - set +x - echo "DRACUT_LOG_END" - exec 0<>/dev/console 1<>/dev/console 2<>/dev/console + set +x + [ "$RD_DEBUG" = "yes" ] || return + [ -e /run/initramfs/loginit.pipe ] || return + echo "DRACUT_LOG_END" + exec 0<>/dev/console 1<>/dev/console 2<>/dev/console # wait for loginit - i=0 - while [ $i -lt 10 ]; do - if [ -e /run/initramfs/init.log.end ]; then - j=$(jobs) - [ -z "$j" ] && break - [ -z "${j##*Running*}" ] || break - fi - sleep 0.1 - i=$(($i+1)) - done - [ $i -eq 10 ] && kill %1 >/dev/null 2>&1 - - while pidof -x /sbin/loginit >/dev/null 2>&1; do - for pid in $(pidof -x /sbin/loginit); do - kill $HARD $pid >/dev/null 2>&1 - done - HARD="-9" - done - set -x + i=0 + while [ $i -lt 10 ]; do + if [ ! -e /run/initramfs/loginit.pipe ]; then + j=$(jobs) + [ -z "$j" ] && break + [ -z "${j##*Running*}" ] || break + fi + sleep 0.1 + i=$(($i+1)) + done + + if [ $i -eq 10 ]; then + kill %1 >/dev/null 2>&1 + kill $(while read line;do echo $line;done/dev/null 2>&1 -mount -t sysfs -o nosuid,noexec,nodev /sys /sys >/dev/null 2>&1 +[ ! -d /proc/self ] && \ + mount -t proc -o nosuid,noexec,nodev /proc /proc >/dev/null 2>&1 + +[ ! -d /sys/kernel ] && \ + mount -t sysfs -o nosuid,noexec,nodev /sys /sys >/dev/null 2>&1 if [ -x /lib/systemd/systemd-timestamp ]; then RD_TIMESTAMP=$(/lib/systemd/systemd-timestamp) @@ -88,11 +91,19 @@ unset _tmp fi -if [ ! -c /dev/ptmx ]; then +setdebug + +if [ "$RD_DEBUG" = "yes" ]; then + getarg quiet && DRACUT_QUIET="yes" + a=$(getarg loglevel=) + [ -n "$a" ] && [ $a -ge 8 ] && unset DRACUT_QUIET +fi + +if ! ismounted /dev; then # try to mount devtmpfs - if ! mount -t devtmpfs -o mode=0755,nosuid udev /dev >/dev/null 2>&1; then + if ! mount -t devtmpfs -o mode=0755,nosuid,noexec udev /dev >/dev/null 2>&1; then # if it failed fall back to normal tmpfs - mount -t tmpfs -o mode=0755,nosuid udev /dev >/dev/null 2>&1 + mount -t tmpfs -o mode=0755,nosuid udev /dev >/dev/null 2>&1 # Make some basic devices first, let udev handle the rest mknod -m 0666 /dev/null c 1 3 mknod -m 0666 /dev/ptmx c 5 2 @@ -102,48 +113,50 @@ fi # prepare the /dev directory -ln -s /proc/self/fd /dev/fd >/dev/null 2>&1 -ln -s /proc/self/fd/0 /dev/stdin >/dev/null 2>&1 -ln -s /proc/self/fd/1 /dev/stdout >/dev/null 2>&1 -ln -s /proc/self/fd/2 /dev/stderr >/dev/null 2>&1 -mkdir -m 0755 /dev/shm /dev/pts /run -mount -t devpts -o gid=5,mode=620,noexec,nosuid devpts /dev/pts >/dev/null 2>&1 -mount -t tmpfs -o mode=1777,nosuid,nodev tmpfs /dev/shm >/dev/null 2>&1 -# create /run which will obsolete /var/run -mount -t tmpfs -o mode=0755,nodev,noexec,nosuid tmpfs /run >/dev/null 2>&1 +[ ! -h /dev/fd ] && ln -s /proc/self/fd /dev/fd >/dev/null 2>&1 +[ ! -h /dev/stdin ] && ln -s /proc/self/fd/0 /dev/stdin >/dev/null 2>&1 +[ ! -h /dev/stdout ] && ln -s /proc/self/fd/1 /dev/stdout >/dev/null 2>&1 +[ ! -h /dev/stderr ] && ln -s /proc/self/fd/2 /dev/stderr >/dev/null 2>&1 + +if ! ismounted /dev/pts; then + mkdir -m 0755 /dev/pts + mount -t devpts -o gid=5,mode=620,noexec,nosuid devpts /dev/pts >/dev/null 2>&1 +fi + +if ! ismounted /dev/shm; then + mkdir -m 0755 /dev/shm + mount -t tmpfs -o mode=1777,nosuid,nodev tmpfs /dev/shm >/dev/null 2>&1 +fi + +if ! ismounted /run; then + mkdir -m 0755 /newrun + mount -t tmpfs -o mode=0755,nosuid,nodev tmpfs /newrun >/dev/null 2>&1 + cp -a -t /newrun /run/* + mount --move /newrun /run + rm -fr /newrun +fi -mkdir -m 0755 /run/initramfs +[ -d /run/initramfs ] || mkdir -p -m 0755 /run/initramfs UDEVVERSION=$(udevadm --version) if [ $UDEVVERSION -gt 166 ]; then # newer versions of udev use /run/udev/rules.d - mkdir -m 0755 /run/udev /run/udev/rules.d export UDEVRULESD=/run/udev/rules.d + [ -d /run/udev ] || mkdir -p -m 0755 /run/udev + [ -d $UDEVRULESD ] || mkdir -p -m 0755 $UDEVRULESD else - mkdir -m 0755 /dev/.udev /dev/.udev/rules.d + mkdir -m 0755 /dev/.udev /dev/.udev/rules.d export UDEVRULESD=/dev/.udev/rules.d fi -[ -e /var/run ] && mv /var/run /var/run.bak -[ -e /var/lock ] && mv /var/lock /var/lock.bak -ln -fs /run /var/run -mkdir -m 0755 /run/lock -ln -fs /run/lock /var/lock -# copy over any possible directory structure -cp -ar /var/run.bak/* /run/ 2>/dev/null -cp -ar /var/lock.bak/* /run/lock/ 2>/dev/null - -if getargbool 0 rd.debug -y rdinitdebug -y rdnetdebug; then - getarg quiet && DRACUT_QUIET="yes" - mkfifo /run/initramfs/initlog.pipe - /sbin/loginit $DRACUT_QUIET /dev/console 2>&1 & - exec >/run/initramfs/initlog.pipe 2>&1 +if [ "$RD_DEBUG" = "yes" ]; then + mkfifo /run/initramfs/loginit.pipe + loginit $DRACUT_QUIET /dev/console 2>&1 & + exec >/run/initramfs/loginit.pipe 2>&1 else exec 0<>/dev/console 1<>/dev/console 2<>/dev/console fi -setdebug - source_conf /etc/conf.d # run scriptlets to parse the command line @@ -178,8 +191,9 @@ UDEV_QUEUE_EMPTY="udevadm settle --timeout=1" fi -getargbool 0 rd.udev.info -y rdudevinfo && udevadm control $UDEV_LOG_PRIO_ARG=info -getargbool 0 rd.udev.debug -y rdudevdebug && udevadm control $UDEV_LOG_PRIO_ARG=debug +getargbool 0 rd.udev.info -y rdudevinfo && udevproperty "$UDEV_LOG_PRIO_ARG=info" +getargbool 0 rd.udev.debug -y rdudevdebug && udevproperty "$UDEV_LOG_PRIO_ARG=debug" +udevproperty "hookdir=$hookdir" getarg 'rd.break=pre-trigger' 'rdbreak=pre-trigger' && emergency_shell -n pre-trigger "Break before pre-trigger" source_hook pre-trigger @@ -197,7 +211,7 @@ while :; do check_finished && break - + udevsettle check_finished && break @@ -205,7 +219,7 @@ if [ -f $hookdir/initqueue/work ]; then rm $hookdir/initqueue/work fi - + for job in $hookdir/initqueue/*.sh; do [ -e "$job" ] || break job=$job . $job @@ -229,7 +243,7 @@ # which report no medium for quiet # some time. for cdrom in /sys/block/sr*; do - [ -e "$cdrom" ] || continue + [ -e "$cdrom" ] || continue # skip, if cdrom medium was already found strstr "$(udevadm info --query=env --path=${cdrom##/sys})" \ ID_CDROM_MEDIA && continue @@ -244,7 +258,7 @@ echo change > "$cdrom/uevent" fi done - + i=$(($i+1)) [ $i -gt $RDRETRY ] \ && { flock -s 9 ; emergency_shell "No root device \"$root\" found"; } 9>/.console_lock @@ -254,7 +268,7 @@ # reset cdrom polling for cdrom in /sys/block/sr*; do - [ -e "$cdrom" ] || continue + [ -e "$cdrom" ] || continue if [ -e "$cdrom"/events_poll_msecs ]; then echo -1 > "$cdrom"/events_poll_msecs fi @@ -284,7 +298,7 @@ { echo -n "Mounted root filesystem " - while read dev mp rest; do [ "$mp" = "$NEWROOT" ] && echo $dev; done < /proc/mounts + while read dev mp rest; do [ "$mp" = "$NEWROOT" ] && echo $dev; done < /proc/mounts } | vinfo # pre pivot scripts are sourced just before we switch over to the new root. @@ -309,46 +323,58 @@ getarg rd.break rdbreak && emergency_shell -n switch_root "Break before switch_root" -# stop udev queue before killing it -udevadm control --stop-exec-queue - -HARD="" -while pidof udevd >/dev/null 2>&1; do - for pid in $(pidof udevd); do - kill $HARD $pid >/dev/null 2>&1 +if [ $UDEVVERSION -lt 168 ]; then + # stop udev queue before killing it + udevadm control --stop-exec-queue + + HARD="" + while pidof udevd >/dev/null 2>&1; do + for pid in $(pidof udevd); do + kill $HARD $pid >/dev/null 2>&1 + done + HARD="-9" done - HARD="-9" -done +else + udevadm control --exit + udevadm info --cleanup-db +fi +export RD_TIMESTAMP +set +x # Turn off debugging for this section # Clean up the environment for i in $(export -p); do i=${i#declare -x} i=${i#export} - # skip RD_ vars - [ "$i" != "${i#RD_}" ] && continue + strstr "$i" "=" || continue i=${i%%=*} - [ "$i" = "root" -o "$i" = "PATH" -o "$i" = "HOME" -o "$i" = "TERM" ] || unset $i + [ -z "$i" ] && continue + case $i in + root|PATH|HOME|TERM|PS4|RD_*) + :;; + *) + unset "$i";; + esac done initargs="" - read CLINE /dev/null ; then + set +x # Turn off debugging for this section ignoreargs="console BOOT_IMAGE" # only pass arguments after init= to the init CLINE=${CLINE#*init=} - set $CLINE - shift - for x in "$@"; do - for s in $ignoreargs; do - [ "${x%%=*}" = $s ] && continue 2 - done - initargs="$initargs $x" + set -- $CLINE + shift # clear out the rest of the "init=" arg + for x in "$@"; do + for s in $ignoreargs; do + [ "${x%%=*}" = $s ] && continue 2 done - unset CLINE + initargs="$initargs $x" + done + unset CLINE else - set $CLINE - shift + set +x # Turn off debugging for this section + set -- $CLINE for x in "$@"; do case "$x" in [0-9]|s|S|single|emergency|auto ) \ @@ -357,43 +383,42 @@ esac done fi +[ "$RD_DEBUG" = "yes" ] && set -x -# Debug: Copy state -if getargbool 0 rd.copystate -y rdcopystate; then - cp -axr /tmp/* /run/initramfs/ >/dev/null 2>&1 -fi - -if getargbool 1 rd.timestamp; then - export RD_TIMESTAMP +if [ -d "$NEWROOT"/run ]; then + NEWRUN="${NEWROOT}/run" + mount --bind /run "$NEWRUN" + NEWINITRAMFSROOT="$NEWRUN/initramfs" + + if [ "$NEWINITRAMFSROOT/lib" -ef "/lib" ]; then + for d in bin etc lib lib64 sbin tmp usr var; do + [ -h /$d ] && ln -fsn $NEWINITRAMFSROOT/$d /$d + done + fi else - unset RD_TIMESTAMP -fi - -info "Switching root" + NEWRUN=/dev/.initramfs + mkdir -m 0755 "$NEWRUN" + mount --bind /run/initramfs "$NEWRUN" +fi wait_for_loginit +info "Switching root" -if [ -d "$NEWROOT"/run ]; then - mount --move /run "$NEWROOT"/run -else - if [ -e /run/initramfs ]; then - cp -axr /run/initramfs /dev/.initramfs >/dev/null 2>&1 - if [ -e /run/initramfs/live ]; then - mkdir -m 0755 /dev/.initramfs/live - mount --move /run/initramfs/live /dev/.initramfs/live - fi - fi - umount -l /run -fi +unset PS4 -export PATH="$OLD_PATH" +CAPSH=$(command -v capsh) +SWITCH_ROOT=$(command -v switch_root) +PATH=$OLDPATH +export PATH if [ -f /etc/capsdrop ]; then . /etc/capsdrop info "Calling $INIT with capabilities $CAPS_INIT_DROP dropped." unset RD_DEBUG - exec /usr/sbin/capsh --drop="$CAPS_INIT_DROP" -- -c "exec /sbin/switch_root \"$NEWROOT\" \"$INIT\" $initargs" || { + exec $CAPSH --drop="$CAPS_INIT_DROP" -- \ + -c "exec switch_root \"$NEWROOT\" \"$INIT\" $initargs" || \ + { warn "Command:" warn capsh --drop=$CAPS_INIT_DROP -- -c exec switch_root "$NEWROOT" "$INIT" $initargs warn "failed." @@ -401,7 +426,7 @@ } else unset RD_DEBUG - exec /sbin/switch_root "$NEWROOT" "$INIT" $initargs || { + exec $SWITCH_ROOT "$NEWROOT" "$INIT" $initargs || { warn "Something went very badly wrong in the initramfs. Please " warn "file a bug against dracut." emergency_shell diff -Naur dracut-010/modules.d/99base/initqueue dracut-0e6a94b/modules.d/99base/initqueue --- dracut-010/modules.d/99base/initqueue 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/99base/initqueue 2011-05-31 16:34:37.000000000 +0200 @@ -7,6 +7,8 @@ # Copyright 2008-2010, Red Hat, Inc. # Harald Hoyer +PATH=/usr/sbin:/usr/bin:/sbin:/bin + type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh while [ $# -gt 0 ]; do @@ -14,7 +16,9 @@ --onetime) onetime="yes";; --settled) - settled="/settled";; + qname="/settled";; + --finished) + qname="/finished";; --unique) unique="yes";; --name) @@ -32,16 +36,20 @@ job=${job##*/} fi +exe=$1 +shift + +[ -x "$exe" ] || exe=$(command -v $exe) if [ -n "$onetime" ]; then - { + { echo '[ -e "$job" ] && rm "$job"' - echo "$@" + echo "$exe $@" } > "/tmp/$$-${job}.sh" else - echo "$@" > "/tmp/$$-${job}.sh" + echo "$exe $@" > "/tmp/$$-${job}.sh" fi -mv -f "/tmp/$$-${job}.sh" "$hookdir/initqueue${settled}/${job}.sh" -[ -z "$settled" ] && >> $hookdir/initqueue/work +mv -f "/tmp/$$-${job}.sh" "$hookdir/initqueue${qname}/${job}.sh" +[ -z "$qname" ] && >> $hookdir/initqueue/work diff -Naur dracut-010/modules.d/99base/loginit dracut-0e6a94b/modules.d/99base/loginit --- dracut-010/modules.d/99base/loginit 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/99base/loginit 2011-05-31 16:34:37.000000000 +0200 @@ -7,16 +7,18 @@ QUIET=$1 +printf -- "$$" > /run/initramfs/loginit.pid + [ -e /dev/kmsg ] && exec 5>/dev/kmsg || exec 5>/dev/null exec 6>/run/initramfs/init.log -while read line; do +while read line; do if [ "$line" = "DRACUT_LOG_END" ]; then - > /run/initramfs/init.log.end + rm -f /run/initramfs/loginit.pipe exit 0 fi - echo "<7>dracut: $line" >&5 + echo "<31>dracut: $line" >&5 # if "quiet" is specified we output to /dev/console - [ -n "$QUIET" ] && echo "dracut: $line" + [ -n "$QUIET" ] && echo "dracut: $line" echo "$line" >&6 done diff -Naur dracut-010/modules.d/99base/module-setup.sh dracut-0e6a94b/modules.d/99base/module-setup.sh --- dracut-010/modules.d/99base/module-setup.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/modules.d/99base/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -7,14 +7,15 @@ } depends() { - echo udev-rules + echo udev-rules return 0 } install() { + local _d dracut_install mount mknod mkdir modprobe pidof sleep chroot \ - sed ls flock cp mv dmesg rm ln rmmod mkfifo - dracut_install -o less + sed ls flock cp mv dmesg rm ln rmmod mkfifo umount + dracut_install -o less if [ ! -e "${initdir}/bin/sh" ]; then dracut_install bash (ln -s bash "${initdir}/bin/sh" || :) @@ -24,23 +25,18 @@ inst "$moddir/initqueue" "/sbin/initqueue" inst "$moddir/loginit" "/sbin/loginit" - mkdir -m 0755 -p ${initdir}/lib + [ -e "${initdir}/lib" ] || mkdir -m 0755 -p ${initdir}/lib mkdir -m 0755 -p ${initdir}/lib/dracut mkdir -m 0755 -p ${initdir}/lib/dracut/hooks - for d in $hookdirs emergency \ + for _d in $hookdirs emergency \ initqueue initqueue/finished initqueue/settled; do - mkdir -m 0755 -p ${initdir}/lib/dracut/hooks/$d + mkdir -m 0755 -p ${initdir}/lib/dracut/hooks/$_d done mkdir -p ${initdir}/tmp - # Bail out if switch_root does not exist - if type -P switch_root >/dev/null; then - inst $(type -P switch_root) /sbin/switch_root \ - || dfatal "Failed to install switch_root" - else - inst "$moddir/switch_root" "/sbin/switch_root" \ - || dfatal "Failed to install switch_root" - fi + + dracut_install switch_root || dfatal "Failed to install switch_root" + inst "$moddir/dracut-lib.sh" "/lib/dracut-lib.sh" inst_hook cmdline 10 "$moddir/parse-root-opts.sh" mkdir -p "${initdir}/var" diff -Naur dracut-010/modules.d/99shutdown/module-setup.sh dracut-0e6a94b/modules.d/99shutdown/module-setup.sh --- dracut-010/modules.d/99shutdown/module-setup.sh 1970-01-01 01:00:00.000000000 +0100 +++ dracut-0e6a94b/modules.d/99shutdown/module-setup.sh 2011-05-31 16:34:37.000000000 +0200 @@ -0,0 +1,27 @@ +#!/bin/bash +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ex: ts=8 sw=4 sts=4 et filetype=sh + +check() { + return 255 +} + +depends() { + echo base + return 0 +} + +install() { + local _d + dracut_install umount + dracut_install poweroff reboot halt + dracut_install -o kexec + inst "$moddir/shutdown" "$prefix/shutdown" + [ -e "${initdir}/lib" ] || mkdir -m 0755 -p ${initdir}/lib + mkdir -m 0755 -p ${initdir}/lib/dracut + mkdir -m 0755 -p ${initdir}/lib/dracut/hooks + for _d in $hookdirs shutdown shutdown-emergency; do + mkdir -m 0755 -p ${initdir}/lib/dracut/hooks/$_d + done +} + diff -Naur dracut-010/modules.d/99shutdown/shutdown dracut-0e6a94b/modules.d/99shutdown/shutdown --- dracut-010/modules.d/99shutdown/shutdown 1970-01-01 01:00:00.000000000 +0100 +++ dracut-0e6a94b/modules.d/99shutdown/shutdown 2011-05-31 16:34:37.000000000 +0200 @@ -0,0 +1,87 @@ +#!/bin/sh +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ex: ts=8 sw=4 sts=4 et filetype=sh +# +# Licensed under the GPLv2 +# +# Copyright 2011, Red Hat, Inc. +# Harald Hoyer + +#!/bin/sh +. /lib/dracut-lib.sh +export TERM=linux + +emergency_shell() +{ + set +e + if [ "$1" = "-n" ]; then + _rdshell_name=$2 + shift 2 + else + _rdshell_name=dracut + fi + echo ; echo + warn $@ + source_hook shutdown-emergency + echo + if getargbool 1 rd.shell -y rdshell || getarg rd.break rdbreak; then + [ -x /lib/udev/console_init ] && /lib/udev/console_init /dev/console + echo "Dropping to debug shell." + echo + export PS1="$_rdshell_name:\${PWD}# " + [ -e /.profile ] || echo "exec 0<>/dev/console 1<>/dev/console 2<>/dev/console" > /.profile + sh -i -l + else + exec /lib/systemd/systemd-shutdown "$@" + warn "Shutdown has failed. To debug this issue add \"rdshell\" to the kernel command line." + # cause a kernel panic + exit 1 + fi +} + +trap "emergency_shell Signal caught!" 0 + +getarg 'rd.break=pre-shutdown' && emergency_shell -n cmdline "Break before pre-shutdown" + +umount_a() { + local _did_umount="n" + while read a mp a; do + if strstr "$mp" oldroot; then + if umount "$mp"; then + _did_umount="y" + echo "Unmounted $mp." + fi + fi + done /dev/null || break + _cnt=$(($_cnt+1)) +done +[ $_cnt -ge 40 ] && umount_a + +check_finished() { + local f + for f in $hookdir/shutdown/*.sh; do + [ -e "$f" ] || continue + ( . "$f" ) || return 1 + done + return 0 +} + +_cnt=0 +while [ $_cnt -le 40 ]; do + check_finished 2>/dev/null && break + _cnt=$(($_cnt+1)) +done +[ $_cnt -ge 40 ] && check_finished + +getarg 'rd.break=shutdown' && emergency_shell -n cmdline "Break before shutdown" +[ "$1" = "reboot" ] && reboot -f -d -n --no-wall +[ "$1" = "poweroff" ] && poweroff -f -d -n --no-wall +[ "$1" = "halt" ] && halt -f -d -n --no-wall +[ "$1" = "kexec" ] && kexec -e diff -Naur dracut-010/NEWS dracut-0e6a94b/NEWS --- dracut-010/NEWS 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/NEWS 2011-05-31 16:34:37.000000000 +0200 @@ -1,3 +1,9 @@ +dracut-011 +========== +- use udev-168 features for shutting down udev +- introduce "--prefix" to put all initramfs files in /run/initramfs +- new shutdown script + dracut-010 ========== - lots of bugfixes @@ -62,7 +68,7 @@ - add btrfsctl scan for btrfs multi-devices (raid) - teach dmsquash live-root to use rootflags - trigger udev with action=add -- fixed add_drivers handling +- fixed add_drivers handling - add sr_mod - use pigz instead of gzip, if available - boot from LVM mirrors and snapshots @@ -75,7 +81,7 @@ dracut-005 ========== -- dcb support to dracut's FCoE support +- dcb support to dracut's FCoE support - add readonly overlay support for dmsquash - add keyboard kernel modules - dracut.conf: added add_dracutmodules @@ -113,7 +119,7 @@ - add s390 network support - fixed dracut-gencmdline for root=UUID or LABEL - do not destroy assembled raid arrays if mdadm.conf present -- mount /dev/shm +- mount /dev/shm - let udevd not resolve group and user names - moved network from udev to initqueue - improved debug output: specifying "rdinitdebug" now logs @@ -121,7 +127,7 @@ - strip kernel modules which have no x bit set - redirect stdin, stdout, stderr all RW to /dev/console so the user can use "less" to view /init.log and dmesg -- add new device mapper udev rules and dmeventd +- add new device mapper udev rules and dmeventd - fixed dracut-gencmdline for root=UUID or LABEL - do not destroy assembled raid arrays if mdadm.conf present - mount /dev/shm @@ -166,17 +172,17 @@ Supported cmdline formats: fcoe=: fcoe=: - + Note currently only nodcb is supported, the dcb option is reserved for future use. - + Note letters in the macaddress must be lowercase! - + Examples: fcoe=eth0:nodcb fcoe=4A:3F:4C:04:F8:D7:nodcb -- Syslog support for dracut +- Syslog support for dracut This module provides syslog functionality in the initrd. This is especially interesting when complex configuration being used to provide access to the device the rootfs resides on. @@ -203,20 +209,20 @@ dracut-0.7 ========== - dracut: strip binaries in initramfs - + --strip strip binaries in the initramfs (default) - + --nostrip do not strip binaries in the initramfs - dracut-catimages - + Usage: ./dracut-catimages [OPTION]... [...] Creates initial ramdisk image by concatenating several images from the command line and /boot/dracut/ - + -f, --force Overwrite existing initramfs file. -i, --imagedir Directory with additional images to add (default: /boot/dracut/) @@ -233,44 +239,44 @@ dracut-0.6 ========== - dracut: add --kernel-only and --no-kernel arguments - + --kernel-only only install kernel drivers and firmware files - + --no-kernel do not install kernel drivers and firmware files - + All kernel module related install commands moved from "install" to "installkernel". - + For "--kernel-only" all installkernel scripts of the specified modules are used, regardless of any checks, so that all modules which might be needed by any dracut generic image are in. - + The basic idea is to create two images. One image with the kernel modules and one without. So if the kernel changes, you only have to replace one image. - + Grub and the kernel can handle multiple images, so grub entry can look like this: - + title Fedora (2.6.29.5-191.fc11.i586) root (hd0,0) kernel /vmlinuz-2.6.29.5-191.fc11.i586 ro rhgb quiet initrd /initrd-20090722.img /initrd-kernel-2.6.29.5-191.fc11.i586.img /initrd-config.img - + initrd-20090722.img the image provided by the initrd rpm one old backup version is kept like with the kernel - + initrd-kernel-2.6.29.5-191.fc11.i586.img the image provided by the kernel rpm - + initrd-config.img optional image with local configuration files - dracut: add --kmoddir directory, where to look for kernel modules - + -k, --kmoddir [DIR] specify the directory, where to look for kernel modules @@ -290,18 +296,18 @@ - firmware loading support - new internal queue (initqueue) initqueue now loops until /dev/root exists or root is mounted - + init now has the following points to inject scripts: - + /cmdline/*.sh scripts for command line parsing - + /pre-udev/*.sh scripts to run before udev is started - + /pre-trigger/*.sh scripts to run before the main udev trigger is pulled - + /initqueue/*.sh runs in parallel to the udev trigger Udev events can add scripts here with /sbin/initqueue. @@ -313,12 +319,12 @@ filesystem was mounted, the user will be dropped to a shell after a timeout. Scripts can remove themselves from the initqueue by "rm $job". - + /pre-mount/*.sh scripts to run before the root filesystem is mounted NFS is an exception, because it has no device node to be created and mounts in the udev events - + /mount/*.sh scripts to mount the root filesystem NFS is an exception, because it has no device node to be created @@ -326,12 +332,12 @@ If the udev queue is empty and no root device is found or no root filesystem was mounted, the user will be dropped to a shell after a timeout. - + /pre-pivot/*.sh scripts to run before the real init is executed and the initramfs disappears All processes started before should be killed here. - + The behaviour of the dmraid module demonstrates how to use the new mechanism. If it detects a device which is part of a raidmember from a udev rule, it installs a job to scan for dmraid devices, if the udev diff -Naur dracut-010/README dracut-0e6a94b/README --- dracut-010/README 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/README 2011-05-31 16:34:37.000000000 +0200 @@ -2,8 +2,8 @@ ------ Dracut is a new initramfs infrastructure. -Information about the initial goals and aims can be found at -https://fedoraproject.org/wiki/Initrdrewrite +Information about the initial goals and aims can be found at +https://fedoraproject.org/wiki/Initrdrewrite Unlike existing initramfs's, this is an attempt at having as little as possible hard-coded into the initramfs as possible. The initramfs has @@ -19,19 +19,19 @@ the script, but it's worth trying to resist the urge as much as we can as hooks are guaranteed to be the path to slow-down. -Most of the initrd generation functionality in dracut is provided by a bunch +Most of the initramfs generation functionality in dracut is provided by a bunch of generator modules that are sourced by the main dracut script to install -specific functionality into the initrd. They live in the modules.d -subdirectory, and use functionality provided by dracut-functions to do their +specific functionality into the initramfs. They live in the modules.d +subdirectory, and use functionality provided by dracut-functions to do their work. Some general rules for writing modules: * Use one of the inst family of functions to actually install files - on to the initrd. They handle mangling the pathnames and (for binaries, + on to the initramfs. They handle mangling the pathnames and (for binaries, scripts, and kernel modules) installing dependencies as appropriate so you do not have to. - * Scripts that end up on the initrd should be POSIX compliant. dracut - will try to use /bin/dash as /bin/sh for the initrd if it is available, + * Scripts that end up on the initramfs should be POSIX compliant. dracut + will try to use /bin/dash as /bin/sh for the initramfs if it is available, so you should install it on your system -- dash aims for strict POSIX compliance to the extent possible. * Hooks MUST be POSIX compliant -- they are sourced by the init script, @@ -44,35 +44,41 @@ * We have some breakpoints for debugging your hooks. If you pass 'rdbreak' as a kernel parameter, the initramfs will drop to a shell just before switching to a new root. You can pass 'rdbreak=hookpoint', and the initramfs - will break just before hooks in that hookpoint run. + will break just before hooks in that hookpoint run. Also, there is an attempt to keep things as distribution-agnostic as possible. Every distribution has their own tool here and it's not something which is really interesting to have separate across them. So contributions to help decrease the distro-dependencies are welcome. -Currently dracut lives on sourceforge. +Currently dracut lives on kernel.org. + +The tarballs can be found here: + http://www.kernel.org/pub/linux/utils/boot/dracut/ + ftp://ftp.kernel.org/pub/linux/utils/boot/dracut/ + +Git: + git://git.kernel.org/pub/scm/boot/dracut/dracut.git + http://git.kernel.org/pub/scm/boot/dracut/dracut.git + https://git.kernel.org/pub/scm/boot/dracut/dracut.git + +Git Web: + http://git.kernel.org/?p=boot/dracut/dracut.git + +Git Web RSS Feed: + http://git.kernel.org/?p=boot/dracut/dracut.git;a=rss Project Page: -https://sourceforge.net/projects/dracut/ + http://www.kernel.org/pub/linux/utils/boot/dracut/dracut.html -Drop Harald Hoyer a mail, if you want to help with -the documentation, git access, etc. +Project Wiki: + http://dracut.wiki.kernel.org -Git Repository: -http://dracut.git.sourceforge.net/ -git://dracut.git.sourceforge.net/gitroot/dracut/dracut - -Trac Instance: -http://apps.sourceforge.net/trac/dracut/ - -The git tree can be found at -git://dracut.git.sourceforge.net/gitroot/dracut/dracut for now. See the TODO -file for things which still need to be done and HACKING for some -instructions on how to get started. There is also a mailing list that -is being used for the discussion -- initramfs@vger.kernel.org. It is -a typical vger list, send mail to majordomo@vger.kernel.org with body -of 'subscribe initramfs email@host.com' +See the TODO file for things which still need to be done and HACKING for +some instructions on how to get started. There is also a mailing list +that is being used for the discussion -- initramfs@vger.kernel.org. +It is a typical vger list, send mail to majordomo@vger.kernel.org with body +of 'subscribe initramfs email@host.com' Licensed under the GPLv2 diff -Naur dracut-010/README.generic dracut-0e6a94b/README.generic --- dracut-010/README.generic 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/README.generic 2011-05-31 16:34:37.000000000 +0200 @@ -1,7 +1,7 @@ To build a generic initramfs, you have to install the following software packages: * device-mapper * cryptsetup-luks - * rpcbind nfs-utils + * rpcbind nfs-utils * lvm2 * iscsi-initiator-utils * nbd diff -Naur dracut-010/README.modules dracut-0e6a94b/README.modules --- dracut-010/README.modules 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/README.modules 2011-05-31 16:34:37.000000000 +0200 @@ -4,7 +4,7 @@ dracut_install_dir/modules.d/ 00modname/ - install + module-setup.sh check @@ -12,45 +12,55 @@ The numeric code must be present and in the range of 00 - 99. Modules with lower numbers are installed first. This is important because the dracut install functions (which install files onto - the initrd) refuse to overwrite already installed files. This makes - it easy for an earlier module to override the functionality of a + the initrd) refuse to overwrite already installed files. This makes + it easy for an earlier module to override the functionality of a later module, so that you can have a distro or system specific module override or modify the functionality of a generic module without having to patch the more generic module. -install: dracut sources this script to install the functionality that a +module-setup.sh: + dracut sources this script to install the functionality that a module implements onto the initrd. For the most part, this amounts to copying files from the host system onto the initrd in a controlled - manner. dracut supplies several install functions that are + manner. + +install(): + This function of module-setup.sh is called to install all + non-kernel files. dracut supplies several install functions that are specialized for different file types. Browse through dracut-functions fore more details. dracut also provides a $moddir variable if you need to install a file from the module directory, such as an initrd hook, a udev rule, or a specialized executable. -check: Dracut calls this program to check and see if a module can be installed +installkernel(): + This function of module-setup.sh is called to install all + kernel related files. + + +check(): + Dracut calls this function to check and see if a module can be installed on the initrd. - + When called without options, check should check to make sure that any files it needs to install into the initrd from the host system are present. It should exit with a 0 if they are, and a 1 if they are not. - When called with -h, it should perform the same check that it would - without any options, and it should also check to see if the + When called with $hostonly set, it should perform the same check + that it would without it set, and it should also check to see if the functionality the module implements is being used on the host system. For example, if this module handles installing support for LUKS encrypted volumes, it should return 0 if all the tools to handle encrpted volumes are available and the host system has the root partition on an encrypted volume, 1 otherwise. - When called with -d, it should output a list of dracut modules +depends(): + This function should output a list of dracut modules that it relies upon. An example would be the nfs and iscsi modules, which rely on the network module to detect and configure network interfaces. - Check may take additional options in the future. - -Any other files in the module will not be touched by dracut directly. +Any other files in the module will not be touched by dracut directly. You are encouraged to provide a README that describes what the module is for. @@ -60,39 +70,39 @@ init has the following hook points to inject scripts: -/cmdline/*.sh +/lib/dracut/hooks/cmdline/*.sh scripts for command line parsing -/pre-udev/*.sh +/lib/dracut/hooks/pre-udev/*.sh scripts to run before udev is started -/pre-trigger/*.sh +/lib/dracut/hooks/pre-trigger/*.sh scripts to run before the main udev trigger is pulled -/initqueue/*.sh +/lib/dracut/hooks/initqueue/*.sh runs in parallel to the udev trigger Udev events can add scripts here with /sbin/initqueue. If /sbin/initqueue is called with the "--onetime" option, the script will be removed after it was run. - If /initqueue/work is created and udev >= 143 then this loop can - process the jobs in parallel to the udevtrigger. + If /lib/dracut/hooks/initqueue/work is created and udev >= 143 then + this loop can process the jobs in parallel to the udevtrigger. If the udev queue is empty and no root device is found or no root filesystem was mounted, the user will be dropped to a shell after a timeout. Scripts can remove themselves from the initqueue by "rm $job". -/pre-mount/*.sh +/lib/dracut/hooks/pre-mount/*.sh scripts to run before the root filesystem is mounted - Network filesystems like NFS that do not use device files are an + Network filesystems like NFS that do not use device files are an exception. Root can be mounted already at this point. -/mount/*.sh +/lib/dracut/hooks/mount/*.sh scripts to mount the root filesystem If the udev queue is empty and no root device is found or no root filesystem was mounted, the user will be dropped to a shell after a timeout. -/pre-pivot/*.sh +/lib/dracut/hooks/pre-pivot/*.sh scripts to run before the real init is executed and the initramfs disappears All processes started before should be killed here. diff -Naur dracut-010/switch_root.c dracut-0e6a94b/switch_root.c --- dracut-010/switch_root.c 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/switch_root.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,279 +0,0 @@ -/* - * switchroot.c - switch to new root directory and start init. - * - * Copyright 2002-2009 Red Hat, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Authors: - * Peter Jones - * Jeremy Katz - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef MS_MOVE -#define MS_MOVE 8192 -#endif - -/* find the enclosing mount point of a path, by examining the backing device - * of parent directories until we reach / or find a parent with a differing - * device. - * result must be freed. - */ -static char *get_parent_mount(const char *path) -{ - struct stat sb; - char dir[PATH_MAX]; - char tmp[PATH_MAX]; - dev_t inner_dev; - int r; - - r = stat(path, &sb); - if (r != 0) { - warn("failed to stat %s", path); - return NULL; - } - inner_dev = sb.st_dev; - - /* dirname has some annoying properties of modifying the input... */ - strncpy(dir, path, PATH_MAX); - dir[PATH_MAX - 1] = 0; /* for safety */ - - while (1) { - char *parent; - - strncpy(tmp, dir, PATH_MAX); - tmp[PATH_MAX - 1] = 0; - parent = dirname(tmp); - - r = stat(parent, &sb); - if (r != 0) { - warn("failed to stat %s", parent); - return NULL; - } - - /* if the parent directory's device differs then we have found a mount - * point */ - if (sb.st_dev != inner_dev) - return strdup(dir); - - strncpy(dir, parent, PATH_MAX); - dir[PATH_MAX - 1] = 0; - - /* maybe we've reached / */ - if (strlen(dir) == 1) - return strdup(dir); - } -} - -/* remove all files/directories below dirName -- don't cross mountpoints */ -static int recursiveRemove(char *dirName) -{ - struct stat rb; - DIR *dir; - int rc = -1; - int dfd; - - if (!(dir = opendir(dirName))) { - warn("failed to open %s", dirName); - goto done; - } - - dfd = dirfd(dir); - - if (fstat(dfd, &rb)) { - warn("failed to stat %s", dirName); - goto done; - } - - while(1) { - struct dirent *d; - - errno = 0; - if (!(d = readdir(dir))) { - if (errno) { - warn("failed to read %s", dirName); - goto done; - } - break; /* end of directory */ - } - - if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) - continue; - - if (d->d_type == DT_DIR) { - struct stat sb; - - if (fstatat(dfd, d->d_name, &sb, AT_SYMLINK_NOFOLLOW)) { - warn("failed to stat %s/%s", dirName, d->d_name); - continue; - } - - /* remove subdirectories if device is same as dir */ - if (sb.st_dev == rb.st_dev) { - char subdir[ strlen(dirName) + - strlen(d->d_name) + 2 ]; - - sprintf(subdir, "%s/%s", dirName, d->d_name); - recursiveRemove(subdir); - } else - continue; - } - - if (unlinkat(dfd, d->d_name, - d->d_type == DT_DIR ? AT_REMOVEDIR : 0)) - warn("failed to unlink %s/%s", dirName, d->d_name); - } - - rc = 0; /* success */ - -done: - if (dir) - closedir(dir); - return rc; -} - -static int switchroot(const char *newroot) -{ - /* Don't try to unmount the old "/", there's no way to do it. */ - const char *umounts[] = { "/dev", "/proc", "/sys", NULL }; - char *newroot_mnt; - const char *chroot_path = NULL; - int i; - int r = -1; - - for (i = 0; umounts[i] != NULL; i++) { - char newmount[PATH_MAX]; - - snprintf(newmount, sizeof(newmount), "%s%s", newroot, umounts[i]); - - if (mount(umounts[i], newmount, NULL, MS_MOVE, NULL) < 0) { - warn("failed to mount moving %s to %s", - umounts[i], newmount); - warnx("forcing unmount of %s", umounts[i]); - umount2(umounts[i], MNT_FORCE); - } - } - - if (chdir(newroot)) { - warn("failed to change directory to %s", newroot); - return -1; - } - - recursiveRemove("/"); - - newroot_mnt = get_parent_mount(newroot); - if (newroot_mnt && strcmp(newroot, newroot_mnt)) { - /* newroot is not a mount point, so we have to MS_MOVE the parent - * mount point and then chroot in to the "subroot" */ - chroot_path = newroot + strlen(newroot_mnt); - newroot = newroot_mnt; - - if (chdir(newroot)) { - warn("failed to chdir to newroot mount %s", newroot); - goto err; - } - } - - if (mount(newroot, "/", NULL, MS_MOVE, NULL) < 0) { - warn("failed to mount moving %s to /", newroot); - goto err; - } - - if (chroot(".")) { - warn("failed to change root"); - goto err; - } - - if (chroot_path) { - if (chdir(chroot_path)) { - warn("failed to chdir to subroot %s", chroot_path); - goto err; - } - - if (chroot(".")) { - warn("failed to change root to subroot"); - goto err; - } - } - - r = 0; -err: - if (newroot_mnt) - free(newroot_mnt); - return r; -} - -static void usage(FILE *output) -{ - fprintf(output, "usage: %s \n", - program_invocation_short_name); - exit(output == stderr ? EXIT_FAILURE : EXIT_SUCCESS); -} - -static void version(void) -{ - fprintf(stdout, "%s from %s\n", program_invocation_short_name, - PACKAGE_STRING); - exit(EXIT_SUCCESS); -} - -int main(int argc, char *argv[]) -{ - char *newroot, *init, **initargs; - - if (argv[1] && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h"))) - usage(stdout); - if (argv[1] && (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-V"))) - version(); - if (argc < 3) - usage(stderr); - - newroot = argv[1]; - init = argv[2]; - initargs = &argv[2]; - - if (!*newroot || !*init) - usage(stderr); - - if (switchroot(newroot)) - errx(EXIT_FAILURE, "failed. Sorry."); - - if (access(init, X_OK)) - warn("cannot access %s", init); - - /* get session leader */ - setsid(); - - /* set controlling terminal */ - if (ioctl (0, TIOCSCTTY, 1)) - warn("failed to TIOCSCTTY"); - - execv(init, initargs); - err(EXIT_FAILURE, "failed to execute %s", init); -} - diff -Naur dracut-010/test/TEST-01-BASIC/99-idesymlinks.rules dracut-0e6a94b/test/TEST-01-BASIC/99-idesymlinks.rules --- dracut-010/test/TEST-01-BASIC/99-idesymlinks.rules 1970-01-01 01:00:00.000000000 +0100 +++ dracut-0e6a94b/test/TEST-01-BASIC/99-idesymlinks.rules 2011-05-31 16:34:37.000000000 +0200 @@ -0,0 +1,8 @@ +ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hda", SYMLINK+="sda" +ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hda*", SYMLINK+="sda$env{MINOR}" +ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdb", SYMLINK+="sdb" +ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdb*", SYMLINK+="sdb$env{MINOR}" +ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdc", SYMLINK+="sdc" +ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdc*", SYMLINK+="sdc$env{MINOR}" +ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdd", SYMLINK+="sdd" +ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdd*", SYMLINK+="sdd$env{MINOR}" diff -Naur dracut-010/test/TEST-01-BASIC/create-root.sh dracut-0e6a94b/test/TEST-01-BASIC/create-root.sh --- dracut-010/test/TEST-01-BASIC/create-root.sh 1970-01-01 01:00:00.000000000 +0100 +++ dracut-0e6a94b/test/TEST-01-BASIC/create-root.sh 2011-05-31 16:34:37.000000000 +0200 @@ -0,0 +1,23 @@ +#!/bin/sh +# don't let udev and this script step on eachother's toes +for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do + > "/etc/udev/rules.d/$x" +done +rm /etc/lvm/lvm.conf +udevadm control --reload-rules +set -e +# save a partition at the beginning for future flagging purposes +sfdisk -C 1280 -H 2 -S 32 -L /dev/sda </dev/sda1 +poweroff -f + diff -Naur dracut-010/test/TEST-01-BASIC/cryptroot-ask dracut-0e6a94b/test/TEST-01-BASIC/cryptroot-ask --- dracut-010/test/TEST-01-BASIC/cryptroot-ask 1970-01-01 01:00:00.000000000 +0100 +++ dracut-0e6a94b/test/TEST-01-BASIC/cryptroot-ask 2011-05-31 16:34:37.000000000 +0200 @@ -0,0 +1,6 @@ +#!/bin/sh + +[ -b /dev/mapper/$2 ] && exit 0 +echo -n test >/keyfile +/sbin/cryptsetup luksOpen $1 $2 /dev/console 2>&1 +echo "dracut-root-block-success" >/dev/sda1 +export TERM=linux +export PS1='initramfs-test:\w\$ ' +[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab +[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab +stty sane +echo "made it to the rootfs!" +strstr "$CMDLINE" "rd.shell" && sh -i +echo "Powering down." +mount -n -o remount,ro / +poweroff -f diff -Naur dracut-010/test/TEST-01-BASIC/test.sh dracut-0e6a94b/test/TEST-01-BASIC/test.sh --- dracut-010/test/TEST-01-BASIC/test.sh 1970-01-01 01:00:00.000000000 +0100 +++ dracut-0e6a94b/test/TEST-01-BASIC/test.sh 2011-05-31 16:34:37.000000000 +0200 @@ -0,0 +1,88 @@ +#!/bin/bash +TEST_DESCRIPTION="root filesystem on a ext3 filesystem" + +KVERSION=${KVERSION-$(uname -r)} + +# Uncomment this to debug failures +#DEBUGFAIL="rd.shell rd.break" + +test_run() { + $testdir/run-qemu -hda root.ext3 -m 256M -nographic \ + -net none -kernel /boot/vmlinuz-$KVERSION \ + -append "root=LABEL=dracut rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \ + -initrd initramfs.testing + grep -m 1 -q dracut-root-block-success root.ext3 || return 1 +} + +test_setup() { + + if [ ! -e root.ext3 ]; then + + # Create the blank file to use as a root filesystem + dd if=/dev/zero of=root.ext3 bs=1M count=40 + + kernel=$KVERSION + # Create what will eventually be our root filesystem onto an overlay + ( + initdir=overlay/source + . $basedir/dracut-functions + dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \ + /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient \ + umount strace less + inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script" + inst "$basedir/modules.d/40network/ifup" "/sbin/ifup" + dracut_install grep + inst ./test-init /sbin/init + find_binary plymouth >/dev/null && dracut_install plymouth + (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp ) + cp -a /etc/ld.so.conf* $initdir/etc + sudo ldconfig -r "$initdir" + ) + + # second, install the files needed to make the root filesystem + ( + initdir=overlay + . $basedir/dracut-functions + dracut_install sfdisk mkfs.ext3 poweroff cp umount + inst_hook initqueue 01 ./create-root.sh + inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules + ) + + # create an initramfs that will create the target root filesystem. + # We do it this way so that we do not risk trashing the host mdraid + # devices, volume groups, encrypted partitions, etc. + $basedir/dracut -l -i overlay / \ + -m "dash udev-rules base rootfs-block kernel-modules" \ + -d "piix ide-gd_mod ata_piix ext3 sd_mod" \ + --nomdadmconf \ + -f initramfs.makeroot $KVERSION || return 1 + rm -rf overlay + # Invoke KVM and/or QEMU to actually create the target filesystem. + $testdir/run-qemu -hda root.ext3 -m 256M -nographic -net none \ + -kernel "/boot/vmlinuz-$kernel" \ + -append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \ + -initrd initramfs.makeroot || return 1 + grep -m 1 -q dracut-root-block-created root.ext3 || return 1 + fi + + ( + initdir=overlay + . $basedir/dracut-functions + dracut_install poweroff shutdown + inst_hook emergency 000 ./hard-off.sh + inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules + ) + sudo $basedir/dracut -l -i overlay / \ + -a "debug" \ + -d "piix ide-gd_mod ata_piix ext3 sd_mod" \ + -f initramfs.testing $KVERSION || return 1 + +# -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm" +} + +test_cleanup() { + rm -fr overlay mnt + rm -f root.ext3 initramfs.makeroot initramfs.testing +} + +. $testdir/test-functions diff -Naur dracut-010/test/TEST-10-RAID/test.sh dracut-0e6a94b/test/TEST-10-RAID/test.sh --- dracut-010/test/TEST-10-RAID/test.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/test/TEST-10-RAID/test.sh 2011-05-31 16:34:37.000000000 +0200 @@ -24,7 +24,7 @@ initdir=overlay/source . $basedir/dracut-functions dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \ - /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient + /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script" inst "$basedir/modules.d/40network/ifup" "/sbin/ifup" dracut_install grep @@ -34,16 +34,16 @@ cp -a /etc/ld.so.conf* $initdir/etc sudo ldconfig -r "$initdir" ) - + # second, install the files needed to make the root filesystem ( initdir=overlay . $basedir/dracut-functions - dracut_install sfdisk mke2fs poweroff cp umount + dracut_install sfdisk mke2fs poweroff cp umount inst_hook initqueue 01 ./create-root.sh inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules ) - + # create an initramfs that will create the target root filesystem. # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. diff -Naur dracut-010/test/TEST-11-LVM/test-init dracut-0e6a94b/test/TEST-11-LVM/test-init --- dracut-010/test/TEST-11-LVM/test-init 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/test/TEST-11-LVM/test-init 2011-05-31 16:34:37.000000000 +0200 @@ -1,11 +1,17 @@ #!/bin/sh export PATH=/sbin:/bin:/usr/sbin:/usr/bin +strstr() { [ "${1#*$2*}" != "$1" ]; } +CMDLINE=$(while read line; do echo $line;done < /proc/cmdline) +plymouth --quit exec >/dev/console 2>&1 echo "dracut-root-block-success" >/dev/sda1 export TERM=linux export PS1='initramfs-test:\w\$ ' -[ -f /etc/fstab ] || ln -s /proc/mounts /etc/fstab +[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab +[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab stty sane -echo "made it to the rootfs! Powering down." +echo "made it to the rootfs!" +strstr "$CMDLINE" "rd.shell" && sh -i +echo "Powering down." mount -n -o remount,ro / poweroff -f diff -Naur dracut-010/test/TEST-11-LVM/test.sh dracut-0e6a94b/test/TEST-11-LVM/test.sh --- dracut-010/test/TEST-11-LVM/test.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/test/TEST-11-LVM/test.sh 2011-05-31 16:34:37.000000000 +0200 @@ -4,7 +4,7 @@ KVERSION=${KVERSION-$(uname -r)} # Uncomment this to debug failures -#DEBUGFAIL="rd.shell" +#DEBUGFAIL="rd.break rd.shell" test_run() { $testdir/run-qemu -hda root.ext2 -m 256M -nographic \ @@ -24,7 +24,7 @@ initdir=overlay/source . $basedir/dracut-functions dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \ - /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient + /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script" inst "$basedir/modules.d/40network/ifup" "/sbin/ifup" dracut_install grep @@ -32,18 +32,19 @@ find_binary plymouth >/dev/null && dracut_install plymouth (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp ) cp -a /etc/ld.so.conf* $initdir/etc + mkdir $initdir/run sudo ldconfig -r "$initdir" ) - + # second, install the files needed to make the root filesystem ( initdir=overlay . $basedir/dracut-functions - dracut_install sfdisk mke2fs poweroff cp umount + dracut_install sfdisk mke2fs poweroff cp umount inst_hook initqueue 01 ./create-root.sh inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules ) - + # create an initramfs that will create the target root filesystem. # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. diff -Naur dracut-010/test/TEST-12-RAID-DEG/create-root.sh dracut-0e6a94b/test/TEST-12-RAID-DEG/create-root.sh --- dracut-010/test/TEST-12-RAID-DEG/create-root.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/test/TEST-12-RAID-DEG/create-root.sh 2011-05-31 16:34:37.000000000 +0200 @@ -39,8 +39,8 @@ . /tmp/mduuid; } && \ { -echo "dracut-root-block-created" -echo MD_UUID=$MD_UUID +echo "dracut-root-block-created" +echo MD_UUID=$MD_UUID }> /dev/sda1 dd if=/dev/zero of=/dev/sda2 poweroff -f diff -Naur dracut-010/test/TEST-12-RAID-DEG/test.sh dracut-0e6a94b/test/TEST-12-RAID-DEG/test.sh --- dracut-010/test/TEST-12-RAID-DEG/test.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/test/TEST-12-RAID-DEG/test.sh 2011-05-31 16:34:37.000000000 +0200 @@ -27,7 +27,7 @@ echo "MD_UUID=$MD_UUID" client_run || return 1 - + # client_run rd.md.conf=0 || return 1 client_run rd.lvm=0 failme && return 1 @@ -52,14 +52,14 @@ test_setup() { # Create the blank file to use as a root filesystem dd if=/dev/zero of=root.ext2 bs=1M count=40 - + kernel=$KVERSION # Create what will eventually be our root filesystem onto an overlay ( initdir=overlay/source . $basedir/dracut-functions dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \ - /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient + /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script" inst "$basedir/modules.d/40network/ifup" "/sbin/ifup" dracut_install grep @@ -69,7 +69,7 @@ cp -a /etc/ld.so.conf* $initdir/etc sudo ldconfig -r "$initdir" ) - + # second, install the files needed to make the root filesystem ( initdir=overlay @@ -78,7 +78,7 @@ inst_hook initqueue 01 ./create-root.sh inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules ) - + # create an initramfs that will create the target root filesystem. # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. diff -Naur dracut-010/test/TEST-13-ENC-RAID-LVM/create-root.sh dracut-0e6a94b/test/TEST-13-ENC-RAID-LVM/create-root.sh --- dracut-010/test/TEST-13-ENC-RAID-LVM/create-root.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/test/TEST-13-ENC-RAID-LVM/create-root.sh 2011-05-31 16:34:37.000000000 +0200 @@ -7,18 +7,18 @@ rm /etc/lvm/lvm.conf udevadm control --reload-rules # save a partition at the beginning for future flagging purposes -sfdisk -C 1280 -H 2 -S 32 -L /dev/sda <keyfile cryptsetup -q luksFormat /dev/sda2 /keyfile cryptsetup -q luksFormat /dev/sda3 /keyfile cryptsetup -q luksFormat /dev/sda4 /keyfile cryptsetup luksOpen /dev/sda2 dracut_sda2 luks.txt - + ( initdir=overlay diff -Naur dracut-010/test/TEST-14-IMSM/create-root.sh dracut-0e6a94b/test/TEST-14-IMSM/create-root.sh --- dracut-010/test/TEST-14-IMSM/create-root.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/test/TEST-14-IMSM/create-root.sh 2011-05-31 16:34:37.000000000 +0200 @@ -7,9 +7,9 @@ udevadm control --reload-rules # dmraid does not want symlinks in --disk "..." -if [ -e /dev/hda ] ; then +if [ -e /dev/hda ] ; then echo y|dmraid -f isw -C Test0 --type 1 --disk "/dev/hdb /dev/hdc" -else +else echo y|dmraid -f isw -C Test0 --type 1 --disk "/dev/sdb /dev/sdc" fi udevadm settle @@ -17,18 +17,18 @@ SETS=$(dmraid -c -s) # scan and activate all DM RAIDS for s in $SETS; do - dmraid -ay -i -p --rm_partitions "$s" - [ -e "/dev/mapper/$s" ] && kpartx -a -p p "/dev/mapper/$s" + dmraid -ay -i -p --rm_partitions "$s" + [ -e "/dev/mapper/$s" ] && kpartx -a -p p "/dev/mapper/$s" done udevadm settle -sfdisk -g /dev/mapper/isw*Test0 +sfdisk -g /dev/mapper/isw*Test0 # save a partition at the beginning for future flagging purposes -sfdisk -C 1280 -H 2 -S 32 -L /dev/mapper/isw*Test0 </dev/console 2>&1 echo "dracut-root-block-success" >/dev/sda export TERM=linux @@ -7,6 +10,8 @@ cat /proc/mdstat [ -f /etc/fstab ] || ln -s /proc/mounts /etc/fstab stty sane -echo "made it to the rootfs! Powering down." +echo "made it to the rootfs!" +strstr "$CMDLINE" "rd.shell" && sh -i +echo "Powering down." mount -n -o remount,ro / poweroff -f diff -Naur dracut-010/test/TEST-14-IMSM/test.sh dracut-0e6a94b/test/TEST-14-IMSM/test.sh --- dracut-010/test/TEST-14-IMSM/test.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/test/TEST-14-IMSM/test.sh 2011-05-31 16:34:37.000000000 +0200 @@ -4,7 +4,7 @@ KVERSION=${KVERSION-$(uname -r)} # Uncomment this to debug failures -DEBUGFAIL="rd.shell" +#DEBUGFAIL="rd.shell rd.break" #DEBUGFAIL="$DEBUGFAIL udev.log-priority=debug" client_run() { @@ -39,8 +39,8 @@ test_setup() { # Create the blank file to use as a root filesystem dd if=/dev/zero of=root.ext2 bs=1M count=1 - dd if=/dev/zero of=disk1 bs=1M count=40 - dd if=/dev/zero of=disk2 bs=1M count=40 + dd if=/dev/zero of=disk1 bs=1M count=80 + dd if=/dev/zero of=disk2 bs=1M count=80 kernel=$KVERSION # Create what will eventually be our root filesystem onto an overlay @@ -48,7 +48,7 @@ initdir=overlay/source . $basedir/dracut-functions dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \ - /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient + /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script" inst "$basedir/modules.d/40network/ifup" "/sbin/ifup" dracut_install grep @@ -56,18 +56,19 @@ find_binary plymouth >/dev/null && dracut_install plymouth (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp ) cp -a /etc/ld.so.conf* $initdir/etc + mkdir $initdir/run sudo ldconfig -r "$initdir" ) - + # second, install the files needed to make the root filesystem ( initdir=overlay . $basedir/dracut-functions - dracut_install sfdisk mke2fs poweroff cp umount + dracut_install sfdisk mke2fs poweroff cp umount inst_hook initqueue 01 ./create-root.sh inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules ) - + # create an initramfs that will create the target root filesystem. # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. diff -Naur dracut-010/test/TEST-20-NFS/server-init dracut-0e6a94b/test/TEST-20-NFS/server-init --- dracut-010/test/TEST-20-NFS/server-init 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/test/TEST-20-NFS/server-init 2011-05-31 16:34:37.000000000 +0200 @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh export PATH=/sbin:/bin:/usr/sbin:/usr/bin export TERM=linux export PS1='nfstest-server:\w\$ ' diff -Naur dracut-010/test/TEST-20-NFS/test.sh dracut-0e6a94b/test/TEST-20-NFS/test.sh --- dracut-010/test/TEST-20-NFS/test.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/test/TEST-20-NFS/test.sh 2011-05-31 16:34:37.000000000 +0200 @@ -57,7 +57,7 @@ fi # nfsinfo=( server:/path nfs{,4} options ) - nfsinfo=($(awk '{print $2, $3, $4; exit}' client.img)) + nfsinfo=($(awk '{print $2, $3, $4; exit}' client.img)) if [[ "${nfsinfo[0]%%:*}" != "$server" ]]; then echo "CLIENT TEST INFO: got server: ${nfsinfo[0]%%:*}" @@ -210,7 +210,7 @@ /etc/services sleep mount chmod type -P portmap >/dev/null && dracut_install portmap type -P rpcbind >/dev/null && dracut_install rpcbind - [ -f /etc/netconfig ] && dracut_install /etc/netconfig + [ -f /etc/netconfig ] && dracut_install /etc/netconfig type -P dhcpd >/dev/null && dracut_install dhcpd [ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd instmods nfsd sunrpc ipv6 diff -Naur dracut-010/test/TEST-30-ISCSI/server-init dracut-0e6a94b/test/TEST-30-ISCSI/server-init --- dracut-010/test/TEST-30-ISCSI/server-init 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/test/TEST-30-ISCSI/server-init 2011-05-31 16:34:37.000000000 +0200 @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh export PATH=/sbin:/bin:/usr/sbin:/usr/bin export TERM=linux export PS1='nfstest-server:\w\$ ' diff -Naur dracut-010/test/TEST-30-ISCSI/test.sh dracut-0e6a94b/test/TEST-30-ISCSI/test.sh --- dracut-010/test/TEST-30-ISCSI/test.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/test/TEST-30-ISCSI/test.sh 2011-05-31 16:34:37.000000000 +0200 @@ -93,16 +93,16 @@ cp -a /etc/ld.so.conf* $initdir/etc sudo ldconfig -r "$initdir" ) - + # second, install the files needed to make the root filesystem ( initdir=overlay . $basedir/dracut-functions - dracut_install sfdisk mke2fs poweroff cp umount + dracut_install sfdisk mke2fs poweroff cp umount inst_hook initqueue 01 ./create-root.sh inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules ) - + # create an initramfs that will create the target root filesystem. # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. @@ -162,7 +162,7 @@ dracut_install /usr/sbin/iscsi-target instmods iscsi_tcp crc32c ipv6 inst ./targets /etc/iscsi/targets - [ -f /etc/netconfig ] && dracut_install /etc/netconfig + [ -f /etc/netconfig ] && dracut_install /etc/netconfig type -P dhcpd >/dev/null && dracut_install dhcpd [ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd inst ./server-init /sbin/init diff -Naur dracut-010/test/TEST-40-NBD/server-init dracut-0e6a94b/test/TEST-40-NBD/server-init --- dracut-010/test/TEST-40-NBD/server-init 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/test/TEST-40-NBD/server-init 2011-05-31 16:34:37.000000000 +0200 @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh export PATH=/sbin:/bin:/usr/sbin:/usr/bin export TERM=linux export PS1='nbdtest-server:\w\$ ' diff -Naur dracut-010/test/TEST-50-MULTINIC/client-init dracut-0e6a94b/test/TEST-50-MULTINIC/client-init --- dracut-010/test/TEST-50-MULTINIC/client-init 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/test/TEST-50-MULTINIC/client-init 2011-05-31 16:34:37.000000000 +0200 @@ -1,10 +1,13 @@ #!/bin/sh export PATH=/sbin:/bin:/usr/sbin:/usr/bin +strstr() { [ "${1#*$2*}" != "$1" ]; } +CMDLINE=$(while read line; do echo $line;done < /proc/cmdline) exec >/dev/console 2>&1 export TERM=linux export PS1='initramfs-test:\w\$ ' stty sane echo "made it to the rootfs! Powering down." -echo OK $(cat /dev/.initramfs/net.ifaces) > /dev/sda -#sh -i +[ -e /dev/.initramfs/net.ifaces ] && echo OK $(cat /dev/.initramfs/net.ifaces) > /dev/sda +[ -e /run/initramfs/net.ifaces ] && echo OK $(cat /run/initramfs/net.ifaces) > /dev/sda +strstr "$CMDLINE" "rd.shell" && sh -i poweroff -f diff -Naur dracut-010/test/TEST-50-MULTINIC/server-init dracut-0e6a94b/test/TEST-50-MULTINIC/server-init --- dracut-010/test/TEST-50-MULTINIC/server-init 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/test/TEST-50-MULTINIC/server-init 2011-05-31 16:34:37.000000000 +0200 @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh export PATH=/sbin:/bin:/usr/sbin:/usr/bin export TERM=linux export PS1='nfstest-server:\w\$ ' diff -Naur dracut-010/test/TEST-50-MULTINIC/test.sh dracut-0e6a94b/test/TEST-50-MULTINIC/test.sh --- dracut-010/test/TEST-50-MULTINIC/test.sh 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/test/TEST-50-MULTINIC/test.sh 2011-05-31 16:34:37.000000000 +0200 @@ -137,7 +137,7 @@ /etc/services sleep mount chmod type -P portmap >/dev/null && dracut_install portmap type -P rpcbind >/dev/null && dracut_install rpcbind - [ -f /etc/netconfig ] && dracut_install /etc/netconfig + [ -f /etc/netconfig ] && dracut_install /etc/netconfig type -P dhcpd >/dev/null && dracut_install dhcpd [ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd instmods nfsd sunrpc ipv6 @@ -190,11 +190,11 @@ . $basedir/dracut-functions dracut_install sh shutdown poweroff stty cat ps ln ip \ /lib/terminfo/l/linux mount dmesg mkdir \ - cp ping grep + cp ping grep ls inst ./client-init /sbin/init ( cd "$initdir" - mkdir -p dev sys proc etc + mkdir -p dev sys proc etc run mkdir -p var/lib/nfs/rpc_pipefs ) inst /etc/nsswitch.conf /etc/nsswitch.conf diff -Naur dracut-010/test/test-functions dracut-0e6a94b/test/test-functions --- dracut-010/test/test-functions 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/test/test-functions 2011-05-31 16:34:37.000000000 +0200 @@ -4,19 +4,19 @@ while (($# > 0)); do case $1 in - --run) + --run) echo "TEST RUN: $TEST_DESCRIPTION" test_run exit $?;; - --setup) + --setup) echo "TEST SETUP: $TEST_DESCRIPTION" test_setup exit $?;; - --clean) + --clean) echo "TEST CLEANUP: $TEST_DESCRIPTION" test_cleanup exit $?;; - --all) + --all) echo -n "TEST: $TEST_DESCRIPTION "; ( test_setup && test_run diff -Naur dracut-010/TODO dracut-0e6a94b/TODO --- dracut-010/TODO 2011-03-31 19:50:31.000000000 +0200 +++ dracut-0e6a94b/TODO 2011-05-31 16:34:37.000000000 +0200 @@ -1,2 +1,28 @@ -See https://sourceforge.net/apps/trac/dracut/wiki/TODO +Current TODO list, broken into things which are relevant for the initramfs itself (/init et al) vs the generator. A lot of things are/should be marked with "FIXME" in the code +INITRAMFS TODO + +- The hard-coded list of udev rules that we care about is kind of lame. + +GENERATOR TODO + +- Default module specification could use some work +- udev rule copying, as mentioned above, is a bit too hard-coded +- pkg-config integration, to make it easy for other packages to use us. + +CODE TODO +- document functions +- make function vars local, and prefix with "_" + +Future Enhancement Requests + +Note that our main concern, especially right now, is proving viability of some of the ideas and then showing it with the things that we already support. If things work out, then it should be doable to start putting in support for new things that we don't already have support for. Nothing in this list is guaranteed but if people have ideas about new things, put them here and they'll at least be considered. + +- run ssh server to enter crypto password or perform debugging (supported by debian) +- cryptokey on usbkey rhbz#459485 +- Bug 524727 - Dracut + encrypted root + networking + + +- add recovery image creator (mkrecovery) +- parameters for automatic kexec fallback +- parameters for automatic panic fallback