Commit 3ac1b129 authored by Carlo Landmeter's avatar Carlo Landmeter
Browse files

abuild: add git/svn snapshot hook

ref #1537
parent a00d100c
......@@ -1651,6 +1651,62 @@ all() {
# 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.
# Base version defaults to 0 except if specified by $basever.
snapshot() {
# 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!"
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."
[ -z "$reporev" ] && local _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
# 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 export $_rev $svnurl $pkgname-$_version || return 1
tar zcf $pkgname-$_version.$_format $pkgname-$_version || return 1
# 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
usage() {
echo "$program $abuild_ver"
echo "usage: $program [options] [-i PKG] [-P REPODEST] [-p PKGDEST]"
......@@ -1692,6 +1748,7 @@ usage() {
echo " up2date Compare target and sources dates"
echo " installdeps Install packages listed in makedepends and depends"
echo " uninstalldeps Uninstall packages listed in makedepends and depends"
echo " snapshot Create a \$giturl or \$svnurl snapshot and upload to \$disturl"
echo ""
exit 0
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment