maint script gnome-latest.sh: support point versions, handle 404 errors

This commit is contained in:
Luca Bruno 2015-09-17 15:48:06 +02:00
parent 389e654e03
commit 39965bba04

View File

@ -24,7 +24,7 @@ if [ "$FTP_CLIENT" = "lftp" ]; then
} }
else else
ls_ftp() { ls_ftp() {
curl -l "$1"/ curl -s -l "$1"/
} }
fi fi
@ -36,15 +36,22 @@ if [ -z "$majorVersion" ]; then
read majorVersion read majorVersion
fi fi
if echo "$majorVersion" | grep -q "[0-9]\+\.[0-9]\+\.[0-9]\+"; then
# not a major version
version="$majorVersion"
majorVersion=$(echo "$majorVersion" | cut -d '.' -f 1,2)
fi
FTPDIR="${GNOME_FTP}/${project}/${majorVersion}" FTPDIR="${GNOME_FTP}/${project}/${majorVersion}"
#version=`curl -l ${FTPDIR}/ 2>/dev/null | grep LATEST-IS | sed -e s/LATEST-IS-//` #version=`curl -l ${FTPDIR}/ 2>/dev/null | grep LATEST-IS | sed -e s/LATEST-IS-//`
# gnome's LATEST-IS is broken. Do not trust it. # gnome's LATEST-IS is broken. Do not trust it.
files=$(ls_ftp "${FTPDIR}") if [ -z "$version" ]; then
declare -A versions files=$(ls_ftp "${FTPDIR}")
declare -A versions
for f in $files; do for f in $files; do
case $f in case $f in
(LATEST-IS-*|*.news|*.changes|*.sha256sum|*.diff*): (LATEST-IS-*|*.news|*.changes|*.sha256sum|*.diff*):
;; ;;
@ -62,14 +69,20 @@ for f in $files; do
echo "UNKNOWN FILE $f" echo "UNKNOWN FILE $f"
;; ;;
esac esac
done done
echo "Found versions ${!versions[@]}" >&2 echo "Found versions ${!versions[@]}" >&2
version=`echo ${!versions[@]} | sed -e 's/ /\n/g' | sort -t. -k1,1n -k 2,2n -k 3,3n | tail -n1` version=`echo ${!versions[@]} | sed -e 's/ /\n/g' | sort -t. -k1,1n -k 2,2n -k 3,3n | tail -n1`
echo "Latest version is: ${version}" >&2 echo "Latest version is: ${version}" >&2
fi
name=${project}-${version} name=${project}-${version}
echo "Fetching .sha256 file" >&2 echo "Fetching .sha256 file" >&2
sha256out=$(curl -s http://${FTPDIR}/${name}.sha256sum) sha256out=$(curl -s -f http://${FTPDIR}/${name}.sha256sum)
if [ "$?" -ne "0" ]; then
echo "Version not found" >&2
exit 1
fi
extensions=( "xz" "bz2" "gz" ) extensions=( "xz" "bz2" "gz" )
echo "Choosing archive extension (known are ${extensions[@]})..." >&2 echo "Choosing archive extension (known are ${extensions[@]})..." >&2