|
Harald Hoyer |
0840a3 |
From 694725abf0d4956bb07b5f96b7887a75e0f430df Mon Sep 17 00:00:00 2001
|
|
Harald Hoyer |
0840a3 |
From: Harald Hoyer <harald@redhat.com>
|
|
Harald Hoyer |
0840a3 |
Date: Thu, 9 Jul 2015 14:33:24 +0200
|
|
Harald Hoyer |
0840a3 |
Subject: [PATCH] dracut.sh: remove pop()
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
---
|
|
Harald Hoyer |
0840a3 |
dracut.sh | 119 ++++++++++++++------------------------------------------------
|
|
Harald Hoyer |
0840a3 |
1 file changed, 27 insertions(+), 92 deletions(-)
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
diff --git a/dracut.sh b/dracut.sh
|
|
Harald Hoyer |
0840a3 |
index f7609fa..54358f3 100755
|
|
Harald Hoyer |
0840a3 |
--- a/dracut.sh
|
|
Harald Hoyer |
0840a3 |
+++ b/dracut.sh
|
|
Harald Hoyer |
0840a3 |
@@ -212,35 +212,10 @@ EOF
|
|
Harald Hoyer |
0840a3 |
# Fills up host_devs stack variable and makes sure there are no duplicates
|
|
Harald Hoyer |
0840a3 |
push_host_devs() {
|
|
Harald Hoyer |
0840a3 |
local _dev
|
|
Harald Hoyer |
0840a3 |
- [[ " ${host_devs[@]} " == *" $1 "* ]] && return
|
|
Harald Hoyer |
0840a3 |
- host_devs+=( "$1" )
|
|
Harald Hoyer |
0840a3 |
-}
|
|
Harald Hoyer |
0840a3 |
-
|
|
Harald Hoyer |
0840a3 |
-# function pop()
|
|
Harald Hoyer |
0840a3 |
-# pops the last value from a stack
|
|
Harald Hoyer |
0840a3 |
-# assigns value to second argument variable
|
|
Harald Hoyer |
0840a3 |
-# or echo to stdout, if no second argument
|
|
Harald Hoyer |
0840a3 |
-# $1 = stack variable
|
|
Harald Hoyer |
0840a3 |
-# $2 = optional variable to store the value
|
|
Harald Hoyer |
0840a3 |
-# example:
|
|
Harald Hoyer |
0840a3 |
-# pop stack val
|
|
Harald Hoyer |
0840a3 |
-# val=$(pop stack)
|
|
Harald Hoyer |
0840a3 |
-pop() {
|
|
Harald Hoyer |
0840a3 |
- local __stack=$1; shift
|
|
Harald Hoyer |
0840a3 |
- local __resultvar=$1
|
|
Harald Hoyer |
0840a3 |
- local _value;
|
|
Harald Hoyer |
0840a3 |
- # check for empty stack
|
|
Harald Hoyer |
0840a3 |
- eval '[[ ${#'${__stack}'[@]} -eq 0 ]] && return 1'
|
|
Harald Hoyer |
0840a3 |
-
|
|
Harald Hoyer |
0840a3 |
- eval _value='${'${__stack}'[${#'${__stack}'[@]}-1]}'
|
|
Harald Hoyer |
0840a3 |
-
|
|
Harald Hoyer |
0840a3 |
- if [[ "$__resultvar" ]]; then
|
|
Harald Hoyer |
0840a3 |
- eval $__resultvar="'$_value'"
|
|
Harald Hoyer |
0840a3 |
- else
|
|
Harald Hoyer |
0840a3 |
- printf "%s" "$_value"
|
|
Harald Hoyer |
0840a3 |
- fi
|
|
Harald Hoyer |
0840a3 |
- eval unset ${__stack}'[${#'${__stack}'[@]}-1]'
|
|
Harald Hoyer |
0840a3 |
- return 0
|
|
Harald Hoyer |
0840a3 |
+ for _dev in "$@"; do
|
|
Harald Hoyer |
0840a3 |
+ [[ " ${host_devs[@]} " == *" $_dev "* ]] && return
|
|
Harald Hoyer |
0840a3 |
+ host_devs+=( "$_dev" )
|
|
Harald Hoyer |
0840a3 |
+ done
|
|
Harald Hoyer |
0840a3 |
}
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
# Little helper function for reading args from the commandline.
|
|
Harald Hoyer |
0840a3 |
@@ -701,81 +676,52 @@ unset NPATH
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
# these optins add to the stuff in the config file
|
|
Harald Hoyer |
0840a3 |
if (( ${#add_dracutmodules_l[@]} )); then
|
|
Harald Hoyer |
0840a3 |
- while pop add_dracutmodules_l val; do
|
|
Harald Hoyer |
0840a3 |
- add_dracutmodules+=" $val "
|
|
Harald Hoyer |
0840a3 |
- done
|
|
Harald Hoyer |
0840a3 |
+ add_dracutmodules+=" ${add_dracutmodules_l[@]} "
|
|
Harald Hoyer |
0840a3 |
fi
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
if (( ${#force_add_dracutmodules_l[@]} )); then
|
|
Harald Hoyer |
0840a3 |
- while pop force_add_dracutmodules_l val; do
|
|
Harald Hoyer |
0840a3 |
- force_add_dracutmodules+=" $val "
|
|
Harald Hoyer |
0840a3 |
- done
|
|
Harald Hoyer |
0840a3 |
+ force_add_dracutmodules+=" ${force_add_dracutmodules_l[@]} "
|
|
Harald Hoyer |
0840a3 |
fi
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
if (( ${#fscks_l[@]} )); then
|
|
Harald Hoyer |
0840a3 |
- while pop fscks_l val; do
|
|
Harald Hoyer |
0840a3 |
- fscks+=" $val "
|
|
Harald Hoyer |
0840a3 |
- done
|
|
Harald Hoyer |
0840a3 |
+ fscks+=" ${fscks_l[@]} "
|
|
Harald Hoyer |
0840a3 |
fi
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
if (( ${#add_fstab_l[@]} )); then
|
|
Harald Hoyer |
0840a3 |
- while pop add_fstab_l val; do
|
|
Harald Hoyer |
0840a3 |
- add_fstab+=" $val "
|
|
Harald Hoyer |
0840a3 |
- done
|
|
Harald Hoyer |
0840a3 |
+ add_fstab+=" ${add_fstab_l[@]} "
|
|
Harald Hoyer |
0840a3 |
fi
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
if (( ${#fstab_lines_l[@]} )); then
|
|
Harald Hoyer |
0840a3 |
- while pop fstab_lines_l val; do
|
|
Harald Hoyer |
0840a3 |
- fstab_lines+=($val)
|
|
Harald Hoyer |
0840a3 |
- done
|
|
Harald Hoyer |
0840a3 |
+ fstab_lines+=( "${fstab_lines_l[@]}" )
|
|
Harald Hoyer |
0840a3 |
fi
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
if (( ${#install_items_l[@]} )); then
|
|
Harald Hoyer |
0840a3 |
- while pop install_items_l val; do
|
|
Harald Hoyer |
0840a3 |
- install_items+=" $val "
|
|
Harald Hoyer |
0840a3 |
- done
|
|
Harald Hoyer |
0840a3 |
+ install_items+=" ${install_items_l[@]} "
|
|
Harald Hoyer |
0840a3 |
fi
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
if (( ${#install_optional_items_l[@]} )); then
|
|
Harald Hoyer |
0840a3 |
- while pop install_optional_items_l val; do
|
|
Harald Hoyer |
0840a3 |
- install_optional_items+=" $val "
|
|
Harald Hoyer |
0840a3 |
- done
|
|
Harald Hoyer |
0840a3 |
+ install_optional_items+=" ${install_optional_items_l[@]} "
|
|
Harald Hoyer |
0840a3 |
fi
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
# these options override the stuff in the config file
|
|
Harald Hoyer |
0840a3 |
if (( ${#dracutmodules_l[@]} )); then
|
|
Harald Hoyer |
0840a3 |
- dracutmodules=''
|
|
Harald Hoyer |
0840a3 |
- while pop dracutmodules_l val; do
|
|
Harald Hoyer |
0840a3 |
- dracutmodules+="$val "
|
|
Harald Hoyer |
0840a3 |
- done
|
|
Harald Hoyer |
0840a3 |
+ dracutmodules="${dracutmodules_l[@]}"
|
|
Harald Hoyer |
0840a3 |
fi
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
if (( ${#omit_dracutmodules_l[@]} )); then
|
|
Harald Hoyer |
0840a3 |
- omit_dracutmodules=''
|
|
Harald Hoyer |
0840a3 |
- while pop omit_dracutmodules_l val; do
|
|
Harald Hoyer |
0840a3 |
- omit_dracutmodules+="$val "
|
|
Harald Hoyer |
0840a3 |
- done
|
|
Harald Hoyer |
0840a3 |
+ omit_dracutmodules="${omit_dracutmodules_l[@]}"
|
|
Harald Hoyer |
0840a3 |
fi
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
if (( ${#filesystems_l[@]} )); then
|
|
Harald Hoyer |
0840a3 |
- filesystems=''
|
|
Harald Hoyer |
0840a3 |
- while pop filesystems_l val; do
|
|
Harald Hoyer |
0840a3 |
- filesystems+="$val "
|
|
Harald Hoyer |
0840a3 |
- done
|
|
Harald Hoyer |
0840a3 |
+ filesystems="${filesystems_l[@]}"
|
|
Harald Hoyer |
0840a3 |
fi
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
if (( ${#fw_dir_l[@]} )); then
|
|
Harald Hoyer |
0840a3 |
- fw_dir=''
|
|
Harald Hoyer |
0840a3 |
- while pop fw_dir_l val; do
|
|
Harald Hoyer |
0840a3 |
- fw_dir+="$val "
|
|
Harald Hoyer |
0840a3 |
- done
|
|
Harald Hoyer |
0840a3 |
+ fw_dir="${fw_dir_l[@]}"
|
|
Harald Hoyer |
0840a3 |
fi
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
if (( ${#libdirs_l[@]} )); then
|
|
Harald Hoyer |
0840a3 |
- libdirs=''
|
|
Harald Hoyer |
0840a3 |
- while pop libdirs_l val; do
|
|
Harald Hoyer |
0840a3 |
- libdirs+="$val "
|
|
Harald Hoyer |
0840a3 |
- done
|
|
Harald Hoyer |
0840a3 |
+ libdirs="${libdirs_l[@]}"
|
|
Harald Hoyer |
0840a3 |
fi
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
[[ $stdloglvl_l ]] && stdloglvl=$stdloglvl_l
|
|
Harald Hoyer |
0840a3 |
@@ -925,38 +871,27 @@ dracutfunctions=$dracutbasedir/dracut-functions.sh
|
|
Harald Hoyer |
0840a3 |
export dracutfunctions
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
if (( ${#drivers_l[@]} )); then
|
|
Harald Hoyer |
0840a3 |
- drivers=''
|
|
Harald Hoyer |
0840a3 |
- while pop drivers_l val; do
|
|
Harald Hoyer |
0840a3 |
- drivers+="$val "
|
|
Harald Hoyer |
0840a3 |
- done
|
|
Harald Hoyer |
0840a3 |
+ drivers="${drivers_l[@]}"
|
|
Harald Hoyer |
0840a3 |
fi
|
|
Harald Hoyer |
0840a3 |
drivers=${drivers/-/_}
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
if (( ${#add_drivers_l[@]} )); then
|
|
Harald Hoyer |
0840a3 |
- while pop add_drivers_l val; do
|
|
Harald Hoyer |
0840a3 |
- add_drivers+=" $val "
|
|
Harald Hoyer |
0840a3 |
- done
|
|
Harald Hoyer |
0840a3 |
+ add_drivers+=" ${add_drivers_l[@]} "
|
|
Harald Hoyer |
0840a3 |
fi
|
|
Harald Hoyer |
0840a3 |
add_drivers=${add_drivers/-/_}
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
if (( ${#force_drivers_l[@]} )); then
|
|
Harald Hoyer |
0840a3 |
- while pop force_drivers_l val; do
|
|
Harald Hoyer |
0840a3 |
- force_drivers+=" $val "
|
|
Harald Hoyer |
0840a3 |
- done
|
|
Harald Hoyer |
0840a3 |
+ force_drivers+=" ${force_drivers_l[@]} "
|
|
Harald Hoyer |
0840a3 |
fi
|
|
Harald Hoyer |
0840a3 |
force_drivers=${force_drivers/-/_}
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
if (( ${#omit_drivers_l[@]} )); then
|
|
Harald Hoyer |
0840a3 |
- while pop omit_drivers_l val; do
|
|
Harald Hoyer |
0840a3 |
- omit_drivers+=" $val "
|
|
Harald Hoyer |
0840a3 |
- done
|
|
Harald Hoyer |
0840a3 |
+ omit_drivers+=" ${omit_drivers_l[@]} "
|
|
Harald Hoyer |
0840a3 |
fi
|
|
Harald Hoyer |
0840a3 |
omit_drivers=${omit_drivers/-/_}
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
if (( ${#kernel_cmdline_l[@]} )); then
|
|
Harald Hoyer |
0840a3 |
- while pop kernel_cmdline_l val; do
|
|
Harald Hoyer |
0840a3 |
- kernel_cmdline+=" $val "
|
|
Harald Hoyer |
0840a3 |
- done
|
|
Harald Hoyer |
0840a3 |
+ kernel_cmdline+=" ${kernel_cmdline_l[@]} "
|
|
Harald Hoyer |
0840a3 |
fi
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
omit_drivers_corrected=""
|
|
Harald Hoyer |
0840a3 |
@@ -1147,10 +1082,8 @@ for dev in $add_device; do
|
|
Harald Hoyer |
0840a3 |
done
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
if (( ${#add_device_l[@]} )); then
|
|
Harald Hoyer |
0840a3 |
- while pop add_device_l val; do
|
|
Harald Hoyer |
0840a3 |
- add_device+=" $val "
|
|
Harald Hoyer |
0840a3 |
- push_host_devs "$val"
|
|
Harald Hoyer |
0840a3 |
- done
|
|
Harald Hoyer |
0840a3 |
+ add_device+=" ${add_device_l[@]} "
|
|
Harald Hoyer |
0840a3 |
+ push_host_devs "${add_device_l[@]}"
|
|
Harald Hoyer |
0840a3 |
fi
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
if [[ $hostonly ]]; then
|
|
Harald Hoyer |
0840a3 |
@@ -1527,7 +1460,7 @@ if [[ $kernel_only != yes ]]; then
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
[[ $kernel_cmdline ]] && printf "%s\n" "$kernel_cmdline" >> "${initdir}/etc/cmdline.d/01-default.conf"
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
- while pop fstab_lines line; do
|
|
Harald Hoyer |
0840a3 |
+ for line in "${fstab_lines[@]}"; do
|
|
Harald Hoyer |
0840a3 |
line=($line)
|
|
Harald Hoyer |
0840a3 |
[ -z "${line[3]}" ] && line[3]="defaults"
|
|
Harald Hoyer |
0840a3 |
[ -z "${line[4]}" ] && line[4]="0"
|
|
Harald Hoyer |
0840a3 |
@@ -1566,7 +1499,9 @@ if [[ $kernel_only != yes ]]; then
|
|
Harald Hoyer |
0840a3 |
done
|
|
Harald Hoyer |
0840a3 |
fi
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
-while pop include_src src && pop include_target target; do
|
|
Harald Hoyer |
0840a3 |
+for ((i=0; i < ${#include_src[@]}; i++)); do
|
|
Harald Hoyer |
0840a3 |
+ src="${include_src[$i]}"
|
|
Harald Hoyer |
0840a3 |
+ target="${include_target[$i]}"
|
|
Harald Hoyer |
0840a3 |
if [[ $src && $target ]]; then
|
|
Harald Hoyer |
0840a3 |
if [[ -f $src ]]; then
|
|
Harald Hoyer |
0840a3 |
inst $src $target
|