Mail archive
alpine-devel

[alpine-devel] [PATCH 2/2] abuild: simplify $pkgver handling in snapshot()

From: Sören Tempel <soeren+git_at_soeren-tempel.net>
Date: Wed, 13 Jul 2016 16:02:27 +0200

Drop $verbase and simply use the version specified in $pkgver for
tarballs. I don't know why this wasn't done before but this seems to be
the easiest approach.
---
 abuild.in | 49 +++++++++++++++++++------------------------------
 1 file changed, 19 insertions(+), 30 deletions(-)
diff --git a/abuild.in b/abuild.in
index a0637c9..7e18885 100644
--- a/abuild.in
+++ b/abuild.in
_at_@ -2066,7 +2066,6 @@ all() {
 #
 # 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
_at_@ -2084,52 +2083,45 @@ snapshot() {
 	[ -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"
 
-	local scr= ver= url= rver= type=
+	local fmt=tar.gz scr= ver= url= 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%\#*}"
+		type="${url%+*}"  # Extract VCS type from URL.
+		url="${url##*+}"  # Remove VCS type from URL.
+		ver="${url##*\#}" # Extract revision from URL.
+		url="${url%\#*}"  # Remove revision from URL.
 
+		scr="$pkgname-${url##*/}-$pkgver"
 		[ -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
+			[ -n "$ver" ] && local rev="-r $ver"
+			msg "Creating svn snapshot for '$url'"
+			svn co $rev "$url" $scr || return 1
+			tar zcf $scr.$fmt $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"
+			local rev="${ver:-HEAD}"
+			[ "$rev" = "HEAD" ] && local _depth="--depth=1"
+			msg "Creating git snapshot for '$url'"
 			git clone $_depth --bare "$url" $scr || return 1
 			git --git-dir $scr archive \
-				-o $scr.$_format \
-				--format=$_format \
-				--prefix=$pkgname-$rver/ $_rev \
+				-o $scr.$fmt \
+				--format=$fmt \
+				--prefix=$scr/ $rev \
 				|| return 1
 			;;
 		*)  die "Unsupported VCS type: '${type}'" ;;
_at_@ -2139,16 +2131,13 @@ snapshot() {
 		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
+			msg "Uploading '$scr' to '$disturl'"
+			rsync --progress -La $scr.$fmt $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
+	[ -n "$disturl" ] && abuild checksum
 }
 
 usage() {
-- 
2.9.0
---
Unsubscribe:  alpine-devel+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-devel+help_at_lists.alpinelinux.org
---
Received on Wed Jul 13 2016 - 16:02:27 GMT