chufan

init

1 +#!/usr/bin/env bash
2 +
3 +INSPECT_ONLY=0
4 +if [[ "$1" == '-i' ]]; then
5 + INSPECT_ONLY=1
6 + shift
7 +fi
8 +
9 +
10 +
11 +if [[ ! ( # any of the following are not true
12 + # 1st arg is an existing regular file
13 + -f "$1" &&
14 + # ...and it has a .ipa extension
15 + "${1##*.}" == "ipa" &&
16 + ($INSPECT_ONLY == 1 || -n "$2")
17 + ) ]];
18 + then
19 + cat << EOF >&2
20 + Usage: $(basename "$0") Application.ipa channel Example: $(basename "$0") ./xxx.ipa youyu
21 + Usage: $(basename "$0") Application.ipa -list
22 +
23 + Options:
24 + -list resign list channel
25 + 注意:
26 + 1 如果是-list 保证resign_list.txt 在根目录下
27 + 2 更换Icon 请将png放在appIcon目录下
28 + 3 更换其它资源请放到res中
29 +EOF
30 + exit;
31 +fi
32 +
33 +
34 +
35 +## Exit on use of an uninitialized variable
36 +set -o nounset
37 +## Exit if any statement returns a non-true return value (non-zero)
38 +set -o errexit
39 +## Announce commands
40 +#set -o xtrace
41 +realpath(){
42 + echo "$(cd "$(dirname "$1")"; echo "$(pwd)/$(basename "$1")")";
43 +}
44 +resign(){
45 + echo "打包渠道: $2"
46 + SDK_HOME="$(realpath $2)"
47 + paramsfile="$(echo "$SDK_HOME""/params.txt")"
48 + #mobileprovision="$(cat $paramsfile |awk -F ',' '{print $1}')"
49 + mobileprovision="$(ls $2 | grep mobileprovision)"
50 + sign="$(cat $paramsfile |awk -F ',' '{print $1}')"
51 +
52 + #echo "描述文件: $(realpath $mobileprovision)"
53 + echo "描述文件: $SDK_HOME/$mobileprovision "
54 + echo "签名: $sign"
55 + echo "参数文件: $paramsfile"
56 + echo "渠道资源目录: $SDK_HOME"
57 +
58 + ./ipa_sign "$1" "$SDK_HOME/$mobileprovision" "$sign" "$2"
59 +}
60 +
61 +if [[ "$2" == '-list' ]]; then
62 + while read line
63 + do
64 + resign $1 $line
65 + done < ./resign_list.txt
66 + exit
67 +fi
68 +
69 +resign $1 $2
1 +#!/usr/bin/env bash
2 +
3 +INSPECT_ONLY=0
4 +if [[ "$1" == '-i' ]]; then
5 + INSPECT_ONLY=1
6 + shift
7 +fi
8 +
9 +if [[ "$1" == '-l' ]]; then
10 + security find-certificate -a | awk '/^keychain/ {if(k!=$0){print; k=$0;}} /"labl"<blob>=/{sub(".*<blob>="," "); print}'
11 + exit
12 +fi
13 +
14 +if [[ ! ( # any of the following are not true
15 + # 1st arg is an existing regular file
16 + -f "$1" &&
17 + # ...and it has a .ipa extension
18 + "${1##*.}" == "ipa" &&
19 + # 2nd arg is an existing regular file
20 + ($INSPECT_ONLY == 1 || -f "$2") &&
21 + # ...and it has an .mobileprovision extension
22 + ($INSPECT_ONLY == 1 || "${2##*.}" == "mobileprovision") &&
23 + # 3rd arg is a non-empty string
24 + ($INSPECT_ONLY == 1 || -n "$3")
25 + ) ]];
26 + then
27 + cat << EOF >&2
28 + 出错了: 参数配置有误请检查
29 + Usage:(请检查显示的这几项是否都有内容,都显示正确)
30 + 打包渠道: youyu --->重新打包的渠道,资源需要放到同名目录
31 + 描述文件: ./youyu/dve_qingyunjue.mobileprovision --> 需要把描述文件放到渠道目录下
32 + 签名: iPhone Developer: Yongxing Yu (7SXDVCVFQZ) -->证书名字写到params.txt
33 + 参数文件: /Users/winfan/gitworkplace/ota-tools/youyu/params.txt
34 + 渠道资源目录: /Users/winfan/gitworkplace/ota-tools/youyu
35 +EOF
36 + exit;
37 +fi
38 +
39 +## Exit on use of an uninitialized variable
40 +set -o nounset
41 +## Exit if any statement returns a non-true return value (non-zero)
42 +set -o errexit
43 +## Announce commands
44 +#set -o xtrace
45 +
46 +realpath(){
47 + echo "$(cd "$(dirname "$1")"; echo -n "$(pwd)/$(basename "$1")")";
48 +}
49 +
50 +IPA="$(realpath $1)"
51 +CHANNEL_HOME="$(realpath $4)"
52 +TMP="$(mktemp -d /tmp/resign.$(basename "$IPA" .ipa).XXXXX)"
53 +IPA_NEW="$(pwd)/$(basename "$IPA" .ipa).$4.resigned.ipa"
54 +CLEANUP_TEMP=0 # Do not remove this line or "set -o nounset" will error on checks below
55 +#CLEANUP_TEMP=1 # Uncomment this line if you want this script to clean up after itself
56 +cd "$TMP"
57 +[[ $CLEANUP_TEMP -ne 1 ]] && echo "Using temp dir: $TMP"
58 +unzip -q "$IPA"
59 +plutil -convert xml1 Payload/*.app/Info.plist -o Info.plist
60 +echo "App has BundleDisplayName '$(/usr/libexec/PlistBuddy -c 'Print :CFBundleDisplayName' Info.plist)' and BundleShortVersionString '$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' Info.plist)'"
61 +echo "App has BundleIdentifier '$(/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' Info.plist)' and BundleVersion $(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' Info.plist)"
62 +security cms -D -i Payload/*.app/embedded.mobileprovision > mobileprovision.plist
63 +echo "App has provision '$(/usr/libexec/PlistBuddy -c "Print :Name" mobileprovision.plist)', which supports '$(/usr/libexec/PlistBuddy -c "Print :Entitlements:application-identifier" mobileprovision.plist)'"
64 +if [[ ! ($INSPECT_ONLY == 1) ]]; then
65 + PROVISION="$(realpath "$2")"
66 + CERTIFICATE="$3"
67 + security cms -D -i "$PROVISION" > provision.plist
68 + /usr/libexec/PlistBuddy -x -c 'Print :Entitlements' provision.plist > entitlements.plist
69 + echo "Embedding provision '$(/usr/libexec/PlistBuddy -c "Print :Name" provision.plist)', which supports '$(/usr/libexec/PlistBuddy -c "Print :Entitlements:application-identifier" provision.plist)'"
70 + rm -rf Payload/*.app/_CodeSignature Payload/*.app/CodeResources
71 + cp "$PROVISION" Payload/*.app/embedded.mobileprovision
72 + echo "replace Icon :$(echo cp $CHANNEL_HOME/appIcon/* Payload/*.app/)"
73 + cp $CHANNEL_HOME/appIcon/* Payload/*.app/
74 + echo "replace Resource: $(echo cp $CHANNEL_HOME/res Payload/*.app/)"
75 + cp -r $CHANNEL_HOME/res Payload/*.app/
76 + /usr/bin/codesign -f -s "$CERTIFICATE" --entitlements entitlements.plist Payload/*.app
77 + zip -qr "$IPA_NEW" Payload
78 +fi
79 +if [[ $CLEANUP_TEMP -eq 1 ]]; then
80 + rm -rf "$TMP"
81 +fi
1 +youyu
2 +i9133
No preview for this file type
1 +/Payload/xw3ztzj.app/res/drawable/qyj_logo_sp.png
2 +Info.plist
3 +
1 +iPhone Developer: Yongxing Yu (7SXDVCVFQZ)
No preview for this file type