Created
May 23, 2012 12:24
-
-
Save 0xc010d/2774989 to your computer and use it in GitHub Desktop.
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 characters
| #!/bin/sh | |
| OLD_PWD="$(pwd)"; | |
| #get script parameters | |
| APP_BUNDLE_DIR=$1; | |
| IPA_URL=$2; | |
| MANIFEST_NAME=$3; | |
| if [ ! -d "$APP_BUNDLE_DIR" -o ! "$IPA_URL" ]; then | |
| echo "\nThe script usage:\n\ | |
| \033[1mwirelessPrepare\033[0m \033[4mbundlePath\033[0m \033[4mipaURL\033[0m [\033[4mmanifestFilename\033[0m]\n"; | |
| exit 1001; | |
| fi; | |
| #get the filename for the ipa archive from the IPA_URL | |
| IPA_NAME=$(basename "$IPA_URL"); | |
| #the default manifest filename is manifest.plist | |
| if [ ! "$MANIFEST_NAME" ]; then | |
| MANIFEST_NAME="manifest.plist"; | |
| fi; | |
| # | |
| #prepare the .ipa archive | |
| # | |
| #APP_BUNDLE_DIR should contain the absolute path | |
| cd "$APP_BUNDLE_DIR"; | |
| APP_BUNDLE_DIR=`pwd`; | |
| cd ..; | |
| if [ -d Payload ]; then | |
| rm -rf Payload; | |
| fi; | |
| mkdir Payload; | |
| cp -R "$APP_BUNDLE_DIR" Payload; | |
| zip -r -y "$IPA_NAME" Payload > /dev/null; | |
| #remove the Payload directory, be clean | |
| rm -rf Payload; | |
| # | |
| #create manifest file | |
| # | |
| #read CFBundleIdentifier, CFBundleVersion, CFBundleDisplayName from Info.plist | |
| BUNDLE_IDENTIFIER=$(defaults read "$APP_BUNDLE_DIR/Info" CFBundleIdentifier); | |
| BUNDLE_VERSION=$(defaults read "$APP_BUNDLE_DIR/Info" CFBundleVersion); | |
| BUNDLE_DISPLAY_NAME=$(defaults read "$APP_BUNDLE_DIR/Info" CFBundleDisplayName); | |
| MANIFEST_DATA="{\ | |
| items = (\ | |
| {\ | |
| assets = (\ | |
| {\ | |
| kind = \"software-package\";\ | |
| url = \"$IPA_URL\";\ | |
| }\ | |
| );\ | |
| metadata = {\ | |
| \"bundle-identifier\" = \"$BUNDLE_IDENTIFIER\";\ | |
| \"bundle-version\" = \"$BUNDLE_VERSION\";\ | |
| kind = software;\ | |
| title = \"$BUNDLE_DISPLAY_NAME\";\ | |
| };\ | |
| }\ | |
| );\ | |
| }"; | |
| #note: we should substract the file extenstion, the .plist extension would be added automatically | |
| defaults write "`pwd`/${MANIFEST_NAME%.*}" "$MANIFEST_DATA"; | |
| #as defaults generates binary plist – lets convert it to XML | |
| #there's no difference for iOS but we'd be able simply read the plist file content | |
| plutil -convert xml1 ${MANIFEST_NAME%.*}.plist; | |
| if [ "$OLD_PWD" != "`pwd`" ]; then | |
| mv "$IPA_NAME" "$OLD_PWD"; | |
| mv "${MANIFEST_NAME%.*}.plist" "$OLD_PWD/$MANIFEST_NAME"; | |
| else | |
| if [ "$MANIFEST_NAME" != "${MANIFEST_NAME%.*}.plist" ]; then | |
| mv "${MANIFEST_NAME%.*}.plist" "$MANIFEST_NAME"; | |
| fi; | |
| fi; | |
| echo "itms-services://?action=download-manifest&url=$(dirname $IPA_URL)/$MANIFEST_NAME"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment