2014-10-31 20:43:30 +01:00
|
|
|
# vim: set ts=4 sw=4 et:
|
|
|
|
|
|
|
|
update_check() {
|
2020-08-17 12:47:29 +02:00
|
|
|
local i p url pkgurlname 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
|
2022-03-17 18:15:03 +01:00
|
|
|
local pkgname=$sourcepkg
|
2018-07-22 15:39:08 +02:00
|
|
|
local urlpfx urlsfx
|
2018-12-31 12:34:10 +01:00
|
|
|
local -A fetchedurls
|
2015-01-15 10:34:44 +01:00
|
|
|
|
2024-03-20 14:34:47 +01:00
|
|
|
local curlargs=(
|
|
|
|
-A "xbps-src-update-check/$XBPS_SRC_VERSION"
|
|
|
|
--max-time 10 --compressed -Lsk
|
|
|
|
)
|
|
|
|
|
2024-02-10 07:47:06 +01:00
|
|
|
# XBPS_UPDATE_CHECK_VERBOSE is the old way to show verbose messages
|
|
|
|
[ "$XBPS_UPDATE_CHECK_VERBOSE" ] && XBPS_VERBOSE="$XBPS_UPDATE_CHECK_VERBOSE"
|
|
|
|
|
2015-01-15 10:34:44 +01:00
|
|
|
if [ -r $update_override ]; then
|
|
|
|
. $update_override
|
2024-02-10 07:47:06 +01:00
|
|
|
msg_verbose "using $XBPS_TARGET_PKG/update overrides\n"
|
2023-07-08 21:34:58 +02:00
|
|
|
if [ -n "$disabled" ]; then
|
2024-02-10 07:47:06 +01:00
|
|
|
msg_verbose "update-check DISABLED for $original_pkgname: $disabled\n"
|
2023-09-08 22:09:14 +02:00
|
|
|
return 0
|
2023-07-08 21:34:58 +02:00
|
|
|
fi
|
2022-08-29 20:37:27 +02:00
|
|
|
elif [ -z "$distfiles" ]; then
|
2024-02-10 07:47:06 +01:00
|
|
|
msg_verbose "NO DISTFILES found for $original_pkgname\n"
|
2022-08-29 20:37:27 +02:00
|
|
|
return 0
|
2015-01-15 10:34:44 +01:00
|
|
|
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
|
2021-01-27 01:12:47 +01:00
|
|
|
case "$distfiles" in
|
2022-09-06 13:34:18 +02:00
|
|
|
# special case those sites provide better source elsewhere
|
|
|
|
*ftp.gnome.org*|*download.gnome.org*) ;;
|
2022-09-06 13:32:41 +02:00
|
|
|
*archive.xfce.org*) ;;
|
2021-01-27 01:12:47 +01:00
|
|
|
*)
|
|
|
|
printf '%s\n' "$homepage" ;;
|
|
|
|
esac
|
2014-10-31 20:43:30 +01:00
|
|
|
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 |
|
2018-07-22 15:39:08 +02: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 10:23:15 +02:00
|
|
|
# default case: don't rewrite url
|
|
|
|
printf '%s\n' "$url"
|
2019-04-29 10:27:34 +02:00
|
|
|
if [ "$single_directory" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
2018-07-22 15:39:08 +02:00
|
|
|
rx=
|
|
|
|
urlpfx="${url}"
|
|
|
|
urlsfx=
|
2019-04-29 10:26:49 +02:00
|
|
|
dirpfx=
|
2018-07-22 15:39:08 +02:00
|
|
|
case "$url" in
|
2019-04-29 10:30:25 +02:00
|
|
|
*.voidlinux.*|\
|
|
|
|
*sourceforge.net/sourceforge*|\
|
|
|
|
*code.google.com*|*googlecode*|\
|
|
|
|
*launchpad.net*|\
|
|
|
|
*cpan.*|\
|
|
|
|
*pythonhosted.org*|\
|
|
|
|
*github.com*|\
|
2019-06-01 14:23:37 +02:00
|
|
|
*//gitlab.*|\
|
2019-04-29 10:30:25 +02:00
|
|
|
*bitbucket.org*|\
|
2022-09-06 13:34:18 +02:00
|
|
|
*ftp.gnome.org*|*download.gnome.org*|\
|
2022-09-06 13:32:41 +02:00
|
|
|
*archive.xfce.org*|\
|
2019-04-29 10:30:25 +02:00
|
|
|
*kernel.org/pub/linux/kernel/*|\
|
|
|
|
*cran.r-project.org/src/contrib*|\
|
2019-06-01 14:23:37 +02:00
|
|
|
*rubygems.org*|\
|
2020-02-03 22:37:03 +01:00
|
|
|
*crates.io*|\
|
2020-08-17 12:51:35 +02:00
|
|
|
*codeberg.org*|\
|
2020-10-20 19:33:55 +02:00
|
|
|
*hg.sr.ht*|\
|
2023-03-18 02:06:07 +01:00
|
|
|
*software.sil.org*|\
|
2020-10-20 19:33:55 +02:00
|
|
|
*git.sr.ht*)
|
2019-04-29 10:30:25 +02:00
|
|
|
continue
|
|
|
|
;;
|
2019-04-29 10:26:49 +02: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 15:39:08 +02:00
|
|
|
;;
|
|
|
|
esac
|
2019-04-29 10:23:15 +02:00
|
|
|
if [ "$rx" ]; then
|
2018-07-22 15:39:08 +02:00
|
|
|
# substitute url if needed
|
2024-02-10 07:47:06 +01:00
|
|
|
msg_verbose "(folder) fetching $urlpfx and scanning with $rx\n"
|
2019-04-29 10:25:27 +02:00
|
|
|
skipdirs=
|
2024-03-20 14:34:47 +01:00
|
|
|
curl "${curlargs[@]}" "$urlpfx" |
|
2019-06-29 17:03:32 +02:00
|
|
|
grep -Po -i "$rx" |
|
|
|
|
# sort -V places 1.1/ before 1/, but 1A/ before 1.1A/
|
|
|
|
sed -e 's:$:A:' -e 's:/A$:A/:' | sort -Vru | sed -e 's:A/$:/A:' -e 's:A$::' |
|
2019-04-29 10:25:27 +02:00
|
|
|
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 15:39:08 +02:00
|
|
|
fi
|
|
|
|
done |
|
2014-10-31 20:43:30 +01:00
|
|
|
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*)
|
2020-08-17 12:47:29 +02:00
|
|
|
pkgurlname="$(printf %s "$url" | cut -d/ -f5)"
|
|
|
|
url="https://sourceforge.net/projects/$pkgurlname/rss?limit=200";;
|
2014-10-31 20:43:30 +01:00
|
|
|
*code.google.com*|*googlecode*)
|
2023-02-24 22:42:23 +01:00
|
|
|
url="https://code.google.com/p/$pkgname/downloads/list";;
|
2014-10-31 20:43:30 +01:00
|
|
|
*launchpad.net*)
|
2020-08-17 12:47:29 +02:00
|
|
|
pkgurlname="$(printf %s "$url" | cut -d/ -f4)"
|
|
|
|
url="https://launchpad.net/$pkgurlname/+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-}
|
2019-01-02 17:19:26 +01:00
|
|
|
pkgname=${pkgname#python3-}
|
2024-04-23 03:08:22 +02:00
|
|
|
rx="(?<=${pkgname//-/[-_]}-)[0-9.]+(post[0-9]*)?(?=(([.]tar|-cp|-py[0-9]+-none)))"
|
2018-04-20 19:34:04 +02:00
|
|
|
url="https://pypi.org/simple/$pkgname";;
|
2014-10-31 20:43:30 +01:00
|
|
|
*github.com*)
|
2020-08-17 12:47:29 +02:00
|
|
|
pkgurlname="$(printf %s "$url" | cut -d/ -f4,5)"
|
|
|
|
url="https://github.com/$pkgurlname/tags"
|
2023-03-13 04:17:21 +01:00
|
|
|
rx='/archive/refs/tags/(v?|\Q'"$pkgname"'\E[-_])?\K[\d.]+(?=\.tar\.gz")';;
|
2022-08-29 23:26:04 +02:00
|
|
|
*//gitlab.*|*code.videolan.org*)
|
2022-05-14 15:36:27 +02:00
|
|
|
case "$url" in
|
|
|
|
*/-/*) pkgurlname="$(printf %s "$url" | sed -e 's%/-/.*%%g; s%/$%%')";;
|
|
|
|
*) pkgurlname="$(printf %s "$url" | cut -d / -f 1-5)";;
|
|
|
|
esac
|
2023-05-19 15:53:08 +02:00
|
|
|
url="$pkgurlname/-/tags"
|
2024-03-23 11:43:09 +01:00
|
|
|
rx='/archive/[^/]+/\Q'"$pkgname"'\E-v?\K[\d.]+(?=\.tar\.gz)';;
|
2014-11-24 15:42:57 +01:00
|
|
|
*bitbucket.org*)
|
2020-08-17 12:47:29 +02:00
|
|
|
pkgurlname="$(printf %s "$url" | cut -d/ -f4,5)"
|
|
|
|
url="https://bitbucket.org/$pkgurlname/downloads"
|
2021-05-19 15:49:45 +02:00
|
|
|
rx='/(get|downloads)/(v?|\Q'"$pkgname"'\E-)?\K[\d.]+(?=\.tar)';;
|
2021-04-03 16:07:13 +02:00
|
|
|
*ftp.gnome.org*|*download.gnome.org*)
|
2024-02-14 07:28:18 +01:00
|
|
|
: ${pattern="(?<=LATEST-IS-)([0-24-9]|3\.[0-9]*[02468]|[4-9][0-9]+)\.[0-9.]*[0-9](?=\")"}
|
2021-04-03 16:07:13 +02:00
|
|
|
url="https://download.gnome.org/sources/$pkgname/cache.json";;
|
2022-09-06 13:32:41 +02:00
|
|
|
*archive.xfce.org*)
|
|
|
|
: ${pattern="\Q$pkgname\E-\K((([4-9]|([1-9][0-9]+))\.[0-9]*[02468]\.[0-9.]*[0-9])|([0-3]\.[0-9.]*))(?=.tar)"}
|
|
|
|
url="https://archive.xfce.org/feeds/project/$pkgname" ;;
|
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)';;
|
2018-11-05 22:12:23 +01:00
|
|
|
*rubygems.org*)
|
|
|
|
url="https://rubygems.org/gems/${pkgname#ruby-}"
|
2021-05-19 15:49:45 +02:00
|
|
|
rx='href="/gems/'${pkgname#ruby-}'/versions/\K[\d.]*(?=")' ;;
|
2019-05-13 19:44:11 +02:00
|
|
|
*crates.io*)
|
|
|
|
url="https://crates.io/api/v1/crates/${pkgname#rust-}"
|
|
|
|
rx='/crates/'${pkgname#rust-}'/\K[0-9.]*(?=/download)' ;;
|
2020-08-17 12:51:35 +02:00
|
|
|
*codeberg.org*)
|
|
|
|
pkgurlname="$(printf %s "$url" | cut -d/ -f4,5)"
|
2022-08-21 21:03:12 +02:00
|
|
|
url="https://codeberg.org/$pkgurlname/tags"
|
|
|
|
rx='/archive/(v-?|\Q'"$pkgname"'\E-)?\K[\d.]+(?=\.tar\.gz)' ;;
|
2020-02-03 22:37:03 +01:00
|
|
|
*hg.sr.ht*)
|
2020-08-17 12:47:29 +02:00
|
|
|
pkgurlname="$(printf %s "$url" | cut -d/ -f4,5)"
|
|
|
|
url="https://hg.sr.ht/$pkgurlname/tags"
|
2021-05-19 15:49:45 +02:00
|
|
|
rx='/archive/(v?|\Q'"$pkgname"'\E-)?\K[\d.]+(?=\.tar\.gz")';;
|
2020-10-20 19:33:55 +02:00
|
|
|
*git.sr.ht*)
|
|
|
|
pkgurlname="$(printf %s "$url" | cut -d/ -f4,5)"
|
2022-11-06 10:42:41 +01:00
|
|
|
url="https://git.sr.ht/$pkgurlname/refs/rss.xml"
|
|
|
|
rx='<guid>\Q'"${url%/*}"'\E/(v-?|\Q'"$pkgname"'\E-)?\K[\d.]+(?=</guid>)' ;;
|
2021-06-10 04:14:25 +02:00
|
|
|
*pkgs.fedoraproject.org*)
|
|
|
|
url="https://pkgs.fedoraproject.org/repo/pkgs/$pkgname" ;;
|
2023-03-18 02:06:07 +01:00
|
|
|
*software.sil.org/downloads/*)
|
|
|
|
pkgurlname=$(printf '%s\n' "$url" | cut -d/ -f6)
|
|
|
|
url="https://software.sil.org/$pkgurlname/download/"
|
|
|
|
pkgname="${pkgname#font-}"
|
|
|
|
pkgname="${pkgname#sil-}"
|
2023-03-18 02:07:41 +01:00
|
|
|
_pkgname="${pkgname//-/}"
|
|
|
|
rx="($_pkgname|${_pkgname}SIL)[_-]\K[0-9.]+(?=\.tar|\.zip)" ;;
|
2023-03-18 02:06:07 +01:00
|
|
|
*software.sil.org/*)
|
|
|
|
pkgname="${pkgname#font-}"
|
|
|
|
pkgname="${pkgname#sil-}"
|
2023-03-18 02:07:41 +01:00
|
|
|
_pkgname="${pkgname//-/}"
|
|
|
|
rx="($_pkgname|${_pkgname}SIL)[_-]\K[0-9.]+(?=\.tar|\.zip)" ;;
|
2014-10-31 20:43:30 +01:00
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2015-01-15 10:34:44 +01:00
|
|
|
rx=${pattern:-$rx}
|
2020-03-05 19:29:04 +01:00
|
|
|
rx=${rx:-'(?<!-)\b\Q'"$pkgname"'\E[-_]?((src|source)[-_])?v?\K([^-/_\s]*?\d[^-/_\s]*?)(?=(?:[-_.](?:src|source|orig))?\.(?:[jt]ar|shar|t[bglx]z|tbz2|zip))\b'}
|
2014-10-31 20:43:30 +01:00
|
|
|
|
2018-12-31 12:34:10 +01:00
|
|
|
if [ "${fetchedurls[$url]}" ]; then
|
2024-02-10 07:47:06 +01:00
|
|
|
msg_verbose "already fetched $url\n"
|
2018-12-31 12:34:10 +01:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2024-02-10 07:47:06 +01:00
|
|
|
msg_verbose "fetching $url and scanning with $rx\n"
|
2024-03-20 14:34:47 +01:00
|
|
|
curl "${curlargs[@]}" -H 'Accept: text/html,application/xhtml+xml,application/xml,text/plain,application/rss+xml' "$url" |
|
2014-10-31 20:43:30 +01:00
|
|
|
grep -Po -i "$rx"
|
2018-12-31 12:34:10 +01:00
|
|
|
fetchedurls[$url]=yes
|
2014-10-31 20:43:30 +01:00
|
|
|
done |
|
2018-04-13 16:36:37 +02:00
|
|
|
tr _ . |
|
2014-10-31 20:43:30 +01:00
|
|
|
sort -Vu |
|
2018-12-08 12:22:56 +01:00
|
|
|
{
|
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
|
2024-02-10 07:47:06 +01:00
|
|
|
msg_verbose "found version $found_version\n"
|
2014-10-31 20:43:30 +01:00
|
|
|
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
|
2024-02-10 07:47:06 +01:00
|
|
|
msg_verbose "ignored $found_version due to $i\n"
|
2014-10-31 20:43:30 +01:00
|
|
|
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
|
|
|
|
}
|