aboutsummaryrefslogtreecommitdiffstats
path: root/main/abuild/0001-abuild-implement-dbg-subpackages.patch
blob: f2d4acdcad1543228e5822d1ca4919dd2ce44f86 (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
67
68
69
70
71
72
73
74
75
From 9cb1ad3cffdb2664205645e2dad0600d6eaa2e1f Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Thu, 16 Jan 2014 14:33:45 +0100
Subject: [PATCH] abuild: implement -dbg subpackages

Patch from Andrew Manison.

ref #626
---
 abuild.in | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/abuild.in b/abuild.in
index c37af4d..0876380 100755
--- a/abuild.in
+++ b/abuild.in
@@ -1245,6 +1245,31 @@ doc() {
 	default_doc
 }
 
+# predefined splitfunc doc
+default_dbg() {
+	local f
+	binfiles=$(scanelf -R "$pkgdir" | grep ET_DYN | sed "s:$pkgdir\/::g" | sed "s:ET_DYN ::g")
+	for f in $binfiles; do
+		srcdir=$(dirname $pkgdir/$f)
+		srcfile=$(basename $pkgdir/$f)
+		dstdir=$(dirname $subpkgdir/usr/lib/debug/$f.debug)
+		dstfile=$(basename $subpkgdir/usr/lib/debug/$f.debug)
+		if [ ! -d $dstdir ] ; then
+			mkdir -p $dstdir
+		fi
+		cd $srcdir
+		objcopy --only-keep-debug $srcfile $dstfile
+		objcopy --add-gnu-debuglink=$dstfile $srcdir/$srcfile
+		mv $dstfile $dstdir
+		strip $srcfile
+	done
+	return 0
+}
+
+dbg() {
+	default_dbg
+}
+
 # predefined splitfunc dev
 default_dev() {
 	local i= j=
@@ -1675,6 +1700,14 @@ subpackages_has() {
 	return 1
 }
 
+subpackage_types_has() {
+	local i
+	for i in $subpackages; do
+		[ "$1" = "${i##*-}" ] && return 0
+	done
+	return 1
+}
+
 list_has() {
 	local needle="$1"
 	local i
@@ -1946,7 +1979,7 @@ else
 fi
 
 # if we want build debug package
-if [ -n "$DEBUG" ]; then
+if [ -n "$DEBUG" ] || subpackage_types_has "dbg"; then
 	CFLAGS="$CFLAGS -g"
 	options="$options !strip"
 fi
-- 
1.8.5.2