summaryrefslogtreecommitdiff
path: root/meta/classes
diff options
context:
space:
mode:
authorJoshua Lock <josh@linux.intel.com>2010-02-11 16:11:01 +0000
committerJoshua Lock <josh@linux.intel.com>2010-02-11 16:21:09 +0000
commit6e1cc7ca104b78ebb34a15eb4a41e33c7186d2fd (patch)
tree0f47b358ce2f5e26c43777c79409274eeb218a17 /meta/classes
parenta0795895e317fddb212dc531e2ac8943f433c562 (diff)
downloadopenembedded-core-6e1cc7ca104b78ebb34a15eb4a41e33c7186d2fd.tar.gz
openembedded-core-6e1cc7ca104b78ebb34a15eb4a41e33c7186d2fd.tar.bz2
openembedded-core-6e1cc7ca104b78ebb34a15eb4a41e33c7186d2fd.tar.xz
openembedded-core-6e1cc7ca104b78ebb34a15eb4a41e33c7186d2fd.zip
relocatable.bbclass: remove hard-coded rpaths from native binaries
The relocatable path will pre-process built binaries in SYSROOT_DESTDIR and replace any harcoded dynamic link rpaths with relative paths. Add an inherit of class in native.bbclass to make our native packages relocatable and tweak the chrpath recipe so that the native package can make itself relocatable with the just built chrpath binary. Signed-off-by: Joshua Lock <josh@linux.intel.com>
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/native.bbclass3
-rw-r--r--meta/classes/relocatable.bbclass24
2 files changed, 27 insertions, 0 deletions
diff --git a/meta/classes/native.bbclass b/meta/classes/native.bbclass
index 01f886294..9d678fd80 100644
--- a/meta/classes/native.bbclass
+++ b/meta/classes/native.bbclass
@@ -1,3 +1,6 @@
+# We want native packages to be relocatable
+inherit relocatable
+
# Native packages are built indirectly via dependency,
# no need for them to be a direct target of 'world'
EXCLUDE_FROM_WORLD = "1"
diff --git a/meta/classes/relocatable.bbclass b/meta/classes/relocatable.bbclass
new file mode 100644
index 000000000..81fe8c518
--- /dev/null
+++ b/meta/classes/relocatable.bbclass
@@ -0,0 +1,24 @@
+SYSROOT_PREPROCESS_FUNCS += "relocatable_binaries_preprocess"
+
+CHRPATH_BIN ?= "chrpath"
+
+def rpath_replace (paths, d):
+ chrpath = bb.data.expand('${CHRPATH_BIN}', d)
+
+ 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))
+
+python relocatable_binaries_preprocess() {
+ paths = []
+ target = bb.data.expand("${SYSROOT_DESTDIR}${TMPDIR}/sysroots/${TARGET_ARCH}-${TARGET_OS}", d)
+
+ paths.append(target + "/bin")
+ paths.append(target + "/usr/bin")
+
+ rpath_replace(paths, d)
+}