3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 # Using codesign, sign the contents of the versioned directory. Namely, this
8 # includes the framework and helper app. After signing, the signatures are
13 # Environment sanitization. Set a known-safe PATH. Clear environment variables
14 # that might impact the interpreter's operation. The |bash -p| invocation
15 # on the #! line takes the bite out of BASH_ENV, ENV, and SHELLOPTS (among
16 # other features), but clearing them here ensures that they won't impact any
17 # shell scripts used as utility programs. SHELLOPTS is read-only and can't be
18 # unset, only unexported.
19 export PATH
="/usr/bin:/bin:/usr/sbin:/sbin"
20 unset BASH_ENV CDPATH ENV GLOBIGNORE IFS POSIXLY_CORRECT
23 ME
="$(basename "${0}")"
26 if [[ ${#} -ne 3 ]]; then
27 echo "usage: ${ME} app_path codesign_keychain codesign_id" >& 2
32 codesign_keychain
="${2}"
35 versioned_dir
="${app_path}/Contents/Versions/@VERSION@"
37 # An .app bundle to be signed can be signed directly. Normally, signing a
38 # framework bundle requires that each version within be signed individually.
39 # http://developer.apple.com/mac/library/technotes/tn2007/tn2206.html#TNTAG13
40 # In Chrome's case, the framework bundle is unversioned, so it too can be
41 # signed directly. See copy_framework_unversioned.sh.
43 framework
="${versioned_dir}/@MAC_PRODUCT_NAME@ Framework.framework"
44 crashpad_handler
="${framework}/Helpers/crashpad_handler"
45 helper_app
="${versioned_dir}/@MAC_PRODUCT_NAME@ Helper.app"
48 and certificate leaf = H\"85cee8254216185620ddc8851c7a9fc4dfe120ef\"\
51 codesign
--sign "${codesign_id}" --keychain "${codesign_keychain}" \
52 "${crashpad_handler}" \
53 -r="designated => identifier \"crashpad_handler\" \
54 ${requirement_suffix}"
55 codesign
--sign "${codesign_id}" --keychain "${codesign_keychain}" \
57 -r="designated => identifier \"com.google.Chrome.framework\" \
58 ${requirement_suffix}"
59 codesign
--sign "${codesign_id}" --keychain "${codesign_keychain}" \
61 -r="designated => identifier \"com.google.Chrome.helper\" \
62 ${requirement_suffix}"
64 # Verify everything. Don't use --deep on the framework because Keystone's
65 # signature is in a transitional state (radar 18474911).
66 codesign
--verify --deep "${crashpad_handler}"
67 codesign
--verify "${framework}"
68 codesign
--verify --deep "${helper_app}"