From 50191049f5c1d7b823bc4a018e989bdd6596d0ed Mon Sep 17 00:00:00 2001 From: Valentin Vidic Date: Fri, 5 Sep 2008 17:03:54 +0200 Subject: [PATCH] Require latest carnet-upgrade version. --- debian/control | 2 +- src/actions/main.queue | 1 + src/cn-upgrade | 4 ++-- src/data.sh | 3 +++ src/functions.sh | 25 ++++++++++++++++++++++++- 5 files changed, 31 insertions(+), 4 deletions(-) diff --git a/debian/control b/debian/control index 213a4c9..fec2101 100644 --- a/debian/control +++ b/debian/control @@ -7,7 +7,7 @@ Standards-Version: 3.7.3 Package: carnet-upgrade Architecture: all -Depends: dialog, ${misc:Depends} +Depends: dialog, wget, ${misc:Depends} Description: CARNet distribution upgrade script This package provides cn-upgrade, a helper script to facilitate upgrades between different versions diff --git a/src/actions/main.queue b/src/actions/main.queue index 0335654..d7b116f 100644 --- a/src/actions/main.queue +++ b/src/actions/main.queue @@ -1,5 +1,6 @@ # Full upgrade true first_warning +true check_my_version true check_apache_version true check_upgrade true check_grsec_kernel diff --git a/src/cn-upgrade b/src/cn-upgrade index fa46875..778b6ba 100755 --- a/src/cn-upgrade +++ b/src/cn-upgrade @@ -2,7 +2,7 @@ # last update: 2005-01-07 # Zoran 'jelly' Dzelajlija # Ivan 'ico' Rako -version="carnet-upgrade v4.0.6" +version="4.0.6" # restart upgrade under script for logging purposes if [ "$1" == "--no-script" ]; then @@ -29,7 +29,7 @@ cnup="/usr/share/carnet-upgrade" . ${ROOT}${cnup}/messages.sh . ${ROOT}${cnup}/functions.sh -log "$version starting" +log "carnet-upgrade v$version starting" main_queuetab="${cnup}/actions/main.queue" post_upgrade_queuetab="/var/lib/carnet-upgrade/post_upgrade.queue" diff --git a/src/data.sh b/src/data.sh index bbb0b6c..0e8b735 100644 --- a/src/data.sh +++ b/src/data.sh @@ -30,6 +30,9 @@ webalizer-cn 2.01.10-1 xinetd-cn 2:2.3.13-1 ' +# URL to use for checking the latest version of carnet-upgrade itself +packages_uri='ftp://ftp.carnet.hr/carnet-debian/dists/carnet-sarge/main/binary-all/Packages' + # Packages to forcibly install before installing the rest with dist-upgrade, # because dist-upgrade would rather remove or keep them back them. packages_first=' diff --git a/src/functions.sh b/src/functions.sh index 4512ee6..6f85840 100644 --- a/src/functions.sh +++ b/src/functions.sh @@ -303,7 +303,7 @@ what_upgrade () { # funkcija za ispis paketa koje treba upgradeati check_upgrade () { local upgrade - upgrade="`what_upgrade`" + upgrade=${1:-"`what_upgrade`"} if [ "$upgrade" ]; then notice " @@ -323,6 +323,29 @@ Nakon toga ponovno pozovite ovu skriptu." fi } +# try to check if we are using the latest version of carnet-upgrade script +check_my_version () { + local packages latest_version + + packages=$(mktemp /var/lib/carnet-upgrade/Packages.XXXXXX) + if wget -q -O$packages $packages_uri; then + latest_version=$(sed -ne \ + '/Package: carnet-upgrade/,/Description:/{ /Version: /s///p }' \ + $packages) + rm -f $packages + + if [ "$latest_version" ]; then + log "Running carnet-upgrade version is $version" + log "Latest carnet-upgrade version is $latest_version" + if dpkg --compare-versions "$version" lt "$latest_version"; then + check_upgrade " carnet-upgrade" + else log "Already using the latest carnet-upgrade version."; fi + else log "Failed to get latest version, skipping check."; fi + else log "Failed to download Packages file, skipping check."; fi + + rm -f $packages +} + # if apache is installed make sure it's version 2 check_apache_version () { -- 1.7.10.4