shlibsign.py 947 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env python2
  2. #
  3. # This Source Code Form is subject to the terms of the Mozilla Public
  4. # License, v. 2.0. If a copy of the MPL was not distributed with this
  5. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  6. import os
  7. import subprocess
  8. import sys
  9. def main():
  10. for lib_file in sys.argv[1:]:
  11. if os.path.isfile(lib_file):
  12. sign(lib_file)
  13. def sign(lib_file):
  14. ld_lib_path = os.path.realpath(os.path.join(lib_file, '..'))
  15. bin_path = os.path.realpath(os.path.join(ld_lib_path, '../bin'))
  16. env = os.environ.copy()
  17. if sys.platform == 'win32':
  18. env['PATH'] = os.pathsep.join((env['PATH'], ld_lib_path))
  19. else:
  20. env['LD_LIBRARY_PATH'] = env['DYLD_LIBRARY_PATH'] = ld_lib_path
  21. dev_null = open(os.devnull, 'wb')
  22. subprocess.check_call([os.path.join(bin_path, 'shlibsign'), '-v', '-i', lib_file], env=env, stdout=dev_null, stderr=dev_null)
  23. if __name__ == '__main__':
  24. main()