summaryrefslogtreecommitdiff
path: root/hook-functions
diff options
context:
space:
mode:
authorMichael Prokop <mika@grml.org>2010-06-15 18:16:37 +0200
committerMichael Prokop <mika@grml.org>2010-06-15 18:16:37 +0200
commit5697c3b7e4ece610e71117f1dddb2cc8637f8420 (patch)
treed0165fd6a129740dbd77744c224c55888a959665 /hook-functions
parent3a02c6f37d4c331b347692a0200941c4c59b3ea3 (diff)
downloadinitramfs-tools-5697c3b7e4ece610e71117f1dddb2cc8637f8420.tar.gz
initramfs-tools-5697c3b7e4ece610e71117f1dddb2cc8637f8420.zip
hook-functions: replace awk calls with sed in dep_add_modules()
If mawk is installed as default awk version it won't handle [:digit:], instead let's replace the grep/awk/shell version with one single sed invocation. Closes: #585991 Thanks: Thorsten Glaser <tg@mirbsd.de> Signed-off-by: Michael Prokop <mika@grml.org>
Diffstat (limited to 'hook-functions')
-rw-r--r--hook-functions21
1 files changed, 3 insertions, 18 deletions
diff --git a/hook-functions b/hook-functions
index ffb6a67..1a0e097 100644
--- a/hook-functions
+++ b/hook-functions
@@ -273,9 +273,7 @@ dep_add_modules()
done
# lvm on md or luks on md
if [ "${block#md}" != "${block}" ]; then
- block=$(grep "^${block}" /proc/mdstat | \
- awk "{gsub(/^${block} : .* (multipath|linear|raid[[:digit:]]+)\ /,\"\")};1")
- block="${block%%\[*}"
+ block=$(sed -ne 's/multipath/[/' -e 's/linear/[/' -e 's/raid[0-9][0-9]*/[/' -e 's/\([hs]d[a-z][a-z]*\)[0-9][0-9]*/\1/g' -e '/^'${block}' :/s/^[^[]*\[ \([^\[]*\)\[.*$/\1/p' </proc/mdstat)
fi
# luks or lvm on cciss or ida
if [ "${block#cciss}" != "${block}" ] \
@@ -287,28 +285,15 @@ dep_add_modules()
# md root new naming scheme /dev/md/X
elif [ "${root#/dev/md/}" != "${root}" ]; then
root=${root#/dev/md/}
- block=$(grep "^md${root}" /proc/mdstat | \
- awk "{gsub(/^md${root} : .* (multipath|linear|raid[[:digit:]]+)\ /,\"\")};1")
- block="${block%%\[*}"
# drop the partition number only for sdX and hdX devices
# and keep it for other devices like loop#, dm-# devices
- case "$block" in
- sd*) block=${block%%[0-9]*};;
- hd*) block=${block%%[0-9]*};;
- esac
+ block=$(sed -ne 's/multipath/[/' -e 's/linear/[/' -e 's/raid[0-9][0-9]*/[/' -e 's/\([hs]d[a-z][a-z]*\)[0-9][0-9]*/\1/g' -e '/^md'$root' :/s/^[^[]*\[ \([^\[]*\)\[.*$/\1/p' </proc/mdstat)
# md root /dev/mdX
elif [ "${root#/dev/md}" != "${root}" ]; then
root=${root#/dev/md}
- block=$(grep "^md${root}" /proc/mdstat | \
- awk "{gsub(/^md${root} : .* (multipath|linear|raid[[:digit:]]+)\ /,\"\")};1")
- block="${block%%\[*}"
# drop the partition number only for sdX and hdX devices
# and keep it for other devices like loop#, dm-# devices
- case "$block" in
- sd*) block=${block%%[0-9]*};;
- hd*) block=${block%%[0-9]*};;
- esac
-
+ block=$(sed -ne 's/multipath/[/' -e 's/linear/[/' -e 's/raid[0-9][0-9]*/[/' -e 's/\([hs]d[a-z][a-z]*\)[0-9][0-9]*/\1/g' -e '/^md'$root' :/s/^[^[]*\[ \([^\[]*\)\[.*$/\1/p' </proc/mdstat)
# cciss device
elif [ "${root#/dev/cciss/}" != "${root}" ]; then
block=${root#/dev/cciss/*}