[readonly/geninitrd/devel: 183/334] - write usage message to stdin not stderr - check version of LVM tools not LVM volumen format - adde

draenog draenog at pld-linux.org
Sat Nov 2 19:26:54 CET 2013


commit 77bcfc68aa5225161cbee52c00d01cf564164926
Author: Artur Frysiak <artur at frysiak.net>
Date:   Fri Jan 30 21:53:04 2004 +0000

    - write usage message to stdin not stderr
    - check version of LVM tools not LVM volumen format
    - added --lvmversion options
    
    
    svn-id: @3228

 geninitrd       | 32 ++++++++++++++++++++++----------
 geninitrd.8.xml |  9 ++++++++-
 2 files changed, 30 insertions(+), 11 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index 9547d61..5d3133f 100755
--- a/geninitrd
+++ b/geninitrd
@@ -40,13 +40,13 @@ modext=".o"
 BOOT_SPLASH=no
 
 usage () {
-	echo "usage: `basename $0` [--version] [-v] [-f] [--ifneeded] [--preload <module>]" 1>&2
-	echo "       [--with=<module>] [--image-version] [--fstab=<fstab>] [--nocompress]" 1>&2
-	echo "       [--initrdfs=rom|ext2|cram] [--modules-conf=<modules.conf>]" 1>&2
-	echo "       [--with-raidstart] [--without-raidstart] [--with-insmod-static]" 1>&2
-	echo "       [--without-bootsplash]" 1>&2
-	echo "       <initrd-image> <kernel-version>" 1>&2
-	echo "       (ex: `basename $0` /boot/initrd-2.2.5-15.img 2.2.5-15)" 1>&2
+	echo "usage: `basename $0` [--version] [-v] [-f] [--ifneeded] [--preload <module>]" 
+	echo "       [--with=<module>] [--image-version] [--fstab=<fstab>] [--nocompress]" 
+	echo "       [--initrdfs=rom|ext2|cram] [--modules-conf=<modules.conf>]" 
+	echo "       [--with-raidstart] [--without-raidstart] [--with-insmod-static]" 
+	echo "       [--without-bootsplash] [--with-lvmversion=1|2]" 
+	echo "       <initrd-image> <kernel-version>" 
+	echo "       (ex: `basename $0` /boot/initrd-2.2.5-15.img 2.2.5-15)" 
 	exit 1
 }
 
@@ -583,9 +583,14 @@ find_modules_for() {
 			echo "Please install lvm(2) and lvm(2)-initrd package and rerun $0."
 			exit 1
 		fi
+		if [ -z "$LVMVERSION" ] ; then 
+		    LVMVERSION=$(/sbin/initrd-lvm vgchange --version 2>/dev/null|head -n 1|awk '{gsub("vgdisplay: Logical Volume Manager ",""); gsub("LVM version:     ",""); gsub(/\..*/,"");print $1}')
+		    if [ -z "$LVMVERSION" ] ; then
+			    echo "WARNING: Can't determine LVM tools version. Please set LVMVERSION."
+		    fi
+		fi
 		if [ -z "$PVDEVICES" ] ; then
     		    VGVOLUME=$(/sbin/lvdisplay -c "$1" 2> /dev/null | awk -F":" ' { print $2 } ')
-		    VGFORMAT=$(/sbin/vgdisplay "${VGVOLUME}" 2> /dev/null | awk ' /Format/ { print $2 } ')
     		    PVDEVICES=$(/sbin/pvdisplay -c | awk -F":" -v vg="$VGVOLUME" ' BEGIN { devices="" } { if ($2 == vg) { devices = devices " " $1 } } END { print devices } ')
 		fi
 		if [ -n "$PVDEVICES" ] ; then
@@ -597,9 +602,9 @@ find_modules_for() {
 			echo "You can try to set PVDEVICES in /etc/sysconfig/geninitrd."
 			exit 1
 		fi
-		if [ "$VGFORMAT" = "lvm2" ]; then
+		if [ "$LVMVERSION" = "2" ]; then
     		    findmodule "-dm-mod"
-		elif [ "$VGFORMAT" = "lvm1" ]; then
+		elif [ "$LVMVERSION" = "1" ]; then
     		    findmodule "-lvm"
     		    findmodule "-lvm-mod"
 		else
@@ -676,6 +681,13 @@ while [ $# -gt 0 ]; do
 	--without-bootsplash)
 		BOOT_SPLASH="no"
 		;;
+	--lvmversion=)
+		LVMVERSION="`echo $1 | awk -F= '{print $2;}'`"
+		;;
+	--lvmversion)
+		LVMVERSION="$2"
+		shift
+		;;
 	--with=*)
 		BASICMODULES="$BASICMODULES `echo $1 | awk -F= '{print $2;}'`"
 		;;
diff --git a/geninitrd.8.xml b/geninitrd.8.xml
index c95353b..116cad8 100644
--- a/geninitrd.8.xml
+++ b/geninitrd.8.xml
@@ -23,6 +23,7 @@
       <arg rep="repeat">--preload=module</arg> 
       <arg>--fstab=fstab</arg>
       <arg>--raidtab=raidtab</arg>
+      <arg>--lvmversion=1|2</arg>
       <arg>--modules-conf=modules.conf</arg>
 	  <arg>--fs=rom|ext2|cram</arg>
 	  <arg>--with-insmod-static</arg>
@@ -166,7 +167,13 @@
 	<listitem>
 		<para>Use <filename>/sbin/insmod.static</filename> insteed of <command>bsp</command> bulitin insmod.</para>
 	</listitem>
-      </varlistentry>
+	</varlistentry>
+	<varlistentry>
+		<term>--lvmversion=1|2</term>
+		<listitem>
+			<para>Tell which version of LVM tools are used.</para>
+		</listitem>
+	</varlistentry>
     </variablelist>
 </refsect1>
 <refsect1>
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/readonly/geninitrd.git/commitdiff/398807324938659207036e520c0950a61ef50c11



More information about the pld-cvs-commit mailing list