-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
codesign_osxapp.sh
executable file
·78 lines (61 loc) · 1.73 KB
/
codesign_osxapp.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
#!/bin/sh
#
# tom hensel <code@jitter.eu> for EmuFlight
#
#
# variables and composition
#
CERTIFICATE_P12="sign/EmuCert.p12"
KEYCHAIN="build.keychain"
ENTITLEMENTS="sign/entitlements.plist"
APP_PATH="apps/emuflight-configurator/osx64/emuflight-configurator.app"
#
# sanity checks
#
if [ -z "${APP_IDENTITY}" ]; then
echo "required variable APP_IDENTITY not set"
exit 2
fi
if [ -z "${BUNDLE_ID}" ]; then
echo "required variable BUNDLE_ID not set"
exit 3
fi
if [ ! -f "${ENTITLEMENTS}" ]; then
echo "unable to find entitlement at: ${ENTITLEMENTS}"
exit 4
fi
#
# keychain
#
if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
security create-keychain -p "${KEYC_PASS}" "${KEYCHAIN}"
security default-keychain -s "${KEYCHAIN}"
security unlock-keychain -p "${KEYC_PASS}" "${KEYCHAIN}"
echo "import cert to keychain"
security import "${CERTIFICATE_P12}" -k "${KEYCHAIN}" -P "${CERT_PASS}" -T /usr/bin/codesign || exit 3
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "${KEYC_PASS}" "${KEYCHAIN}"
else
echo "not running on travis and/or osx. skipping 'keychain' part"
fi
#
# extended attributes
#
# TODO: check if this is any effective
echo "recursively remove quarantine attribute"
xattr -r -d com.apple.quarantine "${APP_PATH}"
#
# bundle id
#
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier ${BUNDLE_ID}" "${APP_PATH}/Contents/Info.plist"
#
# signing
#
codesign --verbose --force --sign "${APP_IDENTITY}" --timestamp --entitlements "${ENTITLEMENTS}" --deep "${APP_PATH}"
codesign --verbose --verify --strict --deep "${APP_PATH}"
#
# check
#
# should result in 'satisfies its Designated Requirement' at least
spctl --assess --type execute "${APP_PATH}" || true
spctl --assess --verbose=4 "${APP_PATH}" || true
exit 0