summaryrefslogtreecommitdiffstats
path: root/functions
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-05-08 06:12:46 +0200
committerDave Reisner <dreisner@archlinux.org>2012-05-16 23:55:54 +0200
commit018ab6e95cd194fe7aef6a66928759075e9259bd (patch)
treed8a8a830758d332779fa42478f5fb7ebf3d1a772 /functions
parent0778982e386d15e381b8f7dddd2a2bd68e78236c (diff)
downloadmkinitcpio-018ab6e95cd194fe7aef6a66928759075e9259bd.tar.gz
mkinitcpio-018ab6e95cd194fe7aef6a66928759075e9259bd.tar.xz
refactor error tracking in build hooks
Rather than catching errors solely from parse_hook via an ERR trap, implement a RETURN trap which catches all errors from the core add_* functions. In the future, this may mean that support for MODULES/FILES/BINARIES within hooks goes away, and those variables remain only in the config. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'functions')
-rw-r--r--functions9
1 files changed, 7 insertions, 2 deletions
diff --git a/functions b/functions
index 5956dc3..bca31b4 100644
--- a/functions
+++ b/functions
@@ -160,6 +160,7 @@ warning() {
error() {
local mesg=$1; shift
printf "$RED==> ERROR:$NC$BOLD $mesg$NC\n" "$@" >&2
+ return 1
}
die() {
@@ -320,7 +321,10 @@ add_dir() {
local path=$1 mode=${2:-755}
- [[ -e $BUILDROOT$1 ]] && return 0 # file exists
+ if [[ -d $BUILDROOT$1 ]]; then
+ # ignore dir already exists
+ return 0
+ fi
(( QUIET )) || plain "adding dir: %s" "$path"
command install -dm$mode "$BUILDROOT$path"
@@ -398,7 +402,8 @@ add_binary() {
# always add the binary itself
add_file "$binary" "$dest" "$mode"
- lddout=$(ldd "$binary" 2>/dev/null) || return 0 # not a binary!
+ # negate this so that the RETURN trap is not fired on non-binaries
+ ! lddout=$(ldd "$binary" 2>/dev/null) && return 0
# resolve sodeps
regex='(/.+) \(0x[a-fA-F0-9]+\)'