| OLD | NEW |
| 1 #!/bin/bash -p | 1 #!/bin/bash -p |
| 2 | 2 |
| 3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 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 old_dmg new_dmg patch_dmg | 7 # usage: dmgdiffer.sh 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 # |
| 14 # This script operates by mounting old_dmg and new_dmg, creating a new | 14 # This script operates by mounting old_dmg and new_dmg, creating a new |
| 15 # filesystem structure containing dirpatches generated by dirdiffer and | 15 # filesystem structure containing dirpatches generated by dirdiffer and |
| 16 # goobsdiff (which should be located in the same directory as this script), | 16 # goobsdiff (which should be located in the same directory as this script), |
| 17 # and producing a disk image from that structure. | 17 # and producing a disk image from that structure. |
| 18 # | 18 # |
| 19 # The Chrome make_patch_fs function produces an disk image that is able to | 19 # The Chrome make_patch_fs function produces an disk image that is able to |
| 20 # update a single old version on any Keystone channel to a new version on a | 20 # update a single old version on any Keystone channel to a new version on a |
| 21 # specific Keystone channel (the Keystone channel associated with new_dmg). | 21 # specific Keystone channel (the Keystone channel associated with new_dmg). |
| 22 # Chrome's updates are split into two dirpatches: one updates the old | 22 # Chrome's updates are split into two dirpatches: one updates the old |
| 23 # versioned directory to the new one, and the other updates the remainder of | 23 # versioned directory to the new one, and the other updates the remainder of |
| 24 # the application. The versioned directory is split out from the rest because | 24 # the application. The versioned directory is split out from the rest because |
| 25 # it contains the bulk of the application and its name changes from version to | 25 # it contains the bulk of the application and its name changes from version to |
| 26 # version, and dirdiffer/dirpatcher do not directly handle name changes. This | 26 # version, and dirdiffer/dirpatcher do not directly handle name changes. This |
| 27 # approach also allows the versioned directory dirpatch to be applied in-place | 27 # approach also allows the versioned directory dirpatch to be applied in-place |
| 28 # in most cases during an update, rather than relying on a temporary | 28 # in most cases during an update, rather than relying on a temporary |
| 29 # directory. In order to allow a single update dmg to apply to an old version | 29 # directory. In order to allow a single update dmg to apply to an old version |
| 30 # on any Keystone channel, several small files are never distributed as diffs, | 30 # on any Keystone channel, several small files are never distributed as diffs, |
| 31 # and only as full (possibly compressed) versions of the new files. These | 31 # and only as full (possibly compressed) versions of the new files. These |
| 32 # files include the outer application's Info.plist which contains Keystone | 32 # files include the outer application's Info.plist which contains Keystone |
| 33 # channel information, and anything created or modified by code-signinig the | 33 # channel information, and anything created or modified by code-signing the |
| 34 # outer application. | 34 # outer application. |
| 35 # | 35 # |
| 36 # Application of update disk images produced by this script is | 36 # Application of update disk images produced by this script is |
| 37 # product-specific. With updates managed by Keystone, the update disk images | 37 # product-specific. With updates managed by Keystone, the update disk images |
| 38 # can contain a .keystone_install script that is able to locate and update | 38 # can contain a .keystone_install script that is able to locate and update |
| 39 # the installed product. | 39 # the installed product. |
| 40 # | 40 # |
| 41 # Exit codes: | 41 # Exit codes: |
| 42 # 0 OK | 42 # 0 OK |
| 43 # 1 Unknown failure | 43 # 1 Unknown failure |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } | 122 } |
| 123 | 123 |
| 124 # make_patch_fs is responsible for comparing the old and new disk images | 124 # make_patch_fs is responsible for comparing the old and new disk images |
| 125 # mounted at old_fs and new_fs, respectively, and populating patch_fs with the | 125 # mounted at old_fs and new_fs, respectively, and populating patch_fs with the |
| 126 # contents of what will become a disk image able to update old_fs to new_fs. | 126 # contents of what will become a disk image able to update old_fs to new_fs. |
| 127 # It then outputs a string which will be used as the volume name of the | 127 # It then outputs a string which will be used as the volume name of the |
| 128 # patch_dmg. | 128 # patch_dmg. |
| 129 # | 129 # |
| 130 # The entire patch contents are placed into a .patch directory to hide them | 130 # The entire patch contents are placed into a .patch directory to hide them |
| 131 # from ordinary view. The disk image will be given a volume name like | 131 # from ordinary view. The disk image will be given a volume name like |
| 132 # "Google Chrome 5.0.375.55-5.0.375.70" as an identifying aide, although | 132 # "Google Chrome 5.0.375.55-5.0.375.70" as an identifying aid, although |
| 133 # uniqueness is not important and users will never interact directly with | 133 # uniqueness is not important and users will never interact directly with |
| 134 # them. | 134 # them. |
| 135 make_patch_fs() { | 135 make_patch_fs() { |
| 136 local old_fs="${1}" | 136 local old_fs="${1}" |
| 137 local new_fs="${2}" | 137 local new_fs="${2}" |
| 138 local patch_fs="${3}" | 138 local patch_fs="${3}" |
| 139 | 139 |
| 140 readonly PRODUCT_NAME="Google Chrome" | 140 readonly PRODUCT_NAME="Google Chrome" |
| 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" |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 unset g_cleanup_mount_points[${#g_cleanup_mount_points[@]}] | 386 unset g_cleanup_mount_points[${#g_cleanup_mount_points[@]}] |
| 387 | 387 |
| 388 package_patch_dmg "${patch_fs}" "${patch_dmg}" "${volume_name}" "${temp_dir}" | 388 package_patch_dmg "${patch_fs}" "${patch_dmg}" "${volume_name}" "${temp_dir}" |
| 389 | 389 |
| 390 rm -rf "${temp_dir}" | 390 rm -rf "${temp_dir}" |
| 391 unset g_cleanup[${#g_cleanup[@]}] | 391 unset g_cleanup[${#g_cleanup[@]}] |
| 392 } | 392 } |
| 393 | 393 |
| 394 # shell_safe_path ensures that |path| is safe to pass to tools as a | 394 # shell_safe_path ensures that |path| is safe to pass to tools as a |
| 395 # command-line argument. If the first character in |path| is "-", "./" is | 395 # command-line argument. If the first character in |path| is "-", "./" is |
| 396 # prepended to it. The possibily-modified |path| is output. | 396 # prepended to it. The possibly-modified |path| is output. |
| 397 shell_safe_path() { | 397 shell_safe_path() { |
| 398 local path="${1}" | 398 local path="${1}" |
| 399 if [[ "${path:0:1}" = "-" ]]; then | 399 if [[ "${path:0:1}" = "-" ]]; then |
| 400 echo "./${path}" | 400 echo "./${path}" |
| 401 else | 401 else |
| 402 echo "${path}" | 402 echo "${path}" |
| 403 fi | 403 fi |
| 404 } | 404 } |
| 405 | 405 |
| 406 usage() { | 406 usage() { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 trap - EXIT | 440 trap - EXIT |
| 441 } | 441 } |
| 442 | 442 |
| 443 if [[ ${#} -ne 3 ]]; then | 443 if [[ ${#} -ne 3 ]]; then |
| 444 usage | 444 usage |
| 445 exit 2 | 445 exit 2 |
| 446 fi | 446 fi |
| 447 | 447 |
| 448 main "${@}" | 448 main "${@}" |
| 449 exit ${?} | 449 exit ${?} |
| OLD | NEW |