From 6d0ae1767dff6753b44a71c4629be3d5cb45aa84 Mon Sep 17 00:00:00 2001 From: Guido Trotter Date: Mon, 16 Feb 2009 10:25:28 +0000 Subject: [PATCH] Fix 1.2 compatibility 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 | 9 +++++---- create.in | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/common.sh b/common.sh index 941e425..78787d6 100644 --- 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 diff --git a/create.in b/create.in index 5f05c18..5916e6a 100755 --- 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 <> $TMPDIR/etc/fstab <