]> git.pld-linux.org Git - projects/geninitrd.git/commitdiff
add debug and verbose output
authorElan Ruusamäe <glen@pld-linux.org>
Tue, 17 Apr 2012 13:45:41 +0000 (13:45 +0000)
committerElan Ruusamäe <glen@pld-linux.org>
Tue, 17 Apr 2012 13:45:41 +0000 (13:45 +0000)
svn-id: @12550

17 files changed:
geninitrd
mod-blkid.sh
mod-bootsplash.sh
mod-condecor.sh
mod-fbsplash.sh
mod-ide.sh
mod-luks.sh
mod-lvm.sh
mod-md.sh
mod-multipath.sh
mod-nfs.sh
mod-sata.sh
mod-scsi.sh
mod-suspend.sh
mod-udev.sh
mod-usbkbd.sh
mod-uvesafb.sh

index 572b6323a6af1ee04c471c5db30bc2a3b4583eb5..a1a198731e4e701d2a69d612e7dc3219e2c8e51e 100755 (executable)
--- 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.
index e8310fd62dd587b200c1b86dafd658396634fa46..6066f91491227130a06e18e4f662c6ca06a42b28 100644 (file)
@@ -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
index 542c2042496f6804f6ac9ff8a63e0e9f0ad63793..338d7492f5a7a467783030fca777481877830d5e 100644 (file)
@@ -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
index 0b4c30db5a1ce4cd423d3d0ac698d348e8188a98..dc0cca12a8756b7ba1af9ce4b4bc30b4be674b5c 100644 (file)
@@ -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
index a9ed6ca505e5fd340f484acab36d96960d2a26e2..8cd162fb334eb6612ab34c9c79f9667a92cfe247 100644 (file)
@@ -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
index 18a9803039e7d490857616de7f4a8eb8c39f083a..d3ab2f94d0c08f6d8742d28f1518985e3d8768ca 100644 (file)
@@ -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
index ca7b6b09dcb3aeebf0cf94b9264ba25359473361..8cee34f6c66dd0b3b1750b701ab18684c718f2a3 100644 (file)
@@ -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
index 1c6ea77c7e98969bc4d9517abaa365648c1b036e..b9c3ba28f1240392aab86849d6f861902ee783d1 100644 (file)
@@ -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"
index 0c06e7285377bc7a32357122c1ad89ad59f778c5..19331cb610b970fd6e965362e72b9970f6abd1f3 100644 (file)
--- 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
 
index 2a6121b9acac8f3462b6451ed5d6cb9b340d5c57..c70f05e4c3807970ed0be172a8971d587f9c537b 100644 (file)
@@ -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
index 7e197afa57554bc3fa0afa002c7fe77cfd0d06cc..feb092792b8187350e02bbdb37789cd4b522c49d 100644 (file)
@@ -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'
index 949c8a6d19c1851b3a30043f8a19f9060d841b9f..7cbff992553bbf32cc2fa5ba40f7dd975ba97a65 100644 (file)
@@ -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
index 57ae04f2983d835138fa41946173ff19c8d44ab1..328b030dbec20bbb79de559ff435916df8ea655d 100644 (file)
@@ -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
index b4aece98095d1c3ca26fef816c627a4f487c5afd..ceb807fabbed1b4bb2bfc633ca75aef2491be71b 100644 (file)
@@ -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%/*}
index ec9b62bb753aa46e41f4580bf46ed46a85685e26..59dd3244d2672a8ec39fbd66da8bc6cf8d0e123a 100644 (file)
@@ -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
index 0c2a7d27f5c77c083b4634df5be8f89c78c099b7..b4fc0f4e204ece4d8ba4df439d053a8ddb3b7254 100644 (file)
@@ -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
index f5e389ae7df89c875a18be817cf5f59100ad5ed7..97c0b35c2abc20f59709fddc21694a2ca33ad68d 100644 (file)
@@ -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
This page took 0.09334 seconds and 4 git commands to generate.