SVN: geninitrd/trunk/geninitrd
glen
glen at pld-linux.org
Fri Oct 20 18:16:14 CEST 2006
Author: glen
Date: Fri Oct 20 18:16:12 2006
New Revision: 7884
Modified:
geninitrd/trunk/geninitrd
Log:
Cosmetics.
Modified: geninitrd/trunk/geninitrd
==============================================================================
--- geninitrd/trunk/geninitrd (original)
+++ geninitrd/trunk/geninitrd Fri Oct 20 18:16:12 2006
@@ -66,6 +66,9 @@
exit 1
}
+debug() {
+ [ -n "$verbose" ] && "$*"
+}
find_depmod () {
typeset mods module f level depfile first
@@ -75,7 +78,7 @@
if [ -f $depfile ] ; then
: ok
else
- echo "Error: no $depfile ! Run depmod and rerun geninitrd." 1>&2
+ echo >&2 "Error: no $depfile ! Run depmod and rerun geninitrd."
exit 1
fi
@@ -107,12 +110,12 @@
if [ "$mods" = "" ] ; then
if [ "$1" != silent ] ; then
- echo "$origmodule: module not found in $depfile" 1>&2
+ echo >&2 "$origmodule: module not found in $depfile"
fi
if ! is_no "$EXIT_IF_MISSING" ; then
exit 1
else
- echo "If $origmodule isn't compiled in kernel then this initrd may not start your system". 1>&2
+ echo >&2 "If $origmodule isn't compiled in kernel then this initrd may not start your system."
fi
fi
@@ -120,9 +123,9 @@
if [ "$level" = "" ] ; then
level=0
fi
- level=$(awk "BEGIN{print $level + 1}")
+ level=$((level + 1))
if [ $level -gt 20 ] ; then
- echo "$origmodule: cycle in $depfile" 1>&2
+ echo >&2 "$origmodule: cycle in $depfile"
exit 1
fi
@@ -147,7 +150,7 @@
return
fi
- echo "module $fmPath present in modules.dep, but not in filesystem (kernel = $kernel)" 1>&2
+ echo >&2 "module $fmPath present in modules.dep, but not in filesystem (kernel = $kernel)"
exit 1
fi
@@ -163,9 +166,9 @@
skiperrors=""
modName=$1
- if [ "$(echo $modName | awk '{print(substr($0,1,1));}')" = "-" ]; then
+ if [ ${modName#-} != ${modName} ]; then
skiperrors=1
- modName="$(echo $modName | awk '{print(substr($0,2));}')"
+ modName=${modName#-}
fi
# what's that?
@@ -179,16 +182,16 @@
fi
if [ -n "$skiperrors" ]; then
- allModulesToFind=`find_depmod silent $modName`
+ allModulesToFind=$(find_depmod silent $modName)
else
- allModulesToFind=`find_depmod normal $modName`
- if [ $? != 0 ] ; then
+ allModulesToFind=$(find_depmod normal $modName)
+ if [ $? != 0 ]; then
exit 1
fi
fi
- for mod in $allModulesToFind ; do
- mod=$(echo $mod | awk '{sub(/^\/lib\/modules\/[^\/]*\//,"");print}')
+ for mod in $allModulesToFind; do
+ mod=$(echo $mod | awk '{sub(/^\/lib\/modules\/[^\/]*\//, ""); print}')
addmodule $mod "$skiperrors"
done
}
@@ -198,7 +201,7 @@
echo "usage: inst <file> <destination>"
return
fi
- [ -n "$verbose" ] && echo "$1 -> $2"
+ debug "$1 -> $2"
cp "$1" "$2"
}
@@ -234,40 +237,38 @@
case $rootFs in
ext2|ext3)
if [ ! -x /sbin/e2label ] ; then
- echo "/sbin/e2label is missing" 1>&2
+ echo >&2 "/sbin/e2label is missing"
exit 1
fi
get_label="get_label_ext2"
;;
xfs)
if [ ! -x /usr/sbin/xfs_db ] ; then
- echo "/usr/sbin/xfs_db is missing" 1>&2
+ echo >&2 "/usr/sbin/xfs_db is missing"
exit 1
fi
get_label="get_label_xfs"
;;
*)
- echo "LABEL on $rootFs in not supported by geninitrd" 1>&2
+ echo >&2 "LABEL on $rootFs in not supported by geninitrd"
exit 1
;;
esac
if [ ! -r /proc/partitions ] ; then
- echo '/proc/partitions is not readable'; 1>&2
+ echo >&2 '/proc/partitions is not readable'
exit 1
fi
label=${rootdev#"LABEL="}
for dev in `awk 'BEGIN {getline;getline} {print "/dev/" $4}' /proc/partitions` ; do
if [ -r $dev ] && [ "$label" = "`$get_label $dev`" ] ; then
- if [ -n "$verbose" ] ; then
- echo "Using $dev as device for rootfs"
- fi
+ debug "Using $dev as device for rootfs"
rootdev=$dev
rootdev_found=1
break
fi
done
if [ "$rootdev_found." != "1." ] ; then
- echo "geninitrd can't find real device for LABEL=$label" 1>&2
+ echo >&2 "geninitrd can't find real device for LABEL=$label"
exit 1
fi
fi
@@ -284,40 +285,38 @@
case $rootFs in
ext2|ext3)
if [ ! -x /sbin/tune2fs ] ; then
- echo "/sbin/tune2fs is missing" 1>&2
+ echo >&2 "/sbin/tune2fs is missing"
exit 1
fi
get_uuid="get_uuid_ext2"
;;
xfs)
if [ ! -x /usr/sbin/xfs_admin ] ; then
- echo "/usr/sbin/xfs_admin is missing" 1>&2
+ echo >&2 "/usr/sbin/xfs_admin is missing"
exit 1
fi
get_uuid="get_uuid_xfs"
;;
*)
- echo "UUID on $rootFs in not supported by geninitrd" 1>&2
+ echo >&2 "UUID on $rootFs in not supported by geninitrd"
exit 1
;;
esac
if [ ! -r /proc/partitions ] ; then
- echo '/proc/partitions is not readable'; 1>&2
+ echo >&2 '/proc/partitions is not readable'
exit 1
fi
uuid=${rootdev#"UUID="}
for dev in $(awk 'BEGIN {getline;getline} {print "/dev/" $4}' /proc/partitions); do
if [ -r $dev ] && [ "$uuid" = "`$get_uuid $dev`" ] ; then
- if [ -n "$verbose" ] ; then
- echo "Using $dev as device for rootfs"
- fi
+ debug "Using $dev as device for rootfs"
rootdev=$dev
rootdev_found=1
break
fi
done
if [ "$rootdev_found" != 1 ] ; then
- echo "geninitrd can't find real device for UUID=$uuid" 1>&2
+ echo >&2 "geninitrd can't find real device for UUID=$uuid"
exit 1
fi
fi
@@ -328,7 +327,7 @@
find_modules_softraid() {
if [ -f /etc/mdadm.conf ]; then
- [ -n "$verbose" ] && echo "Finding RAID details using mdadm for rootdev=$1"
+ debug "Finding RAID details using mdadm for rootdev=$1"
eval `/sbin/mdadm -v --examine --scan --config=/etc/mdadm.conf | awk -v rootdev="$1" '
BEGIN {
found = "no";
@@ -365,7 +364,7 @@
fi
if [ "$raidfound" != "yes" -a -f /etc/raidtab ]; then
- echo "ERROR: raidtools are not longer supported. Please migrate to mdadm setup!" 1>&2
+ echo >&2 "ERROR: raidtools are not longer supported. Please migrate to mdadm setup!"
exit 1
fi
@@ -378,11 +377,11 @@
findmodule "linear"
;;
*)
- echo "raid level $number (in mdadm config) not recognized" 1>&2
+ echo >&2 "raid level $number (in mdadm config) not recognized"
;;
esac
else
- echo "ERROR: RAID devices not found for \"$1\", check your configuration!" 1>&2
+ echo >&2 "ERROR: RAID devices not found for \"$1\", check your configuration!"
exit 1
fi
@@ -417,7 +416,7 @@
rootdev="$(echo "$1" | awk ' { gsub(/\/dev\//,NUL); gsub(/[0-9].*/, NUL); print $0 } ')"
if [ "$pack_version_long" -lt "002004021" ]; then
- [ -n "$verbose" ] && echo "Finding IDE modules for kernels <= 2.4.20"
+ debug "Finding IDE modules for kernels <= 2.4.20"
for n in $PREIDEMODSOLD; do
findmodule "$n"
done
@@ -426,7 +425,7 @@
for n in $PREIDEMODS; do
if [ "X$n" = "Xunknown" ] ; then
if [ -f "$modulefile" ]; then
- [ -n "$verbose" ] && echo "Finding IDE modules using ide_hostadapter"
+ debug "Finding IDE modules using ide_hostadapter"
idemodules="`awk '/ide_hostadapter/ && ! /^[\t ]*#/ { print $3; }' $modulefile`"
for na in $idemodules; do
tryauto=0;
@@ -437,7 +436,7 @@
if [ "$tryauto" -eq 1 ]; then
# If tryauto {{{
if [ -r /usr/share/pci-database/ide.pci -a -r /proc/bus/pci/devices ]; then
- [ -n "$verbose" ] && echo "Finding IDE modules using PCI ID database"
+ debug "Finding IDE modules using PCI ID database"
# Finding IDE modules using PCI ID database {{{
if is_yes "${ide_only_root}"; then
if [ -f /sys/block/${rootdev}/device/../../vendor -a -f /sys/block/${rootdev}/device/../../device ]; then
@@ -539,7 +538,7 @@
_check_lvm() {
local node="$1"
if [ ! -e "$node" ]; then
- echo "WARNING: check_lvm(): node $node doesn't exists!" 1>&2
+ echo >&2 "WARNING: check_lvm(): node $node doesn't exist!"
return 1
fi
@@ -548,7 +547,7 @@
rc=$?
if [ $rc = 0 ]; then
- [ -n "$verbose" ] && echo "$node is LVM1 node"
+ debug "$node is LVM1 node"
# is lvm1
return 0
fi
@@ -563,9 +562,9 @@
fi
if [ $rc = 0 ]; then
- [ -n "$verbose" ] && echo "$node is lvm2 node"
+ debug "$node is lvm2 node"
else
- [ -n "$verbose" ] && echo "$node is not any lvm node"
+ debug "$node is not any lvm node"
fi
return $rc
}
@@ -618,7 +617,7 @@
done
# check to see if we need to set up a loopback filesystem
elif is_yes "`echo "$1" | awk -F/ '{print($3);}' | awk '/loop/ { print "yes"; }'`" ; then
- echo "Sorry, root on loop device isn't supported." 1>&2
+ echo >&2 "Sorry, root on loop device isn't supported."
exit 1
# TODO: rewrite for bsp and make nfs ready
if [ ! -x /sbin/losetup ]; then
@@ -627,8 +626,8 @@
fi
key="^# $(echo $1 | awk -F/ '{print($3);}' | tr '[a-z]' '[A-Z]'):"
if ! is_yes "`awk '/'$key'/ { print( "yes"); }' $fstab`" ; then
- echo "The root filesystem is on a $1, but there is no magic entry in $fstab" 1>&2
- echo "for this device. Consult the geninitrd man page for more information" 1>&2
+ echo >&2 "The root filesystem is on a $1, but there is no magic entry in $fstab"
+ echo >&2 "for this device. Consult the geninitrd man page for more information"
exit 1
fi
@@ -678,7 +677,7 @@
echo "ERROR: LVM version $LVMTOOLSVERSION is not supported yet." >&2
exit 1
fi
- [ -n "$verbose" ] && echo "LVM $LVMTOOLSVERSION enabled"
+ debug "LVM $LVMTOOLSVERSION enabled"
uselvm="yes"
fi
}
@@ -688,7 +687,7 @@
linuxrc="$2"
firmware_files="$3"
- [ -n "$verbose" ] && echo "Adding Firmwares ($firmware_files) to initrd for module $module"
+ debug "Adding Firmwares ($firmware_files) to initrd for module $module"
mkdir -p $MNTIMAGE/proc
mkdir -p $MNTIMAGE/sys
# firmware not yet installed
@@ -701,7 +700,7 @@
echo 0 > /sys$DEVPATH/loading
exit 0
EOF
- chmod 755 "$MNTIMAGE/lib/firmware/firmware.sh"
+ chmod 755 "$MNTIMAGE/lib/firmware/firmware.sh"
fi
for firmware in $firmware_files; do
@@ -745,7 +744,7 @@
generic_module=$(echo "${module}" | awk ' { gsub("-", "_", $0) } { print $0; } ')
sleep_var="$(eval echo \$MODULE_${generic_module}_USLEEP)"
- firmware_var="$(eval echo \$MODULE_${generic_module}_FIRMWARE)"
+ firmware_var="$(eval echo \$MODULE_${generic_module}_FIRMWARE)"
if [ -n "$verbose" ]; then
echo -n "Loading module [$module] "
@@ -871,11 +870,11 @@
shift
;;
--fs=*)
- echo "Warning: --fs option is obsoleted. Use --initrdfs instead" 1>&2
+ echo >&2 "Warning: --fs option is obsoleted. Use --initrdfs instead"
INITRDFS="`echo $1 | awk -F= '{print $2;}'`"
;;
--fs)
- echo "Warning: --fs option is obsoleted. Use --initrdfs instead" 1>&2
+ echo >&2 "Warning: --fs option is obsoleted. Use --initrdfs instead"
INITRDFS="$2"
shift
;;
@@ -923,7 +922,7 @@
INITRDFS="rom"
fi
else
- echo "Warning: FS configuration options is obsoleted. Use INITRDFS instead" 1>&2
+ echo >&2 "Warning: FS configuration options is obsoleted. Use INITRDFS instead"
INITRDFS="$FS"
fi
fi
@@ -953,34 +952,34 @@
case "$INITRDFS" in
ext2)
if [ ! -x /sbin/mke2fs ]; then
- echo "/sbin/mke2fs is missing" 1>&2
+ echo >&2 "/sbin/mke2fs is missing"
exit 1
fi
;;
rom)
if [ ! -x /sbin/genromfs ]; then
- echo "/sbin/genromfs is missing" 1>&2
+ echo >&2 "/sbin/genromfs is missing"
exit 1
fi
;;
cram)
if [ ! -x /sbin/mkcramfs ]; then
- echo "/sbin/mkcramfs is missing" 1>&2
+ echo >&2 "/sbin/mkcramfs is missing"
exit 1
fi
;;
initramfs)
if [ ! -x /bin/cpio ]; then
- echo "/bin/cpio is missing" 1>&2
+ echo >&2 "/bin/cpio is missing"
exit 1
fi
if [ ! -x /usr/bin/find ]; then
- echo "/usr/bin/find is missing" 1>&2
+ echo >&2 "/usr/bin/find is missing"
exit 1
fi
;;
*)
- echo "Filesystem $INITRDFS on initrd is not supported" 1>&2
+ echo >&2 "Filesystem $INITRDFS on initrd is not supported"
exit 1
;;
esac
@@ -990,24 +989,24 @@
fi
if [ -z "$force" -a -f "$target" ]; then
- echo "$target already exists." 1>&2
+ echo >&2 "$target already exists."
exit 1
fi
if [ ! -d "/lib/modules/$kernel" ]; then
- echo "/lib/modules/$kernel is not a directory." 1>&2
+ echo >&2 "/lib/modules/$kernel is not a directory."
exit 1
fi
if is_yes "$USE_SUSPEND"; then
if is_yes "$USE_SUSPEND2"; then
- echo "Suspend2 shouldn't be used in parallel with mainline suspend!." 1>&2
+ echo >&2 "Suspend2 shouldn't be used in parallel with mainline suspend!."
exit 1
fi
fi
if [ ! -f /proc/mounts ]; then
- echo "WARNING: /proc filesystem not mounted, may cause wrong results or failure." 1>&2
+ echo >&2 "WARNING: /proc filesystem not mounted, may cause wrong results or failure."
fi
if [ "$pack_version" -lt "002005" ]; then
@@ -1049,15 +1048,11 @@
fi
if [ -n "$ifneeded" -a -z "$MODULES" ]; then
- if [ -n "$verbose" ]; then
- echo "No modules are needed -- not building initrd image."
- fi
+ debug "No modules are needed -- not building initrd image."
exit 0
fi
-if [ -n "$verbose" ]; then
- echo "Using modules: $MODULES"
-fi
+debug "Using modules: $MODULES"
MNTIMAGE="`mktemp -d /tmp/initrd.XXXXXX`"
IMAGE="`mktemp -u /tmp/initrd.img-XXXXXX`"
@@ -1065,12 +1060,12 @@
RCFILE="$MNTIMAGE/linuxrc"
if [ -f "$MNTIMAGE" ]; then
- echo "$MNTIMAGE already exists. Remove it and try again" 1>&2
+ echo >&2 "$MNTIMAGE already exists. Remove it and try again"
exit 1
fi
if [ -f "$IMAGE" ]; then
- echo "$IMAGE already exists. Remove it and try again" 1>&2
+ echo >&2 "$IMAGE already exists. Remove it and try again"
exit 1
fi
@@ -1167,7 +1162,7 @@
}
initrd_gen_udev() {
- [ -n "$verbose" ] && echo "Setting up udev..."
+ debug "Setting up udev..."
mkdir -p $MNTIMAGE/sbin
mkdir -p $MNTIMAGE/proc
mkdir -p $MNTIMAGE/etc/udev
@@ -1221,7 +1216,7 @@
initrd_gen_softraid() {
- [ -n "$verbose" ] && echo "Setting up mdadm..."
+ debug "Setting up mdadm..."
if [ ! -x /sbin/mdadm -o ! -x /sbin/initrd-mdassemble ] ; then
echo "/sbin/mdadm or /sbin/initrd-mdassemble is missing !"
@@ -1239,7 +1234,7 @@
for nr in `seq 1 $rootdev_nr`; do
eval cr_rootdev="\$rootdev${nr}"
eval cr_dev_list="\$dev_list${nr}"
- [ -n "$verbose" ] && echo "Setting up array ($cr_rootdev = $cr_dev_list)"
+ debug echo "Setting up array ($cr_rootdev = $cr_dev_list)"
[ "$cr_rootdev" = "/dev/md0" ] && do_md0=0
@@ -1256,7 +1251,7 @@
# mkdir in case of devfs name
mkdir -p $MNTIMAGE/`dirname $f`
[ -e "$MNTIMAGE/$f" ] && continue
- [ -n "$verbose" ] && echo "copying $f"
+ debug echo "copying $f"
# this works fine with and without devfs
cp -HR $f $MNTIMAGE/$f
done
@@ -1273,7 +1268,7 @@
<<diff output has been trimmed to 500 lines, 75 line(s) remained.>>
More information about the pld-cvs-commit
mailing list