aboutsummaryrefslogtreecommitdiffstats
path: root/main/abuild/0001-buildrepo-parse-APKBUILDs-in-subshell.patch
blob: 67c79ddf5d6e14368fd759e937ad039c34151af9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
From d0e15dd5b60e76e30f42f0f9061fcce9f5a6d5a3 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Fri, 22 Feb 2013 09:03:13 +0000
Subject: [PATCH] buildrepo: parse APKBUILDs in subshell

so we dont leak functions like 'build' and other variables.
---
 buildrepo.in | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/buildrepo.in b/buildrepo.in
index f1a5749..23cc61e 100755
--- a/buildrepo.in
+++ b/buildrepo.in
@@ -46,9 +46,9 @@ all_exist() {
 	done
 	return 0
 }
-	
-build() {
-	local repo="$1" i needbuild
+
+list_needbuild() {
+	local repo="$1" i=
 
 	cd "$aportsdir/$repo" || return 0
 
@@ -78,14 +78,20 @@ build() {
 
 		# try link or copy the files if they are in the ports dir
 		if all_exist $pkgs; then
-			echo ">>> Copying " $pkgs
+			echo ">>> Copying " $pkgs >&2
 			cp -p -l $pkgs "$repodir/$repo/$CARCH"/ 2>/dev/null \
 				|| cp -p $pkgs "$repodir/$repo/$CARCH"/ \
-				|| needbuild="$needbuild $i"
+				|| echo "$i"
 		else
-			needbuild="$needbuild $i"
+			echo "$i"
 		fi
 	done
+}
+
+do_build() {
+	local repo="$1" i=
+	cd "$aportsdir/$repo" || return 0
+	local needbuild="$(list_needbuild $repo)"
 
 	# build the postponed packages if any
 	if [ -n "$needbuild" ]; then
@@ -146,9 +152,9 @@ shift $(($OPTIND - 1))
 
 while [ $# -gt 0 ]; do
 	if [ -n "$logprefix" ]; then
-		build $1  >$logprefix.$1.log 2>&1 || exit 1
+		do_build $1  >$logprefix.$1.log 2>&1 || exit 1
 	else
-		build $1 || exit 1
+		do_build $1 || exit 1
 	fi
 	deprepo="$deprepo $1"
 	shift
-- 
1.8.1.3