-
-
Save didge/9466154 to your computer and use it in GitHub Desktop.
Revisions
-
didge revised this gist
Nov 28, 2018 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -54,7 +54,10 @@ # June 2015 # 1. Fixed issue with adding keychain-access-groups. # 2. Removed ` that somehow got added in last update. # # Nov 2018 # 1. Fixed logic determining when to replace bundle id. # function checkStatus { if [ $? -ne 0 ]; @@ -65,7 +68,7 @@ fi } if [ $# -lt 3 ]; then echo "usage: $0 source identity [-p provisioning] [-e entitlements] [-d displayName] [-b bundleId] outputIpa" >&2 echo "\t\t -p and -b are optional, but their use is heavly recommonded" >&2 exit 1 fi @@ -166,7 +169,7 @@ checkStatus # get the new bundle id OLD_BUNDLE_ID=`PlistBuddy -c "Print :CFBundleIdentifier" "temp/Payload/$APP_NAME/Info.plist"` if [ "${NEW_BUNDLE_ID}" != "" -a "${NEW_PROVISION}" != "" ]; then NEW_BUNDLE_ID=`egrep -a -A 2 application-identifier "${NEW_PROVISION}" | grep string | sed -e 's/<string>//' -e 's/<\/string>//' -e 's/ //' | awk '{split($0,a,"."); i = length(a); for(ix=2; ix <= i;ix++){ s=s a[ix]; if(i!=ix){s=s "."};} print s;}'` if [[ "${NEW_BUNDLE_ID}" == *\** ]]; then -
didge revised this gist
Nov 27, 2018 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,9 @@ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Please let us know about any improvements you make to this script! # # Usage # ./coderesign.sh source "iPhone Distribution: Name" -p "path/to/profile" [-d "display name"] [-e entitlements] [-k keychain] [-b "BundleIdentifier"] outputIpa # # Changes -
didge revised this gist
Jun 23, 2015 . 1 changed file with 8 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,22 +34,24 @@ # Please let us know about any improvements you make to this script! # ./coderesign.sh source "iPhone Distribution: Name" -p "path/to/profile" [-d "display name"] [-e entitlements] [-k keychain] -b "BundleIdentifier" outputIpa # # Changes # January 2012 # 1. change the app display name # # April 2013 # 1. specify the target bundleId on the command line # 2. correctly handles entitlements for keychain-enabled resigning # # March 2014 # 1. Update App Identifier Prefix and Bundle Id from provided provisioning file. # 2. Cleaned up old code, naming. # 3. Fixed file extension check to handle *.something.ipa or *.something.app # 4. Renamed to coderesign.sh. # # June 2015 # 1. Fixed issue with adding keychain-access-groups. # 2. Removed ` that somehow got added in last update. function checkStatus { -
didge revised this gist
Jun 23, 2015 . 1 changed file with 6 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -48,11 +48,8 @@ # 1. Update App Identifier Prefix and Bundle Id from provided provisioning file. # 2. Cleaned up old code, naming. # 3. Fixed file extension check to handle *.something.ipa or *.something.app # 4. Renamed to coderesign.sh. # function checkStatus { @@ -200,10 +197,9 @@ fi PlistBuddy -c "Set :CFBundleIdentifier $NEW_BUNDLE_ID" "temp/Payload/$APP_NAME/Info.plist" checkStatus # Uncomment to convert Info.plist to binary format (thanks imhui!) # plutil -convert binary1 "temp/Payload/$APP_NAME/Info.plist" # Resign the application echo "Resigning application using certificate: $CERTIFICATE" >&2 if [ "$ENTITLEMENTS" != "" ]; @@ -215,9 +211,10 @@ else if [ "$NEW_APP_ID_PREFIX" != "" -a -s temp/newEntitlements ]; then # extract current entitlements PlistBuddy -c "Set :application-identifier ${NEW_APP_ID_PREFIX}.${NEW_BUNDLE_ID}" temp/newEntitlements checkStatus PlistBuddy -c "Add :keychain-access-groups array" temp/newEntitlements PlistBuddy -c "Add :keychain-access-groups:0 string ${NEW_APP_ID_PREFIX}.\*" temp/newEntitlements checkStatus plutil -lint temp/newEntitlements checkStatus -
didge revised this gist
Jun 2, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -181,7 +181,7 @@ echo "New App Identifier: ${NEW_APP_ID_PREFIX}.${NEW_BUNDLE_ID}" if [ "${DISPLAY_NAME}" != "" ]; then PlistBuddy -c "Set :CFBundleDisplayName $DISPLAY_NAME" "temp/Payload/$APP_NAME/Info.plist" echo "New Bundle Display Name: ${DISPLAY_NAME}" fi -
didge revised this gist
Oct 1, 2014 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -50,6 +50,10 @@ # 3. Fixed file extension check to handle *.something.ipa or *.something.app # 4. Renamed to coderesign.sh # changes Oct 2014 # 1. Fixed typos # 2. Added commented-out command to convert the Info.plist to binary (thanks imhui!) function checkStatus { if [ $? -ne 0 ]; @@ -196,6 +200,9 @@ fi PlistBuddy -c "Set :CFBundleIdentifier $NEW_BUNDLE_ID" "temp/Payload/$APP_NAME/Info.plist" checkStatus # Uncomment to onvert Info.plist to binary format # plutil -convert binary1 "temp/Payload/$APP_NAME/Info.plist" # Resign the application echo "Resigning application using certificate: $CERTIFICATE" >&2 -
didge revised this gist
Oct 1, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,7 @@ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Please let us know about any improvements you make to this script! # ./coderesign.sh source "iPhone Distribution: Name" -p "path/to/profile" [-d "display name"] [-e entitlements] [-k keychain] -b "BundleIdentifier" outputIpa # # # Modifed 26th January 2012 @@ -48,7 +48,7 @@ # 1. Update App Identifier Prefix and Bundle Id from provided provisioning file. # 2. Cleaned up old code, naming. # 3. Fixed file extension check to handle *.something.ipa or *.something.app # 4. Renamed to coderesign.sh function checkStatus { -
didge revised this gist
Oct 1, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,7 @@ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Please let us know about any improvements you make to this script! # ./codesign.sh source "iPhone Distribution: Name" -p "path/to/profile" [-d "display name"] [-e entitlements] [-k keychain] -b "BundleIdentifier" outputIpa # # # Modifed 26th January 2012 @@ -48,7 +48,7 @@ # 1. Update App Identifier Prefix and Bundle Id from provided provisioning file. # 2. Cleaned up old code, naming. # 3. Fixed file extension check to handle *.something.ipa or *.something.app # 4. Renamed to codesign.sh function checkStatus { -
didge revised this gist
Mar 28, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -54,7 +54,7 @@ function checkStatus { if [ $? -ne 0 ]; then echo 'Had an Error, aborting!' exit 1 fi } -
didge revised this gist
Mar 10, 2014 . 1 changed file with 15 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,7 +46,8 @@ # # new features March 2014 # 1. Update App Identifier Prefix and Bundle Id from provided provisioning file. # 2. Cleaned up old code, naming. # 3. Fixed file extension check to handle *.something.ipa or *.something.app # function checkStatus { @@ -114,9 +115,21 @@ shift $((OPTIND-1)) NEW_FILE="$1" # Check if the supplied file is an ipa or an app file if [ "${ORIGINAL_FILE##*.}" = "ipa" ] then # Unzip the old ipa quietly unzip -q "$ORIGINAL_FILE" -d temp checkStatus elif [ "${ORIGINAL_FILE##*.}" = "app" ] then # Copy the app file into an ipa-like structure mkdir -p "temp/Payload" cp -Rf "${ORIGINAL_FILE}" "temp/Payload/${ORIGINAL_FILE}" checkStatus else echo "Error: Only can resign .app files and .ipa files." >&2 exit fi # check the keychain if [ "${KEYCHAIN}" != "" ]; -
didge renamed this gist
Mar 10, 2014 . 1 changed file with 47 additions and 51 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,18 @@ #!/bin/bash -x # Copyright (c) 2011 Float Mobile Learning # http://www.floatlearning.com/ # Extension Copyright (c) 2013 Weptun Gmbh # http://www.weptun.de # Extension Copyright (c) 2013 FoundryLogic LLC # http://foundrylogic.com # # Extended by Ronan O Ciosoig January 2012 # # Extended by Patrick Blitz, April 2013 # # Extended by didge, March 2014 # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation @@ -40,7 +44,10 @@ # 1. specify the target bundleId on the command line # 2. correctly handles entitlements for keychain-enabled resigning # # new features March 2014 # 1. Update App Identifier Prefix and Bundle Id from provided provisioning file. # 2. Removed commented out, old code. # function checkStatus { @@ -61,9 +68,10 @@ ORIGINAL_FILE="$1" CERTIFICATE="$2" NEW_PROVISION= ENTITLEMENTS= NEW_BUNDLE_ID="" DISPLAY_NAME="" NEW_APP_ID_PREFIX="" OLD_APP_ID_PREFIX="" KEYCHAIN="" # options start index @@ -83,8 +91,8 @@ ENTITLEMENTS="$OPTARG" echo "Specified signing entitlements: $ENTITLEMENTS" >&2 ;; b) NEW_BUNDLE_ID="$OPTARG" echo "Specified bundle identifier: $NEW_BUNDLE_ID " >&2 ;; k) KEYCHAIN="$OPTARG" @@ -105,23 +113,10 @@ shift $((OPTIND-1)) NEW_FILE="$1" # Check if the supplied file is an ipa or an app file # Unzip the old ipa quietly unzip -o -q "$ORIGINAL_FILE" -d temp checkStatus # check the keychain if [ "${KEYCHAIN}" != "" ]; @@ -138,53 +133,55 @@ echo "APP_NAME=$APP_NAME" >&2 export PATH=$PATH:/usr/libexec # get the old app id prefix OLD_APP_ID_PREFIX=`grep '<key>application-identifier</key>' "temp/Payload/$APP_NAME/embedded.mobileprovision" -A 1 --binary-files=text | sed -E -e '/<key>/ d' -e 's/(^.*<string>)//' -e 's/([A-Z0-9]*)(.*)/\1/'` checkStatus # get the new app id prefix if [ "${NEW_PROVISION}" != "" ]; then NEW_APP_ID_PREFIX=`grep '<key>application-identifier</key>' "$NEW_PROVISION" -A 1 --binary-files=text | sed -E -e '/<key>/ d' -e 's/(^.*<string>)//' -e 's/([A-Z0-9]*)(.*)/\1/'` else NEW_APP_ID_PREFIX=$OLD_APP_ID_PREFIX fi checkStatus # get the new bundle id OLD_BUNDLE_ID=`PlistBuddy -c "Print :CFBundleIdentifier" "temp/Payload/$APP_NAME/Info.plist"` if [ "${NEW_BUNDLE_ID}" == "" -a "${NEW_PROVISION}" != "" ]; then NEW_BUNDLE_ID=`egrep -a -A 2 application-identifier "${NEW_PROVISION}" | grep string | sed -e 's/<string>//' -e 's/<\/string>//' -e 's/ //' | awk '{split($0,a,"."); i = length(a); for(ix=2; ix <= i;ix++){ s=s a[ix]; if(i!=ix){s=s "."};} print s;}'` if [[ "${NEW_BUNDLE_ID}" == *\** ]]; then echo "Bundle Identifier contains a *, using the current bundle identifier"; NEW_BUNDLE_ID=$OLD_BUNDLE_ID fi else NEW_BUNDLE_ID=$OLD_BUNDLE_ID fi checkStatus echo "New App Identifier: ${NEW_APP_ID_PREFIX}.${NEW_BUNDLE_ID}" if [ "${DISPLAY_NAME}" != "" ]; then PlistBuddy -c "Set :CFBundleDisplayName $DISPLAY_NAME" temp/Payload/$APP_NAME/Info.plist echo "New Bundle Display Name: ${DISPLAY_NAME}" fi # Replace the embedded mobile provisioning profile if [ "$NEW_PROVISION" != "" ]; then ENTITLEMENTS_TEMP=`/usr/bin/codesign -d --entitlements - "temp/Payload/$APP_NAME" | sed -E -e '1d' -e s/$OLD_BUNDLE_ID/$NEW_BUNDLE_ID/ -e s/$OLD_APP_ID_PREFIX/$NEW_APP_ID_PREFIX/` if [ -n "$ENTITLEMENTS_TEMP" ]; then echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>$ENTITLEMENTS_TEMP" > temp/newEntitlements fi cp "$NEW_PROVISION" "temp/Payload/$APP_NAME/embedded.mobileprovision" checkStatus fi # Update the bundle identifier PlistBuddy -c "Set :CFBundleIdentifier $NEW_BUNDLE_ID" "temp/Payload/$APP_NAME/Info.plist" checkStatus # Resign the application @@ -195,13 +192,12 @@ echo "Using Entitlements: $ENTITLEMENTS" >&2 /usr/bin/codesign -f -s "$CERTIFICATE" --entitlements="$ENTITLEMENTS" --resource-rules="temp/Payload/$APP_NAME/ResourceRules.plist" "temp/Payload/$APP_NAME" checkStatus else if [ "$NEW_APP_ID_PREFIX" != "" -a -s temp/newEntitlements ]; then # extract current entitlements PlistBuddy -c "Set :application-identifier ${NEW_APP_ID_PREFIX}.${NEW_BUNDLE_ID}" temp/newEntitlements` checkStatus PlistBuddy -c "Set :keychain-access-groups:0 ${NEW_APP_ID_PREFIX}.${NEW_BUNDLE_ID}" temp/newEntitlements` checkStatus plutil -lint temp/newEntitlements checkStatus @@ -228,4 +224,4 @@ popd > /dev/null mv temp.ipa "$NEW_FILE" # Remove the temp directory rm -rf "temp" -
WeptunUser revised this gist
Feb 7, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -116,7 +116,7 @@ elif [ "${ORIGINAL_FILE#*.}" = "app" ] then # Copy the app file into an ipa-like structure mkdir -p "temp/Payload" cp -Rf "${ORIGINAL_FILE}" "temp/Payload/${ORIGINAL_FILE}" checkStatus else echo "Error: Only can resign .app files and .ipa files." >&2 -
Weptun revised this gist
Jul 22, 2013 . 1 changed file with 114 additions and 109 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,36 +6,36 @@ # http://www.weptun.de # # Extended by Ronan O Ciosoig January 2012 # # Extended by Patrick Blitz, April 2013 # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Please let us know about any improvements you make to this script! # ./floatsign source "iPhone Distribution: Name" -p "path/to/profile" [-d "display name"] [-e entitlements] [-k keychain] -b "BundleIdentifier" outputIpa # # # Modifed 26th January 2012 # # new features January 2012: # 1. change the app display name # # new features April 2013 # 1. specify the target bundleId on the command line # 2. correctly handles entitlements for keychain-enabled resigning @@ -44,17 +44,17 @@ function checkStatus { if [ $? -ne 0 ]; then echo "Had an Error, aborting!" exit 1 fi } if [ $# -lt 3 ]; then echo "usage: $0 source identity -p provisioning [-e entitlements] [-d displayName] -b bundleId outputIpa" >&2 echo "\t\t -p and -b are optional, but their use is heavly recommonded" >&2 exit 1 fi ORIGINAL_FILE="$1" @@ -69,36 +69,36 @@ KEYCHAIN="" # options start index OPTIND=3 while getopts p:d:e:k:b: opt; do case $opt in p) NEW_PROVISION="$OPTARG" echo "Specified provisioning profile: $NEW_PROVISION" >&2 ;; d) DISPLAY_NAME="$OPTARG" echo "Specified display name: $DISPLAY_NAME" >&2 ;; e) ENTITLEMENTS="$OPTARG" echo "Specified signing entitlements: $ENTITLEMENTS" >&2 ;; b) BUNDLE_IDENTIFIER="$OPTARG" echo "Specified bundle identifier: $BUNDLE_IDENTIFIER " >&2 ;; k) KEYCHAIN="$OPTARG" echo "Specified Keychain to use: $KEYCHAIN " >&2 ;; \?) echo "Invalid option: -$OPTARG" >&2 exit 1 ;; :) echo "Option -$OPTARG requires an argument." >&2 exit 1 ;; esac done shift $((OPTIND-1)) @@ -108,27 +108,27 @@ NEW_FILE="$1" # Check if the supplied file is an ipa or an app file if [ "${ORIGINAL_FILE#*.}" = "ipa" ] then # Unzip the old ipa quietly unzip -q "$ORIGINAL_FILE" -d temp checkStatus elif [ "${ORIGINAL_FILE#*.}" = "app" ] then # Copy the app file into an ipa-like structure mkdir -p "temp/Payload" cp -Rf "$ORIGINAL_FILE" "temp/Payload/$ORIGINAL_FILE" checkStatus else echo "Error: Only can resign .app files and .ipa files." >&2 exit fi # check the keychain if [ "${KEYCHAIN}" != "" ]; then security list-keychains -s $KEYCHAIN security unlock $KEYCHAIN security default-keychain -s $KEYCHAIN fi # Set the app name @@ -142,73 +142,78 @@ CURRENT_NAME=`PlistBuddy -c "Print :CFBundleDisplayName" "temp/Payload/$APP_NAME CURRENT_BUNDLE_IDENTIFIER=`PlistBuddy -c "Print :CFBundleIdentifier" "temp/Payload/$APP_NAME/Info.plist"` if [ "${BUNDLE_IDENTIFIER}" == "" ]; then BUNDLE_IDENTIFIER=`egrep -a -A 2 application-identifier "${NEW_PROVISION}" | grep string | sed -e 's/<string>//' -e 's/<\/string>//' -e 's/ //' | awk '{split($0,a,"."); i = length(a); for(ix=2; ix <= i;ix++){ s=s a[ix]; if(i!=ix){s=s "."};} print s;}'` if [[ "${BUNDLE_IDENTIFIER}" == *\** ]]; then echo "Bundle Identifier contains a *, using the current bundle identifier"; BUNDLE_IDENTIFIER=$CURRENT_BUNDLE_IDENTIFIER; fi checkStatus fi echo "Bundle Identifier is ${BUNDLE_IDENTIFIER}" if [ "${DISPLAY_NAME}" != "" ]; then echo "read Info.plist file" "temp/Payload/$ORIGINAL_FILE/Info.plist" # CURRENT_NAME=/usr/libexec/PlistBuddy -c "Print :CFBundleDisplayName" "temp/Payload/$ORIGINAL_FILE/Info.plist" echo "Changing display name from $CURRENT_NAME to " $DISPLAY_NAME `PlistBuddy -c "Set :CFBundleDisplayName $DISPLAY_NAME" "temp/Payload/$APP_NAME/Info.plist"` # PlistBuddy -c "Set :CFBundleDisplayName $DISPLAY_NAME" temp/Payload/$ORIGINAL_FILE/Info.plist fi # Replace the embedded mobile provisioning profile if [ "$NEW_PROVISION" != "" ]; then echo "Adding the new provision: $NEW_PROVISION" ENTITLEMENTS_TEMP=`/usr/bin/codesign -d --entitlements - "temp/Payload/$APP_NAME" | sed -E -e '1d'` if [ -n "$ENTITLEMENTS_TEMP" ]; then echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>$ENTITLEMENTS_TEMP" > temp/newEntitlements fi # echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>`/usr/bin/codesign -d --entitlements - "temp/Payload/$APP_NAME" | sed -E -e '1d'`" > temp/newEntitlements cp "$NEW_PROVISION" "temp/Payload/$APP_NAME/embedded.mobileprovision" PROVISIONING_PROFILE_PREFIX=`grep '<key>application-identifier</key>' "temp/Payload/$APP_NAME/embedded.mobileprovision" -A 1 --binary-files=text | sed -E -e '/<key>/ d' -e 's/(^.*<string>)//' -e 's/([A-Z0-9]*)(.*)/\1/'` checkStatus fi #if the current bundle identifier is different from the new one in the provisioning profile, then change it. if [ "$CURRENT_BUNDLE_IDENTIFIER" != "$BUNDLE_IDENTIFIER" ]; then echo "Update the bundle identifier" `PlistBuddy -c "Set :CFBundleIdentifier $BUNDLE_IDENTIFIER" "temp/Payload/$APP_NAME/Info.plist"` checkStatus fi # Resign the application echo "Resigning application using certificate: $CERTIFICATE" >&2 if [ "$ENTITLEMENTS" != "" ]; then echo "Using Entitlements: $ENTITLEMENTS" >&2 /usr/bin/codesign -f -s "$CERTIFICATE" --entitlements="$ENTITLEMENTS" --resource-rules="temp/Payload/$APP_NAME/ResourceRules.plist" "temp/Payload/$APP_NAME" checkStatus else if [ "$PROVISIONING_PROFILE_PREFIX" != "" ] && [ -s temp/newEntitlements ]; #if [ -s temp/newEntitlements ]; then # extract current entitlements PlistBuddy -c "Set :application-identifier ${PROVISIONING_PROFILE_PREFIX}.${BUNDLE_IDENTIFIER}" temp/newEntitlements` checkStatus PlistBuddy -c "Set :keychain-access-groups:0 ${PROVISIONING_PROFILE_PREFIX}.${BUNDLE_IDENTIFIER}" temp/newEntitlements` checkStatus plutil -lint temp/newEntitlements checkStatus /usr/bin/codesign -f -s "$CERTIFICATE" --resource-rules="temp/Payload/$APP_NAME/ResourceRules.plist" --entitlements="temp/newEntitlements" "temp/Payload/$APP_NAME" checkStatus rm temp/newEntitlements else /usr/bin/codesign -f -s "$CERTIFICATE" --resource-rules="temp/Payload/$APP_NAME/ResourceRules.plist" "temp/Payload/$APP_NAME" fi fi # Repackage quietly echo "Repackaging as $NEW_FILE" # Zip up the contents of the temp folder -
Weptun revised this gist
Jul 16, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -145,7 +145,7 @@ then BUNDLE_IDENTIFIER=`egrep -a -A 2 application-identifier "${NEW_PROVISION}" | grep string | sed -e 's/<string>//' -e 's/<\/string>//' -e 's/ //' | awk '{split($0,a,"."); i = length(a); for(ix=2; ix <= i;ix++){ s=s a[ix]; if(i!=ix){s=s "."};} print s;}'` if [[ "${BUNDLE_IDENTIFIER}" == *\** ]]; then echo "Bundle Identifier contains a *, using the current bundle identifier"; BUNDLE_IDENTIFIER=$CURRENT_BUNDLE_IDENTIFIER; fi checkStatus -
Weptun revised this gist
Jul 16, 2013 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -143,6 +143,11 @@ CURRENT_BUNDLE_IDENTIFIER=`PlistBuddy -c "Print :CFBundleIdentifier" "temp/Paylo if [ "${BUNDLE_IDENTIFIER}" == "" ]; then BUNDLE_IDENTIFIER=`egrep -a -A 2 application-identifier "${NEW_PROVISION}" | grep string | sed -e 's/<string>//' -e 's/<\/string>//' -e 's/ //' | awk '{split($0,a,"."); i = length(a); for(ix=2; ix <= i;ix++){ s=s a[ix]; if(i!=ix){s=s "."};} print s;}'` if [[ "${BUNDLE_IDENTIFIER}" == *\** ]]; then echo "Bundle Identifier contains a *, using the current bundle identifier"; BUNDLE_IDENTIFIER = $CURRENT_BUNDLE_IDENTIFIER; fi checkStatus fi -
Weptun revised this gist
Jul 16, 2013 . 1 changed file with 19 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,7 +28,7 @@ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Please let us know about any improvements you make to this script! # ./floatsign source "iPhone Distribution: Name" -p "path/to/profile" [-d "display name"] [-e entitlements] [-k keychain] -b "BundleIdentifier" outputIpa # # # Modifed 26th January 2012 @@ -64,10 +64,11 @@ ENTITLEMENTS= BUNDLE_IDENTIFIER="" DISPLAY_NAME="" PROVISIONING_PROFILE_PREFIX="" KEYCHAIN="" # options start index OPTIND=3 while getopts p:d:e:k:b: opt; do case $opt in p) NEW_PROVISION="$OPTARG" @@ -85,6 +86,10 @@ while getopts p:d:e:b: opt; do BUNDLE_IDENTIFIER="$OPTARG" echo "Specified bundle identifier: $BUNDLE_IDENTIFIER " >&2 ;; k) KEYCHAIN="$OPTARG" echo "Specified Keychain to use: $KEYCHAIN " >&2 ;; \?) echo "Invalid option: -$OPTARG" >&2 exit 1 @@ -118,6 +123,14 @@ else exit fi # check the keychain if [ "${KEYCHAIN}" != "" ]; then security list-keychains -s $KEYCHAIN security unlock $KEYCHAIN security default-keychain -s $KEYCHAIN fi # Set the app name # The app name is the only file within the Payload directory APP_NAME=$(ls temp/Payload/) @@ -137,8 +150,8 @@ echo "Bundle Identifier is ${BUNDLE_IDENTIFIER}" if [ "${DISPLAY_NAME}" != "" ]; then echo "read Info.plist file" "temp/Payload/$ORIGINAL_FILE/Info.plist" # CURRENT_NAME=/usr/libexec/PlistBuddy -c "Print :CFBundleDisplayName" "temp/Payload/$ORIGINAL_FILE/Info.plist" echo "Changing display name from $CURRENT_NAME to " $DISPLAY_NAME `PlistBuddy -c "Set :CFBundleDisplayName $DISPLAY_NAME" "temp/Payload/$APP_NAME/Info.plist"` @@ -150,9 +163,9 @@ fi if [ "$NEW_PROVISION" != "" ]; then echo "Adding the new provision: $NEW_PROVISION" echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>`/usr/bin/codesign -d --entitlements - "temp/Payload/$APP_NAME" | sed -E -e '1d'`" > temp/newEntitlements cp "$NEW_PROVISION" "temp/Payload/$APP_NAME/embedded.mobileprovision" PROVISIONING_PROFILE_PREFIX=`grep '<key>application-identifier</key>' "temp/Payload/$APP_NAME/embedded.mobileprovision" -A 1 --binary-files=text | sed -E -e '/<key>/ d' -e 's/(^.*<string>)//' -e 's/([A-Z0-9]*)(.*)/\1/'` checkStatus fi -
Weptun revised this gist
Jun 11, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -205,4 +205,4 @@ popd > /dev/null mv temp.ipa "$NEW_FILE" # Remove the temp directory rm -rf "temp" -
Weptun revised this gist
Jun 11, 2013 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,8 @@ # Copyright (c) 2011 Float Mobile Learning # http://www.floatlearning.com/ # Extension Copyright (c) 2013 Weptun Gmbh # http://www.weptun.de # # Extended by Ronan O Ciosoig January 2012 # @@ -26,7 +28,7 @@ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Please let us know about any improvements you make to this script! # ./floatsign source "iPhone Distribution: Name" -p "path/to/profile" [-d "display name"] [-e entitlements] -b "BundleIdentifier" outputIpa # # # Modifed 26th January 2012 @@ -50,7 +52,8 @@ function checkStatus { } if [ $# -lt 3 ]; then echo "usage: $0 source identity -p provisioning [-e entitlements] [-d displayName] -b bundleId outputIpa" >&2 echo "\t\t -p and -b are optional, but their use is heavly recommonded" >&2 exit 1 fi @@ -202,4 +205,4 @@ popd > /dev/null mv temp.ipa "$NEW_FILE" # Remove the temp directory #rm -rf "temp" -
Weptun revised this gist
Jun 11, 2013 . 1 changed file with 25 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -39,6 +39,16 @@ # 2. correctly handles entitlements for keychain-enabled resigning # function checkStatus { if [ $? -ne 0 ]; then echo "Had an Error, aborting!" exit 1 fi } if [ $# -lt 3 ]; then echo "usage: $0 source identity [-p provisioning] [-e entitlements] [-d displayName] [-b bundleId] outputIpa" >&2 exit 1 @@ -93,11 +103,13 @@ if [ "${ORIGINAL_FILE#*.}" = "ipa" ] then # Unzip the old ipa quietly unzip -q "$ORIGINAL_FILE" -d temp checkStatus elif [ "${ORIGINAL_FILE#*.}" = "app" ] then # Copy the app file into an ipa-like structure mkdir -p "temp/Payload" cp -Rf "$ORIGINAL_FILE" "temp/Payload/$ORIGINAL_FILE" checkStatus else echo "Error: Only can resign .app files and .ipa files." >&2 exit @@ -112,11 +124,14 @@ export PATH=$PATH:/usr/libexec CURRENT_NAME=`PlistBuddy -c "Print :CFBundleDisplayName" "temp/Payload/$APP_NAME/Info.plist"` CURRENT_BUNDLE_IDENTIFIER=`PlistBuddy -c "Print :CFBundleIdentifier" "temp/Payload/$APP_NAME/Info.plist"` if [ "${BUNDLE_IDENTIFIER}" == "" ]; then BUNDLE_IDENTIFIER=`egrep -a -A 2 application-identifier "${NEW_PROVISION}" | grep string | sed -e 's/<string>//' -e 's/<\/string>//' -e 's/ //' | awk '{split($0,a,"."); i = length(a); for(ix=2; ix <= i;ix++){ s=s a[ix]; if(i!=ix){s=s "."};} print s;}'` checkStatus fi echo "Bundle Identifier is ${BUNDLE_IDENTIFIER}" if [ "${DISPLAY_NAME}" != "" ]; then echo "read Info.plist file" temp/Payload/$ORIGINAL_FILE/Info.plist @@ -135,13 +150,15 @@ then echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>`/usr/bin/codesign -d --entitlements - temp/Payload/$APP_NAME | sed -E -e '1d'`" > temp/newEntitlements cp "$NEW_PROVISION" "temp/Payload/$APP_NAME/embedded.mobileprovision" PROVISIONING_PROFILE_PREFIX=`grep '<key>application-identifier</key>' temp/Payload/$APP_NAME/embedded.mobileprovision -A 1 --binary-files=text | sed -E -e '/<key>/ d' -e 's/(^.*<string>)//' -e 's/([A-Z0-9]*)(.*)/\1/'` checkStatus fi #if the current bundle identifier is different from the new one in the provisioning profile, then change it. if [ "$CURRENT_BUNDLE_IDENTIFIER" != "$BUNDLE_IDENTIFIER" ]; then echo "Update the bundle identifier" `PlistBuddy -c "Set :CFBundleIdentifier $BUNDLE_IDENTIFIER" "temp/Payload/$APP_NAME/Info.plist"` checkStatus fi @@ -151,20 +168,26 @@ if [ "$ENTITLEMENTS" != "" ]; then echo "Using Entitlements: $ENTITLEMENTS" >&2 /usr/bin/codesign -f -s "$CERTIFICATE" --entitlements="$ENTITLEMENTS" --resource-rules="temp/Payload/$APP_NAME/ResourceRules.plist" "temp/Payload/$APP_NAME" checkStatus else if [ "$PROVISIONING_PROFILE_PREFIX" != "" ]; then # extract current entitlements PlistBuddy -c "Set :application-identifier ${PROVISIONING_PROFILE_PREFIX}.${BUNDLE_IDENTIFIER}" temp/newEntitlements` checkStatus PlistBuddy -c "Set :keychain-access-groups:0 ${PROVISIONING_PROFILE_PREFIX}.${BUNDLE_IDENTIFIER}" temp/newEntitlements` checkStatus plutil -lint temp/newEntitlements checkStatus /usr/bin/codesign -f -s "$CERTIFICATE" --resource-rules="temp/Payload/$APP_NAME/ResourceRules.plist" --entitlements="temp/newEntitlements" "temp/Payload/$APP_NAME" checkStatus else /usr/bin/codesign -f -s "$CERTIFICATE" --resource-rules="temp/Payload/$APP_NAME/ResourceRules.plist" "temp/Payload/$APP_NAME" fi fi # Repackage quietly rm temp/newEntitlements echo "Repackaging as $NEW_FILE" # Zip up the contents of the temp folder -
Weptun revised this gist
Apr 17, 2013 . 1 changed file with 76 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,6 +3,10 @@ # Copyright (c) 2011 Float Mobile Learning # http://www.floatlearning.com/ # # Extended by Ronan O Ciosoig January 2012 # # Extended by Patrick Blitz, April 2013 # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation @@ -22,29 +26,52 @@ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Please let us know about any improvements you make to this script! # ./sign source identity -p "path/to/profile" -e "path/to/entitlements" -d "display name" outputIpa # # # Modifed 26th January 2012 # # new features January 2012: # 1. change the app display name # # new features April 2013 # 1. specify the target bundleId on the command line # 2. correctly handles entitlements for keychain-enabled resigning # if [ $# -lt 3 ]; then echo "usage: $0 source identity [-p provisioning] [-e entitlements] [-d displayName] [-b bundleId] outputIpa" >&2 exit 1 fi ORIGINAL_FILE="$1" CERTIFICATE="$2" NEW_PROVISION= ENTITLEMENTS= BUNDLE_IDENTIFIER="" DISPLAY_NAME="" PROVISIONING_PROFILE_PREFIX="" # options start index OPTIND=3 while getopts p:d:e:b: opt; do case $opt in p) NEW_PROVISION="$OPTARG" echo "Specified provisioning profile: $NEW_PROVISION" >&2 ;; d) DISPLAY_NAME="$OPTARG" echo "Specified display name: $DISPLAY_NAME" >&2 ;; e) ENTITLEMENTS="$OPTARG" echo "Specified signing entitlements: $ENTITLEMENTS" >&2 ;; b) BUNDLE_IDENTIFIER="$OPTARG" echo "Specified bundle identifier: $BUNDLE_IDENTIFIER " >&2 ;; \?) echo "Invalid option: -$OPTARG" >&2 exit 1 @@ -60,6 +87,7 @@ shift $((OPTIND-1)) NEW_FILE="$1" # Check if the supplied file is an ipa or an app file if [ "${ORIGINAL_FILE#*.}" = "ipa" ] then @@ -80,19 +108,60 @@ fi APP_NAME=$(ls temp/Payload/) echo "APP_NAME=$APP_NAME" >&2 export PATH=$PATH:/usr/libexec CURRENT_NAME=`PlistBuddy -c "Print :CFBundleDisplayName" "temp/Payload/$APP_NAME/Info.plist"` CURRENT_BUNDLE_IDENTIFIER=`PlistBuddy -c "Print :CFBundleIdentifier" "temp/Payload/$APP_NAME/Info.plist"` if [ "${BUNDLE_IDENTIFIER}" != "" ]; then BUNDLE_IDENTIFIER=`egrep -a -A 2 application-identifier $NEW_PROVISION | grep string | sed -e 's/<string>//' -e 's/<\/string>//' -e 's/ //' | awk '{split($0,a,"."); i = length(a); for(ix=2; ix <= i;ix++){ s=s a[ix]; if(i!=ix){s=s "."};} print s;}'` fi if [ "${DISPLAY_NAME}" != "" ]; then echo "read Info.plist file" temp/Payload/$ORIGINAL_FILE/Info.plist # CURRENT_NAME=/usr/libexec/PlistBuddy -c "Print :CFBundleDisplayName" temp/Payload/$ORIGINAL_FILE/Info.plist echo "Changing display name from $CURRENT_NAME to " $DISPLAY_NAME `PlistBuddy -c "Set :CFBundleDisplayName $DISPLAY_NAME" "temp/Payload/$APP_NAME/Info.plist"` # PlistBuddy -c "Set :CFBundleDisplayName $DISPLAY_NAME" temp/Payload/$ORIGINAL_FILE/Info.plist fi # Replace the embedded mobile provisioning profile if [ "$NEW_PROVISION" != "" ]; then echo "Adding the new provision: $NEW_PROVISION" echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>`/usr/bin/codesign -d --entitlements - temp/Payload/$APP_NAME | sed -E -e '1d'`" > temp/newEntitlements cp "$NEW_PROVISION" "temp/Payload/$APP_NAME/embedded.mobileprovision" PROVISIONING_PROFILE_PREFIX=`grep '<key>application-identifier</key>' temp/Payload/$APP_NAME/embedded.mobileprovision -A 1 --binary-files=text | sed -E -e '/<key>/ d' -e 's/(^.*<string>)//' -e 's/([A-Z0-9]*)(.*)/\1/'` fi #if the current bundle identifier is different from the new one in the provisioning profile, then change it. if [ "$CURRENT_BUNDLE_IDENTIFIER" != "$BUNDLE_IDENTIFIER" ]; then echo "Update the bundle identifier" `PlistBuddy -c "Set :CFBundleIdentifier $BUNDLE_IDENTIFIER" "temp/Payload/$APP_NAME/Info.plist"` fi # Resign the application echo "Resigning application using certificate: $CERTIFICATE" >&2 if [ "$ENTITLEMENTS" != "" ]; then echo "Using Entitlements: $ENTITLEMENTS" >&2 /usr/bin/codesign -f -s "$CERTIFICATE" --entitlements="$ENTITLEMENTS" --resource-rules="temp/Payload/$APP_NAME/ResourceRules.plist" "temp/Payload/$APP_NAME" else if [ "$PROVISIONING_PROFILE_PREFIX" != "" ]; then # extract current entitlements PlistBuddy -c "Set :application-identifier ${PROVISIONING_PROFILE_PREFIX}.${BUNDLE_IDENTIFIER}" temp/newEntitlements` PlistBuddy -c "Set :keychain-access-groups:0 ${PROVISIONING_PROFILE_PREFIX}.${BUNDLE_IDENTIFIER}" temp/newEntitlements` plutil -lint temp/newEntitlements /usr/bin/codesign -f -s "$CERTIFICATE" --resource-rules="temp/Payload/$APP_NAME/ResourceRules.plist" --entitlements="temp/newEntitlements" "temp/Payload/$APP_NAME" else /usr/bin/codesign -f -s "$CERTIFICATE" --resource-rules="temp/Payload/$APP_NAME/ResourceRules.plist" "temp/Payload/$APP_NAME" fi fi # Repackage quietly @@ -103,7 +172,7 @@ echo "Repackaging as $NEW_FILE" # Zip all the contents, saving the zip file in the above directory # Navigate back to the orignating directory (sending the output to null) pushd temp > /dev/null zip -qr ../temp.ipa * popd > /dev/null # Move the resulting ipa to the target destination -
mediabounds revised this gist
Jan 19, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -103,7 +103,7 @@ echo "Repackaging as $NEW_FILE" # Zip all the contents, saving the zip file in the above directory # Navigate back to the orignating directory (sending the output to null) pushd temp > /dev/null zip -qry ../temp.ipa * popd > /dev/null # Move the resulting ipa to the target destination -
mediabounds created this gist
Nov 15, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,113 @@ # !/bin/bash # Copyright (c) 2011 Float Mobile Learning # http://www.floatlearning.com/ # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Please let us know about any improvements you make to this script! # ./sign source identity -p "path/to/profile" -e "path/to/entitlements" target if [ $# -lt 3 ]; then echo "usage: $0 source identity [-p provisioning] [-e entitlements] target" >&2 exit 1 fi ORIGINAL_FILE="$1" CERTIFICATE="$2" NEW_PROVISION= ENTITLEMENTS= OPTIND=3 while getopts p:e: opt; do case $opt in p) NEW_PROVISION="$OPTARG" echo "Specified provisioning profile: $NEW_PROVISION" >&2 ;; e) ENTITLEMENTS="$OPTARG" echo "Specified signing entitlements: $ENTITLEMENTS" >&2 ;; \?) echo "Invalid option: -$OPTARG" >&2 exit 1 ;; :) echo "Option -$OPTARG requires an argument." >&2 exit 1 ;; esac done shift $((OPTIND-1)) NEW_FILE="$1" # Check if the supplied file is an ipa or an app file if [ "${ORIGINAL_FILE#*.}" = "ipa" ] then # Unzip the old ipa quietly unzip -q "$ORIGINAL_FILE" -d temp elif [ "${ORIGINAL_FILE#*.}" = "app" ] then # Copy the app file into an ipa-like structure mkdir -p "temp/Payload" cp -Rf "$ORIGINAL_FILE" "temp/Payload/$ORIGINAL_FILE" else echo "Error: Only can resign .app files and .ipa files." >&2 exit fi # Set the app name # The app name is the only file within the Payload directory APP_NAME=$(ls temp/Payload/) echo "APP_NAME=$APP_NAME" >&2 # Replace the embedded mobile provisioning profile if [ "$NEW_PROVISION" != "" ]; then echo "Adding the new provision: $NEW_PROVISION" cp "$NEW_PROVISION" "temp/Payload/$APP_NAME/embedded.mobileprovision" fi # Resign the application echo "Resigning application using certificate: $CERTIFICATE" >&2 if [ "$ENTITLEMENTS" != "" ]; then echo "Using Entitlements: $ENTITLEMENTS" >&2 /usr/bin/codesign -f -s "$CERTIFICATE" --entitlements="$ENTITLEMENTS" --resource-rules="temp/Payload/$APP_NAME/ResourceRules.plist" "temp/Payload/$APP_NAME" else /usr/bin/codesign -f -s "$CERTIFICATE" --resource-rules="temp/Payload/$APP_NAME/ResourceRules.plist" "temp/Payload/$APP_NAME" fi # Repackage quietly echo "Repackaging as $NEW_FILE" # Zip up the contents of the temp folder # Navigate to the temporary directory (sending the output to null) # Zip all the contents, saving the zip file in the above directory # Navigate back to the orignating directory (sending the output to null) pushd temp > /dev/null zip -qr ../temp.ipa * popd > /dev/null # Move the resulting ipa to the target destination mv temp.ipa "$NEW_FILE" # Remove the temp directory rm -rf "temp"