chufan

init

#!/usr/bin/env bash
INSPECT_ONLY=0
if [[ "$1" == '-i' ]]; then
INSPECT_ONLY=1
shift
fi
if [[ ! ( # any of the following are not true
# 1st arg is an existing regular file
-f "$1" &&
# ...and it has a .ipa extension
"${1##*.}" == "ipa" &&
($INSPECT_ONLY == 1 || -n "$2")
) ]];
then
cat << EOF >&2
Usage: $(basename "$0") Application.ipa channel Example: $(basename "$0") ./xxx.ipa youyu
Usage: $(basename "$0") Application.ipa -list
Options:
-list resign list channel
注意:
1 如果是-list 保证resign_list.txt 在根目录下
2 更换Icon 请将png放在appIcon目录下
3 更换其它资源请放到res中
EOF
exit;
fi
## Exit on use of an uninitialized variable
set -o nounset
## Exit if any statement returns a non-true return value (non-zero)
set -o errexit
## Announce commands
#set -o xtrace
realpath(){
echo "$(cd "$(dirname "$1")"; echo "$(pwd)/$(basename "$1")")";
}
resign(){
echo "打包渠道: $2"
SDK_HOME="$(realpath $2)"
paramsfile="$(echo "$SDK_HOME""/params.txt")"
#mobileprovision="$(cat $paramsfile |awk -F ',' '{print $1}')"
mobileprovision="$(ls $2 | grep mobileprovision)"
sign="$(cat $paramsfile |awk -F ',' '{print $1}')"
#echo "描述文件: $(realpath $mobileprovision)"
echo "描述文件: $SDK_HOME/$mobileprovision "
echo "签名: $sign"
echo "参数文件: $paramsfile"
echo "渠道资源目录: $SDK_HOME"
./ipa_sign "$1" "$SDK_HOME/$mobileprovision" "$sign" "$2"
}
if [[ "$2" == '-list' ]]; then
while read line
do
resign $1 $line
done < ./resign_list.txt
exit
fi
resign $1 $2
#!/usr/bin/env bash
INSPECT_ONLY=0
if [[ "$1" == '-i' ]]; then
INSPECT_ONLY=1
shift
fi
if [[ "$1" == '-l' ]]; then
security find-certificate -a | awk '/^keychain/ {if(k!=$0){print; k=$0;}} /"labl"<blob>=/{sub(".*<blob>="," "); print}'
exit
fi
if [[ ! ( # any of the following are not true
# 1st arg is an existing regular file
-f "$1" &&
# ...and it has a .ipa extension
"${1##*.}" == "ipa" &&
# 2nd arg is an existing regular file
($INSPECT_ONLY == 1 || -f "$2") &&
# ...and it has an .mobileprovision extension
($INSPECT_ONLY == 1 || "${2##*.}" == "mobileprovision") &&
# 3rd arg is a non-empty string
($INSPECT_ONLY == 1 || -n "$3")
) ]];
then
cat << EOF >&2
出错了: 参数配置有误请检查
Usage:(请检查显示的这几项是否都有内容,都显示正确)
打包渠道: youyu --->重新打包的渠道,资源需要放到同名目录
描述文件: ./youyu/dve_qingyunjue.mobileprovision --> 需要把描述文件放到渠道目录下
签名: iPhone Developer: Yongxing Yu (7SXDVCVFQZ) -->证书名字写到params.txt
参数文件: /Users/winfan/gitworkplace/ota-tools/youyu/params.txt
渠道资源目录: /Users/winfan/gitworkplace/ota-tools/youyu
EOF
exit;
fi
## Exit on use of an uninitialized variable
set -o nounset
## Exit if any statement returns a non-true return value (non-zero)
set -o errexit
## Announce commands
#set -o xtrace
realpath(){
echo "$(cd "$(dirname "$1")"; echo -n "$(pwd)/$(basename "$1")")";
}
IPA="$(realpath $1)"
CHANNEL_HOME="$(realpath $4)"
TMP="$(mktemp -d /tmp/resign.$(basename "$IPA" .ipa).XXXXX)"
IPA_NEW="$(pwd)/$(basename "$IPA" .ipa).$4.resigned.ipa"
CLEANUP_TEMP=0 # Do not remove this line or "set -o nounset" will error on checks below
#CLEANUP_TEMP=1 # Uncomment this line if you want this script to clean up after itself
cd "$TMP"
[[ $CLEANUP_TEMP -ne 1 ]] && echo "Using temp dir: $TMP"
unzip -q "$IPA"
plutil -convert xml1 Payload/*.app/Info.plist -o Info.plist
echo "App has BundleDisplayName '$(/usr/libexec/PlistBuddy -c 'Print :CFBundleDisplayName' Info.plist)' and BundleShortVersionString '$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' Info.plist)'"
echo "App has BundleIdentifier '$(/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' Info.plist)' and BundleVersion $(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' Info.plist)"
security cms -D -i Payload/*.app/embedded.mobileprovision > mobileprovision.plist
echo "App has provision '$(/usr/libexec/PlistBuddy -c "Print :Name" mobileprovision.plist)', which supports '$(/usr/libexec/PlistBuddy -c "Print :Entitlements:application-identifier" mobileprovision.plist)'"
if [[ ! ($INSPECT_ONLY == 1) ]]; then
PROVISION="$(realpath "$2")"
CERTIFICATE="$3"
security cms -D -i "$PROVISION" > provision.plist
/usr/libexec/PlistBuddy -x -c 'Print :Entitlements' provision.plist > entitlements.plist
echo "Embedding provision '$(/usr/libexec/PlistBuddy -c "Print :Name" provision.plist)', which supports '$(/usr/libexec/PlistBuddy -c "Print :Entitlements:application-identifier" provision.plist)'"
rm -rf Payload/*.app/_CodeSignature Payload/*.app/CodeResources
cp "$PROVISION" Payload/*.app/embedded.mobileprovision
echo "replace Icon :$(echo cp $CHANNEL_HOME/appIcon/* Payload/*.app/)"
cp $CHANNEL_HOME/appIcon/* Payload/*.app/
echo "replace Resource: $(echo cp $CHANNEL_HOME/res Payload/*.app/)"
cp -r $CHANNEL_HOME/res Payload/*.app/
/usr/bin/codesign -f -s "$CERTIFICATE" --entitlements entitlements.plist Payload/*.app
zip -qr "$IPA_NEW" Payload
fi
if [[ $CLEANUP_TEMP -eq 1 ]]; then
rm -rf "$TMP"
fi
youyu
i9133
No preview for this file type
/Payload/xw3ztzj.app/res/drawable/qyj_logo_sp.png
Info.plist
iPhone Developer: Yongxing Yu (7SXDVCVFQZ)
No preview for this file type