2014-10-31 20:43:30 +01:00
|
|
|
# vim: set ts=4 sw=4 et:
|
|
|
|
|
|
|
|
update_check() {
|
2014-11-03 12:26:49 +01:00
|
|
|
local i p url sfname lpname githubname rx found_version consider
|
2014-10-31 21:24:07 +01:00
|
|
|
|
2014-11-01 15:23:51 +01:00
|
|
|
if ! type curl >/dev/null 2>&1; then
|
2014-10-31 21:24:07 +01:00
|
|
|
echo "ERROR: cannot find \`curl' executable!"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2014-10-31 20:43:30 +01:00
|
|
|
export LC_ALL=C
|
|
|
|
: ${update_pkgname:=$pkgname}
|
|
|
|
|
|
|
|
if [ -z "$update_site" ]; then
|
|
|
|
printf '%s\n' "$homepage"
|
|
|
|
for i in $distfiles; do
|
|
|
|
printf '%s\n' "${i%/*}/"
|
|
|
|
done
|
|
|
|
else
|
|
|
|
printf '%s\n' "$update_site"
|
|
|
|
fi |
|
|
|
|
while IFS= read -r url; do
|
2014-11-03 12:27:12 +01:00
|
|
|
rx=
|
2014-10-31 20:43:30 +01:00
|
|
|
if [ -z "$update_site" ]; then
|
|
|
|
case "$url" in
|
|
|
|
*sourceforge.net/sourceforge*)
|
2014-11-01 19:04:21 +01:00
|
|
|
sfname="$(printf %s "$url" | cut -d/ -f5)"
|
|
|
|
url="http://sourceforge.net/projects/$sfname/rss?limit=200";;
|
2014-10-31 20:43:30 +01:00
|
|
|
*code.google.com*|*googlecode*)
|
|
|
|
url="http://code.google.com/p/$update_pkgname/downloads/list";;
|
|
|
|
*launchpad.net*)
|
2014-11-01 19:43:55 +01:00
|
|
|
lpname="$(printf %s "$url" | cut -d/ -f4)"
|
|
|
|
url="https://launchpad.net/$lpname/+download";;
|
2014-10-31 20:43:30 +01:00
|
|
|
*cpan.*)
|
|
|
|
update_pkgname=${update_pkgname#perl-};;
|
|
|
|
*pypi.python.org*)
|
|
|
|
update_pkgname=${update_pkgname#python-};;
|
|
|
|
*github.com*)
|
|
|
|
githubname="$(printf %s "$url" | cut -d/ -f4,5)"
|
2014-11-02 16:31:17 +01:00
|
|
|
url="https://github.com/$githubname/tags"
|
|
|
|
rx='/archive/(v?|\Q'"$update_pkgname"'\E-)?\K[\d\.]+(?=\.tar\.gz")';;
|
2014-10-31 20:43:30 +01:00
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
rx=${update_pattern:-$rx}
|
2014-11-02 15:54:08 +01:00
|
|
|
rx=${rx:-'(?<!-)\b\Q'"$update_pkgname"'\E[-_]?((src|source)[-_])?\K([^-/_\s]*?\d[^-/_\s]*?)(?=(?:[-_.](?:src|source|orig))?\.(?:[jt]ar|shar|t[bglx]z|tbz2|zip))\b'}
|
2014-10-31 20:43:30 +01:00
|
|
|
|
|
|
|
if [ -n "$XBPS_UPDATE_CHECK_VERBOSE" ]; then
|
|
|
|
echo "fetching $url" 1>&2
|
|
|
|
fi
|
2014-11-02 15:45:57 +01:00
|
|
|
curl -A "xbps-src-update-check/$XBPS_SRC_VERSION" --max-time 10 -Lsk "$url" |
|
2014-10-31 20:43:30 +01:00
|
|
|
grep -Po -i "$rx"
|
|
|
|
done |
|
|
|
|
sort -Vu |
|
|
|
|
{
|
|
|
|
grep . || echo "NO VERSION found for $pkgname" 1>&2
|
|
|
|
} |
|
|
|
|
while IFS= read -r found_version; do
|
|
|
|
if [ -n "$XBPS_UPDATE_CHECK_VERBOSE" ]; then
|
|
|
|
echo "found version $found_version"
|
|
|
|
fi
|
|
|
|
consider=true
|
|
|
|
p="$update_ignore "
|
|
|
|
while [ -n "$p" ]; do
|
|
|
|
i=${p%% *}
|
|
|
|
p=${p#* }
|
|
|
|
case "$found_version" in
|
|
|
|
$i)
|
|
|
|
consider=false
|
|
|
|
if [ -n "$XBPS_UPDATE_CHECK_VERBOSE" ]; then
|
|
|
|
echo "ignored $found_version due to $i"
|
|
|
|
fi
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
if $consider; then
|
2014-11-01 20:13:34 +01:00
|
|
|
xbps-uhelper cmpver "$pkgname-${version}_1" \
|
|
|
|
"$pkgname-$(printf %s "$found_version" | tr - .)_1"
|
2014-10-31 20:43:30 +01:00
|
|
|
if [ $? = 255 ]; then
|
2014-10-31 21:24:07 +01:00
|
|
|
echo "${pkgname}-${version} -> ${pkgname}-${found_version}"
|
2014-10-31 20:43:30 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|