fi
}
+# Little helper function for reading args from the commandline to a stack.
+# it automatically handles -a b and -a=b variants, and returns 1 if
+# we need to shift $3.
+push_arg() {
+ # $1 = arg name
+ # $2 = arg value
+ # $3 = arg parameter
+ local rematch='^[^=]*=(.*)$'
+ if [[ $2 =~ $rematch ]]; then
+ push "$1" "${BASH_REMATCH[1]}"
+ else
+ push "$1" "$3"
+ # There is no way to shift our callers args, so
+ # return 1 to indicate they should do it instead.
+ return 1
+ fi
+}
+
kernel="unset"
while (($# > 0)); do
case ${1%%=*} in
- -m|--modules) read_arg dracutmodules_l "$@" || shift;;
- -o|--omit) read_arg omit_dracutmodules_l "$@" || shift;;
- -a|--add) read_arg add_dracutmodules_l "$@" || shift;;
- -d|--drivers) read_arg drivers_l "$@" || shift;;
- --add-drivers) read_arg add_drivers_l "$@" || shift;;
- --filesystems) read_arg filesystems_l "$@" || shift;;
+ -a|--add) push_arg add_dracutmodules_l "$@" || shift;;
+ --add-drivers) push_arg add_drivers_l "$@" || shift;;
+ -m|--modules) push_arg dracutmodules_l "$@" || shift;;
+ -o|--omit) push_arg omit_dracutmodules_l "$@" || shift;;
+ -d|--drivers) push_arg drivers_l "$@" || shift;;
+ --filesystems) push_arg filesystems_l "$@" || shift;;
+ -I|--install) push_arg install_items "$@" || shift;;
+ --fwdir) push_arg fw_dir_l "$@" || shift;;
-k|--kmoddir) read_arg drivers_dir_l "$@" || shift;;
-c|--conf) read_arg conffile "$@" || shift;;
--confdir) read_arg confdir "$@" || shift;;
- -I|--install) read_arg install_items "$@" || shift;;
- --fwdir) read_arg fw_dir_l "$@" || shift;;
-f|--force) force=yes;;
--kernel-only) kernel_only="yes"; no_kernel="no";;
--no-kernel) kernel_only="no"; no_kernel="yes";;
-H|--hostonly) hostonly_l="yes" ;;
--fstab) use_fstab_l="yes" ;;
-h|--help) usage; exit 1 ;;
- -i|--include) include_src="$2"; include_target="$3"; shift 2;;
+ -i|--include) push include_src "$2"; push include_target "$3"; shift 2;;
--bzip2) [[ $compress != cat ]] && compress="bzip2 -9";;
--lzma) [[ $compress != cat ]] && compress="lzma -9";;
--no-compress) compress="cat";;
fi
# these optins add to the stuff in the config file
-[[ $add_dracutmodules_l ]] && add_dracutmodules+=" $add_dracutmodules_l"
-[[ $add_drivers_l ]] && add_drivers+=" $add_drivers_l"
+if [[ ${#add_dracutmodules_l[@]} ]]; then
+ while pop add_dracutmodules_l val; do
+ add_dracutmodules+=" $val "
+ done
+fi
+
+if [[ ${#add_drivers_l[@]} ]]; then
+ while pop add_drivers_l val; do
+ add_drivers+=" $val "
+ done
+fi
# these options override the stuff in the config file
-[[ $dracutmodules_l ]] && dracutmodules=$dracutmodules_l
-[[ $omit_dracutmodules_l ]] && omit_dracutmodules=$omit_dracutmodules_l
-[[ $drivers_l ]] && drivers=$drivers_l
-[[ $filesystems_l ]] && filesystems=$filesystems_l
+if [[ ${#dracutmodules_l[@]} ]]; then
+ dracutmodules=''
+ while pop dracutmodules_l val; do
+ dracutmodules+="$val "
+ done
+fi
+
+if [[ ${#omit_dracutmodules_l[@]} ]]; then
+ omit_dracutmodules=''
+ while pop omit_dracutmodules_l val; do
+ omit_dracutmodules+="$val "
+ done
+fi
+
+if [[ ${#drivers_l[@]} ]]; then
+ drivers=''
+ while pop drivers_l val; do
+ drivers+="$val "
+ done
+fi
+
+if [[ ${#filesystems_l[@]} ]]; then
+ filesystems=''
+ while pop filesystems_l val; do
+ filesystems+="$val "
+ done
+fi
+
+if [[ ${#fw_dir_l[@]} ]]; then
+ fw_dir=''
+ while pop fw_dir_l val; do
+ fw_dir+="$val "
+ done
+fi
+
[[ $drivers_dir_l ]] && drivers_dir=$drivers_dir_l
-[[ $fw_dir_l ]] && fw_dir=$fw_dir_l
[[ $do_strip_l ]] && do_strip=$do_strip_l
[[ $hostonly_l ]] && hostonly=$hostonly_l
[[ $use_fstab_l ]] && use_fstab=$use_fstab_l
exit 1
fi
-if [[ $include_src && $include_target ]]; then
- if [[ -f $include_src ]]; then
- inst $include_src $include_target
- else
- mkdir -p "$initdir$include_target"
- cp -a -t "$initdir$include_target" "$include_src"/*
+while pop include_src src && pop include_target tgt; do
+ if [[ $src && $tgt ]]; then
+ if [[ -f $src ]]; then
+ inst $src $tgt
+ else
+ mkdir -p "${initdir}/${tgt}"
+ cp -a -t "${initdir}/${tgt}" "$src"/*
+ fi
fi
-fi
+done
-for item in $install_items; do
- dracut_install "$item"
+while pop install_items items; do
+ for item in $items; do
+ dracut_install "$item"
+ done
done
unset item