fix-info-plist.py 877 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env python3
  2. # Sets these keys in a property list file:
  3. # CFBundleGetInfoString
  4. # CFBundleShortVersionString
  5. # NSHumanReadableCopyright
  6. import getopt
  7. import plistlib
  8. import sys
  9. def usage():
  10. print("usage: %s TORBROWSER_VERSION YEAR < Info.plist > FixedInfo.plist" % sys.argv[0], file=sys.stderr)
  11. sys.exit(2)
  12. _, args = getopt.gnu_getopt(sys.argv[1:], "")
  13. if len(args) != 2:
  14. usage()
  15. TORBROWSER_VERSION = args[0]
  16. YEAR = args[1]
  17. COPYRIGHT = "Tor Browser %s Copyright %s The Tor Project" % (TORBROWSER_VERSION, YEAR)
  18. sys.stdin = open(sys.stdin.fileno(), 'rb')
  19. plist = plistlib.load(sys.stdin)
  20. plist["CFBundleGetInfoString"] = "Tor Browser %s" % TORBROWSER_VERSION
  21. plist["CFBundleShortVersionString"] = TORBROWSER_VERSION
  22. plist["NSHumanReadableCopyright"] = COPYRIGHT
  23. sys.stdout = open(sys.stdout.fileno(), 'wb')
  24. plistlib.dump(plist, sys.stdout)