From 11e6561d93f7c648a920a4451ce25d5c9b78fc85 Mon Sep 17 00:00:00 2001 From: Bob Gilligan Date: Thu, 18 Feb 2010 18:02:56 -0800 Subject: Bugfix 5360: Get name of image from correct source. The name of a system image is supposed to match the Vyatta version string. Previously, the install-image script determined the name of the image being installed by parsing a field in the Vyatta version file on the image being installed. But the format of that file has changed, and may change again the future, so it is not a good source of the Vyatta version string. The most accurate way to determine the Vyatta version string is to look up the debian package version string associated with the vyatta-version package on the image being installed. This changes the install-image script to get the system image name that way. (cherry picked from commit e1864411c77e688b1b67de40441550b1f1eba055) --- scripts/install/install-functions | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'scripts/install/install-functions') diff --git a/scripts/install/install-functions b/scripts/install/install-functions index 5a77a0c6..3f85e75b 100755 --- a/scripts/install/install-functions +++ b/scripts/install/install-functions @@ -293,19 +293,20 @@ get_cur_version () # being installed. this can be from live CD boot or from a ISO image file. get_new_version () { - ver_path=/opt/vyatta/etc/version + ver_path=/var/lib/dpkg/status ver_file=${CD_SQUASH_ROOT}${ver_path} if [ -f "$ver_file" ]; then # CD_SQUASH_ROOT is set up => we are installing with a specified ISO # image file. use the version string from there. - grep '^Version' $ver_file | awk '{ print $3 }' + dpkg -l --root=${CD_SQUASH_ROOT} | \ + grep "^ii vyatta-version" | awk '{print $3}' return fi ver_file=${ver_path} if is_live_cd_boot && [ -f "$ver_file" ]; then # we are installing from a live CD boot - grep '^Version' $ver_file | awk '{ print $3 }' + dpkg -l | grep "^ii vyatta-version" | awk '{print $3}' return fi -- cgit v1.2.3 From 81df5c53d7dd6e7d3869ce96b3febc172e21611b Mon Sep 17 00:00:00 2001 From: Bob Gilligan Date: Mon, 8 Mar 2010 17:36:22 -0800 Subject: Use more reliable method for determining system version. --- scripts/install/install-functions | 7 ++++--- scripts/install/install-image | 8 ++++++-- scripts/install/install-image-existing | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'scripts/install/install-functions') diff --git a/scripts/install/install-functions b/scripts/install/install-functions index 3f85e75b..d88df618 100755 --- a/scripts/install/install-functions +++ b/scripts/install/install-functions @@ -281,7 +281,7 @@ is_union_install () # outputs the version string of the current running version. get_cur_version () { - ver=`dpkg -l | grep "^ii vyatta-version" | awk '{print $3}'` + ver=`dpkg-query --showformat='${Version}' --show vyatta-version` if [ -z "$ver" ]; then echo "UNKNOWN" else @@ -299,14 +299,15 @@ get_new_version () # CD_SQUASH_ROOT is set up => we are installing with a specified ISO # image file. use the version string from there. dpkg -l --root=${CD_SQUASH_ROOT} | \ - grep "^ii vyatta-version" | awk '{print $3}' + grep "^.. vyatta-version " | awk '{print $3}' return fi ver_file=${ver_path} if is_live_cd_boot && [ -f "$ver_file" ]; then # we are installing from a live CD boot - dpkg -l | grep "^ii vyatta-version" | awk '{print $3}' + ver=`dpkg-query --showformat='${Version}' --show vyatta-version` + echo $ver return fi diff --git a/scripts/install/install-image b/scripts/install/install-image index fd306aec..f717588b 100755 --- a/scripts/install/install-image +++ b/scripts/install/install-image @@ -211,9 +211,13 @@ else CURVER=$(get_cur_version) fi NEWVER=$(get_new_version) -if [ -z "$CURVER" ] || [ -z "$NEWVER" ]; then - fail_exit 'Cannot find release version.' +if [ -z "$CURVER" ] ; then + fail_exit 'Cannot find current release version.' fi +if [ -z "$NEWVER" ] ; then + fail_exit 'Cannot find new release version.' +fi + if [ "$CURVER" == "$NEWVER" ]; then fail_exit "Version \"$NEWVER\" is already installed." fi diff --git a/scripts/install/install-image-existing b/scripts/install/install-image-existing index 1514d0a1..86a27f3e 100755 --- a/scripts/install/install-image-existing +++ b/scripts/install/install-image-existing @@ -32,7 +32,7 @@ if [ -z "$CURVER" ]; then fi # get new version string. this is from the squashfs image. -NEWVER=`dpkg -l --root=${CD_SQUASH_ROOT} | grep "^ii vyatta-version" | awk '{print $3}'` +NEWVER=`dpkg -l --root=${CD_SQUASH_ROOT} | grep "^.. vyatta-version " | awk '{print $3}'` if [ -z "$NEWVER" ]; then failure_exit 'Cannot find new release version.' -- cgit v1.2.3