SVN: geninitrd/trunk/geninitrd
glen
glen at pld-linux.org
Thu Oct 4 17:20:45 CEST 2007
Author: glen
Date: Thu Oct 4 17:20:45 2007
New Revision: 8775
Modified:
geninitrd/trunk/geninitrd
Log:
- use die() calls
Modified: geninitrd/trunk/geninitrd
==============================================================================
--- geninitrd/trunk/geninitrd (original)
+++ geninitrd/trunk/geninitrd Thu Oct 4 17:20:45 2007
@@ -68,9 +68,8 @@
fi
usage () {
- self=$(basename "$0")
uname_r=$(uname -r)
- echo "usage: $self [--version] [-v] [-f] [--ifneeded] [--preload <module>]"
+ echo "usage: $PROGRAM [--version] [-v] [-f] [--ifneeded] [--preload <module>]"
echo " [--with=<module>] [--image-version] [--fstab=<fstab>] [--nocompress]"
echo " [--initrdfs=rom|initramfs|ext2|cram] [--modules-conf=<modules.conf>]"
echo " [--with-raidstart] [--without-raidstart] [--with-insmod-static]"
@@ -83,7 +82,7 @@
echo " <initrd-image> <kernel-version>"
echo ""
echo "example:"
- echo " $self -f --initrdfs=rom /boot/initrd-$uname_r.gz $uname_r"
+ echo " $PROGRAM -f --initrdfs=rom /boot/initrd-$uname_r.gz $uname_r"
exit 1
}
@@ -135,8 +134,7 @@
fi
done
if [ $err = 1 ]; then
- echo >&2 "aborted"
- exit 1
+ die "Aborted"
fi
}
@@ -145,11 +143,8 @@
depfile=/lib/modules/$kernel/modules.dep
- if [ -f $depfile ] ; then
- : ok
- else
- echo >&2 "Error: no $depfile ! Run depmod and rerun geninitrd."
- exit 1
+ if [ ! -f $depfile ]; then
+ die "No $depfile! Run depmod and rerun geninitrd."
fi
# prepend / if no path given, append $modext.gz if not given,
@@ -168,9 +163,9 @@
# fallback to $modext
if [ "$mods" = "" ] ; then
- module=$(echo "$module" | \
- awk '{gsub("\'$modext'\.gz$","\'$modext'",$0);print}')
+ module=$(echo "$module" | awk '{gsub("\'$modext'\.gz$","\'$modext'",$0);print}')
fi
+
mods=$(awk '
BEGIN { here = 0 }
/'"$module"':(.*)/ { gsub(/:/," "); gsub(/\\/," "); print; here = 1; next }
@@ -182,7 +177,7 @@
if [ "$1" != silent ] ; then
echo >&2 "$origmodule: module not found in $depfile"
fi
- if ! is_no "$EXIT_IF_MISSING" ; then
+ if ! is_no "$EXIT_IF_MISSING"; then
exit 1
else
echo >&2 "If $origmodule isn't compiled in kernel then this initrd may not start your system."
@@ -195,8 +190,7 @@
fi
level=$((level + 1))
if [ $level -gt 20 ] ; then
- echo >&2 "Error: $origmodule: cycle in $depfile"
- exit 1
+ die "$origmodule: cycle in $depfile"
fi
first=
@@ -220,8 +214,7 @@
return
fi
- echo >&2 "Error: module $fmPath present in modules.dep, but not in filesystem (kernel = $kernel)"
- exit 1
+ die "module $fmPath present in modules.dep, but not in filesystem (kernel = $kernel)"
fi
# only need to add each module once
@@ -314,8 +307,7 @@
fi
if [ "$raidfound" != "yes" -a -f /etc/raidtab ]; then
- echo >&2 "Error: raidtools are not longer supported. Please migrate to mdadm setup!"
- exit 1
+ die "raidtools are not longer supported. Please migrate to mdadm setup!"
fi
if is_yes "$raidfound" ; then
@@ -335,8 +327,7 @@
;;
esac
else
- echo >&2 "Error: RAID devices not found for \"$1\", check your configuration!"
- exit 1
+ die "RAID devices not found for \"$1\", check your configuration!"
fi
rootdev_nr=$(( $rootdev_nr + 1 ))
@@ -488,8 +479,7 @@
rc=$?
if [ $rc -gt 127 ]; then
# lvdisplay terminated by signal! most likely it segfaulted.
- echo >&2 "Error: Unexpected exit from 'lvdisplay $node': $rc - are your lvm tools broken?"
- exit 1
+ die "Unexpected exit from 'lvdisplay $node': $rc - are your lvm tools broken?"
fi
if [ $rc = 0 ]; then
@@ -508,9 +498,7 @@
if is_yes "`echo "$1" | awk '/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:|\/dev\/nfs)/ { print "yes"; }'`"; then
if [ ! -x /usr/bin/pcidev -a -z "$NFS_ETH_MODULES" ] ; then
- echo "Error: root on NFS but /usr/bin/pcidev not found." >&2
- echo "Please install correct pci-database package and rerun $0." >&2
- exit 1
+ die "root on NFS but /usr/bin/pcidev not found. Please install correct pci-database package and rerun $PROGRAM."
fi
[ -z "$NFS_ETH_MODULES" ] && NFS_ETH_MODULES=$(/usr/bin/pcidev /m net | xargs)
for m in $NFS_ETH_MODULES; do
@@ -539,27 +527,21 @@
ataraidmodules="`awk '/ataraid_hostadapter/ && ! /^[\t ]*#/ { print $3; }' $modulefile`"
if -n "$ataraidmodules" ; then
# FIXME: think about modules compiled in kernel
- echo "Error: ataraid_hostadapter alias not defined in $modulefile !"
- echo "Please set it and run $0 again."
- exit 1
+ die "ataraid_hostadapter alias not defined in $modulefile! Please set it and run $PROGRAM again."
fi
for n in $ataraidmodules; do
findmodule "$n"
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 >&2 "Error: Sorry, root on loop device isn't supported."
- exit 1
+ die "Sorry, root on loop device isn't supported."
# TODO: rewrite for bsp and make nfs ready
if [ ! -x /sbin/losetup ]; then
- echo "Error: losetup is missing"
- exit 1
+ die "losetup is missing"
fi
key="^# $(echo $1 | awk -F/ '{print($3);}' | tr '[a-z]' '[A-Z]'):"
if ! is_yes "`awk '/'$key'/ { print( "yes"); }' $fstab`" ; then
- echo >&2 "Error: 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
+ die "The root filesystem is on a $1, but there is no magic entry in $fstab for this device. Consult the geninitrd man page for more information"
fi
line="`awk '/'$key'/ { print $0; }' $fstab`"
@@ -574,16 +556,12 @@
node="$1"
if [ ! -f /sbin/initrd-lvm -o ! -x /sbin/lvdisplay -o ! -x /sbin/pvdisplay ] ; then
- echo "Error: root on LVM but /sbin/initrd-lvm, /sbin/lvdisplay and /sbin/pvdisplay not found." >&2
- echo "Please install lvm(2) and lvm(2)-initrd package and rerun $0." >&2
- exit 1
+ die "root on LVM but /sbin/initrd-lvm, /sbin/lvdisplay and /sbin/pvdisplay not found. Please install lvm(2) and lvm(2)-initrd package and rerun $PROGRAM."
fi
if [ -z "$LVMTOOLSVERSION" ] ; then
LVMTOOLSVERSION=$(/sbin/initrd-lvm vgchange --version 2>/dev/null|head -n 1|awk '{gsub("vgchange: Logical Volume Manager ",NIL); gsub("LVM version: ",NIL); gsub(/\..*/,NIL); print $1}')
if [ -z "$LVMTOOLSVERSION" ] ; then
- echo "Error: Can't determine LVM tools version. Please set LVMTOOLSVERSION" >&2
- echo "and rerun $0." >&2
- exit 1
+ die "Can't determine LVM tools version. Please set LVMTOOLSVERSION and rerun $PROGRAM."
fi
fi
if [ -z "$PVDEVICES" ] ; then
@@ -595,9 +573,7 @@
find_modules_for $device
done
else
- echo "Error: I wasn't able to find PV (via lvdisplay and pvdisplay)." >&2
- echo "You can try to set PVDEVICES in /etc/sysconfig/geninitrd." >&2
- exit 1
+ die "I wasn't able to find PV (via lvdisplay and pvdisplay). You can try to set PVDEVICES in /etc/sysconfig/geninitrd."
fi
if [ "$LVMTOOLSVERSION" = "2" ]; then
findmodule "-dm-mod"
@@ -605,8 +581,7 @@
findmodule "-lvm"
findmodule "-lvm-mod"
else
- echo "Error: LVM version $LVMTOOLSVERSION is not supported yet." >&2
- exit 1
+ die "LVM version $LVMTOOLSVERSION is not supported yet."
fi
debug "LVM $LVMTOOLSVERSION enabled"
uselvm="yes"
@@ -717,8 +692,7 @@
fi
if [ ! -x /bin/initrd-busybox ] ; then
- echo "Error: /bin/initrd-busybox is missing!"
- exit 1
+ die "/bin/initrd-busybox is missing!"
fi
while [ $# -gt 0 ]; do
@@ -893,43 +867,36 @@
INSMOD="/sbin/insmod.static.modutils"
fi
if [ ! -f "$INSMOD" ] ; then
- echo "Error: insmod.static requested but /sbin/insmod.static not found !" >&2
- exit 1
+ die "insmod.static requested but /sbin/insmod.static not found!"
fi
fi
case "$INITRDFS" in
ext2)
if [ ! -x /sbin/mke2fs ]; then
- echo >&2 "Error: /sbin/mke2fs is missing"
- exit 1
+ die "/sbin/mke2fs is missing"
fi
;;
rom)
if [ ! -x /sbin/genromfs ]; then
- echo >&2 "Error: /sbin/genromfs is missing"
- exit 1
+ die "/sbin/genromfs is missing"
fi
;;
cram)
if [ ! -x /sbin/mkcramfs ]; then
- echo >&2 "Error: /sbin/mkcramfs is missing"
- exit 1
+ die "/sbin/mkcramfs is missing"
fi
;;
initramfs)
if [ ! -x /bin/cpio ]; then
- echo >&2 "Erro: /bin/cpio is missing"
- exit 1
+ die "/bin/cpio is missing"
fi
if [ ! -x /usr/bin/find ]; then
- echo >&2 "Error: /usr/bin/find is missing"
- exit 1
+ die "/usr/bin/find is missing"
fi
;;
*)
- echo >&2 "Error: Filesystem $INITRDFS on initrd is not supported"
- exit 1
+ die "Filesystem $INITRDFS on initrd is not supported"
;;
esac
@@ -938,29 +905,22 @@
fi
if [ -z "$force" -a -f "$target" ]; then
- echo >&2 "Error: $target already exists."
- exit 1
+ die "$target already exists."
fi
if [ ! -d "/lib/modules/$kernel" ]; then
- echo >&2 "Error: /lib/modules/$kernel is not a directory."
- exit 1
+ die "/lib/modules/$kernel is not a directory."
fi
-if is_yes "$USE_SUSPEND"; then
- if is_yes "$USE_SUSPEND2"; then
- echo >&2 "Error: Suspend2 shouldn't be used in parallel with mainline suspend!."
- exit 1
- fi
+if is_yes "$USE_SUSPEND" && is_yes "$USE_SUSPEND2"; then
+ die "Suspend2 shouldn't be used in parallel with mainline suspend!."
fi
if is_yes "$FB_SPLASH"; then
if is_yes "$BOOT_SPLASH"; then
- echo >&2 "Error: You can't use both bootsplash and fbsplash! Please choose one."
- exit 1
+ die "You can't use both bootsplash and fbsplash! Please choose one."
elif [ "$INITRDFS" != "initramfs" ]; then
- echo >&2 "Error: FB_SPLASH works only if INITRDFS is initramfs!."
- exit 1
+ die "FB_SPLASH works only if INITRDFS is initramfs!."
fi
fi
@@ -1022,13 +982,11 @@
RCFILE="$MNTIMAGE/linuxrc"
if [ -f "$MNTIMAGE" ]; then
- echo >&2 "Error: $MNTIMAGE already exists. Remove it and try again"
- exit 1
+ die "$MNTIMAGE already exists. Remove it and try again"
fi
if [ -f "$IMAGE" ]; then
- echo >&2 "Error: $IMAGE already exists. Remove it and try again"
- exit 1
+ die "$IMAGE already exists. Remove it and try again"
fi
mkdir -p "$MNTPOINT"
@@ -1090,8 +1048,7 @@
initrd_gen_suspend() {
if [ ! -x /usr/sbin/resume ]; then
- echo "Error: /usr/sbin/resume is missing !"
- exit 1
+ die "/usr/sbin/resume is missing!"
fi
mkdir -p $MNTIMAGE/etc
mkdir -p $MNTIMAGE/dev
@@ -1147,8 +1104,7 @@
mkdir -p $MNTIMAGE/sys
if [ ! -x /sbin/initrd-udevd ]; then
- echo >&2 "Error: /sbin/initrd-udevd not present; aborted"
- exit 1
+ die "/sbin/initrd-udevd not present"
fi
inst /sbin/initrd-udevd $MNTIMAGE/sbin/udevd
@@ -1182,8 +1138,7 @@
initrd_gen_dmraid() {
if [ ! -x /sbin/dmraid-initrd ] ; then
- echo "Error: /sbin/dmraid-initrd is missing missing !"
- exit 1
+ die "/sbin/dmraid-initrd is missing missing!"
fi
# always make /dev on tmpfs
@@ -1209,9 +1164,8 @@
initrd_gen_softraid() {
debug "Setting up mdadm..."
- if [ ! -x /sbin/mdadm -o ! -x /sbin/initrd-mdassemble ] ; then
- echo "Error: /sbin/mdadm or /sbin/initrd-mdassemble is missing !"
- exit 1
+ if [ ! -x /sbin/mdadm -o ! -x /sbin/initrd-mdassemble ]; then
+ die "/sbin/mdadm or /sbin/initrd-mdassemble is missing!"
fi
inst /sbin/initrd-mdassemble "$MNTIMAGE/bin/mdassemble"
More information about the pld-cvs-commit
mailing list