[Dev] [dbscripts] [PATCH 1/2] test: common.bash: Be more careful about what we put in the package cache

Luke Shumaker lukeshu at lukeshu.com
Fri Apr 6 03:20:55 GMT 2018


From: Luke Shumaker <lukeshu at parabola.nu>

The glob that copies makepkg outputs to the package cache was overly
permissive, and copies too much.  releasePackage calls __buildPackage
from "${TMP}/svn-packages-copy/${pkgbase}/trunk/".  This means that
when we update a package, after the updated version is built, both v1
and v2 exist in that trunk/ directory.  Then, this copies both the v1
and v2 .pkg.tar.xz files to the cache directory for v2.

That is: On subsequent runs (e.i. with a cache hit) of __buildPackage
for v2 of that package, it will look like makepkg magically built both
v1 and v2 of the package, instead of just v2.

Right now, that isn't really a problem because further down in
releasePackage, when we copy the makepkg outputs to $STAGING, that
glob is sufficiently strict to only copy the v2 outputs.  However, the
cache is poisoned, and that means that keeping it around longer
increases the odds that we do something that this poisoning breaks.

So, backport using libmakepkg's print_all_package_names to be
extremely careful about what we put in the cache.  This should make
the cache safe to use across test suite runs.

(this is a partial cherry pick of commit 76f95dd139094dc2985b6733f23fcb098f07c64e)

Allways build packages for all supported architectures
---
 test/lib/common.bash | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/test/lib/common.bash b/test/lib/common.bash
index 2d3feab..aeed8a0 100644
--- a/test/lib/common.bash
+++ b/test/lib/common.bash
@@ -16,11 +16,9 @@ __getCheckSum() {
 
 __buildPackage() {
 	local arch=$1
-	local pkgver
-	local pkgname
-	local a
 	local p
 	local checkSum
+	local pkgnames
 
 	if [[ -n ${PACKAGE_CACHE} ]]; then
 		checkSum=$(__getCheckSum PKGBUILD)
@@ -30,9 +28,6 @@ __buildPackage() {
 			fi
 	fi
 
-	pkgname=($(. PKGBUILD; echo "${pkgname[@]}"))
-	pkgver=$(. PKGBUILD; get_full_version)
-
 	if [ "${arch}" == 'any' ]; then
 		sudo librechroot -n "dbscripts@${arch}" make
 	else
@@ -40,16 +35,17 @@ __buildPackage() {
 	fi
 	sudo libremakepkg -n "dbscripts@${arch}"
 
-	for p in "${pkgname[@]}"; do
-		for file in "${p}-${pkgver}-${arch}"*; do
-			gpg --detach-sign --no-armor --use-agent "$file"
-		done
-	done
+	pkgnames=($(. PKGBUILD; print_all_package_names))
+	for p in ${pkgnames[@]/%/${PKGEXT}}; do
+		[[ ${p} = *-${arch}${PKGEXT} ]] || continue
+		# Manually sign packages as "makepkg --sign" is buggy
+		gpg -v --detach-sign --no-armor --use-agent ${p}
 
-	if [[ -n ${PACKAGE_CACHE} ]]; then
-		mkdir -p ${PACKAGE_CACHE}/${checkSum}
-		cp -av *-${arch}${PKGEXT}{,.sig} ${PACKAGE_CACHE}/${checkSum}/
-	fi
+		if [[ -n ${PACKAGE_CACHE} ]]; then
+			mkdir -p ${PACKAGE_CACHE}/${checkSum}
+			cp -Lv ${p}{,.sig} ${PACKAGE_CACHE}/${checkSum}/
+		fi
+	done
 }
 
 setup() {
-- 
2.16.2




More information about the Dev mailing list