From c50825cb8923e35282be44b2c7fc417ee1dc19e0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 31 Dec 2014 19:41:29 -0500 Subject: lib/conf.sh: Update unset_PKGBUILD to support arch-specific variables Also, sha224sums, which is not actually mentioned in the makepkg documentation. --- src/lib/conf.sh.in | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/lib/conf.sh.in b/src/lib/conf.sh.in index 3ddef0b..4f86f12 100644 --- a/src/lib/conf.sh.in +++ b/src/lib/conf.sh.in @@ -188,15 +188,37 @@ set_var() { unset_PKGBUILD() { # This routine is based primarily off of the PKGBUILD(5) man-page, - # version 4.1.2, dated 2013-06-18. + # version 4.2.0, dated 2014-12-31 + + # This is kinda weird, but everything is more readable with + # this as a utility function, but I didn't want to introduce a + # new global function, so I just introduced it with the name + # of a function that we get to unset anyway. So it can't + # clash with anything! + mksource() { + local v + for v in "$@"; do + unset -v "$v" $(declare -p|sed -rn "s/^declare -\S+ ($v_[a-zA-Z0-9_]*)=.*/\1/p") + done + } + + # This line is taken from the makepkg source + local known_hash_algos=('md5' 'sha1' 'sha224' 'sha256' 'sha384' 'sha512') # From the "OPTIONS AND DIRECTIVES" section (in order of mention) unset -v pkgname pkgver unset -f pkgver - unset -v pkgrel pkgdesc epoch url license install changelog source - unset -v noextract md5sums sha{1,256,384,512}sums groups arch backup - unset -v depends makedepends checkdepends optdepends conflicts provides - unset -v replaces options + unset -v pkgrel pkgdesc epoch url license install changelog + + mksource source + unset -v noextract + local sums=("${known_hash_algos[@]/%/sums}") + mksource "${sums[@]}" + + unset -v groups arch backup + mksource depends makedepends checkdepends optdepends + mksource conflicts provides replaces + unset -v options # From the "PACKAGING FUNCTIONS" section (in order of mention) unset -f package prepare build check @@ -206,7 +228,7 @@ unset_PKGBUILD() { unset -v pkgbase # These are used by the `librefetch` program - unset -v mksource mknoextract mkmd5sums mksha{1,256,384,512}sums + unset -v mksource mknoextract "${sums[@]/#/mk}" unset -v mkdepends unset -f mksource } -- cgit v1.2.3