@@ -13,8 +13,8 @@ __checkRepoRemovedPackage() {
local pkgname
for pkgname in $(__getPackageNamesFromPackageBase ${pkgbase}); do
- [[ ! -f ${FTP_BASE}/${PKGPOOL}/${pkgname}-*${PKGEXT} ]]
- [[ ! -f ${FTP_BASE}/${repo}/os/${repoarch}/${pkgname}-*${PKGEXT} ]]
+ ! __isGlobfile "${FTP_BASE}/${PKGPOOL}/${pkgname}"-*"${PKGEXT}"
+ ! __isGlobfile "${FTP_BASE}/${repo}/os/${repoarch}/${pkgname}"-*"${PKGEXT}"
done
}
@@ -2,12 +2,12 @@ load ../lib/common
__checkSourcePackage() {
local pkgbase=$1
- [ -r ${FTP_BASE}/${SRCPOOL}/${pkgbase}-*${SRCEXT} ]
+ __isGlobfile "${FTP_BASE}/${SRCPOOL}/${pkgbase}"-*"${SRCEXT}"
}
__checkRemovedSourcePackage() {
local pkgbase=$1
- [ ! -r ${FTP_BASE}/${SRCPOOL}/${pkgbase}-*${SRCEXT} ]
+ ! __isGlobfile "${FTP_BASE}/${SRCPOOL}/${pkgbase}"-*"${SRCEXT}"
}
@test "create simple package sourceballs" {
@@ -14,6 +14,16 @@ __getCheckSum() {
echo "${result%% *}"
}
+# Proxy function to check if a file exists. Using [[ -f ... ]] directly is not
+# always wanted because we might want to expand bash globs first. This way we
+# can pass unquoted globs to __isGlobfile() and have them expanded as function
+# arguments before being checked.
+#
+# This is a copy of db-functions is_globfile
+__isGlobfile() {
+ [[ -f $1 ]]
+}
+
__buildPackage() {
local pkgdest=${1:-.}
local p
@@ -203,7 +213,7 @@ checkPackageDB() {
for repoarch in ${repoarches[@]}; do
# Only 'any' packages can be found in repos of both arches
if [[ $pkgarch != any ]]; then
- if [[ $pkgarch != ${repoarch} ]]; then
+ if [[ $pkgarch != "$repoarch" ]]; then
continue
fi
fi
From: Luke Shumaker <lukeshu@parabola.nu> - ftpdir-cleanup.bats: Glob expansion does not occur in [[ -f ]] tests. The [[ ! -f .../${pkgname}-*${PKGEXT} ]] checks were checking that there were no files containing a literal '*' for that part of their name. Obviously, this isn't what was intended. - sourceballs.bats: [ -r ] checks explode if the glob returns >1 file. Avoid using them if the path being checked contains a glob. - common.bash: Globbing happens on the RHS of a [[ = ]] test. This means that we must quote variables on the RHS that are to be taken verbatim. This is surprising, because we don't need to quote the LHS. --- test/cases/ftpdir-cleanup.bats | 4 ++-- test/cases/sourceballs.bats | 4 ++-- test/lib/common.bash | 12 +++++++++++- 3 files changed, 15 insertions(+), 5 deletions(-)