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 Iceberg be |
9 # installed (for 'freeze'). | 9 # installed (for 'freeze'). |
10 # | 10 # |
11 # usage: sign_and_build.sh output_dir input_dir codesign_keychain codesign_id | 11 # usage: sign_and_build.sh output_dir input_dir codesign_keychain codesign_id |
12 # | 12 # |
13 # The final disk image (dmg) is placed in |output_dir|. | 13 # The final disk image (dmg) is placed in |output_dir|. |
14 | 14 |
15 set -e -u | 15 set -e -u |
16 | 16 |
17 # Binaries to sign. | 17 # Binaries to sign. |
18 ME2ME_HOST=PrivilegedHelperTools/org.chromium.chromoting.me2me_host | 18 ME2ME_HOST='PrivilegedHelperTools/org.chromium.chromoting.me2me_host' |
| 19 UNINSTALLER='Applications/@@HOST_UNINSTALLER_NAME@@.app' |
19 | 20 |
20 # Iceberg creates this directory to write its output. | 21 # Iceberg creates this directory to write its output. |
21 PKG_DIR=build | 22 PKG_DIR=build |
22 | 23 |
23 # The Chromoting Host installer is a meta-package that consists of 3 | 24 # The Chromoting Host installer is a meta-package that consists of 3 |
24 # components: | 25 # components: |
25 # * Chromoting Host Service package | 26 # * Chromoting Host Service package |
26 # * Chromoting Host Uninstaller package | 27 # * Chromoting Host Uninstaller package |
27 # * Keystone package(GoogleSoftwareUpdate - for Official builds only) | 28 # * Keystone package(GoogleSoftwareUpdate - for Official builds only) |
28 PKGPROJ_HOST='ChromotingHost.packproj' | 29 PKGPROJ_HOST='ChromotingHost.packproj' |
29 PKGPROJ_HOST_SERVICE='ChromotingHostService.packproj' | 30 PKGPROJ_HOST_SERVICE='ChromotingHostService.packproj' |
30 PKGPROJ_HOST_UNINSTALLER='ChromotingHostUninstaller.packproj' | 31 PKGPROJ_HOST_UNINSTALLER='ChromotingHostUninstaller.packproj' |
31 | 32 |
32 # Final mpkg name (for Official builds). | 33 # Final (user-visible) mpkg name. |
33 PKG_FINAL='ChromeRemoteDesktopHost.mpkg' | 34 PKG_FINAL='@@HOST_PKG@@.mpkg' |
34 | 35 |
35 DMG_TEMP=dmg_tmp | 36 DMG_TEMP=dmg_tmp |
36 DMG_NAME='Chrome Remote Desktop' | 37 DMG_NAME='@@DMG_NAME@@' |
37 DMG_DIR="${DMG_TEMP}/${DMG_NAME}" | 38 DMG_DIR="${DMG_TEMP}/${DMG_NAME}" |
38 DMG_FILENAME='Chrome Remote Desktop.dmg' | 39 DMG_FILENAME='@@DMG_NAME@@.dmg' |
39 | 40 |
40 ME="$(basename "${0}")" | 41 ME="$(basename "${0}")" |
41 readonly ME | 42 readonly ME |
42 | 43 |
43 err() { | 44 err() { |
44 echo "[$(date +'%Y-%m-%d %H:%M:%S%z')]: ${@}" >&2 | 45 echo "[$(date +'%Y-%m-%d %H:%M:%S%z')]: ${@}" >&2 |
45 } | 46 } |
46 | 47 |
47 err_exit() { | 48 err_exit() { |
48 err "${@}" | 49 err "${@}" |
(...skipping 16 matching lines...) Expand all Loading... |
65 local dir="${1}" | 66 local dir="${1}" |
66 if [[ ! -d "${dir}" ]]; then | 67 if [[ ! -d "${dir}" ]]; then |
67 mkdir "${dir}" | 68 mkdir "${dir}" |
68 fi | 69 fi |
69 | 70 |
70 shopt -s nullglob dotglob | 71 shopt -s nullglob dotglob |
71 local dir_contents=("${dir}"/*) | 72 local dir_contents=("${dir}"/*) |
72 shopt -u nullglob dotglob | 73 shopt -u nullglob dotglob |
73 | 74 |
74 if [[ ${#dir_contents[@]} -ne 0 ]]; then | 75 if [[ ${#dir_contents[@]} -ne 0 ]]; then |
75 err "output directory must be empty" | 76 err "Output directory must be empty" |
76 exit 1 | 77 exit 1 |
77 fi | 78 fi |
78 } | 79 } |
79 | 80 |
| 81 sign() { |
| 82 local name="${1}" |
| 83 local keychain="${2}" |
| 84 local id="${3}" |
| 85 |
| 86 if [[ ! -e "${name}" ]]; then |
| 87 err_exit "Input file doesn't exist: ${name}" |
| 88 fi |
| 89 |
| 90 echo Signing "${name}" |
| 91 codesign -vv -s "${id}" --keychain "${keychain}" "${name}" |
| 92 codesign -v "${name}" |
| 93 } |
| 94 |
80 sign_binaries() { | 95 sign_binaries() { |
81 local input_dir="${1}" | 96 local input_dir="${1}" |
82 local keychain="${2}" | 97 local keychain="${2}" |
83 local id="${3}" | 98 local id="${3}" |
84 | 99 |
85 me2me_host="${input_dir}/${ME2ME_HOST}" | 100 sign "${input_dir}/${ME2ME_HOST}" "${keychain}" "${id}" |
86 if [[ ! -f "${me2me_host}" ]]; then | 101 sign "${input_dir}/${UNINSTALLER}" "${keychain}" "${id}" |
87 err_exit "Input file doesn't exist: ${me2me_host}" | |
88 fi | |
89 | |
90 echo Signing "${me2me_host}" | |
91 codesign -vv -s "${id}" --keychain "${keychain}" "${me2me_host}" | |
92 | |
93 # Verify signing. | |
94 codesign -v "${me2me_host}" | |
95 } | 102 } |
96 | 103 |
97 build_package() { | 104 build_package() { |
98 local pkg="${1}" | 105 local pkg="${1}" |
99 echo "Building .pkg from ${pkg}" | 106 echo "Building .pkg from ${pkg}" |
100 freeze "${pkg}" | 107 freeze "${pkg}" |
101 } | 108 } |
102 | 109 |
103 build_packages() { | 110 build_packages() { |
104 local input_dir="${1}" | 111 local input_dir="${1}" |
105 build_package "${input_dir}/${PKGPROJ_HOST_SERVICE}" | 112 build_package "${input_dir}/${PKGPROJ_HOST_SERVICE}" |
106 build_package "${input_dir}/${PKGPROJ_HOST_UNINSTALLER}" | 113 build_package "${input_dir}/${PKGPROJ_HOST_UNINSTALLER}" |
107 build_package "${input_dir}/${PKGPROJ_HOST}" | 114 build_package "${input_dir}/${PKGPROJ_HOST}" |
108 } | 115 } |
109 | 116 |
110 build_dmg() { | 117 build_dmg() { |
111 local input_dir="${1}" | 118 local input_dir="${1}" |
112 local output_dir="${2}" | 119 local output_dir="${2}" |
113 | 120 |
114 # TODO(garykac): Change this to use the pkg-dmg script. | 121 # TODO(garykac): Change this to use the pkg-dmg script. |
115 | 122 |
116 # Create the .dmg. | 123 # Create the .dmg. |
117 echo "Building .dmg..." | 124 echo "Building .dmg..." |
118 mkdir -p "${input_dir}/${DMG_DIR}/${PKG_FINAL}" | 125 mkdir -p "${input_dir}/${DMG_DIR}/${PKG_FINAL}" |
119 # Copy .mpkg installer. | 126 # Copy .mpkg installer. |
| 127 echo "Copying ${input_dir}/${PKG_DIR}/${PKG_FINAL}" |
120 ditto "${input_dir}/${PKG_DIR}/${PKG_FINAL}" \ | 128 ditto "${input_dir}/${PKG_DIR}/${PKG_FINAL}" \ |
121 "${input_dir}/${DMG_DIR}/${PKG_FINAL}" | 129 "${input_dir}/${DMG_DIR}/${PKG_FINAL}" |
122 # Copy .keystone_install script to top level of .dmg. | 130 # Copy .keystone_install script to top level of .dmg. |
123 # Keystone calls this script during upgrades. | 131 # Keystone calls this script during upgrades. |
124 cp "${input_dir}/Scripts/keystone_install.sh" \ | 132 cp "${input_dir}/Scripts/keystone_install.sh" \ |
125 "${input_dir}/${DMG_DIR}/.keystone_install" | 133 "${input_dir}/${DMG_DIR}/.keystone_install" |
126 # Build the .dmg from the directory. | 134 # Build the .dmg from the directory. |
127 hdiutil create "${output_dir}/${DMG_FILENAME}" \ | 135 hdiutil create "${output_dir}/${DMG_FILENAME}" \ |
128 -srcfolder "${input_dir}/${DMG_DIR}" -ov -quiet | 136 -srcfolder "${input_dir}/${DMG_DIR}" -ov -quiet |
129 | 137 |
(...skipping 20 matching lines...) Expand all Loading... |
150 build_dmg "${input_dir}" "${output_dir}" | 158 build_dmg "${input_dir}" "${output_dir}" |
151 } | 159 } |
152 | 160 |
153 if [[ ${#} -ne 4 ]]; then | 161 if [[ ${#} -ne 4 ]]; then |
154 usage | 162 usage |
155 exit 1 | 163 exit 1 |
156 fi | 164 fi |
157 | 165 |
158 main "${@}" | 166 main "${@}" |
159 exit ${?} | 167 exit ${?} |
OLD | NEW |