From 3a45395672bd7cdbcfa5c043fe728e7a50410370 Mon Sep 17 00:00:00 2001 From: Greg Neagle Date: Wed, 24 Aug 2011 11:31:52 -0700 Subject: [PATCH] Updated build script for MSU.app to insert build number derived from Git and Git revision into Info.plist --- .../Managed Software Update.xcodeproj/project.pbxproj | 4 ++-- code/tools/make_munki_mpkg.sh | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/code/Managed Software Update/Managed Software Update.xcodeproj/project.pbxproj b/code/Managed Software Update/Managed Software Update.xcodeproj/project.pbxproj index acd74c28..2a86e79d 100644 --- a/code/Managed Software Update/Managed Software Update.xcodeproj/project.pbxproj +++ b/code/Managed Software Update/Managed Software Update.xcodeproj/project.pbxproj @@ -292,8 +292,8 @@ outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "BASEVERNUM=`/usr/libexec/PlistBuddy -c \"Print :CFBundleShortVersionString\" \"${INFOPLIST_FILE}\"`\nREV=`svnversion -n | cut -d: -f2 | tr -cd '[:digit:]'`\n/usr/libexec/PlistBuddy -c \"Set :CFBundleShortVersionString $BASEVERNUM.$REV\" \"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}\"\n/usr/libexec/PlistBuddy -c \"Set :CFBundleVersion $REV\" \"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}\""; + shellPath = /bin/bash; + shellScript = "# add this number to Git revision index to get \"build\" number consistent with old SVN repo\nMAGICNUMBER=482\n\nBASEVERNUM=`/usr/libexec/PlistBuddy -c \"Print :CFBundleShortVersionString\" \"${INFOPLIST_FILE}\"`\n\n# Git isn't installed on 10.6 or earlier by default, so find it\nGIT=`which git`\nif [ \"$GIT\" == \"\" ] ; then\n\t# let's hope it's in /usr/local/bin\n\tif [ -x \"/usr/local/bin/git\" ] ; then\n\t\tGIT=/usr/local/bin/git\n\tfi\nfi\n\nif [ \"$GIT\" != \"\" ] ; then\n\t# generate a psuedo-svn revision number from the list of Git revisions\n\tGITREV=`$GIT log -n1 --format=\"%H\"`\n\tGITREVINDEX=`$GIT rev-list --reverse HEAD | grep -n $GITREV | cut -d: -f1`\n\tREV=$(($GITREVINDEX + $MAGICNUMBER))\n\n\t/usr/libexec/PlistBuddy -c \"Set :CFBundleShortVersionString $BASEVERNUM.$REV\" \"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}\"\n\t/usr/libexec/PlistBuddy -c \"Set :CFBundleVersion $REV\" \"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}\"\n\t/usr/libexec/PlistBuddy -c \"Add :GitRevision string $GITREV\" \"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}\"\nfi"; }; C0C5491712B7EEBA002C76CD /* Localize */ = { isa = PBXShellScriptBuildPhase; diff --git a/code/tools/make_munki_mpkg.sh b/code/tools/make_munki_mpkg.sh index 167e392c..5dba1a75 100755 --- a/code/tools/make_munki_mpkg.sh +++ b/code/tools/make_munki_mpkg.sh @@ -287,12 +287,10 @@ if [ "$SVNREV" -lt "1302" ]; then echo $SVNREV > "$COREROOT/usr/local/munki/munkilib/svnversion" fi # add Build Number and Git Revision to version.plist -defaults write "$COREROOT/usr/local/munki/munkilib/version" BuildNumber "$SVNREV" -defaults write "$COREROOT/usr/local/munki/munkilib/version" GitRevision "$GITREV" -# defaults write converts the file to binary format, so convert back to XML -plutil -convert xml1 "$COREROOT/usr/local/munki/munkilib/version.plist" -# it also sets permissions too restrictively, so fix -chmod a+r "$COREROOT/usr/local/munki/munkilib/version.plist" +/usr/libexec/PlistBuddy -c "Delete :BuildNumber" "$COREROOT/usr/local/munki/munkilib/version.plist" 2>/dev/null +/usr/libexec/PlistBuddy -c "Add :BuildNumber string $SVNREV" "$COREROOT/usr/local/munki/munkilib/version.plist" +/usr/libexec/PlistBuddy -c "Delete :GitRevision" "$COREROOT/usr/local/munki/munkilib/version.plist" 2>/dev/null +/usr/libexec/PlistBuddy -c "Add :GitRevision string $GITREV" "$COREROOT/usr/local/munki/munkilib/version.plist" # Set permissions. chmod -R go-w "$COREROOT/usr/local/munki" chmod +x "$COREROOT/usr/local/munki"