Created
April 21, 2011 19:47
-
-
Save pnasrat/935329 to your computer and use it in GitHub Desktop.
bob's install-name-tool.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import macholib | |
def install_name_tool(fn, new_id=None, changedict=None): | |
m = macholib.MachO(fn) | |
if new_id: | |
m.rewriteInstallNameCommand(new_id) | |
if changedict: | |
m.rewriteLoadCommands(changedict) | |
m.save() | |
if __name__ == '__main__': | |
import sys | |
args = sys.argv[1:] | |
def err(): | |
print >>sys.stderr, 'Usage: %s [-change old new] ... [-id name] input' % (sys.argv[0],) | |
raise SystemExit | |
if not args: | |
err() | |
new_id = None | |
fn = None | |
changedict = {} | |
args = iter(args) | |
try: | |
for arg in args: | |
if arg == '-change': | |
changedict[args.next()] = args.next() | |
elif arg == '-id': | |
new_id = args.next() | |
else: | |
fn = arg | |
if list(args): | |
raise StopIteration | |
break | |
else: | |
raise StopIteration | |
except StopIteration: | |
err() | |
install_name_tool(fn, new_id, changedict) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment