From 02ba8ab737c2aa4ee5df1802932e76fa247e10b5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Elan=20Ruusam=C3=A4e?= Date: Tue, 17 Apr 2012 13:45:41 +0000 Subject: [PATCH] add debug and verbose output svn-id: @12550 --- geninitrd | 51 ++++++++++++++++++++++++++++------------------- mod-blkid.sh | 2 +- mod-bootsplash.sh | 4 ++-- mod-condecor.sh | 4 ++-- mod-fbsplash.sh | 4 ++-- mod-ide.sh | 6 +++--- mod-luks.sh | 10 +++++----- mod-lvm.sh | 12 +++++------ mod-md.sh | 8 ++++---- mod-multipath.sh | 2 +- mod-nfs.sh | 2 +- mod-sata.sh | 2 +- mod-scsi.sh | 2 +- mod-suspend.sh | 4 ++-- mod-udev.sh | 2 +- mod-usbkbd.sh | 8 ++++---- mod-uvesafb.sh | 2 +- 17 files changed, 68 insertions(+), 57 deletions(-) diff --git a/geninitrd b/geninitrd index 572b632..a1a1987 100755 --- a/geninitrd +++ b/geninitrd @@ -79,8 +79,12 @@ warn() { msg "WARNING: $*" >&2 } +verbose() { + [ x"$verbose" = x"-v" ] && msg "$*" >&3 +} + debug() { - [ -n "$verbose" ] && msg "$*" >&3 + [ x"$verbose" = x"-v -v" ] && msg "$*" >&3 } # aborts program abnormally @@ -96,7 +100,7 @@ find_tool() { for x in "$@"; do if [ -x "$x" ]; then echo $x - debug "find_tool: found $x" + verbose "find_tool: found $x" return 0 fi done @@ -402,8 +406,11 @@ inst() { local dest=$1 set -- $src local parentDir=$(dirname $DESTDIR$dest) - [ ! -d "$parentDir" ] && (debug "+ mkdir -p $parentDir"; mkdir -p $parentDir) - debug "+ cp $* $DESTDIR$dest" + if [ ! -d "$parentDir" ]; then + verbose "+ mkdir -p $parentDir" + mkdir -p $parentDir + fi + verbose "+ cp $* $DESTDIR$dest" cp -HR "$@" "$DESTDIR$dest" } @@ -457,7 +464,7 @@ inst_exec() { if [ ! -e $DESTDIR$libdir ]; then libdir=$(dirname "$libdir") inst_d $libdir - debug "+ ln -s /$_lib $DESTDIR$libdir" + verbose "+ ln -s /$_lib $DESTDIR$libdir" ln -s /$_lib $DESTDIR$libdir fi fi @@ -515,7 +522,7 @@ find_modules_for_devpath() { devpath=$(readlink -f "$devpath") fi - debug "Finding modules for device path $devpath" + verbose "Finding modules for device path $devpath" if is_luks "$devpath"; then find_modules_luks "$devpath" @@ -631,7 +638,7 @@ firmware_install_module() { local module="$1" local firmware_files="$2" - debug "Adding Firmwares ($firmware_files) to initrd for module $module" + verbose "Adding Firmwares ($firmware_files) to initrd for module $module" # firmware not yet installed if [ ! -f "$DESTDIR/lib/firmware/firmware.sh" ]; then inst_d /lib/firmware @@ -698,7 +705,7 @@ modules_add_linuxrc() { options="scan=sync $options" fi - if [ -n "$verbose" ]; then + if [ x"$verbose" = x"-v" ]; then s="" if [ "$options" ]; then s="$s with options [$options]" @@ -706,7 +713,7 @@ modules_add_linuxrc() { if [ "$usleep" ]; then s="$s and $usleep usleep" fi - debug "Loading module [$module]$s" + verbose "Loading module [$module]$s" fi if [ -n "$firmware" ]; then @@ -757,7 +764,7 @@ initrd_gen_devices() { initrd_gen_setrootdev() { - debug "Adding rootfs finding based on kernel cmdline root= option support." + verbose "Adding rootfs finding based on kernel cmdline root= option support." busybox_applet ls debug "Current /proc/partitions:\n$(sed -e 's,^,> ,' /proc/partitions)" add_linuxrc <<-'EOF' @@ -898,7 +905,7 @@ find_compressor() { compressors="$mode" fi - debug "finding compressor: $compressors (via $mode)" + verbose "finding compressor: $compressors (via $mode)" # check for compressor validity local c prog map=/boot/System.map-$kernel for c in $compressors; do @@ -938,7 +945,7 @@ find_compressor() { fi done - debug "using gzip for compressor (fallback)" + verbose "using gzip for compressor (fallback)" echo gzip } @@ -1072,7 +1079,11 @@ while [ $# -gt 0 ]; do exit 0 ;; -v) - verbose=-v + if [ x"$verbose" = x"-v" ]; then + verbose="-v -v" + else + verbose="-v" + fi exec 3>&1 ;; --compress) @@ -1158,7 +1169,7 @@ initrd_dir=/usr/$_lib/initrd kernel_version=$(echo "$kernel" | awk -F. '{gsub(/[_-].*/, "", $0); print sprintf("%03d%03d",$1,$2)}') kernel_version_long=$(echo "$kernel" | awk -F. '{gsub(/[_-].*/, "", $0); print sprintf("%03d%03d%03d",$1,$2,$3)}') -debug "# $GENINITRD_RCSID (geninitrd)" +verbose "# $GENINITRD_RCSID (geninitrd)" debug "Using _lib: $_lib" debug "Using initrd_dir: $initrd_dir" @@ -1256,7 +1267,7 @@ if is_yes "$USE_SUSPEND"; then fi find_root "$fstab" || exit -debug "Using $rootdev as device for rootfs" +verbose "Using $rootdev as device for rootfs" find_modules_for_devpath "$rootdev" @@ -1279,11 +1290,11 @@ fi find_modules_fbsplash if [ -n "$ifneeded" -a -z "$MODULES" ]; then - debug "No modules are needed -- not building initrd image." + verbose "No modules are needed -- not building initrd image." exit 0 fi -debug "Building initrd..." +verbose "Building initrd..." DESTDIR=$(mktemp -d -t initrd.XXXXXX) || die "mktemp failed" RCFILE="$DESTDIR/linuxrc" > "$RCFILE" @@ -1459,9 +1470,9 @@ debug "Current /linuxrc:\n$(sed -e 's,^,> ,' $DESTDIR/linuxrc)" IMAGE=$(mktemp -t initrd.img-XXXXXX) || die "mktemp failed" IMAGESIZE=$(du -ks $DESTDIR | awk '{print int(($1+1023+512)/1024)*1024}') -debug "image size: $IMAGESIZE KiB ($DESTDIR)" +verbose "image size: $IMAGESIZE KiB ($DESTDIR)" -debug "Creating $INITRDFS image $IMAGE" +verbose "Creating $INITRDFS image $IMAGE" case "$INITRDFS" in ext2) dd if=/dev/zero of="$IMAGE" bs=1k count="$IMAGESIZE" 2> /dev/null @@ -1506,7 +1517,7 @@ fi if ! is_no "$COMPRESS"; then compressor=$(find_compressor "$COMPRESS") - debug "Compressing $target with $compressor" + verbose "Compressing $target with $compressor" # TODO: the image name (specified from kernel.spec) already contains # extension, which is .gz most of the time. diff --git a/mod-blkid.sh b/mod-blkid.sh index e8310fd..6066f91 100644 --- a/mod-blkid.sh +++ b/mod-blkid.sh @@ -22,7 +22,7 @@ initrd_gen_blkid() { if ! is_yes "$USE_BLKID"; then return fi - debug "Adding BLKID support to initrd" + verbose "Adding BLKID support to initrd" inst_exec $blkid /bin/blkid initrd_gen_devices diff --git a/mod-bootsplash.sh b/mod-bootsplash.sh index 542c204..338d749 100644 --- a/mod-bootsplash.sh +++ b/mod-bootsplash.sh @@ -28,7 +28,7 @@ initrd_gen_bootsplash() { fi local target="$1" - debug "Generating bootsplash" + verbose "Generating bootsplash" if [ ! -x /bin/splash.bin ]; then warn "Failed to execute /bin/splash.bin. Is bootsplash package installed?" @@ -54,7 +54,7 @@ initrd_gen_bootsplash() { for res in $BOOT_SPLASH_RESOLUTIONS; do if [ -f "/etc/bootsplash/themes/$THEME/config/bootsplash-$res.cfg" ]; then $bootsplash_geninitramfs -s -f "/etc/bootsplash/themes/$THEME/config/bootsplash-$res.cfg" >> "$target" && \ - debug "Added $res $THEME theme to initrd." + verbose "Added $res $THEME theme to initrd." else warn "/etc/bootsplash/themes/$THEME/config/bootsplash-$res.cfg doesn't exist, skipped" fi diff --git a/mod-condecor.sh b/mod-condecor.sh index 0b4c30d..dc0cca1 100644 --- a/mod-condecor.sh +++ b/mod-condecor.sh @@ -26,7 +26,7 @@ initrd_gen_fbcondecor() { if ! is_yes "$FB_CON_DECOR"; then return fi - debug "Generating fbcondecor" + verbose "Generating fbcondecor" if [ -r /etc/sysconfig/splash ]; then . /etc/sysconfig/splash @@ -48,7 +48,7 @@ initrd_gen_fbcondecor() { for res in $FB_SPLASH_RESOLUTIONS; do if [ -f "/etc/splash/$SPLASH_THEME/$res.cfg" ]; then $condecor_geninitramfs -c $DESTDIR -r $res $SPLASH_THEME && \ - debug "Added $res $SPLASH_THEME theme to initramfs." + verbose "Added $res $SPLASH_THEME theme to initramfs." else warn "/etc/splash/$SPLASH_THEME/$res.cfg doesn't exist, skipped" fi diff --git a/mod-fbsplash.sh b/mod-fbsplash.sh index a9ed6ca..8cd162f 100644 --- a/mod-fbsplash.sh +++ b/mod-fbsplash.sh @@ -42,7 +42,7 @@ initrd_gen_fbsplash() { if ! is_yes "$FB_SPLASH"; then return fi - debug "Generating fbsplash" + verbose "Generating fbsplash" if [ -r /etc/sysconfig/fbsplash ]; then . /etc/sysconfig/fbsplash @@ -64,7 +64,7 @@ initrd_gen_fbsplash() { for res in $FB_SPLASH_RESOLUTIONS; do if [ -f "/etc/splash/$SPLASH_THEME/$res.cfg" ]; then $fbsplash_geninitramfs -c $DESTDIR -r $res $SPLASH_THEME && \ - debug "Added $res $SPLASH_THEME theme to initramfs." + verbose "Added $res $SPLASH_THEME theme to initramfs." else warn "/etc/splash/$SPLASH_THEME/$res.cfg doesn't exist, skipped" fi diff --git a/mod-ide.sh b/mod-ide.sh index 18a9803..d3ab2f9 100644 --- a/mod-ide.sh +++ b/mod-ide.sh @@ -42,7 +42,7 @@ find_modules_ide() { local n if [ "$kernel_version_long" -lt "002004021" ]; then - debug "Finding IDE modules for kernels <= 2.4.20" + verbose "Finding IDE modules for kernels <= 2.4.20" for n in $PREIDEMODSOLD; do find_module "$n" done @@ -50,7 +50,7 @@ find_modules_ide() { local tryauto=1 for n in $PREIDEMODS; do if [ "X$n" = "Xunknown" ]; then - debug "Finding IDE modules using ide_hostadapter" + verbose "Finding IDE modules using ide_hostadapter" local mod idemodules=$(modprobe_conf | awk '/ide_hostadapter/ { print $3 }') for mod in $idemodules; do tryauto=0 @@ -60,7 +60,7 @@ find_modules_ide() { if [ "$tryauto" -eq 1 ]; then # If tryauto {{{ if [ -r /usr/share/pci-database/ide.pci -a -r /proc/bus/pci/devices ]; then - debug "Finding IDE modules using PCI ID database" + verbose "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/${rootblkdev}/device/../../vendor -a -f /sys/block/${rootblkdev}/device/../../device ]; then diff --git a/mod-luks.sh b/mod-luks.sh index ca7b6b0..8cee34f 100644 --- a/mod-luks.sh +++ b/mod-luks.sh @@ -34,7 +34,7 @@ is_luks() { local dev dm_name=${node#/dev/mapper/} if [ "$node" = "$dm_name" ]; then - debug "is_luks: $node is not device mapper name" + verbose "is_luks: $node is not device mapper name" return 1 fi @@ -47,9 +47,9 @@ is_luks() { fi if [ $rc = 0 ]; then - debug "is_luks: $node is cryptsetup luks" + verbose "is_luks: $node is cryptsetup luks" else - debug "is_luks: $node is not cryptsetup luks" + verbose "is_luks: $node is not cryptsetup luks" fi return $rc } @@ -95,7 +95,7 @@ initrd_gen_luks() { initrd_gen_devices # TODO: 'udevadm settle' is called by lukssetup, is udev optional? - debug "luks: process /etc/crypttab $LUKSNAME" + verbose "luks: process /etc/crypttab $LUKSNAME" luks_crypttab $LUKSNAME } @@ -144,7 +144,7 @@ luks_crypttab() { inst $key $keyfile fi - debug "+ cryptsetup ${keyfile:+-d $keyfile} luksOpen '$src' '$dst'" + verbose "+ cryptsetup ${keyfile:+-d $keyfile} luksOpen '$src' '$dst'" add_linuxrc <<-EOF # cryptsetup can be called twice and in case on crypt on lvm only second # will succeed because there will be no src device in first cryptsetup call diff --git a/mod-lvm.sh b/mod-lvm.sh index 1c6ea77..b9c3ba2 100644 --- a/mod-lvm.sh +++ b/mod-lvm.sh @@ -83,14 +83,14 @@ is_lvm() { find_modules_lvm() { local devpath="$1" - debug "LVM: $devpath is LVM node" + verbose "LVM: $devpath is LVM node" local vg=$(find_lvm_vg "$devpath") - debug "LVM VG for $devpath: $vg" + verbose "LVM VG for $devpath: $vg" LVM_VGVOLUMES=$(echo $LVM_VGVOLUMES $vg | tr ' ' '\n' | sort -u) local pv=$(find_lvm_pv "$vg") - debug "LVM PV for $vg: $pv" + verbose "LVM PV for $vg: $pv" PVDEVICES=$(echo $PVDEVICES $pv | tr ' ' '\n' | sort -u) if [ -n "$PVDEVICES" ]; then @@ -110,7 +110,7 @@ find_modules_lvm() { die "LVM version $LVMTOOLSVERSION is not supported." fi - debug "LVM v$LVMTOOLSVERSION enabled" + verbose "LVM v$LVMTOOLSVERSION enabled" have_lvm=yes } @@ -122,7 +122,7 @@ initrd_gen_lvm() { return fi - debug "Adding LVM support to initrd" + verbose "Adding LVM support to initrd" inst_d /tmp /newroot inst_exec $lvm /bin/lvm.static @@ -170,7 +170,7 @@ initrd_gen_lvm() { echo ' filter = [' >> "$DESTDIR/etc/lvm.conf" local dev for dev in $lvm_ignore_devices; do - debug "LVM v2: ignore device $dev" + verbose "LVM v2: ignore device $dev" printf ' "r|^%s.*|",\n' $dev done >> "$DESTDIR/etc/lvm.conf" echo ']' >> "$DESTDIR/etc/lvm.conf" diff --git a/mod-md.sh b/mod-md.sh index 0c06e72..19331cb 100644 --- a/mod-md.sh +++ b/mod-md.sh @@ -46,7 +46,7 @@ find_modules_md() { local found raidlevel if [ -f /etc/mdadm.conf ]; then - debug "Finding RAID details using mdadm for rootdev=$1" + verbose "Finding RAID details using mdadm for rootdev=$1" eval `($mdadm -v --examine --scan --config=/etc/mdadm.conf 2> /dev/null;$mdadm -v --detail --scan --config=/etc/mdadm.conf 2> /dev/null) | awk -v rootdev="$1" ' BEGIN { found = "no"; @@ -119,7 +119,7 @@ find_modules_md() { die "RAID devices not found for \"$1\", check your configuration!" fi - debug "md: found rootdev=$1 on device $rootdev_new with devices list ${dev_list}" + verbose "md: found rootdev=$1 on device $rootdev_new with devices list ${dev_list}" rootdev_nr=$(( $rootdev_nr + 1 )) eval "rootdev${rootdev_nr}=\"$rootdev_new\"" @@ -137,7 +137,7 @@ initrd_gen_md() { if ! is_yes "$have_md"; then return fi - debug "Setting up mdadm..." + verbose "Setting up mdadm..." inst_exec $mdassemble /bin/mdassemble @@ -161,7 +161,7 @@ initrd_gen_md() { for nr in `seq 1 $rootdev_nr`; do eval cr_rootdev="\$rootdev${nr}" eval cr_dev_list="\$dev_list${nr}" - debug echo "Setting up array ($cr_rootdev = $cr_dev_list)" + verbose "Setting up array ($cr_rootdev = $cr_dev_list)" [ "$cr_rootdev" = "/dev/md0" ] && do_md0=0 diff --git a/mod-multipath.sh b/mod-multipath.sh index 2a6121b..c70f05e 100644 --- a/mod-multipath.sh +++ b/mod-multipath.sh @@ -78,7 +78,7 @@ find_modules_multipath() { return 1 fi - debug "Finding modules for dm-multipath (WWID=$MPATH_WWID)" + verbose "Finding modules for dm-multipath (WWID=$MPATH_WWID)" have_multipath=yes local p list diff --git a/mod-nfs.sh b/mod-nfs.sh index 7e197af..feb0927 100644 --- a/mod-nfs.sh +++ b/mod-nfs.sh @@ -56,7 +56,7 @@ initrd_gen_nfs() { # use root=/dev/ram0 init=/linuxrc when starting kernel or you will # have problems like init(XX) being child process of swapper(1). - debug "Adding rootfs on NFS support to initrd (dhcp)" + verbose "Adding rootfs on NFS support to initrd (dhcp)" mknod "$DESTDIR/dev/urandom" c 1 9 mkdir "$DESTDIR/newroot" add_linuxrc <<-'EOF' diff --git a/mod-sata.sh b/mod-sata.sh index 949c8a6..7cbff99 100644 --- a/mod-sata.sh +++ b/mod-sata.sh @@ -4,7 +4,7 @@ SATA_RCSID='$Revision$ $Date:: $' # geninitrd mod: sata find_modules_sata() { - debug "Finding SATA modules (class=0x0106)" + verbose "Finding SATA modules (class=0x0106)" # Classes (we want only 0106) # http://pci-ids.ucw.cz/read/PD/01 diff --git a/mod-scsi.sh b/mod-scsi.sh index 57ae04f..328b030 100644 --- a/mod-scsi.sh +++ b/mod-scsi.sh @@ -39,7 +39,7 @@ find_modules_scsi() { local n for n in $PRESCSIMODS; do if [ "X$n" = "Xunknown" ]; then - debug "Finding SCSI modules using scsi_hostadapter" + verbose "Finding SCSI modules using scsi_hostadapter" local mod scsimodules=$(modprobe_conf | awk '/scsi_hostadapter/ { print $3 }') for mod in $scsimodules; do # for now allow scsi modules to come from anywhere. There are some diff --git a/mod-suspend.sh b/mod-suspend.sh index b4aece9..ceb807f 100644 --- a/mod-suspend.sh +++ b/mod-suspend.sh @@ -36,7 +36,7 @@ find_modules_suspend() { # save suspend VG int oseparate var LVM_SUSPENDVG=$LVM_VGVOLUMES LVM_VGVOLUMES=$vgvolumes - debug "suspend device is on LVM" + verbose "suspend device is on LVM" fi } @@ -47,7 +47,7 @@ initrd_gen_suspend() { return fi - debug "Setting up suspend..." + verbose "Setting up suspend..." mknod $DESTDIR/dev/snapshot c 10 231 mkdir -p $DESTDIR${resume_dev%/*} diff --git a/mod-udev.sh b/mod-udev.sh index ec9b62b..59dd324 100644 --- a/mod-udev.sh +++ b/mod-udev.sh @@ -41,7 +41,7 @@ setup_mod_udev() { # generate initrd fragment # @access public initrd_gen_udev() { - debug "Setting up udev..." + verbose "Setting up udev..." inst_d /sbin /etc/udev inst_exec $udevd /sbin/udevd diff --git a/mod-usbkbd.sh b/mod-usbkbd.sh index 0c2a7d2..b4fc0f4 100644 --- a/mod-usbkbd.sh +++ b/mod-usbkbd.sh @@ -4,7 +4,7 @@ USBKBD_RCSID='$Revision$ $Date:: $' # geninitrd mod: usbkbd find_modules_usbkbd() { - debug "Finding USB keyboard modules" + verbose "Finding USB keyboard modules" if [ "$(echo /sys/class/input/input*)" = "/sys/class/input/input*" ]; then return @@ -20,9 +20,9 @@ find_modules_usbkbd() { if [ "$bInterfaceClass" = "03" -a "$bInterfaceProtocol" = "01" ]; then module=$(readlink $i/device/driver/module) module=$(basename $module) - + if [ -n "$module" ]; then - debug "Found USB Keyboard: $(cat $i/name)" + verbose "Found USB Keyboard: $(cat $i/name)" modules="$modules $module" fi fi @@ -34,7 +34,7 @@ find_modules_usbkbd() { module=$(basename $module) if [ -n "$module" ]; then - debug "Found USB Logitech Unifying Device: $(cat $i/name)" + verbose "Found USB Logitech Unifying Device: $(cat $i/name)" modules="$modules $module" fi fi diff --git a/mod-uvesafb.sh b/mod-uvesafb.sh index f5e389a..97c0b35 100644 --- a/mod-uvesafb.sh +++ b/mod-uvesafb.sh @@ -40,7 +40,7 @@ initrd_gen_uvesafb() { return fi - debug "initrd_gen_uvesafb" + verbose "initrd_gen_uvesafb" mknod $DESTDIR/dev/mem c 1 1 mknod $DESTDIR/dev/tty1 c 4 1 inst_d /sbin -- 2.44.0