From a00615bfdad628299352b94e0f44d211a758fd17 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Wed, 22 May 2019 10:44:26 -0400 Subject: 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 Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) (limited to 'scripts/makepkg.sh.in') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 4d9948ec..f5285a0d 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -354,15 +354,6 @@ error_function() { exit $E_USER_FUNCTION_FAILED } -source_safe() { - shopt -u extglob - if ! source "$@"; then - error "$(gettext "Failed to source %s")" "$1" - exit $E_MISSING_FILE - fi - shopt -s extglob -} - merge_arch_attrs() { local attr supported_attrs=( provides conflicts depends replaces optdepends @@ -1112,28 +1103,7 @@ trap 'trap_exit USR1 "$(gettext "An unknown error has occurred. Exiting...")"' E # preserve environment variables to override makepkg.conf restore_envvars=$(declare -p PKGDEST SRCDEST SRCPKGDEST LOGDEST BUILDDIR PKGEXT SRCEXT GPGKEY PACKAGER CARCH 2>/dev/null || true) -# default config is makepkg.conf -MAKEPKG_CONF=${MAKEPKG_CONF:-$confdir/makepkg.conf} - -# Source the config file; fail if it is not found -if [[ -r $MAKEPKG_CONF ]]; then - source_safe "$MAKEPKG_CONF" -else - error "$(gettext "%s not found.")" "$MAKEPKG_CONF" - plain "$(gettext "Aborting...")" - exit $E_CONFIG_ERROR -fi - -# Source user-specific makepkg.conf overrides, but only if no override config -# file was specified -XDG_PACMAN_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/pacman" -if [[ "$MAKEPKG_CONF" = "$confdir/makepkg.conf" ]]; then - if [[ -r "$XDG_PACMAN_DIR/makepkg.conf" ]]; then - source_safe "$XDG_PACMAN_DIR/makepkg.conf" - elif [[ -r "$HOME/.makepkg.conf" ]]; then - source_safe "$HOME/.makepkg.conf" - fi -fi +source_makepkg_config eval "$restore_envvars" -- cgit v1.2.3-54-g00ecf