summaryrefslogtreecommitdiff
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
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.
-rwxr-xr-xsrc/abslibre-tools/libreaddiff7
-rwxr-xr-xsrc/abslibre-tools/librestage2
-rwxr-xr-xsrc/aur2
-rwxr-xr-xsrc/fullpkg/fullpkg-find4
-rw-r--r--src/lib/conf.sh34
-rwxr-xr-xsrc/mips64el-tools/mipsrelease2
-rwxr-xr-xsrc/pkgbuild-check-licenses8
-rwxr-xr-xsrc/pkgbuild-check-nonfree8
-rwxr-xr-xsrc/toru/toru-info7
-rwxr-xr-xsrc/toru/toru-path4
-rwxr-xr-xsrc/treepkg2
11 files changed, 46 insertions, 34 deletions
diff --git a/src/abslibre-tools/libreaddiff b/src/abslibre-tools/libreaddiff
index fafdada..e31cc7b 100755
--- a/src/abslibre-tools/libreaddiff
+++ b/src/abslibre-tools/libreaddiff
@@ -68,12 +68,7 @@ except StopIteration:
# Needed to not include pkgnames specific to other arches.
CARCH=$arch
for f in $repo/* ; do
- unset pkgname
- unset epoch
- unset pkgver
- unset pkgrel
- unset arch
- . $f/PKGBUILD || continue
+ load_PKGBUILD "$f/PKGBUILD" || continue
is_here=false
for arc in ${arch[@]} ; do
if [ "$arc" = "any" -o "$arc" = "$CARCH" ] ; then
diff --git a/src/abslibre-tools/librestage b/src/abslibre-tools/librestage
index 6eba8dd..e67e98f 100755
--- a/src/abslibre-tools/librestage
+++ b/src/abslibre-tools/librestage
@@ -63,7 +63,7 @@ main() {
load_files makepkg # for PKGDEST, which is optional
# Load the PKGBUILD
- source ./PKGBUILD
+ load_PKGBUILD
# Now for the main routine.
staged=false
diff --git a/src/aur b/src/aur
index e4c535c..c9bc0cf 100755
--- a/src/aur
+++ b/src/aur
@@ -102,7 +102,7 @@ main() {
cd "$copy_new"
fi
- . PKGBUILD
+ load_PKGBUILD
################################################################
diff --git a/src/fullpkg/fullpkg-find b/src/fullpkg/fullpkg-find
index d110ff2..9bc647f 100755
--- a/src/fullpkg/fullpkg-find
+++ b/src/fullpkg/fullpkg-find
@@ -21,7 +21,7 @@ copy_files() {
# Copy PKGBUILD and sources
cp PKGBUILD "$copydir"
(
- source PKGBUILD
+ load_PKGBUILD
for file in "${source[@]}"; do
file="${file%%::*}"
file="${file##*://*/}"
@@ -46,7 +46,7 @@ copy_files() {
# Checks ABSROOT and look for target pkg deps. Adds them if not built or outdated.
find_deps() {
# Check this level
- source PKGBUILD
+ load_PKGBUILD
local repo="${repo:-$(guess_repo)}"
local pkgbase="${pkgbase:-${pkgname[0]}}"
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"
+}
diff --git a/src/mips64el-tools/mipsrelease b/src/mips64el-tools/mipsrelease
index bd7e217..fc0d904 100755
--- a/src/mips64el-tools/mipsrelease
+++ b/src/mips64el-tools/mipsrelease
@@ -35,7 +35,7 @@ main() {
fi
# Get all needed sources
- source PKGBUILD
+ load_PKGBUILD
pkgs=()
makepkg --source -f --skippgpcheck
diff --git a/src/pkgbuild-check-licenses b/src/pkgbuild-check-licenses
index 846a6e4..c6c8132 100755
--- a/src/pkgbuild-check-licenses
+++ b/src/pkgbuild-check-licenses
@@ -24,19 +24,13 @@
. libremessages
-# Unset any PKGBUILD variables inherited from the environment
-# I took these from makepkg 4.1.1-1
-unset pkgname pkgbase pkgver pkgrel epoch pkgdesc url license groups provides
-unset md5sums replaces depends conflicts backup source install changelog build
-unset makedepends optdepends options noextract
-
# Usage: check_deps $pkgbuild
# Check whether a PKGBUILD package depends on non-free packages
check_licenses() (
# Note that we use () instead of {} for this function; so that variables
# from the PKBUILD don't bubble up
local pkgbuild=$1
- . "$pkgbuild"
+ load_PKGBUILD "$pkgbuild"
if [[ -z $pkgname ]]; then
return $_E_ERROR # not a PKGBUILD
fi
diff --git a/src/pkgbuild-check-nonfree b/src/pkgbuild-check-nonfree
index 0f1f6ff..6f2ae2f 100755
--- a/src/pkgbuild-check-nonfree
+++ b/src/pkgbuild-check-nonfree
@@ -24,19 +24,13 @@
. libremessages
. libreblacklist
-# Unset any PKGBUILD variables inherited from the environment
-# I took these from makepkg 4.1.1-1
-unset pkgname pkgbase pkgver pkgrel epoch pkgdesc url license groups provides
-unset md5sums replaces depends conflicts backup source install changelog build
-unset makedepends optdepends options noextract
-
# Usage: check_deps $pkgbuild
# Check whether a PKGBUILD package depends on non-free packages
check_deps() (
# Note that we use () instead of {} for this function; so that variables
# from the PKBUILD don't bubble up
local pkgbuild=$1
- . "$pkgbuild"
+ load_PKGBUILD "$pkgbuild"
if [[ -z "$pkgname" ]]; then
exit 1 # not a PKGBUILD
fi
diff --git a/src/toru/toru-info b/src/toru/toru-info
index 5b6fd01..6418de4 100755
--- a/src/toru/toru-info
+++ b/src/toru/toru-info
@@ -1,12 +1,13 @@
#!/bin/bash
# Prints info about a given pkgname
. libremessages
+. $(librelib conf)
for _pkg in $@; do
_pkgbuild="$(toru-where $_pkg)"
if [ -f "$_pkgbuild/PKGBUILD" ]; then
- source "$_pkgbuild/PKGBUILD" 2>/dev/null || {
+ load_PKGBUILD "$_pkgbuild/PKGBUILD" 2>/dev/null || {
warning "Errors on %s" $_pkg
continue
}
@@ -14,8 +15,6 @@ for _pkg in $@; do
deps="${depends[@]} ${makedepends[@]} ${checkdepends[@]}"
repo="$(basename $(dirname "$_pkgbuild"))"
- unset build package depends makedepends checkdepends optdepends source md5sums
-
msg "%s/%s %s-%s" $repo $_pkg $pkgver $pkgrel
msg2 "$pkgdesc"
msg2 "$url"
@@ -23,6 +22,4 @@ for _pkg in $@; do
else
warning "%s doesn't exist" $_pkg
fi
-
- unset pkgname pkgver pkgrel pkgdesc url
done
diff --git a/src/toru/toru-path b/src/toru/toru-path
index 3f35dbe..ca87e48 100755
--- a/src/toru/toru-path
+++ b/src/toru/toru-path
@@ -32,7 +32,7 @@ msg "Updating path cache"
msg2 "${#pkgbuilds[@]} PKGBUILDs to update"
for _pkgbuild in ${pkgbuilds[@]}; do
# plain "$_pkgbuild"
- source ${_pkgbuild} >/dev/null 2>&1 || {
+ load_PKGBUILD "${_pkgbuild}" >/dev/null 2>&1 || {
error "${_pkgbuild} contains errors, skipping"
continue
}
@@ -43,8 +43,6 @@ for _pkgbuild in ${pkgbuilds[@]}; do
$VERBOSE && msg2 "${_pkg} -> ${fullpath}"
tcamgr put ${PATHFILE} ${_pkg/[<>=]*} ${fullpath}
done
-
- unset pkgbase pkgname provides
done
lastsync ${LASTSYNCFILE}
diff --git a/src/treepkg b/src/treepkg
index 10bebcf..cdccc21 100755
--- a/src/treepkg
+++ b/src/treepkg
@@ -83,7 +83,7 @@ if [ ! -f PKGBUILD ]; then
exit 1
fi
-if ! source PKGBUILD ; then
+if ! load_PKGBUILD ; then
error "Can't source PKGBUILD"
exit 1
fi