summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2018-02-15 22:34:36 -0500
committerEli Schwartz <eschwartz@archlinux.org>2018-02-22 00:20:32 -0500
commite53cad6e4a8284165c6d0b2c7c86f6c077be693b (patch)
tree705de25a11df86c0a15d5ec9850d6405ed1dd4d1
parentc82f4372440b42f879344f105e12fb358c4c0ccf (diff)
Globally set $PKGEXT to a bash extended glob representing valid choices.
The current glob `*.pkg.tar.?z` is both less restrictive and more restrictive than makepkg, as it accepts any valid unicode character. To be more exact, it's almost completely orthogonal to the one in makepkg. makepkg only accepts .tar.gz, .tar.bz2, .tar.xz, .tar.lzo, .tar.lrz, and .tar.Z and most of those fail to match against a two-char compression type. dbscripts accepts .pkg.tar.💩z which incidentally is what I think of cherry-picking xz and gz as supported methods. Since this can be anything makepkg.conf accepts, it needs to be able to match all that, unless we decide to perform additional restrictions in which case we should still explicitly list each allowed extension. Using bash extended globbing allows us to do this relatively painlessly. Document the fact that this has *always* been some sort of glob, and update the two cases where this was (not!) being evaluated by bash [[ ... ]], to use a not-elegant-at-all proxy function is_globfile() to evaluate globs *before* testing if they exist.
-rw-r--r--config4
-rw-r--r--db-functions14
2 files changed, 14 insertions, 4 deletions
diff --git a/config b/config
index 5bb3b16..c03fe50 100644
--- a/config
+++ b/config
@@ -25,9 +25,11 @@ TMPDIR="/var/tmp"
ARCHES=(x86_64)
DBEXT=".db.tar.gz"
FILESEXT=".files.tar.gz"
-PKGEXTS=".pkg.tar.?z"
SRCEXT=".src.tar.gz"
+# bash glob listing allowed extensions. Note that db-functions turns on extglob.
+PKGEXTS=".pkg.tar.@(gz|bz2|xz|lzo|lrz|Z)"
+
# Allowed licenses: get sourceballs only for licenses in this array
ALLOWED_LICENSES=('GPL' 'GPL1' 'GPL2' 'GPL3' 'LGPL' 'LGPL1' 'LGPL2' 'LGPL2.1' 'LGPL3')
diff --git a/db-functions b/db-functions
index 394c7a2..8b71cae 100644
--- a/db-functions
+++ b/db-functions
@@ -3,7 +3,7 @@
. /usr/share/makepkg/util.sh
# global shell options for enhanced bash scripting
-shopt -s globstar nullglob
+shopt -s extglob globstar nullglob
# Some PKGBUILDs need CARCH to be set
@@ -20,6 +20,14 @@ restore_umask () {
umask $UMASK >/dev/null
}
+# 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 is_globfile() and have them expanded as function
+# arguments before being checked.
+is_globfile() {
+ [[ -f $1 ]]
+}
+
# just like mv -f, but we touch the file and then copy the content so
# default ACLs in the target dir will be applied
mv_acl() {
@@ -378,8 +386,8 @@ check_pkgrepos() {
local pkgver="$(getpkgver ${pkgfile})" || return 1
local pkgarch="$(getpkgarch ${pkgfile})" || return 1
- [[ -f ${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}${PKGEXTS} ]] && return 1
- [[ -f ${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}${PKGEXTS}.sig ]] && return 1
+ is_globfile "${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXTS} && return 1
+ is_globfile "${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXTS}.sig && return 1
[[ -f ${FTP_BASE}/${PKGPOOL}/${pkgfile##*/} ]] && return 1
[[ -f ${FTP_BASE}/${PKGPOOL}/${pkgfile##*/}.sig ]] && return 1