diff options
author | Andoni Morales Alastruey <ylatuya@gmail.com> | 2020-07-29 18:08:52 +0200 |
---|---|---|
committer | GStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2020-07-30 20:55:16 +0000 |
commit | 2f4a73d812c5c0602ded679358838a94712e296f (patch) | |
tree | 1297961e3a233f77c8cdc1218ae99ad27e1058c4 | |
parent | 6f0a8a608901bfc5a344442dbe86c9e1c35c6f02 (diff) |
osx: fix relocation of binaries without extension
The check by extension was only relocation libraries
and skipping binaries. This fix also looks for Mach-O files
if the extension check fails
Fixes: #285
Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/565>
-rwxr-xr-x | cerbero/tools/osxrelocator.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/cerbero/tools/osxrelocator.py b/cerbero/tools/osxrelocator.py index c3a93356..4f2cc440 100755 --- a/cerbero/tools/osxrelocator.py +++ b/cerbero/tools/osxrelocator.py @@ -55,7 +55,7 @@ class OSXRelocator(object): def change_id(self, object_file, id=None): id = id or object_file.replace(self.lib_prefix, '@rpath') filename = os.path.basename(object_file) - if not (filename.endswith('so') or filename.endswith('dylib')): + if not self._is_mach_o_file(filename): return cmd = [INT_CMD, '-id', id, object_file] shell.new_call(cmd, fail=False, logfile=self.logfile) @@ -66,7 +66,7 @@ class OSXRelocator(object): rpaths = ['.'] rpaths += ['@loader_path' + p_depth, '@executable_path' + p_depth] rpaths += ['@loader_path' + '/../lib', '@executable_path' + '/../lib'] - if not (object_file.endswith('so') or object_file.endswith('dylib')): + if not self._is_mach_o_file(object_file): return if depth > 1: rpaths += ['@loader_path/..', '@executable_path/..'] @@ -112,6 +112,11 @@ class OSXRelocator(object): return path[:-1] return path + def _is_mach_o_file(self, filename): + return os.path.splitext(filename)[1] in ['.dylib', '.so'] or \ + shell.check_output(['file', '-bh', filename]).startswith('Mach-O') + + class Main(object): |