daily pastebin goal
17%
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top