diff options
-rw-r--r-- | meta/classes/native.bbclass | 3 | ||||
-rw-r--r-- | meta/classes/relocatable.bbclass | 24 | ||||
-rw-r--r-- | meta/packages/chrpath/chrpath_0.13.bb | 5 |
3 files changed, 32 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) +} diff --git a/meta/packages/chrpath/chrpath_0.13.bb b/meta/packages/chrpath/chrpath_0.13.bb index e843de687..012897d57 100644 --- a/meta/packages/chrpath/chrpath_0.13.bb +++ b/meta/packages/chrpath/chrpath_0.13.bb @@ -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" |