SVN: geninitrd/trunk/geninitrd
glen
glen at pld-linux.org
Thu Oct 25 09:46:11 CEST 2007
Author: glen
Date: Thu Oct 25 09:46:11 2007
New Revision: 8867
Modified:
geninitrd/trunk/geninitrd
Log:
- optimize, cosmetics
Modified: geninitrd/trunk/geninitrd
==============================================================================
--- geninitrd/trunk/geninitrd (original)
+++ geninitrd/trunk/geninitrd Thu Oct 25 09:46:11 2007
@@ -7,7 +7,7 @@
# based on mkinitrd from RedHat Linux
#
# TODO:
-# - make udev start before insomds
+# - make udev start before insmods
# - make proper use of USE_UDEV - don't copy fules if USE_UDEV is off no!
# - sanitize - one mounting of /proc and /sys at the begining and one umount at the end!
#
@@ -19,14 +19,12 @@
. /etc/rc.d/init.d/functions
. /etc/geninitrd/functions
-COMPRESS="yes"
-# INITRDFS is set later (catch obsoleted FS option)
-#INITRDFS="rom"
-USERAIDSTART="yes"
-USEMDADMSTATIC="no"
-USEINSMODSTATIC="no"
-USE_SUSPEND="yes"
-USE_TUXONICE="yes"
+COMPRESS=yes
+USERAIDSTART=yes
+USEMDADMSTATIC=no
+USEINSMODSTATIC=no
+USE_SUSPEND=yes
+USE_TUXONICE=yes
# it should be safe to remove scsi_mod from here, but I'm not sure...
PRESCSIMODS="-scsi_mod unknown -sd_mod"
PREIDEMODS="-ide-core unknown -ide-detect -ide-disk"
@@ -37,10 +35,9 @@
verbose=""
MODULES=""
img_vers=""
-modulefile=""
-fstab="/etc/fstab"
-insmod="insmod"
-modext=".o"
+fstab=/etc/fstab
+insmod=insmod
+modext=.o
rootdev_nr=0
# device node for rootfs from fstab
rootdev=""
@@ -73,16 +70,16 @@
have_multipath=no
if [ -f /etc/udev/udev.conf -a -x /sbin/initrd-udevd ]; then
- USE_UDEV="yes"
+ USE_UDEV=yes
. /etc/udev/udev.conf
fi
if [ -x /sbin/dmraid-initrd ]; then
- USE_DMRAID="yes"
+ USE_DMRAID=yes
fi
if [ -x /sbin/multipath ]; then
- USE_MULTIPATH="yes"
+ USE_MULTIPATH=yes
fi
usage () {
@@ -225,8 +222,8 @@
}
addmodule() {
- fmPath=$1
- skiperrors=$2
+ local fmPath=$1
+ local skiperrors=$2
if [ ! -f "/lib/modules/$kernel/$fmPath" ]; then
if [ -n "$skiperrors" ]; then
@@ -238,15 +235,15 @@
# only need to add each module once
# quote /
- tmpFmPath=$(echo $fmPath | awk '{gsub(/\//,"\\/");print}')
+ local tmpFmPath=$(echo $fmPath | awk '{gsub(/\//,"\\/");print}')
if echo "$MODULES" | awk '/'"$tmpFmPath"'/ {exit 1}' ; then
MODULES="$MODULES $fmPath"
fi
}
findmodule() {
- skiperrors=""
- modName=$1
+ local skiperrors=""
+ local modName=$1
if [ ${modName#-} != ${modName} ]; then
skiperrors=1
@@ -263,6 +260,7 @@
findmodule socal
fi
+ local mod allModulesToFind
if [ -n "$skiperrors" ]; then
allModulesToFind=$(find_depmod silent $modName)
else
@@ -371,6 +369,7 @@
}
find_modules_scsi() {
+ local n
for n in $PRESCSIMODS; do
if [ "X$n" = "Xunknown" ]; then
if [ -f "$modulefile" ]; then
@@ -389,18 +388,20 @@
}
find_modules_ide() {
- local rootblkdev
-
+ local devpath=$1
+ # remove partition, if any
+ local disk=${devpath%[0-9]*}
# set blockdev for rootfs (hda, sdc, ...)
- rootblkdev="$(echo "$1" | awk ' { gsub(/\/dev\//,NUL); gsub(/[0-9].*/, NUL); print $0 } ')"
+ local rootblkdev=${disk#/dev/}
+ local n
if [ "$pack_version_long" -lt "002004021" ]; then
debug "Finding IDE modules for kernels <= 2.4.20"
for n in $PREIDEMODSOLD; do
findmodule "$n"
done
else
- tryauto=1
+ local tryauto=1
for n in $PREIDEMODS; do
if [ "X$n" = "Xunknown" ]; then
if [ -f "$modulefile" ]; then
@@ -642,7 +643,7 @@
return
fi
- if is_yes "`echo "$devpath" | awk '/^\/dev\/(hd|ide)/ { print "yes"; }'`" ; then
+ if is_yes "$(echo "$devpath" | awk '/^\/dev\/(hd|ide)/ { print "yes"; }')" ; then
find_modules_ide "$devpath"
return
fi
@@ -737,9 +738,9 @@
}
firmware_install_module_pre() {
- module="$1"
- linuxrc="$2"
- firmware_files="$3"
+ local module="$1"
+ local linuxrc="$2"
+ local firmware_files="$3"
debug "Adding Firmwares ($firmware_files) to initrd for module $module"
inst_d /proc
@@ -767,15 +768,16 @@
}
firmware_install_module_post() {
- module="$1"
- linuxrc="$2"
- firmware_files="$3"
+ local module="$1"
+ local linuxrc="$2"
+ local firmware_files="$3"
echo "umount /sys" >> "$linuxrc"
echo "umount /proc" >> "$linuxrc"
}
modules_install() {
- modules="$1"
+ local modules="$1"
+ local mod
for mod in $modules; do
MODULEDIR=$(dirname "$mod")
@@ -786,8 +788,9 @@
}
modules_add_linuxrc() {
- modules="$1"
- linuxrc="$2"
+ local modules="$1"
+ local linuxrc="$2"
+ local mod
for mod in $modules; do
MODULE2="`dirname "$mod"`"
@@ -852,76 +855,76 @@
while [ $# -gt 0 ]; do
case $1 in
--fstab=*)
- fstab="`echo $1 | awk -F= '{print $2;}'`"
+ fstab=${1#--fstab=}
;;
--fstab)
- fstab="$2"
+ fstab=$2
shift
;;
--modules-conf=*)
- modulefile="`echo $1 | awk -F= '{print $2;}'`"
+ modulefile=${1#--modules-conf=}
;;
--modules-conf)
- modulefile="$2"
+ modulefile=$2
shift
;;
--use-raidstart|--with-raidstart)
- USERAIDSTART="yes"
+ USERAIDSTART=yes
;;
--without-raidstart)
- USERAIDSTART="no"
+ USERAIDSTART=no
;;
--use-insmod-static|--with-insmod-static)
- USEINSMODSTATIC="yes"
+ USEINSMODSTATIC=yes
;;
--without-insmod-static)
- USEINSMODSTATIC="no"
+ USEINSMODSTATIC=no
;;
--with-bootsplash)
- BOOT_SPLASH="yes"
+ BOOT_SPLASH=yes
;;
--without-bootsplash)
- BOOT_SPLASH="no"
+ BOOT_SPLASH=no
;;
--with-fbsplash)
- FB_SPLASH="yes"
+ FB_SPLASH=yes
;;
--without-fbsplash)
- FB_SPLASH="no"
+ FB_SPLASH=no
;;
--with-suspend)
- USE_SUSPEND="yes"
+ USE_SUSPEND=yes
;;
--without-suspend)
- USE_SUSPEND="no"
+ USE_SUSPEND=no
;;
--with-suspend2 | --with-tuxonice)
- USE_TUXONICE="yes"
+ USE_TUXONICE=yes
;;
--without-suspend2 | --without-tuxonice)
- USE_TUXONICE="no"
+ USE_TUXONICE=no
;;
--lvmtoolsversion=|--lvmversion=)
LVMTOOLSVERSION="`echo $1 | awk -F= '{print $2;}'`"
;;
--lvmtoolsversion|--lvmversion)
- LVMTOOLSVERSION="$2"
+ LVMTOOLSVERSION=$2
shift
;;
--without-udev)
- USE_UDEV=
+ USE_UDEV=no
;;
--with-udev)
- USE_UDEV="yes"
+ USE_UDEV=yes
;;
--without-dmraid)
- USE_DMRAID=
+ USE_DMRAID=no
;;
--without-multipath)
- USE_MULTPATH=
+ USE_MULTPATH=no
;;
--with=*)
- BASICMODULES="$BASICMODULES `echo $1 | awk -F= '{print $2;}'`"
+ BASICMODULES="$BASICMODULES ${1#--with=}"
;;
--with)
BASICMODULES="$BASICMODULES $2"
@@ -935,7 +938,7 @@
verbose=-v
;;
--nocompress)
- COMPRESS="no"
+ COMPRESS=no
;;
--ifneeded)
ifneeded=1
@@ -944,7 +947,7 @@
force=1
;;
--preload=*)
- PREMODS="$PREMODS `echo $1 | awk -F= '{print $2;}'`"
+ PREMODS="$PREMODS ${1#--preload=}"
;;
--preload)
PREMODS="$PREMODS $2"
@@ -952,18 +955,18 @@
;;
--fs=*)
echo >&2 "Warning: --fs option is obsoleted. Use --initrdfs instead"
- INITRDFS="`echo $1 | awk -F= '{print $2;}'`"
+ INITRDFS=${1#--fs=}
;;
--fs)
echo >&2 "Warning: --fs option is obsoleted. Use --initrdfs instead"
- INITRDFS="$2"
+ INITRDFS=$2
shift
;;
--initrdfs=*)
- INITRDFS="`echo $1 | awk -F= '{print $2;}'`"
+ INITRDFS=${1#--initrdfs=}
;;
--initrdfs)
- INITRDFS="$2"
+ INITRDFS=$2
shift
;;
--image-version)
@@ -1008,8 +1011,8 @@
fi
if [ "$pack_version" -lt "002006" ]; then
- USE_UDEV=
- USE_DMRAID=
+ USE_UDEV=no
+ USE_DMRAID=no
fi
if [ "$pack_version" -ge "002005" ]; then
More information about the pld-cvs-commit
mailing list