| OLD | NEW |
| 1 #!/bin/bash -p | 1 #!/bin/bash -p |
| 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 # usage: keystone_install.sh update_dmg_mount_point | 7 # usage: keystone_install.sh update_dmg_mount_point |
| 8 # | 8 # |
| 9 # Called by the Keystone system to update the installed application with a new | 9 # Called by the Keystone system to update the installed application with a new |
| 10 # version from a disk image. | 10 # version from a disk image. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 # 2 Basic sanity check source failure (e.g. no app on disk image) | 22 # 2 Basic sanity check source failure (e.g. no app on disk image) |
| 23 # 3 Basic sanity check destination failure (e.g. ticket points to nothing) | 23 # 3 Basic sanity check destination failure (e.g. ticket points to nothing) |
| 24 # 4 Update driven by user ticket when a system ticket is also present | 24 # 4 Update driven by user ticket when a system ticket is also present |
| 25 # 5 Could not prepare existing installed version to receive update | 25 # 5 Could not prepare existing installed version to receive update |
| 26 # 6 Patch sanity check failure | 26 # 6 Patch sanity check failure |
| 27 # 7 rsync failed (could not copy new versioned directory to Versions) | 27 # 7 rsync failed (could not copy new versioned directory to Versions) |
| 28 # 8 rsync failed (could not update outer .app bundle) | 28 # 8 rsync failed (could not update outer .app bundle) |
| 29 # 9 Could not get the version, update URL, or channel after update | 29 # 9 Could not get the version, update URL, or channel after update |
| 30 # 10 Updated application does not have the version number from the update | 30 # 10 Updated application does not have the version number from the update |
| 31 # 11 ksadmin failure | 31 # 11 ksadmin failure |
| 32 # 12 dirpatcher failed for versioned directory | |
| 33 # 13 dirpatcher failed for outer .app bundle | |
| 34 # | 32 # |
| 35 # The following exit codes are not used by this script, but can be used to | 33 # The following exit codes can be used to convey special meaning to Keystone: |
| 36 # convey special meaning to Keystone: | |
| 37 # 66 (unused) success, request reboot | 34 # 66 (unused) success, request reboot |
| 38 # 77 (unused) try installation again later | 35 # 77 try installation again later |
| 39 | 36 |
| 40 set -eu | 37 set -eu |
| 41 | 38 |
| 42 # http://b/2290916: Keystone runs the installation with a restrictive PATH | 39 # http://b/2290916: Keystone runs the installation with a restrictive PATH |
| 43 # that only includes the directory containing ksadmin, /bin, and /usr/bin. It | 40 # that only includes the directory containing ksadmin, /bin, and /usr/bin. It |
| 44 # does not include /sbin or /usr/sbin. This script uses lsof, which is in | 41 # does not include /sbin or /usr/sbin. This script uses lsof, which is in |
| 45 # /usr/sbin, and it's conceivable that it might want to use other tools in an | 42 # /usr/sbin, and it's conceivable that it might want to use other tools in an |
| 46 # sbin directory. Adjust the path accordingly. | 43 # sbin directory. Adjust the path accordingly. |
| 47 export PATH="${PATH}:/sbin:/usr/sbin" | 44 export PATH="${PATH}:/sbin:/usr/sbin" |
| 48 | 45 |
| 49 # Environment sanitization. Clear environment variables that might impact the | 46 # Environment sanitization. Clear environment variables that might impact the |
| 50 # interpreter's operation. The |bash -p| invocation on the #! line takes the | 47 # interpreter's operation. The |bash -p| invocation on the #! line takes the |
| 51 # bite out of BASH_ENV, ENV, and SHELLOPTS (among other features), but | 48 # bite out of BASH_ENV, ENV, and SHELLOPTS (among other features), but |
| 52 # clearing them here ensures that they won't impact any shell scripts used as | 49 # clearing them here ensures that they won't impact any shell scripts used as |
| 53 # utility programs. SHELLOPTS is read-only and can't be unset, only | 50 # utility programs. SHELLOPTS is read-only and can't be unset, only |
| 54 # unexported. | 51 # unexported. |
| 55 unset BASH_ENV CDPATH ENV GLOBIGNORE IFS POSIXLY_CORRECT | 52 unset BASH_ENV CDPATH ENV GLOBIGNORE IFS POSIXLY_CORRECT |
| 56 export -n SHELLOPTS | 53 export -n SHELLOPTS |
| 57 | 54 |
| 58 set -o pipefail | 55 set -o pipefail |
| 59 shopt -s nullglob | 56 shopt -s nullglob |
| 60 | 57 |
| 61 ME="$(basename "${0}")" | 58 ME="$(basename "${0}")" |
| 62 readonly ME | 59 readonly ME |
| 63 | 60 |
| 61 readonly KS_CHANNEL_KEY="KSChannelID" |
| 62 |
| 64 # Workaround for http://code.google.com/p/chromium/issues/detail?id=83180#c3 | 63 # Workaround for http://code.google.com/p/chromium/issues/detail?id=83180#c3 |
| 65 # In bash 4.0, "declare VAR" no longer initializes VAR if not already set. | 64 # In bash 4.0, "declare VAR" no longer initializes VAR if not already set. |
| 66 : ${GOOGLE_CHROME_UPDATER_DEBUG:=} | 65 : ${GOOGLE_CHROME_UPDATER_DEBUG:=} |
| 67 err() { | 66 err() { |
| 68 local error="${1}" | 67 local error="${1}" |
| 69 | 68 |
| 70 local id= | 69 local id= |
| 71 if [[ -n "${GOOGLE_CHROME_UPDATER_DEBUG}" ]]; then | 70 if [[ -n "${GOOGLE_CHROME_UPDATER_DEBUG}" ]]; then |
| 72 id=": ${$} $(date "+%Y-%m-%d %H:%M:%S %z")" | 71 id=": ${$} $(date "+%Y-%m-%d %H:%M:%S %z")" |
| 73 fi | 72 fi |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 | 443 |
| 445 # Returns 0 (true) if ksadmin supports --version-path and --version-key. | 444 # Returns 0 (true) if ksadmin supports --version-path and --version-key. |
| 446 ksadmin_supports_versionpath_versionkey() { | 445 ksadmin_supports_versionpath_versionkey() { |
| 447 # --version-path and --version-key were introduced in Keystone 1.0.9.2318. | 446 # --version-path and --version-key were introduced in Keystone 1.0.9.2318. |
| 448 is_ksadmin_version_ge 1.0.9.2318 | 447 is_ksadmin_version_ge 1.0.9.2318 |
| 449 | 448 |
| 450 # The return value of is_ksadmin_version_ge is used as this function's | 449 # The return value of is_ksadmin_version_ge is used as this function's |
| 451 # return value. | 450 # return value. |
| 452 } | 451 } |
| 453 | 452 |
| 453 has_32_bit_only_cpu() { |
| 454 local cpu_64_bit_capable="$(sysctl -n hw.cpu64bit_capable 2>/dev/null)" |
| 455 [[ -z "${cpu_64_bit_capable}" || "${cpu_64_bit_capable}" -eq 0 ]] |
| 456 |
| 457 # The return value of the comparison is used as this function's return |
| 458 # value. |
| 459 } |
| 460 |
| 454 # Runs "defaults read" to obtain the value of a key in a property list. As | 461 # Runs "defaults read" to obtain the value of a key in a property list. As |
| 455 # with "defaults read", an absolute path to a plist is supplied, without the | 462 # with "defaults read", an absolute path to a plist is supplied, without the |
| 456 # ".plist" extension. | 463 # ".plist" extension. |
| 457 # | 464 # |
| 458 # As of Mac OS X 10.8, defaults (and NSUserDefaults and CFPreferences) | 465 # As of Mac OS X 10.8, defaults (and NSUserDefaults and CFPreferences) |
| 459 # normally communicates with cfprefsd to read and write plists. Changes to a | 466 # normally communicates with cfprefsd to read and write plists. Changes to a |
| 460 # plist file aren't necessarily reflected immediately via this API family when | 467 # plist file aren't necessarily reflected immediately via this API family when |
| 461 # not made through this API family, because cfprefsd may return cached data | 468 # not made through this API family, because cfprefsd may return cached data |
| 462 # from a former on-disk version of a plist file instead of reading the current | 469 # from a former on-disk version of a plist file instead of reading the current |
| 463 # version from disk. The old behavior can be restored by setting the | 470 # version from disk. The old behavior can be restored by setting the |
| (...skipping 13 matching lines...) Expand all Loading... |
| 477 # This function exists because the update process delivers new copies of | 484 # This function exists because the update process delivers new copies of |
| 478 # Info.plist files to the disk behind cfprefsd's back, and if cfprefsd becomes | 485 # Info.plist files to the disk behind cfprefsd's back, and if cfprefsd becomes |
| 479 # aware of the original version of the file for any reason (such as this | 486 # aware of the original version of the file for any reason (such as this |
| 480 # script reading values from it via "defaults read"), the new version of the | 487 # script reading values from it via "defaults read"), the new version of the |
| 481 # file will not be immediately effective or visible via cfprefsd after the | 488 # file will not be immediately effective or visible via cfprefsd after the |
| 482 # update is applied. | 489 # update is applied. |
| 483 infoplist_read() { | 490 infoplist_read() { |
| 484 __CFPREFERENCES_AVOID_DAEMON=1 defaults read "${@}" | 491 __CFPREFERENCES_AVOID_DAEMON=1 defaults read "${@}" |
| 485 } | 492 } |
| 486 | 493 |
| 494 # When a patch update fails because the old installed copy doesn't match the |
| 495 # expected state, mark_failed_patch_update updates the Keystone ticket by |
| 496 # adding "-full" to the tag. The server will see this on a subsequent update |
| 497 # attempt and will provide a full update (as opposed to a patch) to the |
| 498 # client. |
| 499 # |
| 500 # Even if mark_failed_patch_update fails to modify the tag, the user will |
| 501 # eventually be updated. Patch updates are only provided for successive |
| 502 # releases on a particular channel, to update version o to version o+1. If a |
| 503 # patch update fails in this case, eventually version o+2 will be released, |
| 504 # and no patch update will exist to update o to o+2, so the server will |
| 505 # provide a full update package. |
| 506 mark_failed_patch_update() { |
| 507 local product_id="${1}" |
| 508 local want_full_installer_path="${2}" |
| 509 local old_ks_plist="${3}" |
| 510 local old_version_app="${4}" |
| 511 local system_ticket="${5}" |
| 512 |
| 513 set +e |
| 514 |
| 515 note "marking failed patch update" |
| 516 |
| 517 local channel |
| 518 channel="$(infoplist_read "${old_ks_plist}" "${KS_CHANNEL_KEY}" 2> /dev/null)" |
| 519 |
| 520 local tag="${channel}" |
| 521 local tag_key="${KS_CHANNEL_KEY}" |
| 522 if has_32_bit_only_cpu; then |
| 523 tag="${tag}-32bit" |
| 524 tag_key="${tag_key}-32bit" |
| 525 fi |
| 526 |
| 527 tag="${tag}-full" |
| 528 tag_key="${tag_key}-full" |
| 529 |
| 530 note "tag = ${tag}" |
| 531 note "tag_key = ${tag_key}" |
| 532 |
| 533 # ${old_ks_plist}, used for --tag-path, is the Info.plist for the old |
| 534 # version of Chrome. It may not contain the keys for the "-full" tag suffix. |
| 535 # If it doesn't, just bail out without marking the patch update as failed. |
| 536 local read_tag="$(infoplist_read "${old_ks_plist}" "${tag_key}" 2> /dev/null)" |
| 537 note "read_tag = ${read_tag}" |
| 538 if [[ -z "${read_tag}" ]]; then |
| 539 note "couldn't mark failed patch update" |
| 540 return 0 |
| 541 fi |
| 542 |
| 543 # Chrome can't easily read its Keystone ticket prior to registration, and |
| 544 # when Chrome registers with Keystone, it obliterates old tag values in its |
| 545 # ticket. Therefore, an alternative mechanism is provided to signal to |
| 546 # Chrome that a full installer is desired. If the .want_full_installer file |
| 547 # is present and it contains Chrome's current version number, Chrome will |
| 548 # include "-full" in its tag when it registers with Keystone. This allows |
| 549 # "-full" to persist in the tag even after Chrome is relaunched, which on a |
| 550 # user ticket, triggers a re-registration. |
| 551 # |
| 552 # .want_full_installer is placed immediately inside the .app bundle as a |
| 553 # sibling to the Contents directory. In this location, it's outside of the |
| 554 # view of the code signing and code signature verification machinery. This |
| 555 # file can safely be added, modified, and removed without affecting the |
| 556 # signature. |
| 557 rm -f "${want_full_installer_path}" 2> /dev/null |
| 558 echo "${old_version_app}" > "${want_full_installer_path}" |
| 559 |
| 560 # See the comment below in the "setting permissions" section for an |
| 561 # explanation of the groups and modes selected here. |
| 562 local chmod_mode="644" |
| 563 if [[ -z "${system_ticket}" ]] && |
| 564 [[ "${want_full_installer_path:0:14}" = "/Applications/" ]] && |
| 565 chgrp admin "${want_full_installer_path}" 2> /dev/null; then |
| 566 chmod_mode="664" |
| 567 fi |
| 568 note "chmod_mode = ${chmod_mode}" |
| 569 chmod "${chmod_mode}" "${want_full_installer_path}" 2> /dev/null |
| 570 |
| 571 local old_ks_plist_path="${old_ks_plist}.plist" |
| 572 |
| 573 # Using ksadmin without --register only updates specified values in the |
| 574 # ticket, without changing other existing values. |
| 575 local ksadmin_args=( |
| 576 --productid "${product_id}" |
| 577 ) |
| 578 |
| 579 if ksadmin_supports_tag; then |
| 580 ksadmin_args+=( |
| 581 --tag "${tag}" |
| 582 ) |
| 583 fi |
| 584 |
| 585 if ksadmin_supports_tagpath_tagkey; then |
| 586 ksadmin_args+=( |
| 587 --tag-path "${old_ks_plist_path}" |
| 588 --tag-key "${tag_key}" |
| 589 ) |
| 590 fi |
| 591 |
| 592 note "ksadmin_args = ${ksadmin_args[*]}" |
| 593 |
| 594 if ! ksadmin "${ksadmin_args[@]}"; then |
| 595 err "ksadmin failed" |
| 596 fi |
| 597 |
| 598 note "marked failed patch update" |
| 599 |
| 600 set -e |
| 601 } |
| 602 |
| 487 usage() { | 603 usage() { |
| 488 echo "usage: ${ME} update_dmg_mount_point" >& 2 | 604 echo "usage: ${ME} update_dmg_mount_point" >& 2 |
| 489 } | 605 } |
| 490 | 606 |
| 491 main() { | 607 main() { |
| 492 local update_dmg_mount_point="${1}" | 608 local update_dmg_mount_point="${1}" |
| 493 | 609 |
| 494 # Early steps are critical. Don't continue past any failure. | 610 # Early steps are critical. Don't continue past any failure. |
| 495 set -e | 611 set -e |
| 496 | 612 |
| 497 trap cleanup EXIT HUP INT QUIT TERM | 613 trap cleanup EXIT HUP INT QUIT TERM |
| 498 | 614 |
| 499 readonly PRODUCT_NAME="Google Chrome" | 615 readonly PRODUCT_NAME="Google Chrome" |
| 500 readonly APP_DIR="${PRODUCT_NAME}.app" | 616 readonly APP_DIR="${PRODUCT_NAME}.app" |
| 501 readonly ALTERNATE_APP_DIR="${PRODUCT_NAME} Canary.app" | 617 readonly ALTERNATE_APP_DIR="${PRODUCT_NAME} Canary.app" |
| 502 readonly FRAMEWORK_NAME="${PRODUCT_NAME} Framework" | 618 readonly FRAMEWORK_NAME="${PRODUCT_NAME} Framework" |
| 503 readonly FRAMEWORK_DIR="${FRAMEWORK_NAME}.framework" | 619 readonly FRAMEWORK_DIR="${FRAMEWORK_NAME}.framework" |
| 504 readonly PATCH_DIR=".patch" | 620 readonly PATCH_DIR=".patch" |
| 505 readonly CONTENTS_DIR="Contents" | 621 readonly CONTENTS_DIR="Contents" |
| 506 readonly APP_PLIST="${CONTENTS_DIR}/Info" | 622 readonly APP_PLIST="${CONTENTS_DIR}/Info" |
| 507 readonly VERSIONS_DIR="${CONTENTS_DIR}/Versions" | 623 readonly VERSIONS_DIR="${CONTENTS_DIR}/Versions" |
| 508 readonly UNROOTED_BRAND_PLIST="Library/Google/Google Chrome Brand" | 624 readonly UNROOTED_BRAND_PLIST="Library/Google/Google Chrome Brand" |
| 509 readonly UNROOTED_DEBUG_FILE="Library/Google/Google Chrome Updater Debug" | 625 readonly UNROOTED_DEBUG_FILE="Library/Google/Google Chrome Updater Debug" |
| 510 | 626 |
| 511 readonly APP_VERSION_KEY="CFBundleShortVersionString" | 627 readonly APP_VERSION_KEY="CFBundleShortVersionString" |
| 512 readonly APP_BUNDLEID_KEY="CFBundleIdentifier" | 628 readonly APP_BUNDLEID_KEY="CFBundleIdentifier" |
| 513 readonly KS_VERSION_KEY="KSVersion" | 629 readonly KS_VERSION_KEY="KSVersion" |
| 514 readonly KS_PRODUCT_KEY="KSProductID" | 630 readonly KS_PRODUCT_KEY="KSProductID" |
| 515 readonly KS_URL_KEY="KSUpdateURL" | 631 readonly KS_URL_KEY="KSUpdateURL" |
| 516 readonly KS_CHANNEL_KEY="KSChannelID" | |
| 517 readonly KS_BRAND_KEY="KSBrandID" | 632 readonly KS_BRAND_KEY="KSBrandID" |
| 518 | 633 |
| 519 readonly QUARANTINE_ATTR="com.apple.quarantine" | 634 readonly QUARANTINE_ATTR="com.apple.quarantine" |
| 520 readonly KEYCHAIN_REAUTHORIZE_DIR=".keychain_reauthorize" | 635 readonly KEYCHAIN_REAUTHORIZE_DIR=".keychain_reauthorize" |
| 521 | 636 |
| 522 # Don't use rsync -a, because -a expands to -rlptgoD. -g and -o copy owners | 637 # Don't use rsync -a, because -a expands to -rlptgoD. -g and -o copy owners |
| 523 # and groups, respectively, from the source, and that is undesirable in this | 638 # and groups, respectively, from the source, and that is undesirable in this |
| 524 # case. -D copies devices and special files; copying devices only works | 639 # case. -D copies devices and special files; copying devices only works |
| 525 # when running as root, so for consistency between privileged and | 640 # when running as root, so for consistency between privileged and |
| 526 # unprivileged operation, this option is omitted as well. | 641 # unprivileged operation, this option is omitted as well. |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 # Figure out where to install. | 848 # Figure out where to install. |
| 734 local installed_app | 849 local installed_app |
| 735 if ! installed_app="$(ksadmin -pP "${product_id}" | sed -Ene \ | 850 if ! installed_app="$(ksadmin -pP "${product_id}" | sed -Ene \ |
| 736 "s%^[[:space:]]+xc=<KSPathExistenceChecker:.* path=(/.+)>\$%\\1%p")" || | 851 "s%^[[:space:]]+xc=<KSPathExistenceChecker:.* path=(/.+)>\$%\\1%p")" || |
| 737 [[ -z "${installed_app}" ]]; then | 852 [[ -z "${installed_app}" ]]; then |
| 738 err "couldn't locate installed_app" | 853 err "couldn't locate installed_app" |
| 739 exit 3 | 854 exit 3 |
| 740 fi | 855 fi |
| 741 note "installed_app = ${installed_app}" | 856 note "installed_app = ${installed_app}" |
| 742 | 857 |
| 858 local want_full_installer_path="${installed_app}/.want_full_installer" |
| 859 note "want_full_installer_path = ${want_full_installer_path}" |
| 860 |
| 743 if [[ "${installed_app:0:1}" != "/" ]] || | 861 if [[ "${installed_app:0:1}" != "/" ]] || |
| 744 ! [[ -d "${installed_app}" ]]; then | 862 ! [[ -d "${installed_app}" ]]; then |
| 745 err "installed_app must be an absolute path to a directory" | 863 err "installed_app must be an absolute path to a directory" |
| 746 exit 3 | 864 exit 3 |
| 747 fi | 865 fi |
| 748 | 866 |
| 749 # If this script is running as root, it's being driven by a system ticket. | 867 # If this script is running as root, it's being driven by a system ticket. |
| 750 # Otherwise, it's being driven by a user ticket. | 868 # Otherwise, it's being driven by a user ticket. |
| 751 local system_ticket= | 869 local system_ticket= |
| 752 if [[ ${EUID} -eq 0 ]]; then | 870 if [[ ${EUID} -eq 0 ]]; then |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 note "versioned_dir_target = ${versioned_dir_target}" | 1013 note "versioned_dir_target = ${versioned_dir_target}" |
| 896 update_versioned_dir="${versioned_dir_target}" | 1014 update_versioned_dir="${versioned_dir_target}" |
| 897 note "update_versioned_dir = ${update_versioned_dir}" | 1015 note "update_versioned_dir = ${update_versioned_dir}" |
| 898 fi | 1016 fi |
| 899 | 1017 |
| 900 note "dirpatching versioned directory" | 1018 note "dirpatching versioned directory" |
| 901 if ! "${dirpatcher}" "${old_versioned_dir}" \ | 1019 if ! "${dirpatcher}" "${old_versioned_dir}" \ |
| 902 "${patch_versioned_dir}" \ | 1020 "${patch_versioned_dir}" \ |
| 903 "${versioned_dir_target}"; then | 1021 "${versioned_dir_target}"; then |
| 904 err "dirpatcher of versioned directory failed, status ${PIPESTATUS[0]}" | 1022 err "dirpatcher of versioned directory failed, status ${PIPESTATUS[0]}" |
| 905 exit 12 | 1023 mark_failed_patch_update "${product_id}" \ |
| 1024 "${want_full_installer_path}" \ |
| 1025 "${old_ks_plist}" \ |
| 1026 "${old_version_app}" \ |
| 1027 "${system_ticket}" |
| 1028 exit 77 |
| 906 fi | 1029 fi |
| 907 fi | 1030 fi |
| 908 | 1031 |
| 909 # Copy the versioned directory. The new versioned directory should have a | 1032 # Copy the versioned directory. The new versioned directory should have a |
| 910 # different name than any existing one, so this won't harm anything already | 1033 # different name than any existing one, so this won't harm anything already |
| 911 # present in ${installed_versions_dir}, including the versioned directory | 1034 # present in ${installed_versions_dir}, including the versioned directory |
| 912 # being used by any running processes. If this step is interrupted, there | 1035 # being used by any running processes. If this step is interrupted, there |
| 913 # will be an incomplete versioned directory left behind, but it won't | 1036 # will be an incomplete versioned directory left behind, but it won't |
| 914 # won't interfere with anything, and it will be replaced or removed during a | 1037 # won't interfere with anything, and it will be replaced or removed during a |
| 915 # future update attempt. | 1038 # future update attempt. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 # dirpatcher creates it. | 1072 # dirpatcher creates it. |
| 950 ensure_temp_dir | 1073 ensure_temp_dir |
| 951 update_app="${g_temp_dir}/${APP_DIR}" | 1074 update_app="${g_temp_dir}/${APP_DIR}" |
| 952 note "update_app = ${update_app}" | 1075 note "update_app = ${update_app}" |
| 953 | 1076 |
| 954 note "dirpatching app directory" | 1077 note "dirpatching app directory" |
| 955 if ! "${dirpatcher}" "${installed_app}" \ | 1078 if ! "${dirpatcher}" "${installed_app}" \ |
| 956 "${patch_app_dir}" \ | 1079 "${patch_app_dir}" \ |
| 957 "${update_app}"; then | 1080 "${update_app}"; then |
| 958 err "dirpatcher of app directory failed, status ${PIPESTATUS[0]}" | 1081 err "dirpatcher of app directory failed, status ${PIPESTATUS[0]}" |
| 959 exit 13 | 1082 mark_failed_patch_update "${product_id}" \ |
| 1083 "${want_full_installer_path}" \ |
| 1084 "${old_ks_plist}" \ |
| 1085 "${old_version_app}" \ |
| 1086 "${system_ticket}" |
| 1087 exit 77 |
| 960 fi | 1088 fi |
| 961 fi | 1089 fi |
| 962 | 1090 |
| 963 # See if the timestamp of what's currently on disk is newer than the | 1091 # See if the timestamp of what's currently on disk is newer than the |
| 964 # update's outer .app's timestamp. rsync will copy the update's timestamp | 1092 # update's outer .app's timestamp. rsync will copy the update's timestamp |
| 965 # over, but if that timestamp isn't as recent as what's already on disk, the | 1093 # over, but if that timestamp isn't as recent as what's already on disk, the |
| 966 # .app will need to be touched. | 1094 # .app will need to be touched. |
| 967 local needs_touch= | 1095 local needs_touch= |
| 968 if [[ "${installed_app}" -nt "${update_app}" ]]; then | 1096 if [[ "${installed_app}" -nt "${update_app}" ]]; then |
| 969 needs_touch="y" | 1097 needs_touch="y" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 997 note "update_app = ${update_app}" | 1125 note "update_app = ${update_app}" |
| 998 fi | 1126 fi |
| 999 | 1127 |
| 1000 if [[ -n "${g_temp_dir}" ]]; then | 1128 if [[ -n "${g_temp_dir}" ]]; then |
| 1001 # The temporary directory, if any, is no longer needed. | 1129 # The temporary directory, if any, is no longer needed. |
| 1002 rm -rf "${g_temp_dir}" 2> /dev/null || true | 1130 rm -rf "${g_temp_dir}" 2> /dev/null || true |
| 1003 g_temp_dir= | 1131 g_temp_dir= |
| 1004 note "g_temp_dir = ${g_temp_dir}" | 1132 note "g_temp_dir = ${g_temp_dir}" |
| 1005 fi | 1133 fi |
| 1006 | 1134 |
| 1135 # Clean up any old .want_full_installer files from previous dirpatcher |
| 1136 # failures. This is not considered a critical step, because this file |
| 1137 # normally does not exist at all. |
| 1138 rm -f "${want_full_installer_path}" || true |
| 1139 |
| 1007 # If necessary, touch the outermost .app so that it appears to the outside | 1140 # If necessary, touch the outermost .app so that it appears to the outside |
| 1008 # world that something was done to the bundle. This will cause | 1141 # world that something was done to the bundle. This will cause |
| 1009 # LaunchServices to invalidate the information it has cached about the | 1142 # LaunchServices to invalidate the information it has cached about the |
| 1010 # bundle even if lsregister does not run. This is not done if rsync already | 1143 # bundle even if lsregister does not run. This is not done if rsync already |
| 1011 # updated the timestamp to something newer than what had been on disk. This | 1144 # updated the timestamp to something newer than what had been on disk. This |
| 1012 # is not considered a critical step, and if it fails, this script will not | 1145 # is not considered a critical step, and if it fails, this script will not |
| 1013 # exit. | 1146 # exit. |
| 1014 if [[ -n "${needs_touch}" ]]; then | 1147 if [[ -n "${needs_touch}" ]]; then |
| 1015 touch -cf "${installed_app}" || true | 1148 touch -cf "${installed_app}" || true |
| 1016 fi | 1149 fi |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 fi | 1183 fi |
| 1051 note "update_url = ${update_url}" | 1184 note "update_url = ${update_url}" |
| 1052 | 1185 |
| 1053 # The channel ID is optional. Suppress stderr to prevent Keystone from | 1186 # The channel ID is optional. Suppress stderr to prevent Keystone from |
| 1054 # seeing possible error output. | 1187 # seeing possible error output. |
| 1055 local channel | 1188 local channel |
| 1056 channel="$(infoplist_read "${new_ks_plist}" \ | 1189 channel="$(infoplist_read "${new_ks_plist}" \ |
| 1057 "${KS_CHANNEL_KEY}" 2> /dev/null || true)" | 1190 "${KS_CHANNEL_KEY}" 2> /dev/null || true)" |
| 1058 note "channel = ${channel}" | 1191 note "channel = ${channel}" |
| 1059 | 1192 |
| 1193 local tag="${channel}" |
| 1194 local tag_key="${KS_CHANNEL_KEY}" |
| 1195 if has_32_bit_only_cpu; then |
| 1196 tag="${tag}-32bit" |
| 1197 tag_key="${tag_key}-32bit" |
| 1198 fi |
| 1199 note "tag = ${tag}" |
| 1200 note "tag_key = ${tag_key}" |
| 1201 |
| 1060 # Make sure that the update was successful by comparing the version found in | 1202 # Make sure that the update was successful by comparing the version found in |
| 1061 # the update with the version now on disk. | 1203 # the update with the version now on disk. |
| 1062 if [[ "${new_version_ks}" != "${update_version_ks}" ]]; then | 1204 if [[ "${new_version_ks}" != "${update_version_ks}" ]]; then |
| 1063 err "new_version_ks and update_version_ks do not match" | 1205 err "new_version_ks and update_version_ks do not match" |
| 1064 exit 10 | 1206 exit 10 |
| 1065 fi | 1207 fi |
| 1066 | 1208 |
| 1067 # Notify LaunchServices. This is not considered a critical step, and | 1209 # Notify LaunchServices. This is not considered a critical step, and |
| 1068 # lsregister's exit codes shouldn't be confused with this script's own. | 1210 # lsregister's exit codes shouldn't be confused with this script's own. |
| 1069 # Redirect stdout to /dev/null to suppress the useless "ThrottleProcessIO: | 1211 # Redirect stdout to /dev/null to suppress the useless "ThrottleProcessIO: |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 local ksadmin_args=( | 1300 local ksadmin_args=( |
| 1159 --register | 1301 --register |
| 1160 --productid "${product_id}" | 1302 --productid "${product_id}" |
| 1161 --version "${new_version_ks}" | 1303 --version "${new_version_ks}" |
| 1162 --xcpath "${installed_app}" | 1304 --xcpath "${installed_app}" |
| 1163 --url "${update_url}" | 1305 --url "${update_url}" |
| 1164 ) | 1306 ) |
| 1165 | 1307 |
| 1166 if ksadmin_supports_tag; then | 1308 if ksadmin_supports_tag; then |
| 1167 ksadmin_args+=( | 1309 ksadmin_args+=( |
| 1168 --tag "${channel}" | 1310 --tag "${tag}" |
| 1169 ) | 1311 ) |
| 1170 fi | 1312 fi |
| 1171 | 1313 |
| 1172 if ksadmin_supports_tagpath_tagkey; then | 1314 if ksadmin_supports_tagpath_tagkey; then |
| 1173 ksadmin_args+=( | 1315 ksadmin_args+=( |
| 1174 --tag-path "${installed_app_plist_path}" | 1316 --tag-path "${installed_app_plist_path}" |
| 1175 --tag-key "${KS_CHANNEL_KEY}" | 1317 --tag-key "${tag_key}" |
| 1176 ) | 1318 ) |
| 1177 fi | 1319 fi |
| 1178 | 1320 |
| 1179 if ksadmin_supports_brandpath_brandkey; then | 1321 if ksadmin_supports_brandpath_brandkey; then |
| 1180 ksadmin_args+=( | 1322 ksadmin_args+=( |
| 1181 --brand-path "${ksadmin_brand_plist_path}" | 1323 --brand-path "${ksadmin_brand_plist_path}" |
| 1182 --brand-key "${ksadmin_brand_key}" | 1324 --brand-key "${ksadmin_brand_key}" |
| 1183 ) | 1325 ) |
| 1184 fi | 1326 fi |
| 1185 | 1327 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1405 | 1547 |
| 1406 # Check "less than" instead of "not equal to" in case Keystone ever changes to | 1548 # Check "less than" instead of "not equal to" in case Keystone ever changes to |
| 1407 # pass more arguments. | 1549 # pass more arguments. |
| 1408 if [[ ${#} -lt 1 ]]; then | 1550 if [[ ${#} -lt 1 ]]; then |
| 1409 usage | 1551 usage |
| 1410 exit 2 | 1552 exit 2 |
| 1411 fi | 1553 fi |
| 1412 | 1554 |
| 1413 main "${@}" | 1555 main "${@}" |
| 1414 exit ${?} | 1556 exit ${?} |
| OLD | NEW |