#!/bin/bash
#code by xiaodao 2012-06-05
sourceipaname="test.ipa"
appname="test.app"
targetName="test"
version="1_2_0"
zipTime=`date +%m_%d`
PlistBuddy="/usr/libexec/PlistBuddy"
plutil="plutil"
source="channel"
distDir="${PWD}/pkg"
configname="testConfig.plist"
rm -rdf "${distDir}"
mkdir -p "${distDir}"
unzip ${sourceipaname}
i=0
maxNum=$1
for((;${i}<${maxNum};i++))
do
cd Payload
cd $appname
#echo ">>>>>>>>>>>>>1"
#cat "${configname}"
${PlistBuddy} -c "set :channel-id test${i}" ${configname}
#cat "${configname}"
${plutil} -convert binary1 ${configname}
#cat "${configname}"
#echo ">>>>>>>>>>>>>2"
if [ "${source}" == "channel" ];then
cd ../..
zip -r "${targetName}_${version}_${zipTime}_for_channel${i}.zip" Payload
mv "${targetName}_${version}_${zipTime}_for_channel${i}.zip" "${distDir}/${targetName}_${version}_${zipTime}_for_channel${i}.ipa"
else
cd ..
zip -r "${targetName}_${version}_${zipTime}_for_appstore${i}.zip" $appname
mv "${targetName}_${version}_${zipTime}_for_appstore${i}.zip" $distDir
cd ..
fi
done
rm -rdf Payload