2014-10-31 20:43:30 +01:00
|
|
|
# vim: set ts=4 sw=4 et:
|
|
|
|
|
|
|
|
update_check() {
|
2014-11-24 15:42:57 +01:00
|
|
|
local i p url sfname lpname bbname githubname rx found_version consider
|
2015-01-15 10:34:44 +01:00
|
|
|
local update_override=$XBPS_SRCPKGDIR/$XBPS_TARGET_PKG/update
|
|
|
|
local original_pkgname=$pkgname
|
|
|
|
|
|
|
|
if [ -r $update_override ]; then
|
|
|
|
. $update_override
|
|
|
|
if [ "$XBPS_UPDATE_CHECK_VERBOSE" ]; then
|
|
|
|
echo "using $XBPS_TARGET_PKG/update overrides" 1>&2
|
|
|
|
fi
|
|
|
|
fi
|
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
|
|
|
|
|
2015-01-15 10:34:44 +01:00
|
|
|
if [ -z "$site" ]; then
|
2014-10-31 20:43:30 +01:00
|
|
|
printf '%s\n' "$homepage"
|
|
|
|
for i in $distfiles; do
|
|
|
|
printf '%s\n' "${i%/*}/"
|
|
|
|
done
|
|
|
|
else
|
2015-01-15 10:34:44 +01:00
|
|
|
printf '%s\n' "$site"
|
2014-10-31 20:43:30 +01:00
|
|
|
fi |
|
|
|
|
while IFS= read -r url; do
|
2014-11-03 12:27:12 +01:00
|
|
|
rx=
|
2015-01-15 10:34:44 +01:00
|
|
|
if [ -z "$site" ]; then
|
2014-10-31 20:43:30 +01:00
|
|
|
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*)
|
2015-01-15 10:34:44 +01:00
|
|
|
url="http://code.google.com/p/$pkgname/downloads/list";;
|
2014-10-31 20:43:30 +01:00
|
|
|
*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.*)
|
2015-01-15 10:34:44 +01:00
|
|
|
pkgname=${pkgname#perl-};;
|
2016-05-13 17:35:35 +02:00
|
|
|
*pythonhosted.org*)
|
2015-02-10 12:12:12 +01:00
|
|
|
pkgname=${pkgname#python-}
|
2016-04-25 17:52:51 +02:00
|
|
|
url="https://pypi.io/simple/$pkgname";;
|
2014-10-31 20:43:30 +01:00
|
|
|
*github.com*)
|
|
|
|
githubname="$(printf %s "$url" | cut -d/ -f4,5)"
|
2014-11-02 16:31:17 +01:00
|
|
|
url="https://github.com/$githubname/tags"
|
2015-01-15 10:34:44 +01:00
|
|
|
rx='/archive/(v?|\Q'"$pkgname"'\E-)?\K[\d\.]+(?=\.tar\.gz")';;
|
2018-01-17 12:18:40 +01:00
|
|
|
*gitlab.com*)
|
|
|
|
gitlabname="$(printf %s "$url" | cut -d/ -f4,5)"
|
|
|
|
url="https://gitlab.com/$gitlabname/tags"
|
|
|
|
rx='href="/\Q'$gitlabname'\E/repository/[^\d\.]*\K[\d\.]+(?=/archive\.tar\.gz")';;
|
2014-11-24 15:42:57 +01:00
|
|
|
*bitbucket.org*)
|
|
|
|
bbname="$(printf %s "$url" | cut -d/ -f4,5)"
|
|
|
|
url="https://bitbucket.org/$bbname/downloads"
|
2018-03-24 18:30:25 +01:00
|
|
|
rx='/(get|downloads)/(v?|\Q'"$pkgname"'\E-)?\K[\d\.]+(?=\.tar)';;
|
2014-11-29 17:56:54 +01:00
|
|
|
*ftp.gnome.org*)
|
2015-01-21 19:31:17 +01:00
|
|
|
: ${pattern="\Q$pkgname\E-\K[0-9]\.[0-9]*[02468]\.[0-9.]*[0-9](?=)"}
|
2015-01-15 10:34:44 +01:00
|
|
|
url="http://ftp.gnome.org/pub/GNOME/sources/$pkgname/cache.json";;
|
2014-11-30 20:29:46 +01:00
|
|
|
*kernel.org/pub/linux/kernel/*)
|
|
|
|
rx=linux-'\K'${version%.*}'[\d.]+(?=\.tar\.xz)';;
|
2017-06-06 14:02:47 +02:00
|
|
|
*cran.r-project.org/src/contrib*)
|
|
|
|
rx='\b\Q'"${pkgname#R-cran-}"'\E_\K\d+(\.\d+)*(-\d+)?(?=\.tar)';;
|
2014-10-31 20:43:30 +01:00
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2015-01-15 10:34:44 +01:00
|
|
|
rx=${pattern:-$rx}
|
|
|
|
rx=${rx:-'(?<!-)\b\Q'"$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 |
|
2018-04-13 16:36:37 +02:00
|
|
|
tr _ . |
|
2014-10-31 20:43:30 +01:00
|
|
|
sort -Vu |
|
|
|
|
{
|
2015-01-15 10:34:44 +01:00
|
|
|
grep . || echo "NO VERSION found for $original_pkgname" 1>&2
|
2014-10-31 20:43:30 +01:00
|
|
|
} |
|
|
|
|
while IFS= read -r found_version; do
|
|
|
|
if [ -n "$XBPS_UPDATE_CHECK_VERBOSE" ]; then
|
|
|
|
echo "found version $found_version"
|
|
|
|
fi
|
|
|
|
consider=true
|
2015-01-15 10:34:44 +01:00
|
|
|
p="$ignore "
|
2014-10-31 20:43:30 +01:00
|
|
|
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
|
2015-01-15 10:34:44 +01:00
|
|
|
xbps-uhelper cmpver "$original_pkgname-${version}_1" \
|
|
|
|
"$original_pkgname-$(printf %s "$found_version" | tr - .)_1"
|
2014-10-31 20:43:30 +01:00
|
|
|
if [ $? = 255 ]; then
|
2015-01-15 10:34:44 +01:00
|
|
|
echo "${original_pkgname}-${version} -> ${original_pkgname}-${found_version}"
|
2014-10-31 20:43:30 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|