Instead of having multiple variables for different version control
systems ($svnurl and $giturl) this unites all version control systems in
one URL $vcsurls and also allows you to add more than one URL per
APKBUILD.
The syntax is as follows:
(git|svn)+<url>[#<revision to checkout (previously $reporev)>]
This has various advantages over the old approach: The obvious one being
that you can clone multiple repositories without defining your own
snapshot function now. I needed this for the testing/android-tools
APKBUILD. Additionally it is now much easier to add support for more
version control systems (e.g. mercurial).
The new code should be fully mostly[1] with APKBUILDs that are still
using $giturl, $svnurl and/or $reporev. However, this backwards
compatibility makes the code somewhat uglier and should probably be
removed in a feature version (deprecation warnings are already emitted
in this version).
In general the snapshot function code could be cleaned up a bit by
moving the git/svn clone code to a separate function et cetera.
[1] Since the previous snapshot code assumed that only one repository
would be cloned the tarballs contained a directory called
'$pkgname-${verbase:-0}_git${_date}', however since we have multiple
tarballs now we can't use this as a filename thus you need to update
"$builddir" after creating a new snapshot for your APKBUILD. Besides
stuff *will* break if you used command line flags in $giturl as
instructed in the comment above the snapshot function.
---
abuild.in | 127 ++++++++++++++++++++++++++++++++++++++++----------------------
1 file changed, 82 insertions(+), 45 deletions(-)
diff --git a/abuild.in b/abuild.in
index d4614d1..a0637c9 100644
--- a/abuild.in+++ b/abuild.in
@@ -2057,61 +2057,98 @@ all() {
fi
}
-# This abuild hook will checkout an svn or git repository by specifying-# $svnurl or $giturl in APKBUILD. You can checkout a specific branch in-# git by adding -b $branch in $giturl. $reporev will select the correct-# commit, revision or tag for you. If you specify $disturl your distfile-# will automatically be uploaded with rsync to the url provided.+# This abuild hook will checkout a version control source tree.+# Currently svn and git are supported. To checkout a repository+# add the repository to the $vcsurls variable. The syntax for $vcsurls+# items is the following:+#+# (git|svn)+<url>[#<revision to checkout (previously $reporev)>]+#+# Revision to checkout is optional but recommended. If you specify $disturl+# your distfile will automatically be uploaded with rsync to the url provided.# Base version defaults to 0 except if specified by $verbase.
snapshot() {
+ # included for compatiblity with old APKBUILDs+ [ -n "$svnurl" ] && [ -n "$giturl" ] && die "You can only use a single repository!"+ if [ -n "$svnurl" ]; then+ warning "The \$svnurl variable is deprecated, use \$vcsurls instead."+ vcsurls="svn+$svnurl${reporev:+#$reporev}"+ elif [ -n "$giturl" ]; then+ warning "The \$giturl variable is deprecated, use \$vcsurls instead."+ vcsurls="git+$giturl${reporev:+#$reporev}"+ fi+ # check if we setup vars correctly
[ -z "$disturl" ] && warning "Missing disturl in APKBUILD, auto uploading disabled."
- [ -z "$svnurl" ] && [ -z "$giturl" ] && die "Missding repository url in APKBUILD!"- [ -n "$svnurl" ] && [ -n "$giturl" ] && die "You can only use a single repository!"+ [ -z "$vcsurls" ] && die "Missing repository url in APKBUILD!"+ [ -n "$reporev" ] && warning "The \$reporev variable is deprecated."+ local _date=$(date +%Y%m%d)
local _format="tar.gz"
# remove any repositories left in srcdir
abuild clean
mkdir -p "$srcdir" && cd "$srcdir"
- # clone git repo and archive- if [ -n "$giturl" ]; then- local _version=${verbase:-0}_git${_date}- command -v git >/dev/null || \- die "Missing git! Install git to support git clone."- local _rev="${reporev:-HEAD}"- [ "$_rev" = "HEAD" ] && local _depth="--depth=1"- msg "Creating git snapshot: $pkgname-$_version"- git clone $_depth --bare $giturl $pkgname-$_version || return 1- git --git-dir $pkgname-$_version archive \- --format=$_format \- -o $pkgname-$_version.$_format \- --prefix=$pkgname-$_version/ $_rev \- || return 1- fi- # export svn repo and archive- if [ -n "$svnurl" ]; then- local _version=${verbase:-0}_svn${_date}- command -v svn >/dev/null || \- die "Missing svn! Install subverion to support svn export."- [ -n "$reporev" ] && local _rev="-r $reporev"- msg "Creating svn snapshot: $pkgname-$_version"- svn co $_rev $svnurl $pkgname-$_version || return 1- tar zcf $pkgname-$_version.$_format $pkgname-$_version || return 1- fi- # upload to defined distfiles url- if [ -n "$disturl" ]; then- command -v rsync >/dev/null || \- die "Missing rsync! Install rsync to enable automatic uploads."- msg "Uploading to $disturl"- rsync --progress -La $pkgname-$_version.$_format \- $disturl || return 1- cd "$startdir"- # set the pkgver to current date and update checksum- sed -i -e "s/^pkgver=.*/pkgver=${_version}/" \- APKBUILD || return 1- abuild checksum- fi++ local scr= ver= url= rver= type=+ for url in $vcsurls; do+ echo "$url" | grep -q + 2>/dev/null || \+ die "VCS type for '$url' wasn't specified."+ type="${url%+*}"+ url="${url##*+}"++ ver="${url##*\#}"+ url="${url%\#*}"++ [ -z "${ver}" ] && warning "Please specify a revision to checkout for '$url'."++ case "$type" in+ svn)+ rver=${verbase:-0}_svn${_date}+ scr="$pkgname-${url##*/}-$rver"++ command -v svn >/dev/null || \+ die "Missing svn! Install subverion to support svn export."++ [ -n "$ver" ] && local _rev="-r $ver"+ msg "Creating svn snapshot: $scr"+ svn co $_rev "$url" $scr || return 1+ tar zcf $scr.$_format $scr || return 1+ ;;+ git)+ rver=${verbase:-0}_git${_date}+ scr="$pkgname-${url##*/}-$rver"++ command -v git >/dev/null || \+ die "Missing git! Install git to support git clone."++ local _rev="${ver:-HEAD}"+ [ "$_rev" = "HEAD" ] && local _depth="--depth=1"+ msg "Creating git snapshot: $scr"+ git clone $_depth --bare "$url" $scr || return 1+ git --git-dir $scr archive \+ -o $scr.$_format \+ --format=$_format \+ --prefix=$pkgname-$rver/ $_rev \+ || return 1+ ;;+ *) die "Unsupported VCS type: '${type}'" ;;+ esac++ # upload to defined distfiles url+ if [ -n "$disturl" ]; then+ command -v rsync >/dev/null || \+ die "Missing rsync! Install rsync to enable automatic uploads."+ msg "Uploading to $disturl"+ rsync --progress -La $scr $disturl || return 1+ fi+ done++ cd "$startdir"+ # set the pkgver to current date and update checksum+ sed -i -e "s/^pkgver=.*/pkgver=${rver}/" \+ APKBUILD || return 1+ abuild checksum}
usage() {
--
2.9.0
---
Unsubscribe: alpine-devel+unsubscribe@lists.alpinelinux.org
Help: alpine-devel+help@lists.alpinelinux.org
---
[alpine-devel] [PATCH 2/2] abuild: simplify $pkgver handling in snapshot()