summaryrefslogtreecommitdiffstats
path: root/scripts/libmakepkg/util/util.sh.in
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2019-05-22 16:44:26 +0200
committerAllan McRae <allan@archlinux.org>2019-05-28 03:28:30 +0200
commita00615bfdad628299352b94e0f44d211a758fd17 (patch)
tree6ac7380ccbdbfd0dfc64493e2d025952df133e6e /scripts/libmakepkg/util/util.sh.in
parent5caf45cdbb267ee45c7b4a9c815e500efd350e6e (diff)
downloadpacman-a00615bfdad628299352b94e0f44d211a758fd17.tar.gz
pacman-a00615bfdad628299352b94e0f44d211a758fd17.tar.xz
makepkg: move config loading into libmakepkg
When scripting/automating around makepkg, it is sometimes desirable to know how makepkg will be configured to operate. One example is the archlinux devtools, which must forward select makepkg.conf variables into a build chroot (for example PACKAGER) or use those variables itself (for example {SRC,PKG,LOG}DEST). The configuration file can be in up to 3 places, and should be capable of being overridden via environment variables. It is sufficiently complex to represent distinct functionality, and sufficiently useful to merit easy accessibility in other scripts, therefore, let us move it into a publicly exposed utility library. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'scripts/libmakepkg/util/util.sh.in')
-rw-r--r--scripts/libmakepkg/util/util.sh.in14
1 files changed, 14 insertions, 0 deletions
diff --git a/scripts/libmakepkg/util/util.sh.in b/scripts/libmakepkg/util/util.sh.in
index 5ea3ed9b..b20384b8 100644
--- a/scripts/libmakepkg/util/util.sh.in
+++ b/scripts/libmakepkg/util/util.sh.in
@@ -24,6 +24,7 @@ LIBMAKEPKG_UTIL_UTIL_SH=1
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+source "$LIBRARY/util/error.sh"
source "$LIBRARY/util/message.sh"
##
@@ -98,3 +99,16 @@ ensure_writable_dir() {
return 0
}
+
+# source a file and fail if it does not succeed
+source_safe() {
+ local shellopts=$(shopt -p extglob)
+ shopt -u extglob
+
+ if ! source "$@"; then
+ error "$(gettext "Failed to source %s")" "$1"
+ exit $E_MISSING_FILE
+ fi
+
+ eval "$shellopts"
+}