--- trunk/mage/usr/lib/mage/mage4.functions.sh 2009/11/20 22:39:11 943 +++ trunk/mage/usr/lib/mage/mage4.functions.sh 2010/06/28 18:08:15 1084 @@ -1225,16 +1225,20 @@ # clean up backup files (foo~) find ${MAGEDIR} -name *~ -exec rm '{}' ';' - # check if an newer mage version is available + # check if a newer mage version is available is_newer_mage_version_available } syncmage_tarball() { local latest_tarball + local latest_md5 local temp="$(mktemp -d)" local mirr mymirr + # try to get the md5 marked as latest on the server + latest_md5="mage-latest.md5" + # try to get the tarball marked as latest on the server latest_tarball="mage-latest.tar.bz2" @@ -1244,8 +1248,17 @@ mymirr="${mirr%/*}" echo -ne "${COLBLUE} --- ${COLDEFAULT}" - echo "fetching latest tarball from ${mymirr} ..." + echo "fetching latest md5 from ${mymirr} ..." + wget \ + --passive-ftp \ + --tries 3 \ + --continue \ + --progress bar \ + --directory-prefix=${temp} \ + ${mymirr}/rsync/tarballs/${latest_md5} + echo -ne "${COLBLUE} --- ${COLDEFAULT}" + echo "fetching latest tarball from ${mymirr} ..." wget \ --passive-ftp \ --tries 3 \ @@ -1263,6 +1276,14 @@ if [[ -f ${temp}/${latest_tarball} ]] then + # check md5 + if [[ ! -f ${temp}/${latest_md5} ]] + then + die "md5 is missing ... aborting" + else + ( cd ${temp}; md5sum --check ${lastest_md5} ) || die "md5 for ${lastest_tarball} failed" + fi + if [[ -d ${MAGEDIR} ]] then echo -ne "${COLBLUE} --- ${COLDEFAULT}" @@ -1278,9 +1299,12 @@ if [[ -d ${temp} ]] then echo -ne "${COLBLUE} --- ${COLDEFAULT}" - echo "clenaing temp-files ..." + echo "cleaning temp-files ..." rm -rf ${temp} fi + + # check if a newer mage version is available + is_newer_mage_version_available else die "Could not fetch the latest tarball ... aborting" fi