Fix 1.2 compatibility
authorGuido Trotter <ultrotter@google.com>
Mon, 16 Feb 2009 10:25:28 +0000 (10:25 +0000)
committerGuido Trotter <ultrotter@google.com>
Mon, 16 Feb 2009 10:25:28 +0000 (10:25 +0000)
getopt must be executed outside of the get_api5_arguments function,
because there $@ will be overridden.

vol_id may return an error on old distributions (dapper) in that case we
just... err... well... ignore the error and forget to set up the swap
partition in fstab?? :)

Reviewed-by: iustinp

common.sh
create.in

index 941e425..78787d6 100644 (file)
--- a/common.sh
+++ b/common.sh
@@ -17,10 +17,9 @@ if [ -z "$VOL_ID" ]; then
 fi
 
 get_api5_arguments() {
-  TEMP=`getopt -o o:n:i:b:s: -n '$0' -- "$@"`
-  if [ $? != 0 ] ; then log_error "Terminating..."; exit 1 ; fi
+  GETOPT_RESULT=$*
   # Note the quotes around `$TEMP': they are essential!
-  eval set -- "$TEMP"
+  eval set -- "$GETOPT_RESULT"
   while true; do
     case "$1" in
       -i|-n) instance=$2; shift 2;;
@@ -82,7 +81,9 @@ get_api10_arguments() {
 
 if [ -z "$OS_API_VERSION" -o "$OS_API_VERSION" = "5" ]; then
   OS_API_VERSION=5
-  get_api5_arguments
+  GETOPT_RESULT=`getopt -o o:n:i:b:s: -n '$0' -- "$@"`
+  if [ $? != 0 ] ; then log_error "Terminating..."; exit 1 ; fi
+  get_api5_arguments $GETOPT_RESULT
 elif [ "$OS_API_VERSION" = "10" ]; then
   get_api10_arguments
 else
index 5f05c18..5916e6a 100755 (executable)
--- a/create.in
+++ b/create.in
@@ -96,7 +96,7 @@ root_uuid=$($VOL_ID -u $filesystem_dev )
 
 if [ -n "$swapdev" ]; then
   mkswap $swapdev
-  swap_uuid=$($VOL_ID -u $swapdev )
+  swap_uuid=$($VOL_ID -u $swapdev || true )
 fi
 
 TMPDIR=`mktemp -d` || exit 1
@@ -155,7 +155,7 @@ UUID=$root_uuid   /               ext3    defaults        0       1
 proc              /proc           proc    defaults        0       0
 EOF
 
-[ -n "$swapdev" ] && cat >> $TMPDIR/etc/fstab <<EOF
+[ -n "$swapdev" -a -n "$swap_uuid" ] && cat >> $TMPDIR/etc/fstab <<EOF
 UUID=$swap_uuid   swap            swap    defaults        0       0
 EOF