[Dev] [dbscripts] [PATCH 01/31] test: common.bash: checkPackageDB(): Require the DB file to exist

Luke Shumaker lukeshu at lukeshu.com
Fri Apr 6 18:43:34 GMT 2018


From: Luke Shumaker <lukeshu at parabola.nu>

In 3a9623ba96dc8a26120be89354115dc120e71374 when I adjusted the function to
work correctly with `set -e`, I misread the interaction between parenthesis
and ||.  I had treated it like the more common
    ([ test ] && bsdtar) && fail    ->     if [ test ]; then ! bsdtar; fi
pattern, and incorrectly adjusted it as
    ([ test ] && bsdtar) || fail    ->     if [ test ]; then   bsdtar; fi
but I should have translated it as
    ([ test ] && bsdtar) || fail    ->     [ test ] && bsdtar

The result is that we weren't requiring the DB file to exist.

Note that Pierre got it right in Arch's version of the change,
d0b808b5a58023899c7e76958cdae732bbdfc08e.
---
 test/lib/common.bash | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/test/lib/common.bash b/test/lib/common.bash
index aeed8a0..73248d7 100644
--- a/test/lib/common.bash
+++ b/test/lib/common.bash
@@ -171,9 +171,8 @@ checkAnyPackageDB() {
 		[ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}.sig")" == "$(readlink -e "${FTP_BASE}/${PKGPOOL}/${pkg}.sig")" ]
 
 		for db in "${DBEXT}" "${FILESEXT}"; do
-			if [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ]; then
-				bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkg}" &>/dev/null
-			fi
+			[ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ]
+			bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkg}" &>/dev/null
 		done
 	done
 	[ ! -r "${STAGING}/${repo}/${pkg}" ]
-- 
2.16.2




More information about the Dev mailing list