diff options
| -rw-r--r-- | meta/classes/chrpath.bbclass | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/meta/classes/chrpath.bbclass b/meta/classes/chrpath.bbclass index ad3c3975a5..2870c10d51 100644 --- a/meta/classes/chrpath.bbclass +++ b/meta/classes/chrpath.bbclass | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | CHRPATH_BIN ?= "chrpath" | 1 | CHRPATH_BIN ?= "chrpath" |
| 2 | PREPROCESS_RELOCATE_DIRS ?= "" | 2 | PREPROCESS_RELOCATE_DIRS ?= "" |
| 3 | 3 | ||
| 4 | def process_file_linux(cmd, fpath, rootdir, baseprefix, tmpdir, d): | 4 | def process_file_linux(cmd, fpath, rootdir, baseprefix, tmpdir, d, break_hardlinks = False): |
| 5 | import subprocess as sub | 5 | import subprocess as sub |
| 6 | 6 | ||
| 7 | p = sub.Popen([cmd, '-l', fpath],stdout=sub.PIPE,stderr=sub.PIPE) | 7 | p = sub.Popen([cmd, '-l', fpath],stdout=sub.PIPE,stderr=sub.PIPE) |
| @@ -39,6 +39,9 @@ def process_file_linux(cmd, fpath, rootdir, baseprefix, tmpdir, d): | |||
| 39 | 39 | ||
| 40 | # if we have modified some rpaths call chrpath to update the binary | 40 | # if we have modified some rpaths call chrpath to update the binary |
| 41 | if modified: | 41 | if modified: |
| 42 | if break_hardlinks: | ||
| 43 | bb.utils.break_hardlinks(fpath) | ||
| 44 | |||
| 42 | args = ":".join(new_rpaths) | 45 | args = ":".join(new_rpaths) |
| 43 | #bb.note("Setting rpath for %s to %s" %(fpath, args)) | 46 | #bb.note("Setting rpath for %s to %s" %(fpath, args)) |
| 44 | p = sub.Popen([cmd, '-r', args, fpath],stdout=sub.PIPE,stderr=sub.PIPE) | 47 | p = sub.Popen([cmd, '-r', args, fpath],stdout=sub.PIPE,stderr=sub.PIPE) |
| @@ -46,7 +49,7 @@ def process_file_linux(cmd, fpath, rootdir, baseprefix, tmpdir, d): | |||
| 46 | if p.returncode != 0: | 49 | if p.returncode != 0: |
| 47 | bb.fatal("%s: chrpath command failed with exit code %d:\n%s%s" % (d.getVar('PN'), p.returncode, out, err)) | 50 | bb.fatal("%s: chrpath command failed with exit code %d:\n%s%s" % (d.getVar('PN'), p.returncode, out, err)) |
| 48 | 51 | ||
| 49 | def process_file_darwin(cmd, fpath, rootdir, baseprefix, tmpdir, d): | 52 | def process_file_darwin(cmd, fpath, rootdir, baseprefix, tmpdir, d, break_hardlinks = False): |
| 50 | import subprocess as sub | 53 | import subprocess as sub |
| 51 | 54 | ||
| 52 | p = sub.Popen([d.expand("${HOST_PREFIX}otool"), '-L', fpath],stdout=sub.PIPE,stderr=sub.PIPE) | 55 | p = sub.Popen([d.expand("${HOST_PREFIX}otool"), '-L', fpath],stdout=sub.PIPE,stderr=sub.PIPE) |
| @@ -61,11 +64,14 @@ def process_file_darwin(cmd, fpath, rootdir, baseprefix, tmpdir, d): | |||
| 61 | if baseprefix not in rpath: | 64 | if baseprefix not in rpath: |
| 62 | continue | 65 | continue |
| 63 | 66 | ||
| 67 | if break_hardlinks: | ||
| 68 | bb.utils.break_hardlinks(fpath) | ||
| 69 | |||
| 64 | newpath = "@loader_path/" + os.path.relpath(rpath, os.path.dirname(fpath.replace(rootdir, "/"))) | 70 | newpath = "@loader_path/" + os.path.relpath(rpath, os.path.dirname(fpath.replace(rootdir, "/"))) |
| 65 | p = sub.Popen([d.expand("${HOST_PREFIX}install_name_tool"), '-change', rpath, newpath, fpath],stdout=sub.PIPE,stderr=sub.PIPE) | 71 | p = sub.Popen([d.expand("${HOST_PREFIX}install_name_tool"), '-change', rpath, newpath, fpath],stdout=sub.PIPE,stderr=sub.PIPE) |
| 66 | out, err = p.communicate() | 72 | out, err = p.communicate() |
| 67 | 73 | ||
| 68 | def process_dir (rootdir, directory, d): | 74 | def process_dir(rootdir, directory, d, break_hardlinks = False): |
| 69 | import stat | 75 | import stat |
| 70 | 76 | ||
| 71 | rootdir = os.path.normpath(rootdir) | 77 | rootdir = os.path.normpath(rootdir) |
| @@ -95,7 +101,7 @@ def process_dir (rootdir, directory, d): | |||
| 95 | continue | 101 | continue |
| 96 | 102 | ||
| 97 | if os.path.isdir(fpath): | 103 | if os.path.isdir(fpath): |
| 98 | process_dir(rootdir, fpath, d) | 104 | process_dir(rootdir, fpath, d, break_hardlinks = break_hardlinks) |
| 99 | else: | 105 | else: |
| 100 | #bb.note("Testing %s for relocatability" % fpath) | 106 | #bb.note("Testing %s for relocatability" % fpath) |
| 101 | 107 | ||
| @@ -108,8 +114,9 @@ def process_dir (rootdir, directory, d): | |||
| 108 | else: | 114 | else: |
| 109 | # Temporarily make the file writeable so we can chrpath it | 115 | # Temporarily make the file writeable so we can chrpath it |
| 110 | os.chmod(fpath, perms|stat.S_IRWXU) | 116 | os.chmod(fpath, perms|stat.S_IRWXU) |
| 111 | process_file(cmd, fpath, rootdir, baseprefix, tmpdir, d) | 117 | |
| 112 | 118 | process_file(cmd, fpath, rootdir, baseprefix, tmpdir, d, break_hardlinks = break_hardlinks) | |
| 119 | |||
| 113 | if perms: | 120 | if perms: |
| 114 | os.chmod(fpath, perms) | 121 | os.chmod(fpath, perms) |
| 115 | 122 | ||
