diff options
author | Dave Reisner <dreisner@archlinux.org> | 2012-02-10 15:10:32 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2012-04-08 21:52:26 -0500 |
commit | 8fe67919284446a0d83755df3b7d64f54d4a4962 (patch) | |
tree | b3cb7aa66a1c8daa6513c49ebfcc99bd7cdd2f91 | |
parent | dca10b062f27a67dd2daafbe73641b1b7279408e (diff) | |
download | pacman-8fe67919284446a0d83755df3b7d64f54d4a4962.tar.xz |
makepkg: catch errors sourcing files
create source_safe() function which temporarily disables extglob and
exits on error.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
-rw-r--r-- | scripts/makepkg.sh.in | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index ec5f1ee1..3a689ff1 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -873,6 +873,15 @@ cd_safe() { fi } +source_safe() { + shopt -u extglob + if ! source "$@"; then + error "$(gettext "Failed to source %s")" "$1" + exit 1 + fi + shopt -s extglob +} + run_function_safe() { local restoretrap @@ -1816,7 +1825,7 @@ devel_update() { if [[ -f $BUILDFILE && -w $BUILDFILE ]]; then @SEDINPLACE@ "s/^pkgver=[^ ]*/pkgver=$newpkgver/" "$BUILDFILE" @SEDINPLACE@ "s/^pkgrel=[^ ]*/pkgrel=1/" "$BUILDFILE" - source "$BUILDFILE" + source_safe "$BUILDFILE" fi fi fi @@ -2026,7 +2035,7 @@ MAKEPKG_CONF=${MAKEPKG_CONF:-$confdir/makepkg.conf} # Source the config file; fail if it is not found if [[ -r $MAKEPKG_CONF ]]; then - source "$MAKEPKG_CONF" + source_safe "$MAKEPKG_CONF" else error "$(gettext "%s not found.")" "$MAKEPKG_CONF" plain "$(gettext "Aborting...")" @@ -2036,7 +2045,7 @@ fi # Source user-specific makepkg.conf overrides, but only if no override config # file was specified if [[ $MAKEPKG_CONF = "$confdir/makepkg.conf" && -r ~/.makepkg.conf ]]; then - source ~/.makepkg.conf + source_safe ~/.makepkg.conf fi # set pacman command if not already defined @@ -2153,9 +2162,7 @@ if [[ ! -f $BUILDFILE ]]; then else # PKGBUILD passed through a pipe BUILDFILE=/dev/stdin - shopt -u extglob - source "$BUILDFILE" - shopt -s extglob + source_safe "$BUILDFILE" fi else crlftest=$(file "$BUILDFILE" | grep -F 'CRLF' || true) @@ -2167,9 +2174,7 @@ else if [[ ${BUILDFILE:0:1} != "/" ]]; then BUILDFILE="$startdir/$BUILDFILE" fi - shopt -u extglob - source "$BUILDFILE" - shopt -s extglob + source_safe "$BUILDFILE" fi # set defaults if they weren't specified in buildfile |