2014-10-31 19:43:30 +00:00
|
|
|
# vim: set ts=4 sw=4 et:
|
|
|
|
|
|
|
|
update_check() {
|
2014-11-24 14:42:57 +00:00
|
|
|
local i p url sfname lpname bbname githubname rx found_version consider
|
2015-01-15 09:34:44 +00:00
|
|
|
local update_override=$XBPS_SRCPKGDIR/$XBPS_TARGET_PKG/update
|
|
|
|
local original_pkgname=$pkgname
|
2018-07-22 13:39:08 +00:00
|
|
|
local urlpfx urlsfx
|
2018-12-31 11:34:10 +00:00
|
|
|
local -A fetchedurls
|
2015-01-15 09:34:44 +00:00
|
|
|
|
|
|
|
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 20:24:07 +00:00
|
|
|
|
2014-11-01 14:23:51 +00:00
|
|
|
if ! type curl >/dev/null 2>&1; then
|
2014-10-31 20:24:07 +00:00
|
|
|
echo "ERROR: cannot find \`curl' executable!"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2014-10-31 19:43:30 +00:00
|
|
|
export LC_ALL=C
|
|
|
|
|
2015-01-15 09:34:44 +00:00
|
|
|
if [ -z "$site" ]; then
|
2014-10-31 19:43:30 +00:00
|
|
|
printf '%s\n' "$homepage"
|
|
|
|
for i in $distfiles; do
|
|
|
|
printf '%s\n' "${i%/*}/"
|
|
|
|
done
|
|
|
|
else
|
2015-01-15 09:34:44 +00:00
|
|
|
printf '%s\n' "$site"
|
2014-10-31 19:43:30 +00:00
|
|
|
fi |
|
2018-07-22 13:39:08 +00:00
|
|
|
# filter loop: if version are "folder" name based,
|
|
|
|
# substitute original url by every folder based ones (expand)
|
|
|
|
while IFS= read -r url; do
|
2019-04-29 08:23:15 +00:00
|
|
|
# default case: don't rewrite url
|
|
|
|
printf '%s\n' "$url"
|
2019-04-29 08:27:34 +00:00
|
|
|
if [ "$single_directory" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
2018-07-22 13:39:08 +00:00
|
|
|
rx=
|
|
|
|
urlpfx="${url}"
|
|
|
|
urlsfx=
|
2019-04-29 08:26:49 +00:00
|
|
|
dirpfx=
|
2018-07-22 13:39:08 +00:00
|
|
|
case "$url" in
|
2019-04-29 08:30:25 +00:00
|
|
|
*.voidlinux.*|\
|
|
|
|
*sourceforge.net/sourceforge*|\
|
|
|
|
*code.google.com*|*googlecode*|\
|
|
|
|
*launchpad.net*|\
|
|
|
|
*cpan.*|\
|
|
|
|
*pythonhosted.org*|\
|
|
|
|
*github.com*|\
|
2019-06-01 12:23:37 +00:00
|
|
|
*//gitlab.*|\
|
2019-04-29 08:30:25 +00:00
|
|
|
*bitbucket.org*|\
|
|
|
|
*ftp.gnome.org*|\
|
|
|
|
*kernel.org/pub/linux/kernel/*|\
|
|
|
|
*cran.r-project.org/src/contrib*|\
|
2019-06-01 12:23:37 +00:00
|
|
|
*rubygems.org*|\
|
|
|
|
*crates.io*)
|
2019-04-29 08:30:25 +00:00
|
|
|
continue
|
|
|
|
;;
|
2019-04-29 08:26:49 +00:00
|
|
|
*)
|
|
|
|
vdpfx=${vdprefix:-"|v|\\Q$pkgname\\E"}
|
|
|
|
vdsfx=${vdsuffix:-"|\\.x"}
|
|
|
|
match=$(grep -Po "^[^/]+//[^/]+(/.+)?/($vdpfx)(?=[-_.0-9]*[0-9](?<!\\Q$pkgname\\E)($vdsfx)/)" <<< "$url")
|
|
|
|
if [ "$?" = 0 ]; then
|
|
|
|
urlpfx="${match%/*}/"
|
|
|
|
dirpfx="${match##*/}"
|
|
|
|
urlsfx="${url#$urlpfx}"
|
|
|
|
urlsfx="${urlsfx#*/}"
|
|
|
|
rx="href=[\"']?(\\Q$urlpfx\\E)?\\.?/?\\K\\Q$dirpfx\\E[-_.0-9]*[0-9]($vdsfx)[\"'/]"
|
|
|
|
fi
|
2018-07-22 13:39:08 +00:00
|
|
|
;;
|
|
|
|
esac
|
2019-04-29 08:23:15 +00:00
|
|
|
if [ "$rx" ]; then
|
2018-07-22 13:39:08 +00:00
|
|
|
# substitute url if needed
|
|
|
|
if [ -n "$XBPS_UPDATE_CHECK_VERBOSE" ]; then
|
|
|
|
echo "(folder) fetching $urlpfx" 1>&2
|
|
|
|
fi
|
2019-04-29 08:25:27 +00:00
|
|
|
skipdirs=
|
2018-07-22 13:39:08 +00:00
|
|
|
curl -A "xbps-src-update-check/$XBPS_SRC_VERSION" --max-time 10 -Lsk "$urlpfx" |
|
2019-04-29 08:25:27 +00:00
|
|
|
grep -Po -i "$rx" | sort -Vru |
|
|
|
|
while IFS= read -r newver; do
|
|
|
|
newurl="${urlpfx}${newver}${urlsfx}"
|
|
|
|
if [ "$newurl" = "$url" ]; then
|
|
|
|
skipdirs=yes
|
|
|
|
fi
|
|
|
|
if [ -z "$skipdirs" ]; then
|
|
|
|
printf '%s\n' "$newurl"
|
|
|
|
fi
|
|
|
|
done
|
2018-07-22 13:39:08 +00:00
|
|
|
fi
|
|
|
|
done |
|
2014-10-31 19:43:30 +00:00
|
|
|
while IFS= read -r url; do
|
2014-11-03 11:27:12 +00:00
|
|
|
rx=
|
2015-01-15 09:34:44 +00:00
|
|
|
if [ -z "$site" ]; then
|
2014-10-31 19:43:30 +00:00
|
|
|
case "$url" in
|
|
|
|
*sourceforge.net/sourceforge*)
|
2014-11-01 18:04:21 +00:00
|
|
|
sfname="$(printf %s "$url" | cut -d/ -f5)"
|
2019-02-18 15:20:12 +00:00
|
|
|
url="https://sourceforge.net/projects/$sfname/rss?limit=200";;
|
2014-10-31 19:43:30 +00:00
|
|
|
*code.google.com*|*googlecode*)
|
2015-01-15 09:34:44 +00:00
|
|
|
url="http://code.google.com/p/$pkgname/downloads/list";;
|
2014-10-31 19:43:30 +00:00
|
|
|
*launchpad.net*)
|
2014-11-01 18:43:55 +00:00
|
|
|
lpname="$(printf %s "$url" | cut -d/ -f4)"
|
|
|
|
url="https://launchpad.net/$lpname/+download";;
|
2014-10-31 19:43:30 +00:00
|
|
|
*cpan.*)
|
2015-01-15 09:34:44 +00:00
|
|
|
pkgname=${pkgname#perl-};;
|
2016-05-13 15:35:35 +00:00
|
|
|
*pythonhosted.org*)
|
2015-02-10 11:12:12 +00:00
|
|
|
pkgname=${pkgname#python-}
|
2019-01-02 16:19:26 +00:00
|
|
|
pkgname=${pkgname#python3-}
|
2018-04-20 17:34:04 +00:00
|
|
|
url="https://pypi.org/simple/$pkgname";;
|
2014-10-31 19:43:30 +00:00
|
|
|
*github.com*)
|
|
|
|
githubname="$(printf %s "$url" | cut -d/ -f4,5)"
|
2014-11-02 15:31:17 +00:00
|
|
|
url="https://github.com/$githubname/tags"
|
2015-01-15 09:34:44 +00:00
|
|
|
rx='/archive/(v?|\Q'"$pkgname"'\E-)?\K[\d\.]+(?=\.tar\.gz")';;
|
2019-06-01 12:23:37 +00:00
|
|
|
*//gitlab.*)
|
2018-05-23 21:34:29 +00:00
|
|
|
gitlaburl="$(printf %s "$url" | cut -d/ -f1-5)"
|
|
|
|
url="$gitlaburl/tags"
|
2018-05-11 21:16:53 +00:00
|
|
|
rx='/archive/[^/]+/\Q'"$pkgname"'\E-v?\K[\d\.]+(?=\.tar\.gz")';;
|
2014-11-24 14:42:57 +00:00
|
|
|
*bitbucket.org*)
|
|
|
|
bbname="$(printf %s "$url" | cut -d/ -f4,5)"
|
|
|
|
url="https://bitbucket.org/$bbname/downloads"
|
2018-03-24 17:30:25 +00:00
|
|
|
rx='/(get|downloads)/(v?|\Q'"$pkgname"'\E-)?\K[\d\.]+(?=\.tar)';;
|
2014-11-29 16:56:54 +00:00
|
|
|
*ftp.gnome.org*)
|
2018-09-05 18:18:07 +00:00
|
|
|
: ${pattern="\Q$pkgname\E-\K[0-9]+\.[0-9]*[02468]\.[0-9.]*[0-9](?=)"}
|
2015-01-15 09:34:44 +00:00
|
|
|
url="http://ftp.gnome.org/pub/GNOME/sources/$pkgname/cache.json";;
|
2014-11-30 19:29:46 +00:00
|
|
|
*kernel.org/pub/linux/kernel/*)
|
|
|
|
rx=linux-'\K'${version%.*}'[\d.]+(?=\.tar\.xz)';;
|
2017-06-06 12:02:47 +00:00
|
|
|
*cran.r-project.org/src/contrib*)
|
|
|
|
rx='\b\Q'"${pkgname#R-cran-}"'\E_\K\d+(\.\d+)*(-\d+)?(?=\.tar)';;
|
2018-11-05 21:12:23 +00:00
|
|
|
*rubygems.org*)
|
|
|
|
url="https://rubygems.org/gems/${pkgname#ruby-}"
|
2018-11-15 20:41:53 +00:00
|
|
|
rx='href="/gems/'${pkgname#ruby-}'/versions/\K[\d\.]*(?=")' ;;
|
2019-05-13 17:44:11 +00:00
|
|
|
*crates.io*)
|
|
|
|
url="https://crates.io/api/v1/crates/${pkgname#rust-}"
|
|
|
|
rx='/crates/'${pkgname#rust-}'/\K[0-9.]*(?=/download)' ;;
|
2014-10-31 19:43:30 +00:00
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2015-01-15 09:34:44 +00: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 19:43:30 +00:00
|
|
|
|
2018-12-31 11:34:10 +00:00
|
|
|
if [ "${fetchedurls[$url]}" ]; then
|
|
|
|
if [ -n "$XBPS_UPDATE_CHECK_VERBOSE" ]; then
|
|
|
|
echo "already fetched $url" 1>&2
|
|
|
|
fi
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2014-10-31 19:43:30 +00:00
|
|
|
if [ -n "$XBPS_UPDATE_CHECK_VERBOSE" ]; then
|
|
|
|
echo "fetching $url" 1>&2
|
|
|
|
fi
|
2018-10-02 05:54:14 +00:00
|
|
|
curl -H 'Accept: text/html,application/xhtml+xml,application/xml,text/plain,application/rss+xml' -A "xbps-src-update-check/$XBPS_SRC_VERSION" --max-time 10 -Lsk "$url" |
|
2014-10-31 19:43:30 +00:00
|
|
|
grep -Po -i "$rx"
|
2018-12-31 11:34:10 +00:00
|
|
|
fetchedurls[$url]=yes
|
2014-10-31 19:43:30 +00:00
|
|
|
done |
|
2018-04-13 14:36:37 +00:00
|
|
|
tr _ . |
|
2014-10-31 19:43:30 +00:00
|
|
|
sort -Vu |
|
2018-12-08 11:22:56 +00:00
|
|
|
{
|
2015-01-15 09:34:44 +00:00
|
|
|
grep . || echo "NO VERSION found for $original_pkgname" 1>&2
|
2014-10-31 19:43:30 +00: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 09:34:44 +00:00
|
|
|
p="$ignore "
|
2014-10-31 19:43:30 +00: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 09:34:44 +00:00
|
|
|
xbps-uhelper cmpver "$original_pkgname-${version}_1" \
|
|
|
|
"$original_pkgname-$(printf %s "$found_version" | tr - .)_1"
|
2014-10-31 19:43:30 +00:00
|
|
|
if [ $? = 255 ]; then
|
2015-01-15 09:34:44 +00:00
|
|
|
echo "${original_pkgname}-${version} -> ${original_pkgname}-${found_version}"
|
2014-10-31 19:43:30 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|