2010-02-11 16:11:01 +00:00
|
|
|
SYSROOT_PREPROCESS_FUNCS += "relocatable_binaries_preprocess"
|
|
|
|
|
|
|
|
CHRPATH_BIN ?= "chrpath"
|
|
|
|
|
2010-02-12 14:55:32 +00:00
|
|
|
def rpath_replace (path, d):
|
|
|
|
import subprocess as sub
|
2010-02-11 16:11:01 +00:00
|
|
|
|
2010-02-12 14:55:32 +00:00
|
|
|
cmd = bb.data.expand('${CHRPATH_BIN}', d)
|
2010-02-11 16:11:01 +00:00
|
|
|
|
2010-02-12 14:55:32 +00:00
|
|
|
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:
|
2010-02-12 17:10:50 +00:00
|
|
|
depth = fpath.partition(path)[2].count('/')
|
2010-02-12 14:55:32 +00:00
|
|
|
if depth == 3:
|
|
|
|
# / is two levels up
|
|
|
|
root = "$ORIGIN/../.."
|
|
|
|
else:
|
|
|
|
root = "$ORIGIN/.."
|
2010-02-11 16:11:01 +00:00
|
|
|
|
2010-02-12 14:55:32 +00:00
|
|
|
# kill everything up to "/"
|
2010-02-12 17:10:50 +00:00
|
|
|
new_rpaths.append("%s%s" % (root, rpath.partition(path)[2].strip()))
|
2010-02-12 14:55:32 +00:00
|
|
|
args = ":".join(new_rpaths)
|
|
|
|
#bb.note("Setting rpath to " + args)
|
|
|
|
sub.call([cmd, '-r', args, fpath])
|
2010-02-11 16:11:01 +00:00
|
|
|
|
2010-02-12 14:55:32 +00:00
|
|
|
python relocatable_binaries_preprocess() {
|
2010-02-12 17:10:50 +00:00
|
|
|
rpath_replace(bb.data.getVar('base_prefix', d, True), d)
|
2010-02-11 16:11:01 +00:00
|
|
|
}
|