Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, subprocess, re, sys
- appname = "yourappname"
- hgbin = "/usr/local/bin/hg"
- targetBuildDir = os.getenv("TARGET_BUILD_DIR")
- getChangeset = subprocess.Popen(hgbin + ' parent --template "{node|short}" --cwd ' + targetBuildDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
- if (getChangeset.stderr.read() != ""):
- print "Error in obtaining current changeset of the Mercurial repository. '" + getChangeset.stderr.read() + "'"
- sys.exit(0) # if you want the build to fail here since the changeset is malformed change this to sys.exit(1)
- changeset = getChangeset.stdout.read()
- if (not re.search("^[0-9a-f]{12}$", changeset)):
- print "Current changeset of the Mercurial repository is malformed"
- sys.exit(0) # if you want the build to fail here since the changeset is malformed change this to sys.exit(1)
- infoPlist = os.path.join(targetBuildDir, appname + ".app/Info.plist")
- if not os.path.exists(infoPlist):
- print "Cannot locate " + appname +".app/Info.plist"
- sys.exit(1) # if you want the build to not fail here change this to sys.exit(0)
- result = subprocess.Popen('/usr/libexec/PlistBuddy -c "Delete BuildHashKey" ' + infoPlist, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
- result = subprocess.Popen('/usr/libexec/PlistBuddy -c "Add BuildHashKey string '+ changeset + '" ' + infoPlist, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
- print appname + " BuildHashKey set to " + changeset
Add Comment
Please, Sign In to add comment