[readonly/geninitrd: 520/1068] Introduce msg() for messages. Use everywhere.

draenog draenog at pld-linux.org
Sat Nov 2 19:56:07 CET 2013


commit 779a218a20b706eed927e0a4953a41e2b79cc61e
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Wed Nov 7 11:55:07 2007 +0000

    Introduce msg() for messages. Use everywhere.
    
    svn-id: @9008

 geninitrd | 79 ++++++++++++++++++++++++++++++++++++---------------------------
 1 file changed, 45 insertions(+), 34 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index 90db5a5..3faeaaa 100755
--- a/geninitrd
+++ b/geninitrd
@@ -98,14 +98,25 @@ usage() {
 	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 @@ busybox_applet() {
 		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 @@ BEGIN { here = 0 }
 
 	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 @@ find_modules_md() {
 			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 @@ find_modules_ide() {
 _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 @@ find_modules_for_devpath() {
 		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 @@ modules_add_linuxrc() {
 		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 @@ initrd_gen_bootsplash() {
 
 	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 @@ initrd_gen_bootsplash() {
 					/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 @@ initrd_gen_fbsplash() {
 	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 @@ initrd_gen_fbsplash() {
 			/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 @@ fi
 # 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 @@ while [ $# -gt 0 ]; do
 		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 @@ if [ -z "$target" -o -z "$kernel" ]; then
 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 @@ if [ -z "$INITRDFS" ]; then
 			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 @@ if is_yes "$FB_SPLASH"; then
 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 @@ case "$INITRDFS" in
 		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 @@ case "$INITRDFS" in
 		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)
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/readonly/geninitrd.git/commitdiff/147754ca159d40ca5eb541074dc043d8cbd92090



More information about the pld-cvs-commit mailing list