From: Victor Lowther Date: Sat, 23 May 2009 02:24:29 +0000 (-0700) Subject: Style cleanups in main dracut script. X-Git-Tag: 0.1~203 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f1336ac775af519a6c763e348d730db60742230b;p=thirdparty%2Fdracut.git Style cleanups in main dracut script. This patch series applies on top of my previous patch series, and is mainly concerned with coding style updates and better documentation. Apparently [[ ]] && { ; } type flow control is scary, so translate most instances of them into standard if-then and case constructs. --- diff --git a/dracut b/dracut index be3c20332..b299f82e5 100755 --- a/dracut +++ b/dracut @@ -62,8 +62,13 @@ while (($# > 0)); do shift done -[[ -f $conffile ]] || { [[ -f /etc/dracut.conf ]] && conffile="/etc/dracut.conf" } +# if we were not passed a config file, try the default one +[[ ! -f $conffile ]] && conffile="/etc/dracut.conf" + +# source our config file [[ -f $conffile ]] && . "$conffile" + +# these options override the stuff in the config file [[ $dracutmodules_l ]] && dracutmodules=$dracutmodules_l [[ $omit_dracutmodules_l ]] && omit_dracutmodules=$omit_dracutmodules_l [[ $modules_l ]] && modules=$modules_l @@ -79,16 +84,18 @@ fi dracutfunctions=$dsrc/dracut-functions export dracutfunctions -[[ $dracutmodules ]] || dracutmodules="auto" -[[ $dracutmodules = "auto" ]] && { - dracutmodules="all" - skipmissing="yes" -} -[[ $dracutmodules = "hostonly" ]] && { - dracutmodules="all" - skipmissing="yes" - hostonly="-h" -} +# this logic is weird and convoluted. We should simplify it. +case $dracutmodules in + ""|auto) + dracutmodules="all" + skipmissing="yes" + ;; + hostonly) + dracutmodules="all" + skipmissing="yes" + hostonly="-h" + ;; +esac [[ $2 ]] && kernel=$2 || kernel=$(uname -r) @@ -111,6 +118,8 @@ for d in bin sbin usr/bin usr/sbin usr/lib etc proc sys sysroot dev/pts; do mkdir -p "$initdir/$d"; done +# these bits are fugly, and need some cleanup. +# Actually documenting how dracut modules work these days would be good. skip_missing() { # $1 = location of module [[ $skipmissing ]] || return 0 @@ -139,18 +148,18 @@ unset moddir ## final stuff that has to happen # generate module dependencies for the initrd -/sbin/depmod -a -b "$initdir" $kernel || { +if ! /sbin/depmod -a -b "$initdir" $kernel; then echo "\"/sbin/depmod -a $kernel\" failed." exit 1 -} +fi # make sure that library links are correct and up to date ldconfig -n -r "$initdir" /lib* /usr/lib* -[[ $include_src && $include_target ]] && { +if [[ $include_src && $include_target ]]; then mkdir -p "$initdir$include_target" cp -a -t "$initdir$include_target" "$include_src"/* -} +fi for item in $install_items; do dracut_install "$item"