summaryrefslogtreecommitdiffstats
path: root/meta/classes/relocatable.bbclass
diff options
context:
space:
mode:
authorJoshua Lock <josh@linux.intel.com>2010-02-12 14:55:32 +0000
committerJoshua Lock <josh@linux.intel.com>2010-02-12 15:00:44 +0000
commitf1a87fadc7c091c67499a0c953603ce63f826177 (patch)
tree9e49d3682feb96eb4bf763b94d22d6155736f52b /meta/classes/relocatable.bbclass
parent62c103ce0e154ee5bf6183987adc90fc6df154c6 (diff)
downloadopenembedded-core-f1a87fadc7c091c67499a0c953603ce63f826177.tar.gz
relocatable.bbclass: Improve logic and style
The initial pass at this class was pretty lame and broke on a lot of native packages. This rewrite makes the code a lot more dynamic, removing use of hard coded paths and improving the logic. The class now runs a chrpath -l over the binary to determine what rpaths are currently set. It then munges the output and determines relative versions of each component of the rpath and uses chrpath -r to set them. Signed-off-by: Joshua Lock <josh@linux.intel.com>
Diffstat (limited to 'meta/classes/relocatable.bbclass')
-rw-r--r--meta/classes/relocatable.bbclass46
1 files changed, 31 insertions, 15 deletions
diff --git a/meta/classes/relocatable.bbclass b/meta/classes/relocatable.bbclass
index 81fe8c518d..95be7b6e88 100644
--- a/meta/classes/relocatable.bbclass
+++ b/meta/classes/relocatable.bbclass
@@ -2,23 +2,39 @@ SYSROOT_PREPROCESS_FUNCS += "relocatable_binaries_preprocess"
CHRPATH_BIN ?= "chrpath"
-def rpath_replace (paths, d):
- chrpath = bb.data.expand('${CHRPATH_BIN}', d)
+def rpath_replace (path, d):
+ import subprocess as sub
- for path in paths:
- for root, dirs, files in os.walk(path):
- for f in files:
- if 'usr' in path:
- os.system("%s -r $ORIGIN/../lib:$ORIGIN/../../lib %s/%s" % (chrpath, path,f))
- else:
- os.system("%s -r $ORIGIN/../lib %s/%s" % (chrpath, path, f))
+ cmd = bb.data.expand('${CHRPATH_BIN}', d)
+ tmpdir = bb.data.expand('${base_prefix}', d)
-python relocatable_binaries_preprocess() {
- paths = []
- target = bb.data.expand("${SYSROOT_DESTDIR}${TMPDIR}/sysroots/${TARGET_ARCH}-${TARGET_OS}", d)
+ for root, dirs, files in os.walk(path):
+ for file in files:
+ fpath = root + '/' + file
+ if '/bin/' in fpath:
+ p = sub.Popen([cmd, '-l', fpath],stdout=sub.PIPE,stderr=sub.PIPE)
+ err, out = p.communicate()
+ # If returned succesfully, process stderr for results
+ if p.returncode == 0:
+ # Throw away everything other than the rpath list
+ curr_rpath = err.partition("RPATH=")[2]
+ #bb.note("Current rpath for %s is %s" % (fpath, curr_rpath.strip()))
+ rpaths = curr_rpath.split(":")
+ new_rpaths = []
+ for rpath in rpaths:
+ depth = fpath.partition(tmpdir)[2].strip().count('/')
+ if depth == 3:
+ # / is two levels up
+ root = "$ORIGIN/../.."
+ else:
+ root = "$ORIGIN/.."
- paths.append(target + "/bin")
- paths.append(target + "/usr/bin")
+ # kill everything up to "/"
+ new_rpaths.append("%s%s" % (root, rpath.partition(tmpdir)[2].strip()))
+ args = ":".join(new_rpaths)
+ #bb.note("Setting rpath to " + args)
+ sub.call([cmd, '-r', args, fpath])
- rpath_replace(paths, d)
+python relocatable_binaries_preprocess() {
+ rpath_replace(bb.data.expand("${SYSROOT_DESTDIR}${TMPDIR}/sysroots/${TARGET_ARCH}-${TARGET_OS}", d), d)
}
ter/pybootchart_wip OpenEmbedded Core user contribution treesGrokmirror user
summaryrefslogtreecommitdiffstats
path: root/meta/files/common-licenses/RHeCos-1.1
blob: f98900abf1d232372382429e1f3eb4399ba19c95 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151