forked from parallaxinc/SimpleIDE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmacappcodesign.sh
executable file
·100 lines (88 loc) · 2.07 KB
/
macappcodesign.sh
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/sh --
#
# macappcodesign.sh
#
# A shell script that codesigns the SimpleIDE application
#
# Assumes the app bundle is within a directory with the app's base name
#
# Using sudo ./macappcodesign.sh is strongly recommended
#
# Example usage:
# ./macappcodesign -s "Developer ID Application" -a SimpleIDE/SimpleIDE.app
#
# defaults
IDENTITY="Developer ID Application"
APPNAME=SimpleIDE
usage()
{
cat << EOF
usage: $0 options
codesigns a Mac application (defaults to SimpleIDE.app)
OPTIONS:
-h show usage
-s identity developer certificate key - example: -s "Developer ID Application" (default)
-n name app name - example: -n SimpleIDE (default)
-? show usage
EOF
}
while getopts "h:s:n:?" OPTION
do
case $OPTION in
h)
usage
exit 0
;;
s)
IDENTITY=$OPTARG
echo "overriding Identity default with: \"${IDENTITY}\""
;;
n)
APPNAME=$OPTARG
echo "overriding app name default with: \"${APPNAME}\""
;;
?)
usage
exit 0
;;
esac
done
# must have an identity and an app name
if [[ -z $IDENTITY ]] || [[ -z $APPNAME ]]
then
usage
exit 1
fi
#
# App path must exist
if [[ ! -d ${APPNAME}/${APPNAME}.app ]]
then
echo "[Error] ${APPNAME}.app does not exist!"
echo
usage
exit 1
else
echo " App name: \"${APPNAME}\" found..."
fi
# use security utility to determine if the identity is valid
#SECUREID=""
SECUREID=`security find-certificate -c "$IDENTITY" | grep labl`
if [[ -n ${SECUREID} ]]
then
echo " Identity: \"${IDENTITY}\" found..."
else
echo "[Error] Identity: \"${IDENTITY}\" does not exist!"
echo
usage
exit 1
fi
# full app path
APPPATH=${APPNAME}/${APPNAME}.app
# attempt codesigning of the app bundle
echo code signing the app bundle @: ${APPPATH} for identity: \"${IDENTITY}\"
codesign -s "$IDENTITY" --deep -f -v ${APPPATH}
if [ "$?" != "0" ]; then
echo "[Error] codesign failed!" 1>&2
exit 1
fi
exit 0