update_check.sh: use external update file for overrides

This commit is contained in:
Eivind Uggedal 2015-01-15 09:34:44 +00:00
parent 218d6b6bb7
commit 3b7a76512d
3 changed files with 39 additions and 32 deletions

View File

@ -459,29 +459,29 @@ The following repository names are valid:
#### Checking for new upstream releases #### Checking for new upstream releases
For automatic checking of new versions, in some cases you need to define New upstream versions can be automatically checked using
these variables (in most cases, the sensible defaults work): `./xbps-src update-check <pkgname>`. In some cases you need to override
the sensible defaults by assigning the following variables in a `update`
file in the same directory as the relevant `template` file:
- `update_site` contains the URL where the version number is - `site` contains the URL where the version number is
mentioned. If unset, defaults to `homepage` and the directories where mentioned. If unset, defaults to `homepage` and the directories where
`distfiles` reside. `distfiles` reside.
- `update_pkgname` is the package name the default pattern checks for. - `pkgname` is the package name the default pattern checks for.
If unset, defaults to `pkgname`. If unset, defaults to `pkgname` from the template.
- `update_pattern` is a perl-compatible regular expression - `pattern` is a perl-compatible regular expression
matching the version number. Anchor the version number using `\K` matching the version number. Anchor the version number using `\K`
and `(?=...)`. Example: `update_pattern='<b>\K[\d.]+(?=</b>)'`, this and `(?=...)`. Example: `pattern='<b>\K[\d.]+(?=</b>)'`, this
matches a version number enclosed in `<b>...</b>` tags. matches a version number enclosed in `<b>...</b>` tags.
- `update_ignore` is a space-separated list of shell globs that match - `ignore` is a space-separated list of shell globs that match
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: `ignore="*b*"`
- `update_version` is the version number used to compare against - `version` is the version number used to compare against
upstream versions. Example: `update_version=${version//./_}` upstream versions. Example: `version=${version//./_}`
You can run such a check using `./xbps-src update-check <pkgname>`.
### build style scripts ### build style scripts

View File

@ -9,7 +9,6 @@ unset -v make_cmd make_build_args make_install_args make_build_target make_insta
unset -v patch_args disable_parallel_build keep_libtool_archives unset -v patch_args disable_parallel_build keep_libtool_archives
unset -v reverts subpackages makedepends hostmakedepends depends unset -v reverts subpackages makedepends hostmakedepends depends
unset -v build_options build_options_default bootstrap repository unset -v build_options build_options_default bootstrap repository
unset -v update_pkgname update_site update_pattern update_ignore update_version
unset -v CFLAGS CXXFLAGS CPPFLAGS LDFLAGS LD_LIBRARY_PATH unset -v CFLAGS CXXFLAGS CPPFLAGS LDFLAGS LD_LIBRARY_PATH
unset -v CC CXX CPP GCC LD AR AS RANLIB NM OBJDUMP OBJCOPY STRIP READELF unset -v CC CXX CPP GCC LD AR AS RANLIB NM OBJDUMP OBJCOPY STRIP READELF

View File

@ -2,6 +2,15 @@
update_check() { update_check() {
local i p url sfname lpname bbname githubname rx found_version consider local i p url sfname lpname bbname githubname rx found_version consider
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
if ! type curl >/dev/null 2>&1; then if ! type curl >/dev/null 2>&1; then
echo "ERROR: cannot find \`curl' executable!" echo "ERROR: cannot find \`curl' executable!"
@ -9,50 +18,49 @@ update_check() {
fi fi
export LC_ALL=C export LC_ALL=C
: ${update_pkgname:=$pkgname}
if [ -z "$update_site" ]; then if [ -z "$site" ]; then
printf '%s\n' "$homepage" printf '%s\n' "$homepage"
for i in $distfiles; do for i in $distfiles; do
printf '%s\n' "${i%/*}/" printf '%s\n' "${i%/*}/"
done done
else else
printf '%s\n' "$update_site" printf '%s\n' "$site"
fi | fi |
while IFS= read -r url; do while IFS= read -r url; do
rx= rx=
if [ -z "$update_site" ]; then if [ -z "$site" ]; then
case "$url" in case "$url" in
*sourceforge.net/sourceforge*) *sourceforge.net/sourceforge*)
sfname="$(printf %s "$url" | cut -d/ -f5)" sfname="$(printf %s "$url" | cut -d/ -f5)"
url="http://sourceforge.net/projects/$sfname/rss?limit=200";; url="http://sourceforge.net/projects/$sfname/rss?limit=200";;
*code.google.com*|*googlecode*) *code.google.com*|*googlecode*)
url="http://code.google.com/p/$update_pkgname/downloads/list";; url="http://code.google.com/p/$pkgname/downloads/list";;
*launchpad.net*) *launchpad.net*)
lpname="$(printf %s "$url" | cut -d/ -f4)" lpname="$(printf %s "$url" | cut -d/ -f4)"
url="https://launchpad.net/$lpname/+download";; url="https://launchpad.net/$lpname/+download";;
*cpan.*) *cpan.*)
update_pkgname=${update_pkgname#perl-};; pkgname=${pkgname#perl-};;
*pypi.python.org*) *pypi.python.org*)
update_pkgname=${update_pkgname#python-};; pkgname=${pkgname#python-};;
*github.com*) *github.com*)
githubname="$(printf %s "$url" | cut -d/ -f4,5)" githubname="$(printf %s "$url" | cut -d/ -f4,5)"
url="https://github.com/$githubname/tags" url="https://github.com/$githubname/tags"
rx='/archive/(v?|\Q'"$update_pkgname"'\E-)?\K[\d\.]+(?=\.tar\.gz")';; rx='/archive/(v?|\Q'"$pkgname"'\E-)?\K[\d\.]+(?=\.tar\.gz")';;
*bitbucket.org*) *bitbucket.org*)
bbname="$(printf %s "$url" | cut -d/ -f4,5)" bbname="$(printf %s "$url" | cut -d/ -f4,5)"
url="https://bitbucket.org/$bbname/downloads" url="https://bitbucket.org/$bbname/downloads"
rx='/(get|downloads)/(v?|\Q'"$update_pkgname"'\E-)?\K[\d\.]+(?=\.tar\.gz")';; rx='/(get|downloads)/(v?|\Q'"$pkgname"'\E-)?\K[\d\.]+(?=\.tar\.gz")';;
*ftp.gnome.org*) *ftp.gnome.org*)
: ${update_pattern="$update_pkgname-\K[0-9]\.[0-9]*[02468]\.[0-9.]*[0-9](?=)"} : ${pattern="$pkgname-\K[0-9]\.[0-9]*[02468]\.[0-9.]*[0-9](?=)"}
url="http://ftp.gnome.org/pub/GNOME/sources/$update_pkgname/cache.json";; url="http://ftp.gnome.org/pub/GNOME/sources/$pkgname/cache.json";;
*kernel.org/pub/linux/kernel/*) *kernel.org/pub/linux/kernel/*)
rx=linux-'\K'${version%.*}'[\d.]+(?=\.tar\.xz)';; rx=linux-'\K'${version%.*}'[\d.]+(?=\.tar\.xz)';;
esac esac
fi fi
rx=${update_pattern:-$rx} rx=${pattern:-$rx}
rx=${rx:-'(?<!-)\b\Q'"$update_pkgname"'\E[-_]?((src|source)[-_])?\K([^-/_\s]*?\d[^-/_\s]*?)(?=(?:[-_.](?:src|source|orig))?\.(?:[jt]ar|shar|t[bglx]z|tbz2|zip))\b'} rx=${rx:-'(?<!-)\b\Q'"$pkgname"'\E[-_]?((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 if [ -n "$XBPS_UPDATE_CHECK_VERBOSE" ]; then
echo "fetching $url" 1>&2 echo "fetching $url" 1>&2
@ -62,14 +70,14 @@ update_check() {
done | done |
sort -Vu | sort -Vu |
{ {
grep . || echo "NO VERSION found for $pkgname" 1>&2 grep . || echo "NO VERSION found for $original_pkgname" 1>&2
} | } |
while IFS= read -r found_version; do while IFS= read -r found_version; do
if [ -n "$XBPS_UPDATE_CHECK_VERBOSE" ]; then if [ -n "$XBPS_UPDATE_CHECK_VERBOSE" ]; then
echo "found version $found_version" echo "found version $found_version"
fi fi
consider=true consider=true
p="$update_ignore " p="$ignore "
while [ -n "$p" ]; do while [ -n "$p" ]; do
i=${p%% *} i=${p%% *}
p=${p#* } p=${p#* }
@ -82,10 +90,10 @@ update_check() {
esac esac
done done
if $consider; then if $consider; then
xbps-uhelper cmpver "$pkgname-${update_version:-$version}_1" \ xbps-uhelper cmpver "$original_pkgname-${version}_1" \
"$pkgname-$(printf %s "$found_version" | tr - .)_1" "$original_pkgname-$(printf %s "$found_version" | tr - .)_1"
if [ $? = 255 ]; then if [ $? = 255 ]; then
echo "${pkgname}-${version} -> ${pkgname}-${found_version}" echo "${original_pkgname}-${version} -> ${original_pkgname}-${found_version}"
fi fi
fi fi
done done