Guest User

Untitled

a guest
Jun 14th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. import os, subprocess, re, sys
  2.  
  3.  
  4. appname = "yourappname"
  5. hgbin = "/usr/local/bin/hg"
  6. targetBuildDir = os.getenv("TARGET_BUILD_DIR")
  7.  
  8. getChangeset = subprocess.Popen(hgbin + ' parent --template "{node|short}" --cwd ' + targetBuildDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
  9.  
  10. if (getChangeset.stderr.read() != ""):
  11. print "Error in obtaining current changeset of the Mercurial repository. '" + getChangeset.stderr.read() + "'"
  12. sys.exit(0) # if you want the build to fail here since the changeset is malformed change this to sys.exit(1)
  13.  
  14. changeset = getChangeset.stdout.read()
  15. if (not re.search("^[0-9a-f]{12}$", changeset)):
  16. print "Current changeset of the Mercurial repository is malformed"
  17. sys.exit(0) # if you want the build to fail here since the changeset is malformed change this to sys.exit(1)
  18.  
  19. infoPlist = os.path.join(targetBuildDir, appname + ".app/Info.plist")
  20. if not os.path.exists(infoPlist):
  21. print "Cannot locate " + appname +".app/Info.plist"
  22. sys.exit(1) # if you want the build to not fail here change this to sys.exit(0)
  23.  
  24. result = subprocess.Popen('/usr/libexec/PlistBuddy -c "Delete BuildHashKey" ' + infoPlist, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
  25. result = subprocess.Popen('/usr/libexec/PlistBuddy -c "Add BuildHashKey string '+ changeset + '" ' + infoPlist, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
  26.  
  27. print appname + " BuildHashKey set to " + changeset
Add Comment
Please, Sign In to add comment