Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3886)

Unified Diff: chrome/installer/mac/keystone_install.sh

Issue 10810059: Update keystone_install.sh for 10.8, avoiding cfprefsd when reading from Info.plist files (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/mac/keystone_install.sh
diff --git a/chrome/installer/mac/keystone_install.sh b/chrome/installer/mac/keystone_install.sh
index 4dca1e2a4f1da44ec7116589212b308dc232ed63..6f038ba321b1101dae5962f0833f8336f1064f43 100755
--- a/chrome/installer/mac/keystone_install.sh
+++ b/chrome/installer/mac/keystone_install.sh
@@ -388,6 +388,39 @@ ksadmin_supports_versionpath_versionkey() {
# return value.
}
+# Runs "defaults read" to obtain the value of a key in a property list. As
+# with "defaults read", an absolute path to a plist is supplied, without the
+# ".plist" extension.
+#
+# As of Mac OS X 10.8, defaults (and NSUserDefaults and CFPreferences)
+# normally communicates with cfprefsd to read and write plists. Changes to a
+# plist file aren't necessarily reflected immediately via this API family when
+# not made through this API family, because cfprefsd may return cached data
+# from a former on-disk version of a plist file instead of reading the current
+# version from disk. The old behavior can be restored by setting the
+# __CFPREFERENCES_AVOID_DAEMON environment variable, although extreme care
+# should be used because portions of the system that use this API family
+# normally and thus use cfprefsd and its cache will become unsynchronized with
+# the on-disk state.
+#
+# This function is provided to set __CFPREFERENCES_AVOID_DAEMON when calling
+# "defaults read" and thus avoid cfprefsd and its on-disk cache, and is
+# intended only to be used to read values from Info.plist files, which are not
+# preferences. The use of "defaults" for this purpose has always been
+# questionable, but there's no better option to interact with plists from
+# shell scripts. Definitely don't use infoplist_read to read preference
+# plists.
+#
+# This function exists because the update process delivers new copies of
+# Info.plist files to the disk behind cfprefsd's back, and if cfprefsd becomes
+# aware of the original version of the file for any reason (such as this
+# script reading values from it via "defaults read"), the new version of the
+# file will not be immediately effective or visible via cfprefsd after the
+# update is applied.
+infoplist_read() {
+ __CFPREFERENCES_AVOID_DAEMON=1 defaults read "${@}"
+}
+
usage() {
echo "usage: ${ME} update_dmg_mount_point" >& 2
}
@@ -538,8 +571,8 @@ main() {
local update_app_plist="${update_app}/${APP_PLIST}"
note "update_app_plist = ${update_app_plist}"
- if ! update_version_app="$(defaults read "${update_app_plist}" \
- "${APP_VERSION_KEY}")" ||
+ if ! update_version_app="$(infoplist_read "${update_app_plist}" \
+ "${APP_VERSION_KEY}")" ||
[[ -z "${update_version_app}" ]]; then
err "couldn't determine update_version_app"
exit 2
@@ -548,16 +581,16 @@ main() {
local update_ks_plist="${update_app_plist}"
note "update_ks_plist = ${update_ks_plist}"
- if ! update_version_ks="$(defaults read "${update_ks_plist}" \
- "${KS_VERSION_KEY}")" ||
+ if ! update_version_ks="$(infoplist_read "${update_ks_plist}" \
+ "${KS_VERSION_KEY}")" ||
[[ -z "${update_version_ks}" ]]; then
err "couldn't determine update_version_ks"
exit 2
fi
note "update_version_ks = ${update_version_ks}"
- if ! product_id="$(defaults read "${update_ks_plist}" \
- "${KS_PRODUCT_KEY}")" ||
+ if ! product_id="$(infoplist_read "${update_ks_plist}" \
+ "${KS_PRODUCT_KEY}")" ||
[[ -z "${product_id}" ]]; then
err "couldn't determine product_id"
exit 2
@@ -692,8 +725,8 @@ main() {
local installed_app_plist_path="${installed_app_plist}.plist"
note "installed_app_plist_path = ${installed_app_plist_path}"
local old_version_app
- old_version_app="$(defaults read "${installed_app_plist}" \
- "${APP_VERSION_KEY}" || true)"
+ old_version_app="$(infoplist_read "${installed_app_plist}" \
+ "${APP_VERSION_KEY}" || true)"
note "old_version_app = ${old_version_app}"
# old_version_app is not required, because it won't be present in skeleton
@@ -728,8 +761,8 @@ main() {
local old_ks_plist="${installed_app_plist}"
note "old_ks_plist = ${old_ks_plist}"
local old_brand
- old_brand="$(defaults read "${old_ks_plist}" \
- "${KS_BRAND_KEY}" 2> /dev/null ||
+ old_brand="$(infoplist_read "${old_ks_plist}" \
+ "${KS_BRAND_KEY}" 2> /dev/null ||
true)"
note "old_brand = ${old_brand}"
@@ -923,8 +956,8 @@ main() {
note "reading new values"
local new_version_app
- if ! new_version_app="$(defaults read "${installed_app_plist}" \
- "${APP_VERSION_KEY}")" ||
+ if ! new_version_app="$(infoplist_read "${installed_app_plist}" \
+ "${APP_VERSION_KEY}")" ||
[[ -z "${new_version_app}" ]]; then
err "couldn't determine new_version_app"
exit 9
@@ -938,8 +971,8 @@ main() {
note "new_ks_plist = ${new_ks_plist}"
local new_version_ks
- if ! new_version_ks="$(defaults read "${new_ks_plist}" \
- "${KS_VERSION_KEY}")" ||
+ if ! new_version_ks="$(infoplist_read "${new_ks_plist}" \
+ "${KS_VERSION_KEY}")" ||
[[ -z "${new_version_ks}" ]]; then
err "couldn't determine new_version_ks"
exit 9
@@ -947,7 +980,7 @@ main() {
note "new_version_ks = ${new_version_ks}"
local update_url
- if ! update_url="$(defaults read "${new_ks_plist}" "${KS_URL_KEY}")" ||
+ if ! update_url="$(infoplist_read "${new_ks_plist}" "${KS_URL_KEY}")" ||
[[ -z "${update_url}" ]]; then
err "couldn't determine update_url"
exit 9
@@ -957,8 +990,8 @@ main() {
# The channel ID is optional. Suppress stderr to prevent Keystone from
# seeing possible error output.
local channel
- channel="$(defaults read "${new_ks_plist}" "${KS_CHANNEL_KEY}" 2> /dev/null ||
- true)"
+ channel="$(infoplist_read "${new_ks_plist}" \
+ "${KS_CHANNEL_KEY}" 2> /dev/null || true)"
note "channel = ${channel}"
# Make sure that the update was successful by comparing the version found in
@@ -1291,8 +1324,8 @@ main() {
if [[ -z "${system_ticket}" ]]; then
local new_bundleid_app
- new_bundleid_app="$(defaults read "${installed_app_plist}" \
- "${APP_BUNDLEID_KEY}" || true)"
+ new_bundleid_app="$(infoplist_read "${installed_app_plist}" \
+ "${APP_BUNDLEID_KEY}" || true)"
note "new_bundleid_app = ${new_bundleid_app}"
local keychain_reauthorize_dir="\
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698