shlibsign.py (953B)
1 #!/usr/bin/env python3 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 7 import os 8 import subprocess 9 import sys 10 11 def main(): 12 for lib_file in sys.argv[1:]: 13 if os.path.isfile(lib_file): 14 sign(lib_file) 15 16 def sign(lib_file): 17 ld_lib_path = os.path.realpath(os.path.join(lib_file, '..')) 18 bin_path = os.path.realpath(os.path.join(ld_lib_path, '../bin')) 19 20 env = os.environ.copy() 21 if sys.platform == 'win32': 22 env['PATH'] = os.pathsep.join((env['PATH'], ld_lib_path)) 23 else: 24 env['LD_LIBRARY_PATH'] = env['DYLD_LIBRARY_PATH'] = ld_lib_path 25 26 dev_null = open(os.devnull, 'wb') 27 subprocess.check_call([os.path.join(bin_path, 'shlibsign'), '-C', '-v', '-i', lib_file], env=env, stdout=dev_null, stderr=dev_null) 28 29 if __name__ == '__main__': 30 main()