[pacman-dev] [PATCH] makepkg: Exit on failure within build() or package() functions

Allan McRae allan at archlinux.org
Fri Jul 3 11:57:57 EDT 2009


Errors in build() functions were only fatal, if "--log" was enabled. Errors in
package() functions were never fatal. Piping these functions through "cat -"
triggers error trapping. This prevents the need for "|| return 1" usage in
PKGBUILDs.

Original-patch-by: Juergen Hoetzel <juergen at archlinux.org>
Signed-off-by: Allan McRae <allan at archlinux.org>
---
 scripts/makepkg.sh.in |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 91e2518..34c92c7 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -717,8 +717,10 @@ run_build() {
 
 		build 2>&1 | tee "$BUILDLOG"; ret=${PIPESTATUS[0]}
 	else
-		build 2>&1 || ret=$?
+		# piping to cat ensures makepkg fails on any build error
+		build 2>&1 | cat -; ret=${PIPESTATUS[0]}
 	fi
+
 	# reset our shell options
 	eval "$shellopts"
 
@@ -771,12 +773,12 @@ run_package() {
 		exec 3>&1
 		tee "$BUILDLOG" < "$logpipe" &
 		exec 1>"$logpipe" 2>"$logpipe"
-		$pkgfunc 2>&1 || ret=$?
+		$pkgfunc 2>&1 | cat -; ret=${PIPESTATUS[0]}
 		sync
 		exec 1>&3 2>&3 3>&-
 		rm "$logpipe"
 	else
-		$pkgfunc 2>&1 || ret=$?
+		$pkgfunc 2>&1 | cat -; ret=${PIPESTATUS[0]}
 	fi
 
 	if [ $ret -gt 0 ]; then
-- 
1.6.3.3



More information about the pacman-dev mailing list