Guest User

Untitled

a guest
Dec 14th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. '''
  3. Usage:
  4. patchRpath.py executable_or_library
  5.  
  6. This program patchs the rpath of an executable or shared library to
  7. include all the directories of the nix libraries. This is normally
  8. done by wrapped ld, but it is broken if you use an unwrapped loader
  9. (such as ldd)
  10. '''
  11.  
  12. import os
  13. import sys
  14. import subprocess
  15.  
  16. paths = []
  17.  
  18. for i in os.environ['NIX_LDFLAGS'].split():
  19. if i.startswith('-L'):
  20. # strip the '-L'
  21. paths.append(i[2:])
  22.  
  23. rpaths = ':'.join(paths)
  24.  
  25. patchedBidule = sys.argv[1]
  26. print(rpaths)
  27. subprocess.check_call(['patchelf', '--set-rpath', rpaths, patchedBidule])
  28. subprocess.check_call(['patchelf', '--shrink-rpath', patchedBidule])
Add Comment
Please, Sign In to add comment