OLD | NEW |
1 #!/bin/sh | 1 #!/bin/sh |
2 | 2 |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # This script signs the Chromoting binaries, builds the Chrome Remote Desktop | 7 # This script signs the Chromoting binaries, builds the Chrome Remote Desktop |
8 # installer and then packages it into a .dmg. It requires that Iceberg be | 8 # installer and then packages it into a .dmg. It requires that Packages be |
9 # installed (for 'freeze'). | 9 # installed (for 'packagesbuild'). |
| 10 # Packages: http://s.sudre.free.fr/Software/Packages/about.html |
10 # | 11 # |
11 # usage: sign_and_build.sh output_dir input_dir codesign_keychain codesign_id | 12 # usage: sign_and_build.sh output_dir input_dir codesign_keychain codesign_id |
12 # | 13 # |
13 # The final disk image (dmg) is placed in |output_dir|. | 14 # The final disk image (dmg) is placed in |output_dir|. |
14 | 15 |
15 set -e -u | 16 set -e -u |
16 | 17 |
17 ME="$(basename "${0}")" | 18 ME="$(basename "${0}")" |
18 readonly ME | 19 readonly ME |
19 | 20 |
20 # Choose which installer package to use: | 21 # Choose which installer package to use: |
21 # 'true' to use Iceberg, 'false' to use Packages. | 22 # 'true' to use Iceberg, 'false' to use Packages. |
22 # TODO(garykac) Switch completely to Packages so we can sign for 10.8. | 23 # TODO(garykac) Switch completely to Packages so we can sign for 10.8. |
23 # (crbug.com/127267) | 24 # (crbug.com/127267) |
24 USE_ICEBERG=false | 25 USE_ICEBERG=false |
25 | 26 |
26 declare -a g_cleanup_dirs | 27 declare -a g_cleanup_dirs |
27 | 28 |
28 # Binaries to sign. | 29 setup() { |
29 ME2ME_HOST='PrivilegedHelperTools/org.chromium.chromoting.me2me_host.app' | 30 local input_dir="${1}" |
30 UNINSTALLER='Applications/@@HOST_UNINSTALLER_NAME@@.app' | |
31 PREFPANE='PreferencePanes/org.chromium.chromoting.prefPane' | |
32 | 31 |
33 # The Chromoting Host installer is a meta-package that consists of 3 | 32 # The file that contains the properties for this signing build. |
34 # components: | 33 # The file should contain only key=value pairs, one per line. |
35 # * Chromoting Host Service package | 34 PROPS_FILENAME="${input_dir}/do_signing.props" |
36 # * Chromoting Host Uninstaller package | |
37 # * Keystone package (GoogleSoftwareUpdate - for Official builds only) | |
38 if $USE_ICEBERG ; then | |
39 PKGPROJ_HOST='ChromotingHost.packproj' | |
40 PKGPROJ_HOST_SERVICE='ChromotingHostService.packproj' | |
41 PKGPROJ_HOST_UNINSTALLER='ChromotingHostUninstaller.packproj' | |
42 | 35 |
43 # Final (user-visible) mpkg name. | 36 # Individually load the properties for this build. Don't 'source' the file |
44 PKG_FINAL='@@HOST_PKG@@.mpkg' | 37 # to guard against code accidentally being added to the props file. |
45 else | 38 HOST_UNINSTALLER_NAME=$(read_property "HOST_UNINSTALLER_NAME") |
46 PKGPROJ_HOST='ChromotingHost.pkgproj' | 39 HOST_PKG=$(read_property "HOST_PKG") |
47 PKGPROJ_HOST_SERVICE='ChromotingHostService.pkgproj' | 40 DMG_VOLUME_NAME=$(read_property "DMG_VOLUME_NAME") |
48 PKGPROJ_HOST_UNINSTALLER='ChromotingHostUninstaller.pkgproj' | 41 DMG_FILE_NAME=$(read_property "DMG_FILE_NAME") |
49 | 42 |
50 # Final (user-visible) pkg name. | 43 # Binaries to sign. |
51 PKG_FINAL='@@HOST_PKG@@.pkg' | 44 ME2ME_HOST='PrivilegedHelperTools/org.chromium.chromoting.me2me_host.app' |
52 fi | 45 UNINSTALLER="Applications/${HOST_UNINSTALLER_NAME}.app" |
| 46 PREFPANE='PreferencePanes/org.chromium.chromoting.prefPane' |
53 | 47 |
54 DMG_VOLUME_NAME='@@DMG_VOLUME_NAME@@' | 48 # The Chromoting Host installer is a meta-package that consists of 3 |
55 DMG_FILE_NAME='@@DMG_FILE_NAME@@.dmg' | 49 # components: |
| 50 # * Chromoting Host Service package |
| 51 # * Chromoting Host Uninstaller package |
| 52 # * Keystone package (GoogleSoftwareUpdate - for Official builds only) |
| 53 if $USE_ICEBERG ; then |
| 54 PKGPROJ_HOST='ChromotingHost.packproj' |
| 55 PKGPROJ_HOST_SERVICE='ChromotingHostService.packproj' |
| 56 PKGPROJ_HOST_UNINSTALLER='ChromotingHostUninstaller.packproj' |
56 | 57 |
57 # Temp directory for Iceberg output. | 58 # Final (user-visible) mpkg name. |
58 PKG_DIR=build | 59 PKG_FINAL="${HOST_PKG}.mpkg" |
59 g_cleanup_dirs+=("${PKG_DIR}") | 60 else |
| 61 PKGPROJ_HOST='ChromotingHost.pkgproj' |
| 62 PKGPROJ_HOST_SERVICE='ChromotingHostService.pkgproj' |
| 63 PKGPROJ_HOST_UNINSTALLER='ChromotingHostUninstaller.pkgproj' |
60 | 64 |
61 # Temp directories for building the dmg. | 65 # Final (user-visible) pkg name. |
62 DMG_TEMP_DIR="$(mktemp -d -t "${ME}"-dmg)" | 66 PKG_FINAL="${HOST_PKG}.pkg" |
63 g_cleanup_dirs+=("${DMG_TEMP_DIR}") | 67 fi |
64 | 68 |
65 DMG_EMPTY_DIR="$(mktemp -d -t "${ME}"-empty)" | 69 DMG_FILE_NAME="${DMG_FILE_NAME}.dmg" |
66 g_cleanup_dirs+=("${DMG_EMPTY_DIR}") | 70 |
| 71 # Temp directory for Packages output. |
| 72 PKG_DIR=build |
| 73 g_cleanup_dirs+=("${PKG_DIR}") |
| 74 |
| 75 # Temp directories for building the dmg. |
| 76 DMG_TEMP_DIR="$(mktemp -d -t "${ME}"-dmg)" |
| 77 g_cleanup_dirs+=("${DMG_TEMP_DIR}") |
| 78 |
| 79 DMG_EMPTY_DIR="$(mktemp -d -t "${ME}"-empty)" |
| 80 g_cleanup_dirs+=("${DMG_EMPTY_DIR}") |
| 81 } |
67 | 82 |
68 err() { | 83 err() { |
69 echo "[$(date +'%Y-%m-%d %H:%M:%S%z')]: ${@}" >&2 | 84 echo "[$(date +'%Y-%m-%d %H:%M:%S%z')]: ${@}" >&2 |
70 } | 85 } |
71 | 86 |
72 err_exit() { | 87 err_exit() { |
73 err "${@}" | 88 err "${@}" |
74 exit 1 | 89 exit 1 |
75 } | 90 } |
76 | 91 |
77 # shell_safe_path ensures that |path| is safe to pass to tools as a | 92 # shell_safe_path ensures that |path| is safe to pass to tools as a |
78 # command-line argument. If the first character in |path| is "-", "./" is | 93 # command-line argument. If the first character in |path| is "-", "./" is |
79 # prepended to it. The possibly-modified |path| is output. | 94 # prepended to it. The possibly-modified |path| is output. |
80 shell_safe_path() { | 95 shell_safe_path() { |
81 local path="${1}" | 96 local path="${1}" |
82 if [[ "${path:0:1}" = "-" ]]; then | 97 if [[ "${path:0:1}" = "-" ]]; then |
83 echo "./${path}" | 98 echo "./${path}" |
84 else | 99 else |
85 echo "${path}" | 100 echo "${path}" |
86 fi | 101 fi |
87 } | 102 } |
88 | 103 |
| 104 # Read a single property from the properties file. |
| 105 read_property() { |
| 106 local property="${1}" |
| 107 local filename="${PROPS_FILENAME}" |
| 108 echo `grep "${property}" "${filename}" | tail -n 1 | cut -d "=" -f2-` |
| 109 } |
| 110 |
89 verify_clean_dir() { | 111 verify_clean_dir() { |
90 local dir="${1}" | 112 local dir="${1}" |
91 if [[ ! -d "${dir}" ]]; then | 113 if [[ ! -d "${dir}" ]]; then |
92 mkdir "${dir}" | 114 mkdir "${dir}" |
93 fi | 115 fi |
94 | 116 |
95 if [[ -e "${output_dir}/${DMG_FILE_NAME}" ]]; then | 117 if [[ -e "${output_dir}/${DMG_FILE_NAME}" ]]; then |
96 err "Output directory is dirty from previous build." | 118 err "Output directory is dirty from previous build." |
97 exit 1 | 119 exit 1 |
98 fi | 120 fi |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 main() { | 206 main() { |
185 local output_dir="$(shell_safe_path "${1}")" | 207 local output_dir="$(shell_safe_path "${1}")" |
186 local input_dir="$(shell_safe_path "${2}")" | 208 local input_dir="$(shell_safe_path "${2}")" |
187 local keychain="$(shell_safe_path "${3}")" | 209 local keychain="$(shell_safe_path "${3}")" |
188 local codesign_id="${4}" | 210 local codesign_id="${4}" |
189 local productsign_id="" | 211 local productsign_id="" |
190 if [[ ${#} -ge 5 ]]; then | 212 if [[ ${#} -ge 5 ]]; then |
191 productsign_id="${5}" | 213 productsign_id="${5}" |
192 fi | 214 fi |
193 | 215 |
| 216 setup "${input_dir}" |
194 verify_clean_dir "${output_dir}" | 217 verify_clean_dir "${output_dir}" |
195 | 218 |
196 sign_binaries "${input_dir}" "${keychain}" "${codesign_id}" | 219 sign_binaries "${input_dir}" "${keychain}" "${codesign_id}" |
197 build_packages "${input_dir}" | 220 build_packages "${input_dir}" |
198 if [[ -n "${productsign_id}" ]]; then | 221 if [[ -n "${productsign_id}" ]]; then |
199 echo "Signing installer..." | 222 echo "Signing installer..." |
200 sign_installer "${input_dir}" "${keychain}" "${productsign_id}" | 223 sign_installer "${input_dir}" "${keychain}" "${productsign_id}" |
201 fi | 224 fi |
202 build_dmg "${input_dir}" "${output_dir}" | 225 build_dmg "${input_dir}" "${output_dir}" |
203 | 226 |
204 cleanup | 227 cleanup |
205 } | 228 } |
206 | 229 |
207 if [[ ${#} < 4 ]]; then | 230 if [[ ${#} < 4 ]]; then |
208 usage | 231 usage |
209 exit 1 | 232 exit 1 |
210 fi | 233 fi |
211 | 234 |
212 main "${@}" | 235 main "${@}" |
213 exit ${?} | 236 exit ${?} |
OLD | NEW |