[pacman-dev] [PATCH 6/9] Cleaned up and simplified run_build().

Andrew Fyfe andrew at neptune-one.net
Sun Apr 1 18:49:58 EDT 2007


Restore LC_ALL and LANG after running build().

Signed-off-by: Andrew Fyfe <andrew at neptune-one.net>

diff --git a/scripts/makepkg.in b/scripts/makepkg.in
index 1fd7cf9..75832f1 100755
--- a/scripts/makepkg.in
+++ b/scripts/makepkg.in
@@ -359,7 +359,7 @@ removedeps() {
 run_build () {
 	# use distcc if it is requested (check buildenv and PKGBUILD opts)
 	if [ "$(check_buildenv distcc)" = "y" -a "$(check_option distcc)" != "n" ]; then
-		[ -d /usr/lib/distcc/bin ] && export PATH=/usr/lib/distcc/bin:$PATH
+		[ -d /usr/lib/distcc/bin ] && export PATH="/usr/lib/distcc/bin:$PATH"
 	elif [ "$(check_option distcc)" = "n" ]; then
 		# if it is not wanted, clear the makeflags too
 		export MAKEFLAGS=""
@@ -367,7 +367,7 @@ run_build () {
 
 	# use ccache if it is requested (check buildenv and PKGBUILD opts)
 	if [ "$(check_buildenv ccache)" = "y" -a "$(check_option ccache)" != "n" ]; then
-		[ -d /usr/lib/ccache/bin ] && export PATH=/usr/lib/ccache/bin:$PATH
+		[ -d /usr/lib/ccache/bin ] && export PATH="/usr/lib/ccache/bin:$PATH"
 	fi
 
 	# clear user-specified makeflags if requested
@@ -375,22 +375,23 @@ run_build () {
 		export MAKEFLAGS=""
 	fi
 
-	# build
 	msg "$(gettext "Starting build()...")"
+	cd "$startdir"/src
 
 	# some applications (eg, blackbox) will not build with some languages
+	local _LC_ALL="$LC_ALL"
+	local _LANG="$LANG"
 	unset LC_ALL LANG
 	umask 0022
 
-	#check for "exit on syntax error" shell option
-	echo $SHELLOPTS | grep errexit 2>&1 >/dev/null
-	set_e=$?
+	# check for "exit on syntax error" shell option
+	echo $SHELLOPTS | grep errexit 2>&1 >/dev/null; set_e=$?
 
-	ret=0
+	local ret=0
 	if [ "$LOGGING" = "1" ]; then
 		BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log"
 		if [ -f "$BUILDLOG" ]; then
-			i=1
+			local i=1
 			while true; do
 				if [ -f "$BUILDLOG.$i" ]; then
 					i=$(($i +1))
@@ -401,7 +402,7 @@ run_build () {
 			mv "$BUILDLOG" "$BUILDLOG.$i"
 		fi
 
-		#use 'errexit' to bail on syntax error
+		# use 'errexit' to bail on syntax error
 		[ $set_e -eq 1 ] && set -e
 		build 2>&1 | tee "$BUILDLOG"; ret=${PIPESTATUS[0]}
 		[ $set_e -eq 1 ] && set +e
@@ -411,10 +412,15 @@ run_build () {
 		build 2>&1 || ret=$?
 		[ $set_e -eq 1 ] && set +e
 	fi
+
+	# restore LC_ALL & LANG
+	export LC_ALL="$_LC_ALL"
+	export LANG="$_LANG"
+
 	if [ $ret -gt 0 ]; then
 		error "$(gettext "Build Failed.  Aborting...")"
 		removedeps
-		exit 2
+		exit 2 # $E_BUILD_FAILED # TODO: error code
 	fi
 }
 
-- 
1.5.0.6





More information about the pacman-dev mailing list