]> code.ossystems Code Review - openembedded-core.git/commitdiff
relocatable.bbclass: remove hard-coded rpaths from native binaries
authorJoshua Lock <josh@linux.intel.com>
Thu, 11 Feb 2010 16:11:01 +0000 (16:11 +0000)
committerJoshua Lock <josh@linux.intel.com>
Thu, 11 Feb 2010 16:21:09 +0000 (16:21 +0000)
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>
meta/classes/native.bbclass
meta/classes/relocatable.bbclass [new file with mode: 0644]
meta/packages/chrpath/chrpath_0.13.bb

index 01f886294e74becbb16e204314afecd7006b907f..9d678fd802978bbb89683cb4495d48e964db6d56 100644 (file)
@@ -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 (file)
index 0000000..81fe8c5
--- /dev/null
@@ -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)
+}
index e843de6872aa3de8c2fcb5bb55941891580d396a..012897d5755f87617b513d6d763a50206840fe72 100644 (file)
@@ -2,6 +2,7 @@ DESCRIPTION = "chrpath allows you to change the rpath (where the application \
 looks for libraries) in an application. It does not (yet) allow you to add an \
 rpath if there isn't one already."
 LICENSE = "GPL"
+PR = "r1"
 
 SRC_URI = "${DEBIAN_MIRROR}/main/c/chrpath/chrpath_${PV}.orig.tar.gz"
 
@@ -9,4 +10,8 @@ inherit autotools
 
 S = "${WORKDIR}/chrpath-${PV}"
 
+# We don't have a staged chrpath-native for ensuring our binary is relocatable
+# so must use the one we've just built
+CHRPATH_BIN = "${S}/chrpath"
+
 BBCLASSEXTEND = "native"