Mail archive
alpine-devel

[alpine-devel] [PATCH 21/31] abump: refactor verification of APKBUILD

From: Dubiousjim <dubiousjim_at_gmail.com>
Date: Fri, 5 Jul 2013 00:21:30 -0400

* includes renaming pkgname, pkgver
---
 abump.in | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/abump.in b/abump.in
index 7a0bd57..f25a4ea 100755
--- a/abump.in
+++ b/abump.in
_at_@ -18,19 +18,26 @@ fi
 
 # version bump packages
 do_bump() {
-	local p rc=0 pkgname pkgver section message
+	local p rc=0 name ver section message
 	local upgrade="${cvelist:+security }upgrade"
 	local a
 	for p; do
-		pkgname=${p%-[0-9]*}
-		pkgver=${p#${pkgname}-}
+		name=${p%-[0-9]*}
+		ver=${p#${name}-}
 
 		# calculate APKBUILD's path
-		if [ "${pkgname#*/}" != "$pkgname" ] && ! [ -d "$APORTSDIR/${pkgname%/*} ]; then
+		if [ "${name#*/}" != "$name" ] && ! [ -d "$APORTSDIR/${name%/*} ]; then
 			error "'$p' should be of form 'foo-1.2.3' or 'main/foo-1.2.3'"
 			rc=1; continue
 		fi
-		a=$(aports_buildscript "$pkgname" || die "can't find APKBUILD for $pkgname") || { rc=1; continue; }
+		a=$(aports_buildscript "$name" || die "can't find APKBUILD for $name") || { rc=1; continue; }
+
+		# verify APKBUILD
+		(
+		. "$a" || exit 1
+		[ "$pkgname" = "$name" ] || die "$name: APKBUILD has different \$pkgname"
+		type package | grep -q function || die "$name: missing package()"
+		) || { rc=1; continue; }
 
 		(
 		set -e
_at_@ -39,7 +46,7 @@ do_bump() {
 		section=${PWD%/*}
 		section=${section##*/}
 
-		message="$section/$pkgname: $upgrade to ${pkgver}${cvelist}"
+		message="$section/$name: $upgrade to ${ver}${cvelist}"
 		if [ -n "$fixes" ]; then
 			message="$message
 
_at_@ -48,9 +55,7 @@ fixes #${fixes#\#}
 		fi
 		echo "$message"
 
-		( . ./APKBUILD; type package | grep -q function ) || die "package() missing"
-
-		sed -i -e "s/^pkgver=.*/pkgver=$pkgver/" \
+		sed -i -e "s/^pkgver=.*/pkgver=$ver/" \
 			-e "s/^pkgrel=.*/pkgrel=0/" \
 			APKBUILD
 
-- 
1.8.3.1
---
Unsubscribe:  alpine-devel+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-devel+help_at_lists.alpinelinux.org
---
Received on Fri Jul 05 2013 - 00:21:30 GMT