#!/bin/sh project=$1 app=$2 type=Release extra= if [ -z "${project}" -o -z "${app}" ]; then echo "Usage: $(basename $0) [configuration]" echo "example: $(basename $0) FivePeeEmm 5somewhere" echo "configuration defaults to 'Release'" exit 1 fi if [ ! -z "$3" ]; then type=$3 extra="-$3" fi base="${HOME}/Documents/iPhone Projects/${project}" if [ ! -d "${base}" ]; then echo "ERROR: Can't find project \"${project}\" at \"${base}\"" exit 1 fi appdir="${base}/build/${type}-iphoneos" if [ ! -d "${appdir}/${app}.app" ]; then echo "ERROR: Can't find app \"${app}\" at \"${appdir}/${app}.app\"" exit 1 fi mkdir -p $HOME/Applications || exit 1 # Make a copy of the build into the Payload directory payloaddir="${base}/build/Payload" payload="Payload" rm -rf "${payloaddir}" mkdir -p "${payloaddir}" cp -rp "${appdir}/" "${payloaddir}/" cd "${payloaddir}/.." bindir="${payload}/${app}.app" # Get build and release versions bundle_id=$(plutil -convert xml1 -o - - < "${bindir}/Info.plist" | grep -A 1 CFBundleIdentifier | sed -e 's/<[^>]*>//g' -e 's/[ ]//g'| tail -1) bundle_short=$(echo "${bundle_id}" | sed -Ee 's/^.*\.(.*)$/\1/') release_ver=$(plutil -convert xml1 -o - - < "${bindir}/Info.plist" | grep -A 1 CFBundleShortVersionString | sed -e 's/<[^>]*>//g' -e 's/[ ]//g'| tail -1) build_ver=$(plutil -convert xml1 -o - - < "${bindir}/Info.plist" | grep -A 1 CFBundleVersion | sed -e 's/<[^>]*>//g' -e 's/[ ]//g'| tail -1) echo "Packaging project \"${project}\" target \"${app}\"" echo " Bundle ID \"${bundle_id}\" (${bundle_short}) version ${release_ver} build ${build_ver}..." zip="$HOME/Applications/${app}-${release_ver}-${build_ver}${extra}.zip" zip=$(echo "${zip}" | sed -e 's/ */_/g') year=$(date +%Y) rm -f "${zip}" zip -Xoyrz "${zip}" "${bindir}" << EOT | grep -v 'enter new zip file comment' Project: ${project} App: ${app} Release: ${release_ver} Build: ${build_ver} (c) ${year} Chris Luke . EOT zip -T "${zip}" || exit 1 unzip -tq "${zip}" || exit 1 echo "Done. Package is ${zip}" if [ "${type}" = "Ad Hoc" ]; then # One more step - package it up for iosbeta distribution! odir="$HOME/Documents/iosbeta/${bundle_short}-${build_ver}" ourl="http://iosbeta.flirble.org/${bundle_short}-${build_ver}" echo "Distributing Ad Hoc release into ${odir}..." mkdir -p "${odir}" || exit 1 if open "$HOME/Documents/MacOSX Projects/BetaBuilder TFO/build/Debug/BetaBuilder.app" --args \ -i "${zip}" -o "${odir}" -u "${ourl}" -r "${base}/README.txt" ; then $HOME/bin/sync-iosbeta else echo "BetaBuilder encountered an error. Check system logs." exit 1 fi fi