OLD | NEW |
1 #!/bin/bash -p | 1 #!/bin/bash -p |
2 | 2 |
3 # Copyright (c) 2011 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 # usage: dmgdiffer.sh product_name old_dmg new_dmg patch_dmg | 7 # usage: dmgdiffer.sh product_name old_dmg new_dmg patch_dmg |
8 # | 8 # |
9 # dmgdiffer creates a disk image containing a binary update able to patch | 9 # dmgdiffer creates a disk image containing a binary update able to patch |
10 # a product originally distributed in old_dmg to the version in new_dmg. Much | 10 # a product originally distributed in old_dmg to the version in new_dmg. Much |
11 # of this script is generic, but the make_patch_fs function is specific to | 11 # of this script is generic, but the make_patch_fs function is specific to |
12 # a product: in this case, Google Chrome. | 12 # a product: in this case, Google Chrome. |
13 # | 13 # |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 make_patch_fs() { | 135 make_patch_fs() { |
136 local product_name="${1}" | 136 local product_name="${1}" |
137 local old_fs="${2}" | 137 local old_fs="${2}" |
138 local new_fs="${3}" | 138 local new_fs="${3}" |
139 local patch_fs="${4}" | 139 local patch_fs="${4}" |
140 | 140 |
141 readonly APP_NAME="${product_name}.app" | 141 readonly APP_NAME="${product_name}.app" |
142 readonly APP_NAME_RE="${product_name}\\.app" | 142 readonly APP_NAME_RE="${product_name}\\.app" |
143 readonly APP_PLIST="Contents/Info" | 143 readonly APP_PLIST="Contents/Info" |
144 readonly APP_VERSION_KEY="CFBundleShortVersionString" | 144 readonly APP_VERSION_KEY="CFBundleShortVersionString" |
| 145 readonly APP_BUNDLEID_KEY="CFBundleIdentifier" |
145 readonly KS_VERSION_KEY="KSVersion" | 146 readonly KS_VERSION_KEY="KSVersion" |
146 readonly KS_PRODUCT_KEY="KSProductID" | 147 readonly KS_PRODUCT_KEY="KSProductID" |
147 readonly KS_CHANNEL_KEY="KSChannelID" | 148 readonly KS_CHANNEL_KEY="KSChannelID" |
148 readonly VERSIONS_DIR="Contents/Versions" | 149 readonly VERSIONS_DIR="Contents/Versions" |
149 readonly BUILD_RE="^[0-9]+\\.[0-9]+\\.([0-9]+)\\.[0-9]+\$" | 150 readonly BUILD_RE="^[0-9]+\\.[0-9]+\\.([0-9]+)\\.[0-9]+\$" |
150 readonly MIN_BUILD=434 | 151 readonly MIN_BUILD=434 |
151 | 152 |
152 local product_url="http://www.google.com/chrome/" | 153 local product_url="http://www.google.com/chrome/" |
153 if [[ "${product_name}" = "Google Chrome Canary" ]]; then | 154 if [[ "${product_name}" = "Google Chrome Canary" ]]; then |
154 product_url="http://tools.google.com/dlpage/chromesxs" | 155 product_url="http://tools.google.com/dlpage/chromesxs" |
155 fi | 156 fi |
156 | 157 |
157 local old_app_path="${old_fs}/${APP_NAME}" | 158 local old_app_path="${old_fs}/${APP_NAME}" |
158 local old_app_plist="${old_app_path}/${APP_PLIST}" | 159 local old_app_plist="${old_app_path}/${APP_PLIST}" |
159 local old_app_version | 160 local old_app_version |
160 if ! old_app_version="$(defaults read "${old_app_plist}" \ | 161 if ! old_app_version="$(defaults read "${old_app_plist}" \ |
161 "${APP_VERSION_KEY}")"; then | 162 "${APP_VERSION_KEY}")"; then |
162 err "could not read old app version" | 163 err "could not read old app version" |
163 exit 10 | 164 exit 10 |
164 fi | 165 fi |
165 if ! [[ "${old_app_version}" =~ ${BUILD_RE} ]]; then | 166 if ! [[ "${old_app_version}" =~ ${BUILD_RE} ]]; then |
166 err "old app version not of expected format" | 167 err "old app version not of expected format" |
167 exit 10 | 168 exit 10 |
168 fi | 169 fi |
169 local old_app_version_build="${BASH_REMATCH[1]}" | 170 local old_app_version_build="${BASH_REMATCH[1]}" |
170 | 171 |
| 172 local old_app_bundleid |
| 173 if ! old_app_bundleid="$(defaults read "${old_app_plist}" \ |
| 174 "${APP_BUNDLEID_KEY}")"; then |
| 175 err "could not read old app bundle ID" |
| 176 exit 10 |
| 177 fi |
| 178 |
171 local old_ks_plist="${old_app_plist}" | 179 local old_ks_plist="${old_app_plist}" |
172 local old_ks_version | 180 local old_ks_version |
173 if ! old_ks_version="$(defaults read "${old_ks_plist}" \ | 181 if ! old_ks_version="$(defaults read "${old_ks_plist}" \ |
174 "${KS_VERSION_KEY}")"; then | 182 "${KS_VERSION_KEY}")"; then |
175 err "could not read old Keystone version" | 183 err "could not read old Keystone version" |
176 exit 10 | 184 exit 10 |
177 fi | 185 fi |
178 | 186 |
179 local new_app_path="${new_fs}/${APP_NAME}" | 187 local new_app_path="${new_fs}/${APP_NAME}" |
180 local new_app_plist="${new_app_path}/${APP_PLIST}" | 188 local new_app_plist="${new_app_path}/${APP_PLIST}" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 236 |
229 local old_versioned_dir="${old_app_path}/${VERSIONS_DIR}/${old_app_version}" | 237 local old_versioned_dir="${old_app_path}/${VERSIONS_DIR}/${old_app_version}" |
230 local new_versioned_dir="${new_app_path}/${VERSIONS_DIR}/${new_app_version}" | 238 local new_versioned_dir="${new_app_path}/${VERSIONS_DIR}/${new_app_version}" |
231 | 239 |
232 if ! cp -p "${SCRIPT_DIR}/keystone_install.sh" \ | 240 if ! cp -p "${SCRIPT_DIR}/keystone_install.sh" \ |
233 "${patch_fs}/.keystone_install"; then | 241 "${patch_fs}/.keystone_install"; then |
234 err "could not copy .keystone_install" | 242 err "could not copy .keystone_install" |
235 exit 13 | 243 exit 13 |
236 fi | 244 fi |
237 | 245 |
| 246 local patch_keychain_reauthorize_dir="${patch_fs}/.keychain_reauthorize" |
| 247 if ! mkdir "${patch_keychain_reauthorize_dir}"; then |
| 248 err "could not mkdir patch_keychain_reauthorize_dir" |
| 249 exit 13 |
| 250 fi |
| 251 |
| 252 if ! cp -p "${SCRIPT_DIR}/.keychain_reauthorize/${old_app_bundleid}" \ |
| 253 "${patch_keychain_reauthorize_dir}/${old_app_bundleid}"; then |
| 254 err "could not copy keychain_reauthorize" |
| 255 exit 13 |
| 256 fi |
| 257 |
238 local patch_dotpatch_dir="${patch_fs}/.patch" | 258 local patch_dotpatch_dir="${patch_fs}/.patch" |
239 if ! mkdir "${patch_dotpatch_dir}"; then | 259 if ! mkdir "${patch_dotpatch_dir}"; then |
240 err "could not mkdir patch_dotpatch_dir" | 260 err "could not mkdir patch_dotpatch_dir" |
241 exit 13 | 261 exit 13 |
242 fi | 262 fi |
243 | 263 |
244 if ! cp -p "${SCRIPT_DIR}/dirpatcher.sh" \ | 264 if ! cp -p "${SCRIPT_DIR}/dirpatcher.sh" \ |
245 "${SCRIPT_DIR}/goobspatch" \ | 265 "${SCRIPT_DIR}/goobspatch" \ |
246 "${SCRIPT_DIR}/liblzma_decompress.dylib" \ | 266 "${SCRIPT_DIR}/liblzma_decompress.dylib" \ |
247 "${SCRIPT_DIR}/xzdec" \ | 267 "${SCRIPT_DIR}/xzdec" \ |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 trap - EXIT | 470 trap - EXIT |
451 } | 471 } |
452 | 472 |
453 if [[ ${#} -ne 4 ]]; then | 473 if [[ ${#} -ne 4 ]]; then |
454 usage | 474 usage |
455 exit 2 | 475 exit 2 |
456 fi | 476 fi |
457 | 477 |
458 main "${@}" | 478 main "${@}" |
459 exit ${?} | 479 exit ${?} |
OLD | NEW |