Upstream version 9.37.195.0
[platform/framework/web/crosswalk.git] / src / chrome / installer / mac / sign_versioned_dir.sh.in
1 #!/bin/bash -p
2
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.
6
7 # Using codesign, sign the contents of the versioned directory. Namely, this
8 # includes the framework and helper app. After signing, the signatures are
9 # verified.
10
11 set -eu
12
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
21 export -n SHELLOPTS
22
23 ME="$(basename "${0}")"
24 readonly ME
25
26 if [[ ${#} -ne 3 ]]; then
27   echo "usage: ${ME} app_path codesign_keychain codesign_id" >& 2
28   exit 1
29 fi
30
31 app_path="${1}"
32 codesign_keychain="${2}"
33 codesign_id="${3}"
34
35 versioned_dir="${app_path}/Contents/Versions/@VERSION@"
36
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.
42
43 framework="${versioned_dir}/@MAC_PRODUCT_NAME@ Framework.framework"
44 helper_app="${versioned_dir}/@MAC_PRODUCT_NAME@ Helper.app"
45 helper_eh_app="${versioned_dir}/@MAC_PRODUCT_NAME@ Helper EH.app"
46 helper_np_app="${versioned_dir}/@MAC_PRODUCT_NAME@ Helper NP.app"
47
48 # libplugin_carbon_interpose.dylib was removed in r280670, but it's still
49 # present on the 37.0.2062 branch (and earlier). Accounting for it here makes
50 # it easier to merge the fix for http://crbug.com/399276 to other branches.
51 #
52 # TODO(mark): Remove this plugin_carbon_interpose code on the trunk as soon
53 # as it lands.
54 plugin_carbon_interpose="${versioned_dir}/libplugin_carbon_interpose.dylib"
55 if [[ ! -e "${plugin_carbon_interpose}" ]]; then
56   plugin_carbon_interpose=
57 fi
58
59 requirement_suffix="\
60 and certificate leaf = H\"85cee8254216185620ddc8851c7a9fc4dfe120ef\"\
61 "
62
63 codesign -s "${codesign_id}" --keychain "${codesign_keychain}" "${framework}" \
64     -r="designated => identifier \"com.google.Chrome.framework\" \
65 ${requirement_suffix}"
66 codesign -s "${codesign_id}" --keychain "${codesign_keychain}" "${helper_app}" \
67     -r="designated => identifier \"com.google.Chrome.helper\" \
68 ${requirement_suffix}"
69 codesign -s "${codesign_id}" --keychain "${codesign_keychain}" \
70     "${helper_eh_app}" \
71     -r="designated => identifier \"com.google.Chrome.helper.EH\" \
72 ${requirement_suffix}"
73 codesign -s "${codesign_id}" --keychain "${codesign_keychain}" \
74     "${helper_np_app}" \
75     -r="designated => identifier \"com.google.Chrome.helper.NP\" \
76 ${requirement_suffix}"
77
78 if [[ -n "${plugin_carbon_interpose}" ]]; then
79   plugin_carbon_interpose_identifier="com.google.Chrome.plugin_carbon_interpose"
80   codesign -s "${codesign_id}" --keychain "${codesign_keychain}" \
81       "${plugin_carbon_interpose}" \
82       -i "${plugin_carbon_interpose_identifier}" \
83       -r="designated => identifier \"${plugin_carbon_interpose_identifier}\" \
84 ${requirement_suffix}"
85 fi
86
87 # Verify everything.
88 codesign -v "${framework}"
89 codesign -v "${helper_app}"
90 codesign -v "${helper_eh_app}"
91 codesign -v "${helper_np_app}"
92
93 if [[ -n "${plugin_carbon_interpose}" ]]; then
94   codesign -v "${plugin_carbon_interpose}"
95 fi