-
Notifications
You must be signed in to change notification settings - Fork 132
/
Copy pathDYFCodesign
executable file
·63 lines (46 loc) · 1.65 KB
/
DYFCodesign
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#! /bin/sh
#-------------------------------------------------------
#
# Sign all the files in the Payload/xxx.app.
#
# 1. The first parameter is the path of Payload directory.
# 2. The second parameter is the name of certificate.
# 3. The third parameter is the path of mobileprovision.
#
# Author: dyf
# Email : [email protected]
# Date : 2016/03/31
#
#-------------------------------------------------------
if [ $# -lt 3 ];then
echo 'Error! Should enter the path of Payload, certificate name and the path of mobileprovision.'
exit 1
fi
payloadPath=$1
cd ${payloadPath}
payloadPath=`pwd`
homePath=$(dirname ${payloadPath})
cd ${homePath}
certificateName=$2
mobileprovisionFilepath=$3
appPath=$(find ${payloadPath} -name '*.app')
securitCmd='/usr/bin/security'
codesignCmd='/usr/bin/codesign'
plistbuddyCmd='/usr/libexec/PlistBuddy'
infoplistPath="${appPath}/Info.plist"
payloadDir=$(echo ${payloadPath} | rev | awk -F '/' '{print $1}' | rev)
entitlementsPlistName="entitlements.plist"
entitlementsPlistPath=${homePath}/${entitlementsPlistName}
${plistbuddyCmd} -x -c "print :Entitlements" /dev/stdin <<< $(${securitCmd} cms -D -i ${mobileprovisionFilepath}) > ${entitlementsPlistPath}
codeSignatureDirpath="${appPath}/_CodeSignature"
rm -rf ${codeSignatureDirpath}
embeddedMobileprovisionFilepath="${appPath}/embedded.mobileprovision"
cp -f ${mobileprovisionFilepath} ${embeddedMobileprovisionFilepath}
if [ -e ${entitlementsPlistPath} ];then
${codesignCmd} -f -s "${certificateName}" --no-strict --entitlements=${entitlementsPlistPath} ${appPath}
if [ $? -eq 0 ];then
${codesignCmd} -v ${appPath}
fi
fi
# remove
rm -rf ${entitlementsPlistPath}