autodist-upstream-updates: fixes and some code rework

This commit is contained in:
Silvan Calarco 2013-11-09 14:34:49 +01:00
parent 094174a2b6
commit dd9fb71c1b

View File

@ -43,6 +43,7 @@ function usage()
echo
echo " -h: generate distromatic HTML output"
echo " -m: report missing packages only"
echo " -s: skip fetching and parsing upstream updates"
echo " -u: output not up-to-date packages only"
echo " -q: produces quite output"
echo " -r repository: specify the distromatic base (default: devel)"
@ -78,10 +79,10 @@ function version_compare()
A=$1
B=$2
if [[ ${1} =~ "^[0-9]+$" && ${2} =~ "^[0-9]+$" ]]; then
if [ ${A/[a-zA-Z_]*} -gt ${B/[a-zA-Z_]*} ]; then
if [[ ${1} =~ ^[0-9]+$ && ${2} =~ ^[0-9]+$ ]]; then
if [ $((10#${A/[a-zA-Z_]*})) -gt $((10#${B/[a-zA-Z_]*})) ]; then
return 1
elif [ ${A/[a-zA-Z_]*} -lt ${B/[a-zA-Z_]*} ]; then
elif [ $((10#${A/[a-zA-Z_]*})) -lt $((10#${B/[a-zA-Z_]*})) ]; then
return 2
fi
else
@ -132,6 +133,7 @@ while [ "$1" ]; do
else
missing_only=1
fi ;;
-s) skip_parsing=1 ;;
-u) needupdate_only=1 ;;
-r) [ "$2" ] || {
echo "Error: option -r requires repository name as parameter"
@ -166,17 +168,15 @@ UPDATES_DB=$CACHE_DIR/upstream-updates
ALIASES_DB=$CACHE_DIR/aliases
MANUALVER_DB=$CACHE_DIR/manualver
tmpfile=`mktemp -q -t autodist-upstream-updates.XXXXXXXX`
buildstmp=`mktemp -q -t autodist-upstream-updates.XXXXXXXX`
tail -n+2 $BUILDS_FILE > $buildstmp
parse_arch_linux() {
# parse Arch Linux package list
[ "$quiet" ] || echo -n "Parsing Arch Linux packages list..." >&2
#for page in `seq 1 45`; do
for rep in core community extra; do
# SOURCEURL="https://www.archlinux.org/packages/?page=$page&sort=-last_update&q=&arch=i686&maintainer=&flagged="
SOURCEURL="http://lug.mtu.edu/archlinux/$rep/os/i686/"
curl -s "$SOURCEURL" | \
curl -L -s "$SOURCEURL" | \
grep ".pkg." | grep -v ".sig\"" | \
while read line; do
line=`echo $line | sed "s|.*href=\"\([^\"]*\)\">.*|\1|"`
@ -195,11 +195,13 @@ for rep in core community extra; do
done
done
rm -f $buildstmp
}
parse_xorg() {
# parse X.org stable packages list
[ "$quiet" ] || echo "Parsing X.org release ftp directory..." >&2
SOURCEURL="ftp://ftp.x.org/pub/$XORG_RELEASE/src/everything/"
curl -s $SOURCEURL -l | sed "s|\.tar\..*||" | sort -u |
curl -L -s $SOURCEURL -l | sed "s|\.tar\..*||" | sort -u |
while read line; do
if [ "$line" ]; then
ver=`echo $line | sed "s|.*-||"`
@ -213,12 +215,14 @@ while read line; do
[ "$pkg" -a "$ver" ] && echo "$pkg $ver $SOURCEURL ${alias/* /}" >> $tmpfile
fi
done
}
parse_gnome() {
# parse Gnome stable packages list
[ "$quiet" ] || echo "Parsing GNOME stable versions file..." >&2
for f in versions-stable versions-stable-extras; do
SOURCEURL="http://people.gnome.org/~vuntz/tmp/versions/$f"
curl -s $SOURCEURL | grep -v "^#" |
SOURCEURL="https://people.gnome.org/~vuntz/tmp/versions/$f"
curl -s -L $SOURCEURL | grep -v "^#" |
while read line; do
if [ "$line" ]; then
IFS=":"
@ -231,7 +235,9 @@ for f in versions-stable versions-stable-extras; do
fi
done
done
}
parse_distromatic() {
# parse distrowatch.com packages list
[ "$quiet" ] || echo "Parsing Distrowatch packages list..." >&2
SOURCEURL="http://distrowatch.com/packages.php"
@ -248,6 +254,17 @@ while read line; do
echo "$pkg $ver $SOURCEURL ${alias/* /}" >> $tmpfile
}
done
}
if [ ! "$skip_parsing" ]; then
tmpfile=`mktemp -q -t autodist-upstream-updates.XXXXXXXX`
buildstmp=`mktemp -q -t autodist-upstream-updates.XXXXXXXX`
tail -n+2 $BUILDS_FILE > $buildstmp
parse_arch_linux
parse_xorg
parse_gnome
parse_distromatic
cat $tmpfile | sort -uf > $UPDATES_DB.tmp
rm -f $tmpfile
@ -276,6 +293,7 @@ while read pkg ver upsource alias; do
lastver=$ver
done < $UPDATES_DB.tmp
rm -f $UPDATES_DB.tmp
fi
> $UPDATES_DB.missing
> $BUILDLIST_FILE
@ -311,6 +329,7 @@ while read pkg ver upsource alias; do
pkgrep=$4
version_find_bigger $pkgver ${ver/-/.}
vercmp=$?
#echo "$pkgname - version_find_bigger $pkgver ${ver/-/.} result=$vercmp"
[ "${vercmp}" != "2" -a "$needupdate_only" ] && continue
[ "$found_manual" ] && pkgname=$3
[ "$found_alias" -o "$found_manual" ] && nameadd="$pkg" || unset nameadd