From 92417870e61f83d2ae4d4d4c7f0931461d3b9c58 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Thu, 6 May 2010 19:37:52 +0000
Subject: [PATCH] abuild: properly pass over args when building recursively

---
 abuild.in | 38 ++++++++++++++++++++++----------------
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/abuild.in b/abuild.in
index 6570abecbf42..3fea58ad6024 100755
--- a/abuild.in
+++ b/abuild.in
@@ -804,7 +804,7 @@ deptrace() {
 # build and install dependencies
 builddeps() {
 	local deps= alldeps= pkg= i= dir= ver= missing= installed_deps=
-	local filtered_deps=
+	local filtered_deps= conflicts=
 	[ -n "$nodeps" ] && return 0
 	msg "Analyzing dependencies..."
 
@@ -819,17 +819,22 @@ builddeps() {
 	for i in $deps; do
 		if [ "${i#\!}" != "$i" ]; then
 			list_has ${i#\!} $installed_deps \
-				&& die "Conflicting package ${i#\!} is installed."
+				&& conflicts="$conflicts ${i#\!}"
 		elif ! deplist_has $i $installed_deps; then
-			if [ -z "$install_deps" ] && [ -z "$recursive" ]; then
-				die "Missing dependency $i. Use -r to autoinstall or -R to build"
-			fi
 			missing="$missing $i"
 		fi
 	done
 
-	[ -z "$missing" ] && [ -z "$install_deps" ] && [ -z "$recursive" ] \
-		&& return 0
+	if [ -n "$conflicts" ]; then
+		die "Conflicting package(s) installed:$conflics"
+	fi
+	
+	if [ -z "$install_deps" ] && [ -z "$recursive" ]; then
+		# if we dont have any missing deps we are done now
+		[ -z "$missing" ] && return 0
+		error "Missing dependencies: $missing Use -r to autoinstall or -R to build"
+		return 1
+	fi
 
 	uninstall_after=".makedepends-$pkgname $uninstall_after"
 	if [ -n "$install_deps" ] && [ -z "$recursive" ]; then
@@ -860,7 +865,8 @@ builddeps() {
 		local pkg=${i%:*}
 		if [ -d "$dir" ]; then
 			msg "Entering $dir"
-			cd "$dir" && $0 -k -r abuildindex || return 1
+			cd "$dir" && $0 $forceroot $keep $quiet $install_deps \
+				$recursive $upgrade abuildindex || return 1
 		fi
 	done
 	$SUDO $APK add -u --repository "$abuildrepo" \
@@ -1046,20 +1052,20 @@ unset recursive
 while getopts "dfFhi:kinp:P:qrRs:u" opt; do
 	case $opt in
 		'd') nodeps=1;;
-		'f') force=1;;
-		'F') forceroot=1;;
+		'f') force="-f";;
+		'F') forceroot="-F";;
 		'h') usage;;
 		'i') install_after="$install_after $OPTARG";;
-		'k') keep=1;;
+		'k') keep="-k";;
 		'n') die "Use newapkbuild to create new aports";;
 		'p') PKGDEST=$OPTARG;;
 		'P') REPODEST=$OPTARG;;
-		'q') quiet=1;;
-		'r') install_deps=1;;
-		'R') recursive=1;;
+		'q') quiet="-q";;
+		'r') install_deps="-r";;
+		'R') recursive="-R";;
 		's') SRCDEST=$OPTARG;;
-		'u') upgrade=1
-		     recursive=1;;
+		'u') upgrade="-u"
+		     recursive="-R";;
 	esac
 done
 shift $(( $OPTIND - 1 ))
-- 
GitLab