Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- '''
- Usage:
- patchRpath.py executable_or_library
- This program patchs the rpath of an executable or shared library to
- include all the directories of the nix libraries. This is normally
- done by wrapped ld, but it is broken if you use an unwrapped loader
- (such as ldd)
- '''
- import os
- import sys
- import subprocess
- paths = []
- for i in os.environ['NIX_LDFLAGS'].split():
- if i.startswith('-L'):
- # strip the '-L'
- paths.append(i[2:])
- rpaths = ':'.join(paths)
- patchedBidule = sys.argv[1]
- print(rpaths)
- subprocess.check_call(['patchelf', '--set-rpath', rpaths, patchedBidule])
- subprocess.check_call(['patchelf', '--shrink-rpath', patchedBidule])
Add Comment
Please, Sign In to add comment