1 # vim: set ts=4 sw=4 et ft=bash :
4 local i p url pkgurlname rx found_version consider
5 local update_override
=$XBPS_SRCPKGDIR/$XBPS_TARGET_PKG/update
6 local original_pkgname
=$pkgname
7 local pkgname
=$sourcepkg
12 -A "xbps-src-update-check/$XBPS_SRC_VERSION"
13 --max-time 10 --compressed -Lsk
16 pkgname
=${pkgname#kf6-}
18 # XBPS_UPDATE_CHECK_VERBOSE is the old way to show verbose messages
19 [ "$XBPS_UPDATE_CHECK_VERBOSE" ] && XBPS_VERBOSE
="$XBPS_UPDATE_CHECK_VERBOSE"
21 if [ -r $update_override ]; then
23 msg_verbose
"using $XBPS_TARGET_PKG/update overrides\n"
24 if [ -n "$disabled" ]; then
25 msg_verbose
"update-check DISABLED for $original_pkgname: $disabled\n"
28 elif [ -z "$distfiles" ]; then
29 msg_verbose
"NO DISTFILES found for $original_pkgname\n"
33 if ! type curl
>/dev
/null
2>&1; then
34 echo "ERROR: cannot find \`curl' executable!"
40 if [ -z "$site" ]; then
42 # special case those sites provide better source elsewhere
43 *ftp.gnome.org
*|
*download.gnome.org
*) ;;
44 *archive.xfce.org
*) ;;
46 printf '%s\n' "$homepage" ;;
48 for i
in $distfiles; do
49 printf '%s\n' "${i%/*}/"
54 # filter loop: if version are "folder" name based,
55 # substitute original url by every folder based ones (expand)
56 while IFS
= read -r url
; do
57 # default case: don't rewrite url
59 if [ "$single_directory" ]; then
68 *sourceforge.net
/sourceforge
*|\
69 *code.google.com
*|
*googlecode
*|\
72 *pythonhosted.org
*|
*pypi.org
/project
/*|\
76 *ftp.gnome.org
*|
*download.gnome.org
*|\
78 *kernel.org
/pub
/linux
/kernel
/*|\
79 *cran.r-project.org
/src
/contrib
*|\
89 vdpfx
=${vdprefix:-"|v|\\Q$pkgname\\E"}
90 vdsfx
=${vdsuffix:-"|\\.x"}
91 match
=$
(grep -Po "^[^/]+//[^/]+(/.+)?/($vdpfx)(?=[-_.0-9]*[0-9](?<!\\Q$pkgname\\E)($vdsfx)/)" <<< "$url")
95 urlsfx
="${url#$urlpfx}"
97 rx
="href=[\"']?(\\Q$urlpfx\\E)?\\.?/?\\K\\Q$dirpfx\\E[-_.0-9]*[0-9]($vdsfx)[\"'/]"
102 # substitute url if needed
103 msg_verbose
"(folder) fetching $urlpfx and scanning with $rx\n"
105 curl
"${curlargs[@]}" "$urlpfx" |
107 # sort -V places 1.1/ before 1/, but 1A/ before 1.1A/
108 sed -e 's:$:A:' -e 's:/A$:A/:' |
sort -Vru |
sed -e 's:A/$:/A:' -e 's:A$::' |
109 while IFS
= read -r newver
; do
110 newurl
="${urlpfx}${newver}${urlsfx}"
111 if [ "$newurl" = "$url" ]; then
114 if [ -z "$skipdirs" ]; then
115 printf '%s\n' "$newurl"
120 while IFS
= read -r url
; do
122 if [ -z "$site" ]; then
124 *sourceforge.net
/sourceforge
*)
125 pkgurlname
="$(printf %s "$url" | cut -d/ -f5)"
126 url
="https://sourceforge.net/projects/$pkgurlname/rss?limit=200";;
127 *code.google.com
*|
*googlecode
*)
128 url
="https://code.google.com/p/$pkgname/downloads/list";;
130 pkgurlname
="$(printf %s "$url" | cut -d/ -f4)"
131 url
="https://launchpad.net/$pkgurlname/+download";;
133 pkgname
=${pkgname#perl-};;
134 *pythonhosted.org
*|
*pypi.org
/project
/*)
135 pkgname
=${pkgname#python-}
136 pkgname
=${pkgname#python3-}
137 rx
="(?<=${pkgname//-/[-_]}-)[0-9.]+(post[0-9]*)?(?=(([.]tar|-cp|-py)))"
138 url
="https://pypi.org/simple/$pkgname";;
140 pkgurlname
="$(printf %s "$url" | cut -d/ -f4,5)"
141 url
="https://github.com/$pkgurlname/tags"
142 rx
='/archive/refs/tags/(v?|\Q'"$pkgname"'\E[-_])?\K[\d.]+(?=\.tar\.gz")';;
143 *//gitlab.
*|
*code.videolan.org
*)
145 */-/*) pkgurlname
="$(printf %s "$url" | sed -e 's%/-/.*%%g; s%/$%%')";;
146 *) pkgurlname
="$(printf %s "$url" | cut -d / -f 1-5)";;
148 url
="$pkgurlname/-/tags"
149 rx
='/archive/[^/]+/\Q'"$pkgname"'\E-v?\K[\d.]+(?=\.tar\.gz)';;
151 pkgurlname
="$(printf %s "$url" | cut -d/ -f4,5)"
152 url
="https://bitbucket.org/$pkgurlname/downloads"
153 rx
='/(get|downloads)/(v?|\Q'"$pkgname"'\E-)?\K[\d.]+(?=\.tar)';;
154 *ftp.gnome.org
*|
*download.gnome.org
*)
155 rx
='(?<=LATEST-IS-)([0-24-9]|3\.[0-9]*[02468]|[4-9][0-9]+)\.[0-9.]*[0-9](?=\")'
156 url
="https://download.gnome.org/sources/$pkgname/cache.json";;
158 rx
='\Q'"$pkgname"'\E-\K((([4-9]|([1-9][0-9]+))\.[0-9]*[02468]\.[0-9.]*[0-9])|([0-3]\.[0-9.]*))(?=.tar)'
159 url
="https://archive.xfce.org/feeds/project/$pkgname" ;;
160 *kernel.org
/pub
/linux
/kernel
/*)
161 rx
=linux-
'\K'${version%.*}'\.[\d.]+(?=\.tar\.xz)';;
162 *cran.r-project.org
/src
/contrib
*)
163 rx
='\b\Q'"${pkgname#R-cran-}"'\E_\K\d+(\.\d+)*(-\d+)?(?=\.tar)';;
165 url
="https://rubygems.org/gems/${pkgname#ruby-}"
166 rx
='href="/gems/'${pkgname#ruby-}'/versions/\K[\d.]*(?=")' ;;
168 url
="https://crates.io/api/v1/crates/${pkgname#rust-}"
169 rx
='/crates/'${pkgname#rust-}'/\K[0-9.]*(?=/download)' ;;
171 pkgurlname
="$(printf %s "$url" | cut -d/ -f4,5)"
172 url
="https://codeberg.org/$pkgurlname/tags"
173 rx
='/archive/(v-?|\Q'"$pkgname"'\E-)?\K[\d.]+(?=\.tar\.gz)' ;;
175 pkgurlname
="$(printf %s "$url" | cut -d/ -f4,5)"
176 url
="https://hg.sr.ht/$pkgurlname/tags"
177 rx
='/archive/(v?|\Q'"$pkgname"'\E-)?\K[\d.]+(?=\.tar\.gz")';;
179 pkgurlname
="$(printf %s "$url" | cut -d/ -f4,5)"
180 url
="https://git.sr.ht/$pkgurlname/refs/rss.xml"
181 rx
='<guid>\Q'"${url%/*}"'\E/(v-?|\Q'"$pkgname"'\E-)?\K[\d.]+(?=</guid>)' ;;
182 *pkgs.fedoraproject.org
*)
183 url
="https://pkgs.fedoraproject.org/repo/pkgs/$pkgname" ;;
184 *software.sil.org
/downloads
/*)
185 pkgurlname
=$
(printf '%s\n' "$url" | cut
-d/ -f6)
186 url
="https://software.sil.org/$pkgurlname/download/"
187 pkgname
="${pkgname#font-}"
188 pkgname
="${pkgname#sil-}"
189 _pkgname
="${pkgname//-/}"
190 rx
="($_pkgname|${_pkgname}SIL)[_-]\K[0-9.]+(?=\.tar|\.zip)" ;;
192 pkgname
="${pkgname#font-}"
193 pkgname
="${pkgname#sil-}"
194 _pkgname
="${pkgname//-/}"
195 rx
="($_pkgname|${_pkgname}SIL)[_-]\K[0-9.]+(?=\.tar|\.zip)" ;;
200 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'}
202 if [ "${fetchedurls[$url]}" ]; then
203 msg_verbose
"already fetched $url\n"
207 msg_verbose
"fetching $url and scanning with $rx\n"
208 curl
"${curlargs[@]}" -H 'Accept: text/html,application/xhtml+xml,application/xml,text/plain,application/rss+xml' "$url" |
210 fetchedurls
[$url]=yes
215 grep . ||
echo "NO VERSION found for $original_pkgname" 1>&2
217 while IFS
= read -r found_version
; do
218 msg_verbose
"found version $found_version\n"
221 while [ -n "$p" ]; do
224 case "$found_version" in
227 msg_verbose
"ignored $found_version due to $i\n"
231 xbps-uhelper cmpver
"$original_pkgname-${version}_1" \
232 "$original_pkgname-$(printf %s "$found_version" | tr - .)_1"
233 if [ $?
= 255 ]; then
234 echo "${original_pkgname}-${version} -> ${original_pkgname}-${found_version}"