From b369d323c9859290e2f29c6d07e7f0394ed88cd9 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 27 Jun 2013 21:15:00 -0600 Subject: add {load,unset}_PKGBUILD to conf.sh, use it. There are a bunch of caveats to loading a PKGBUILD file. This way it is all done correctly in one place. unset_PKGBUILD unsets any functions and variables that are normally set in a PKGBUILD. The list is far more complete than any existing implementation. load_PKGBUILD loads the file given, or "./PKGBUILD" if none is given. But first it calls unset_PKGBUILD and then sets CARCH. --- src/lib/conf.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/lib') diff --git a/src/lib/conf.sh b/src/lib/conf.sh index f6ae91d..2dc5b70 100644 --- a/src/lib/conf.sh +++ b/src/lib/conf.sh @@ -150,3 +150,37 @@ set_conf_makepkg() { done return 1 } + +# PKGBUILD (not configuration, per se) ######################################### + +unset_PKGBUILD() { + # This routine is based primarily off of the PKGBUILD(5) man-page, + # version 4.1.2, dated 2013-06-18. + + # 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 + + # From the "PACKAGING FUNCTIONS" section (in order of mention) + unset -f package prepare build check + + # From the "PACKAGE SPLITTING" section + unset -f $(declare -f|sed -n 's/^\(package_\S*\) ()\s*$/\1/p') + unset -v pkgbase + + # These are used by the `librefetch` program + unset -v mksource mknoextract mkmd5sums mksha{1,256,384,512}sums + unset -v mkdepends + unset -f mksource +} + +load_PKGBUILD() { + local file=${1:-./PKGBUILD} + unset_PKGBUILD + CARCH="$(get_conf_makepkg CARCH "`uname -m`")" + . "$file" +} -- cgit v1.2.2