[pacman-dev] [PATCH 9/9] Added support for fake_install().

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


Modified run_build() so it can be used to run other functions.

Added support for fake_install().

If a PKGBUILD contains a fake_install() function, build() will be run as
the user calling makepkg and fake_install() will be called inside
fakeroot. Otherwise build() will be run inside fakeroot as normal.

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

diff --git a/scripts/makepkg.in b/scripts/makepkg.in
index 54b9f12..daff198 100755
--- a/scripts/makepkg.in
+++ b/scripts/makepkg.in
@@ -350,6 +350,12 @@ removedeps() {
 }
 
 run_build () {
+	if [ "$(type -t $1)" != "function" ]; then
+		error "$(gettext_eval "Unknown function '\${1}'.")"
+		error "$(gettext "Aborting...")"
+		exit 1 # TODO: error code
+	fi
+
 	# 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"
@@ -368,7 +374,7 @@ run_build () {
 		export MAKEFLAGS=""
 	fi
 
-	msg "$(gettext "Starting build()...")"
+	msg "$(gettext_eval "Starting \${1}()...")"
 	cd "$startdir"/src
 
 	# some applications (eg, blackbox) will not build with some languages
@@ -382,7 +388,7 @@ run_build () {
 
 	local ret=0
 	if [ "$LOGGING" = "1" ]; then
-		BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log"
+		BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}-${1}.log"
 		if [ -f "$BUILDLOG" ]; then
 			local i=1
 			while true; do
@@ -397,12 +403,12 @@ run_build () {
 
 		# use 'errexit' to bail on syntax error
 		[ $set_e -eq 1 ] && set -e
-		build 2>&1 | tee "$BUILDLOG"; ret=${PIPESTATUS[0]}
+		$1 2>&1 | tee "$BUILDLOG"; ret=${PIPESTATUS[0]}
 		[ $set_e -eq 1 ] && set +e
 	else
 		#use 'errexit' to bail on syntax error
 		[ $set_e -eq 1 ] && set -e
-		build 2>&1 || ret=$?
+		$1 2>&1 || ret=$?
 		[ $set_e -eq 1 ] && set +e
 	fi
 
@@ -851,7 +857,12 @@ if [ "$INFAKEROOT" = "1" ]; then
 	if [ "$REPKG" = "1" ]; then
 		warning "$(gettext "Skipping build.")"
 	else
-		run_build
+		if [ "$(type -t fake_install)" != "function" ]; then
+			run_build build
+		else
+			run_build fake_install
+		fi
+
 		tidy_install
  	fi
 
@@ -1103,12 +1114,17 @@ else
 		if [ "$REPKG" = "1" ]; then
 			warning "$(gettext "Skipping build.")"
 		else
-			run_build
+			run_build build
+			[ "$(type -t fake_install)" = "function" ] && run_build fake_install
 			tidy_install
 		fi
 
 		create_package
 	else
+		if [ "$REPKG" = "0" -a "$(type -t fake_install)" = "function" ]; then
+			run_build build
+		fi
+
 		msg "$(gettext "Entering fakeroot environment...")"
 		cd "$startdir"
 
@@ -1124,7 +1140,9 @@ cd "$startdir"
 if [ "$CLEANUP" = "1" ]; then
 	msg "$(gettext "Cleaning up...")"
 	rm -rf src pkg
-	rm -rf ${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log*
+	rm -f ${pkgname}-${pkgver}-${pkgrel}-${CARCH}-build.log*
+	[ "$(type -t fake_install)" = "function" ] &&
+		rm -f ${pkgname}-${pkgver}-${pkgrel}-${CARCH}-fake_install.log*
 fi
 
 removedeps
-- 
1.5.0.6





More information about the pacman-dev mailing list