summaryrefslogtreecommitdiff
path: root/src/lib/conf.sh
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-06-27 21:15:00 -0600
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-06-27 21:15:00 -0600
commitb369d323c9859290e2f29c6d07e7f0394ed88cd9 (patch)
treeb0454d30775d3ab662b9c4c9e4bd24094c98ce19 /src/lib/conf.sh
parent81c44824f174eda5f57c396cc7d91e2c97490d93 (diff)
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.
Diffstat (limited to 'src/lib/conf.sh')
-rw-r--r--src/lib/conf.sh34
1 files changed, 34 insertions, 0 deletions
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"
+}