Author: arekm
Date: Wed Nov  7 12:55:07 2007
New Revision: 9008

Modified:
   geninitrd/trunk/geninitrd
Log:
Introduce msg() for messages. Use everywhere.

Modified: geninitrd/trunk/geninitrd
==============================================================================
--- geninitrd/trunk/geninitrd   (original)
+++ geninitrd/trunk/geninitrd   Wed Nov  7 12:55:07 2007
@@ -98,14 +98,25 @@
        exit 1
 }
 
+msg() {
+       local opt=""
+       case "$1" in
+               -n)
+                       opt="$opt -n"
+                       shift
+                       ;;
+       esac
+       echo $opt >&2 "$PROGRAM: $*"
+}
+
 debug() {
-       [ -n "$verbose" ] && echo >&2 "$*"
+       [ -n "$verbose" ] && msg "$*"
 }
 
 # aborts program abnormally
 die() {
        local rc=${2:-1}
-       echo >&2 "$PROGRAM: ERROR: $1"
+       msg "ERROR: $1"
        exit $rc
 }
 
@@ -238,7 +249,7 @@
                if [ -z "$have" ]; then
                        have=$(echo "$busybox_functions" | egrep -c "( 
|^)$applet(,|$)")
                        if [ "$have" = 0 ]; then
-                               echo >&2 "This setup requires busybox-initrd 
compiled with applet '$applet' support"
+                               msg "This setup requires busybox-initrd 
compiled with applet '$applet' support"
                                err=1
                        fi
                        eval busybox_have_$applet=$have
@@ -287,12 +298,12 @@
 
        if [ "$mods" = "" ]; then
                if [ "$1" != silent ]; then
-                       echo >&2 "$origmodule: module not found in $depfile"
+                       msg "$origmodule: module not found in $depfile"
                fi
                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."
+                       msg "If $origmodule isn't compiled in kernel then this 
initrd may not start your system."
                fi
        fi
 
@@ -509,7 +520,7 @@
                        findmodule "linear"
                        ;;
                *)
-                       echo >&2 "raid level $number (in mdadm config) not 
recognized"
+                       msg >&2 "raid level $number (in mdadm config) not 
recognized"
                        ;;
                esac
        else
@@ -647,7 +658,7 @@
 _check_lvm() {
        local node="$1"
        if [ ! -e "$node" ]; then
-               echo >&2 "WARNING: check_lvm(): node $node doesn't exist!"
+               msg >&2 "WARNING: check_lvm(): node $node doesn't exist!"
                return 1
        fi
 
@@ -767,8 +778,8 @@
                findmodule "-ipv4"
                findmodule "nfs"
                have_nfs=yes
-               echo >&2 "Remember to use \`root=/dev/ram0 init=/linuxrc' when 
starting kernel"
-               echo >&2 "or you will have problems like init(xx) being child 
process of swapper(1)."
+               msg "Remember to use \`root=/dev/ram0 init=/linuxrc' when 
starting kernel"
+               msg "or you will have problems like init(xx) being child 
process of swapper(1)."
                return
        fi
 
@@ -944,16 +955,16 @@
                firmware_var="$(eval echo \$MODULE_${generic_module}_FIRMWARE)"
 
                if [ -n "$verbose" ]; then
-                       echo -n "Loading module [$module] "
+                       msg -n "Loading module [$module] "
                        if [ -n "$options" ]; then
-                               echo -n "with options [$options]"
+                               msg -n "with options [$options]"
                        else
-                               echo -n "without options"
+                               msg -n "without options"
                        fi
                        if [ -n "$sleep_var" ]; then
-                               echo " and $sleep_var usleep."
+                               msg " and $sleep_var usleep."
                        else
-                               echo "."
+                               msg "."
                        fi
                fi
 
@@ -1083,10 +1094,10 @@
 
        debug "Generating bootsplash"
        if [ ! -x /bin/splash.bin ]; then
-               echo >&2 "Failed to execute /bin/splash.bin. Is bootsplash 
package installed?"
+               msg "Failed to execute /bin/splash.bin. Is bootsplash package 
installed?"
        elif [ -z "$THEME" ]; then
-               echo >&2 "Please configure your /etc/sysconfig/bootsplash 
first."
-               echo >&2 "Generating bootsplashes skipped."
+               msg "Please configure your /etc/sysconfig/bootsplash first."
+               msg "Generating bootsplashes skipped."
        else
                if [ -n "$BOOT_SPLASH_RESOLUTIONS" ]; then
                        for res in $BOOT_SPLASH_RESOLUTIONS; do
@@ -1094,12 +1105,12 @@
                                        /bin/splash.bin -s -f 
"/etc/bootsplash/themes/$THEME/config/bootsplash-$res.cfg" >> "$target" && \
                                        debug "Added $res $THEME theme to 
initrd."
                                else
-                                       echo >&2 
"/etc/bootsplash/themes/$THEME/config/bootsplash-$res.cfg doesn't exist, 
skipped"
+                                       msg 
"/etc/bootsplash/themes/$THEME/config/bootsplash-$res.cfg doesn't exist, 
skipped"
                                fi
                        done
                else
-                       echo >&2 "No BOOT_SPLASH_RESOLUTIONS specified in 
/etc/sysconfig/bootsplash."
-                       echo >&2 "Not adding bootsplash to initrd."
+                       msg "No BOOT_SPLASH_RESOLUTIONS specified in 
/etc/sysconfig/bootsplash."
+                       msg "Not adding bootsplash to initrd."
                fi
        fi
 }
@@ -1108,19 +1119,19 @@
        debug "Generating fbsplash"
 
        if [ ! -x /usr/bin/splash_geninitramfs ]; then
-               echo >&2 "Failed to execute /usr/bin/splash_geninitramfs. Is 
splashutils package installed?"
+               msg "Failed to execute /usr/bin/splash_geninitramfs. Is 
splashutils package installed?"
                return
        fi
 
        if [ -z "$SPLASH_THEME" ]; then
-               echo >&2 "Please configure your /etc/sysconfig/fbsplash first."
-               echo >&2 "Generating fbsplashes skipped."
+               msg "Please configure your /etc/sysconfig/fbsplash first."
+               msg "Generating fbsplashes skipped."
                return
        fi
 
        if [ -z "$FB_SPLASH_RESOLUTIONS" ]; then
-               echo >&2 "No FB_SPLASH_RESOLUTIONS specified in 
/etc/sysconfig/fbsplash."
-               echo >&2 "Not adding fbsplash to initramfs."
+               msg "No FB_SPLASH_RESOLUTIONS specified in 
/etc/sysconfig/fbsplash."
+               msg "Not adding fbsplash to initramfs."
                return
        fi
 
@@ -1129,7 +1140,7 @@
                        /usr/bin/splash_geninitramfs -c $DESTDIR -r $res 
$SPLASH_THEME && \
                        debug "Added $res $SPLASH_THEME theme to initramfs."
                else
-                       echo >&2 "/etc/splash/$SPLASH_THEME/$res.cfg doesn't 
exist, skipped"
+                       msg "/etc/splash/$SPLASH_THEME/$res.cfg doesn't exist, 
skipped"
                fi
        done
 }
@@ -1401,7 +1412,7 @@
 # backwards compatible
 if [ "$USE_SUSPEND2" ]; then
        USE_TUXONICE=$USE_SUSPEND2
-       echo >&2 "USE_SUSPEND2 is deprecated, use USE_TUXONICE now instead."
+       msg "USE_SUSPEND2 is deprecated, use USE_TUXONICE now instead."
 fi
 
 while [ $# -gt 0 ]; do
@@ -1506,11 +1517,11 @@
                shift
                ;;
        --fs=*)
-               echo >&2 "Warning: --fs option is obsoleted. Use --initrdfs 
instead"
+               msg "Warning: --fs option is obsoleted. Use --initrdfs instead"
                INITRDFS=${1#--fs=}
                ;;
        --fs)
-               echo >&2 "Warning: --fs option is obsoleted. Use --initrdfs 
instead"
+               msg "Warning: --fs option is obsoleted. Use --initrdfs instead"
                INITRDFS=$2
                shift
                ;;
@@ -1546,7 +1557,7 @@
 fi
 
 if [ ! -f /boot/vmlinuz-"$kernel" ]; then
-       die "/boot/vmlinuz-$kernel doesn't exist, is your /boot mounted?"
+       msg "/boot/vmlinuz-$kernel doesn't exist, is your /boot mounted?"
 fi
 
 pack_version="`echo "$kernel"|awk -F. '{print sprintf("%03d%03d",$1,$2)}'`"
@@ -1561,7 +1572,7 @@
                        INITRDFS="rom"
                fi
        else
-               echo >&2 "Warning: FS configuration options is obsoleted. Use 
INITRDFS instead"
+               msg "Warning: FS configuration options is obsoleted. Use 
INITRDFS instead"
                INITRDFS="$FS"
        fi
 fi
@@ -1641,7 +1652,7 @@
 fi
 
 if [ ! -f /proc/mounts ]; then
-       echo >&2 "WARNING: /proc filesystem not mounted, may cause wrong 
results or failure."
+       msg "WARNING: /proc filesystem not mounted, may cause wrong results or 
failure."
 fi
 
 if [ -d /usr/lib64 ]; then
@@ -1895,7 +1906,7 @@
                IMAGESIZE=$(du -ks $DESTDIR | awk '{print 
int(($1+1023+512)/1024)*1024}')
                debug   "ext2 image size: $IMAGESIZE ($DESTDIR)"
                if [ "$IMAGESIZE" -gt 4096 ]; then
-                       echo >&2 "$PROGRAM: Your image size is larger than 
4096, Be sure to boot kernel with ramdisk_size=$IMAGESIZE!"
+                       msg "$PROGRAM: Your image size is larger than 4096, Be 
sure to boot kernel with ramdisk_size=$IMAGESIZE!"
                fi
 
                debug "Creating ext2 image $IMAGE"
@@ -1921,7 +1932,7 @@
                IMAGESIZE=$(stat -c %s $IMAGE | awk '{print 
int((($1/1024)+1023)/1024)*1024}')
                debug "Image size for romfs: ${IMAGESIZE}KiB ($IMAGE)"
                if [ "$IMAGESIZE" -gt 4096 ]; then
-                       echo >&2 "$PROGRAM: Your image size is larger than 
4096, Be sure to boot kernel with ramdisk_size=$IMAGESIZE!"
+                       msg "$PROGRAM: Your image size is larger than 4096, Be 
sure to boot kernel with ramdisk_size=$IMAGESIZE!"
                fi
                ;;
        cram|cramfs)
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to