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