summaryrefslogtreecommitdiffstats
path: root/meta/classes/chrpath.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/chrpath.bbclass')
-rw-r--r--meta/classes/chrpath.bbclass37
1 files changed, 24 insertions, 13 deletions
diff --git a/meta/classes/chrpath.bbclass b/meta/classes/chrpath.bbclass
index 72e8a122e3..2870c10d51 100644
--- a/meta/classes/chrpath.bbclass
+++ b/meta/classes/chrpath.bbclass
@@ -1,7 +1,7 @@
CHRPATH_BIN ?= "chrpath"
PREPROCESS_RELOCATE_DIRS ?= ""
-def process_file_linux(cmd, fpath, rootdir, baseprefix, tmpdir, d):
+def process_file_linux(cmd, fpath, rootdir, baseprefix, tmpdir, d, break_hardlinks = False):
import subprocess as sub
p = sub.Popen([cmd, '-l', fpath],stdout=sub.PIPE,stderr=sub.PIPE)
@@ -17,32 +17,39 @@ def process_file_linux(cmd, fpath, rootdir, baseprefix, tmpdir, d):
# Throw away everything other than the rpath list
curr_rpath = out.partition("RPATH=")[2]
#bb.note("Current rpath for %s is %s" % (fpath, curr_rpath.strip()))
- rpaths = curr_rpath.split(":")
+ rpaths = curr_rpath.strip().split(":")
new_rpaths = []
modified = False
for rpath in rpaths:
# If rpath is already dynamic copy it to new_rpath and continue
if rpath.find("$ORIGIN") != -1:
- new_rpaths.append(rpath.strip())
+ new_rpaths.append(rpath)
continue
rpath = os.path.normpath(rpath)
if baseprefix not in rpath and tmpdir not in rpath:
- new_rpaths.append(rpath.strip())
+ # Skip standard search paths
+ if rpath in ['/lib', '/usr/lib', '/lib64/', '/usr/lib64']:
+ bb.warn("Skipping RPATH %s as is a standard search path for %s" % (rpath, fpath))
+ modified = True
+ continue
+ new_rpaths.append(rpath)
continue
- new_rpaths.append("$ORIGIN/" + os.path.relpath(rpath.strip(), os.path.dirname(fpath.replace(rootdir, "/"))))
+ new_rpaths.append("$ORIGIN/" + os.path.relpath(rpath, os.path.dirname(fpath.replace(rootdir, "/"))))
modified = True
# if we have modified some rpaths call chrpath to update the binary
if modified:
+ if break_hardlinks:
+ bb.utils.break_hardlinks(fpath)
+
args = ":".join(new_rpaths)
#bb.note("Setting rpath for %s to %s" %(fpath, args))
p = sub.Popen([cmd, '-r', args, fpath],stdout=sub.PIPE,stderr=sub.PIPE)
out, err = p.communicate()
if p.returncode != 0:
- bb.error("%s: chrpath command failed with exit code %d:\n%s%s" % (d.getVar('PN', True), p.returncode, out, err))
- raise bb.build.FuncFailed
+ bb.fatal("%s: chrpath command failed with exit code %d:\n%s%s" % (d.getVar('PN'), p.returncode, out, err))
-def process_file_darwin(cmd, fpath, rootdir, baseprefix, tmpdir, d):
+def process_file_darwin(cmd, fpath, rootdir, baseprefix, tmpdir, d, break_hardlinks = False):
import subprocess as sub
p = sub.Popen([d.expand("${HOST_PREFIX}otool"), '-L', fpath],stdout=sub.PIPE,stderr=sub.PIPE)
@@ -57,18 +64,21 @@ def process_file_darwin(cmd, fpath, rootdir, baseprefix, tmpdir, d):
if baseprefix not in rpath:
continue
+ if break_hardlinks:
+ bb.utils.break_hardlinks(fpath)
+
newpath = "@loader_path/" + os.path.relpath(rpath, os.path.dirname(fpath.replace(rootdir, "/")))
p = sub.Popen([d.expand("${HOST_PREFIX}install_name_tool"), '-change', rpath, newpath, fpath],stdout=sub.PIPE,stderr=sub.PIPE)
out, err = p.communicate()
-def process_dir (rootdir, directory, d):
+def process_dir(rootdir, directory, d, break_hardlinks = False):
import stat
rootdir = os.path.normpath(rootdir)
cmd = d.expand('${CHRPATH_BIN}')
tmpdir = os.path.normpath(d.getVar('TMPDIR', False))
baseprefix = os.path.normpath(d.expand('${base_prefix}'))
- hostos = d.getVar("HOST_OS", True)
+ hostos = d.getVar("HOST_OS")
#bb.debug("Checking %s for binaries to process" % directory)
if not os.path.exists(directory):
@@ -91,7 +101,7 @@ def process_dir (rootdir, directory, d):
continue
if os.path.isdir(fpath):
- process_dir(rootdir, fpath, d)
+ process_dir(rootdir, fpath, d, break_hardlinks = break_hardlinks)
else:
#bb.note("Testing %s for relocatability" % fpath)
@@ -104,8 +114,9 @@ def process_dir (rootdir, directory, d):
else:
# Temporarily make the file writeable so we can chrpath it
os.chmod(fpath, perms|stat.S_IRWXU)
- process_file(cmd, fpath, rootdir, baseprefix, tmpdir, d)
-
+
+ process_file(cmd, fpath, rootdir, baseprefix, tmpdir, d, break_hardlinks = break_hardlinks)
+
if perms:
os.chmod(fpath, perms)