xbps-src: add update-check.

This commit is contained in:
Christian Neukirchen 2014-10-31 20:43:30 +01:00
parent fbc588a273
commit 60ac25fd1f
3 changed files with 83 additions and 1 deletions

View File

@ -453,6 +453,8 @@ matches a version number enclosed in `<b>...</b>` tags.
version numbers which are not taken into account for checking newer version numbers which are not taken into account for checking newer
versions. Example: `update_ignore="*b*"` versions. Example: `update_ignore="*b*"`
You can run such a check using `./xbps-src update-check <pkgname>`.
### build style scripts ### build style scripts
The `build_style` variable specifies the build method to build and install a The `build_style` variable specifies the build method to build and install a

View File

@ -0,0 +1,73 @@
# vim: set ts=4 sw=4 et:
update_check() {
local i p url rx found_version consider
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
if [ -z "$update_site" ]; then
case "$url" in
*sourceforge.net/sourceforge*)
url="http://sourceforge.net/projects/$update_pkgname/rss?limit=200";;
*code.google.com*|*googlecode*)
url="http://code.google.com/p/$update_pkgname/downloads/list";;
*launchpad.net*)
url="https://launchpad.net/$update_pkgname/+download";;
*cpan.*)
update_pkgname=${update_pkgname#perl-};;
*pypi.python.org*)
update_pkgname=${update_pkgname#python-};;
*github.com*)
githubname="$(printf %s "$url" | cut -d/ -f4,5)"
url="https://api.github.com/repos/$githubname/tags"
rx='"name":\s*"(v|'"$update_pkgname"'-)?\K[^\d]*([\d\.]+)(?=")';;
esac
fi
rx=${update_pattern:-$rx}
rx=${rx:-'(?<!-)\b'"$update_pkgname"'[-_]?((src|source)[-_])?\K([^-/_\s]*?\d[^-/_\s]*?)(?=(?:[-_.](?:src|source|orig))?\.(?:[jt]ar|shar|t[bglx]z|tbz2|zip))\b'}
if [ -n "$XBPS_UPDATE_CHECK_VERBOSE" ]; then
echo "fetching $url" 1>&2
fi
curl -A "xbps-src-update-check/$XBPS_SRC_VERSION" --max-time 10 -Ls "$url" |
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
xbps-uhelper cmpver "$pkgname-${version}_1" "$pkgname-${found_version}_1"
if [ $? = 255 ]; then
echo "NEWER VERSION $pkgname-$found_version (have $pkgname-${version})"
fi
fi
done
}

View File

@ -95,6 +95,9 @@ update-bulk
update-sys update-sys
Rebuilds all packages in your system that are outdated and updates them. Rebuilds all packages in your system that are outdated and updates them.
update-check <pkgname>
Check upstream site of <pkgname> for new releases.
zap zap
Removes a masterdir but preserving ccache, distcc and host directories. Removes a masterdir but preserving ccache, distcc and host directories.
@ -638,6 +641,10 @@ case "$XBPS_TARGET" in
update-sys) update-sys)
bulk_update -i bulk_update -i
;; ;;
update-check)
read_pkg
update_check
;;
zap) zap)
masterdir_zap masterdir_zap
;; ;;