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

Side by Side Diff: chrome/tools/build/mac/keystone_install.sh

Issue 505055: Merge trunk r35030 to the 249 branch (Closed) Base URL: svn://svn.chromium.org/chrome/branches/249/src/
Patch Set: Created 11 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/chrome.gyp ('k') | chrome/tools/build/mac/keystone_install_test.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 2
3 # Copyright (c) 2009 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2009 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 # Called by the Keystone system to update the installed application with a new 7 # Called by the Keystone system to update the installed application with a new
8 # version from a disk image. 8 # version from a disk image.
9 9
10 # Return values: 10 # Return values:
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 (mkdir "${TEMPLINKDIR}" && \ 116 (mkdir "${TEMPLINKDIR}" && \
117 ln -fhs "${TARGET}" "${TEMPLINK}" && \ 117 ln -fhs "${TARGET}" "${TEMPLINK}" && \
118 chmod -h 755 "${TEMPLINK}" && \ 118 chmod -h 755 "${TEMPLINK}" && \
119 mv -f "${TEMPLINK}" "${SYMLINKDIR}") || true 119 mv -f "${TEMPLINK}" "${SYMLINKDIR}") || true
120 rm -rf "${TEMPLINKDIR}" 120 rm -rf "${TEMPLINKDIR}"
121 fi 121 fi
122 122
123 return 0 123 return 0
124 } 124 }
125 125
126 # Prints the version of ksadmin, as reported by ksadmin --ksadmin-version, to
127 # stdout. This function operates with "static" variables: it will only check
128 # the ksadmin version once per script run. If ksadmin is old enough to not
129 # support --ksadmin-version, or another error occurs, this function prints an
130 # empty string.
131 G_CHECKED_KSADMIN_VERSION=
132 G_KSADMIN_VERSION=
133 function ksadmin_version() {
134 if [ -z "${G_CHECKED_KSADMIN_VERSION}" ] ; then
135 G_CHECKED_KSADMIN_VERSION=1
136 G_KSADMIN_VERSION=$(ksadmin --ksadmin-version || true)
137 fi
138 echo "${G_KSADMIN_VERSION}"
139 return 0
140 }
141
142 # Compares the installed ksadmin version against a supplied version number,
143 # and returns 0 (true) if the number to check is the same as or newer than the
144 # installed Keystone. Returns 1 (false) if the installed Keystone version
145 # number cannot be determined or if the number to check is less than the
146 # installed Keystone. The check argument should be a string of the form
147 # "major.minor.micro.build".
148 function is_ksadmin_version_ge() {
149 CHECK_VERSION=${1}
150 KSADMIN_VERSION=$(ksadmin_version)
151 if [ -n "${KSADMIN_VERSION}" ] ; then
152 VER_RE='^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$'
153
154 KSADMIN_VERSION_MAJOR=$(sed -Ene "s/${VER_RE}/\1/p" <<< ${KSADMIN_VERSION})
155 KSADMIN_VERSION_MINOR=$(sed -Ene "s/${VER_RE}/\2/p" <<< ${KSADMIN_VERSION})
156 KSADMIN_VERSION_MICRO=$(sed -Ene "s/${VER_RE}/\3/p" <<< ${KSADMIN_VERSION})
157 KSADMIN_VERSION_BUILD=$(sed -Ene "s/${VER_RE}/\4/p" <<< ${KSADMIN_VERSION})
158
159 CHECK_VERSION_MAJOR=$(sed -Ene "s/${VER_RE}/\1/p" <<< ${CHECK_VERSION})
160 CHECK_VERSION_MINOR=$(sed -Ene "s/${VER_RE}/\2/p" <<< ${CHECK_VERSION})
161 CHECK_VERSION_MICRO=$(sed -Ene "s/${VER_RE}/\3/p" <<< ${CHECK_VERSION})
162 CHECK_VERSION_BUILD=$(sed -Ene "s/${VER_RE}/\4/p" <<< ${CHECK_VERSION})
163
164 if [ ${KSADMIN_VERSION_MAJOR} -gt ${CHECK_VERSION_MAJOR} ] ||
165 ([ ${KSADMIN_VERSION_MAJOR} -eq ${CHECK_VERSION_MAJOR} ] && (
166 [ ${KSADMIN_VERSION_MINOR} -gt ${CHECK_VERSION_MINOR} ] ||
167 ([ ${KSADMIN_VERSION_MINOR} -eq ${CHECK_VERSION_MINOR} ] && (
168 [ ${KSADMIN_VERSION_MICRO} -gt ${CHECK_VERSION_MICRO} ] ||
169 ([ ${KSADMIN_VERSION_MICRO} -eq ${CHECK_VERSION_MICRO} ] &&
170 [ ${KSADMIN_VERSION_BUILD} -ge ${CHECK_VERSION_BUILD} ])
171 ))
172 )) ; then
173 return 0
174 fi
175 fi
176
177 return 1
178 }
179
180 # Returns 0 (true) if ksadmin supports --tag.
181 function ksadmin_supports_tag() {
182 KSADMIN_VERSION=$(ksadmin_version)
183 if [ -n "${KSADMIN_VERSION}" ] ; then
184 # A ksadmin that recognizes --ksadmin-version and provides a version
185 # number is new enough to recognize --tag.
186 return 0
187 fi
188 return 1
189 }
190
191 # Returns 0 (true) if ksadmin supports --tag-path and --tag-key.
192 function ksadmin_supports_tagpath_tagkey() {
193 # --tag-path and --tag-key were introduced in Keystone 1.0.7.1306.
194 is_ksadmin_version_ge 1.0.7.1306
195 # The return value of is_ksadmin_version_ge is used as this function's
196 # return value.
197 }
198
126 # The argument should be the disk image path. Make sure it exists. 199 # The argument should be the disk image path. Make sure it exists.
127 if [ $# -lt 1 ] || [ ! -d "${1}" ]; then 200 if [ $# -lt 1 ] || [ ! -d "${1}" ]; then
128 exit 2 201 exit 2
129 fi 202 fi
130 203
131 # Who we are. 204 # Who we are.
132 PRODUCT_NAME="Google Chrome" 205 PRODUCT_NAME="Google Chrome"
133 APP_DIR="${PRODUCT_NAME}.app" 206 APP_DIR="${PRODUCT_NAME}.app"
134 FRAMEWORK_NAME="${PRODUCT_NAME} Framework" 207 FRAMEWORK_NAME="${PRODUCT_NAME} Framework"
135 FRAMEWORK_DIR="${FRAMEWORK_NAME}.framework" 208 FRAMEWORK_DIR="${FRAMEWORK_NAME}.framework"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 391
319 # Read the new values (e.g. version). Get the installed application version 392 # Read the new values (e.g. version). Get the installed application version
320 # to get the path to the framework, where the Keystone keys are stored. 393 # to get the path to the framework, where the Keystone keys are stored.
321 NEW_VERSION_APP=$(defaults read "${DEST}/Contents/Info" "${APP_VERSION_KEY}" || 394 NEW_VERSION_APP=$(defaults read "${DEST}/Contents/Info" "${APP_VERSION_KEY}" ||
322 exit 9) 395 exit 9)
323 NEW_KS_PLIST="${DEST}/Contents/Versions/${NEW_VERSION_APP}/${FRAMEWORK_DIR}/Reso urces/Info" 396 NEW_KS_PLIST="${DEST}/Contents/Versions/${NEW_VERSION_APP}/${FRAMEWORK_DIR}/Reso urces/Info"
324 NEW_VERSION_KS=$(defaults read "${NEW_KS_PLIST}" "${KS_VERSION_KEY}" || exit 9) 397 NEW_VERSION_KS=$(defaults read "${NEW_KS_PLIST}" "${KS_VERSION_KEY}" || exit 9)
325 URL=$(defaults read "${NEW_KS_PLIST}" KSUpdateURL || exit 9) 398 URL=$(defaults read "${NEW_KS_PLIST}" KSUpdateURL || exit 9)
326 # The channel ID is optional. Suppress stderr to prevent Keystone from seeing 399 # The channel ID is optional. Suppress stderr to prevent Keystone from seeing
327 # possible error output. 400 # possible error output.
328 CHANNEL_ID=$(defaults read "${NEW_KS_PLIST}" KSChannelID 2>/dev/null || true) 401 CHANNEL_ID_KEY=KSChannelID
402 CHANNEL_ID=$(defaults read "${NEW_KS_PLIST}" "${CHANNEL_ID_KEY}" 2>/dev/null ||
403 true)
329 404
330 # Make sure that the update was successful by comparing the version found in 405 # Make sure that the update was successful by comparing the version found in
331 # the update with the version now on disk. 406 # the update with the version now on disk.
332 if [ "${NEW_VERSION_KS}" != "${UPD_VERSION_KS}" ]; then 407 if [ "${NEW_VERSION_KS}" != "${UPD_VERSION_KS}" ]; then
333 exit 10 408 exit 10
334 fi 409 fi
335 410
336 # Notify LaunchServices. This is not considered a critical step, and 411 # Notify LaunchServices. This is not considered a critical step, and
337 # lsregister's exit codes shouldn't be confused with this script's own. 412 # lsregister's exit codes shouldn't be confused with this script's own.
338 /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.fram ework/Support/lsregister "${DEST}" || true 413 /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.fram ework/Support/lsregister "${DEST}" || true
339 414
415 # Call ksadmin_version once to prime the global state. This is needed because
416 # subsequent calls to ksadmin_version that occur in $(...) expansions will not
417 # affect the global state (although they can read from the already-initialized
418 # global state) and thus will cause a new ksadmin --ksadmin-version process to
419 # run for each check unless the globals have been properly initialized
420 # beforehand.
421 ksadmin_version >& /dev/null || true
422
340 # Notify Keystone. 423 # Notify Keystone.
341 KSADMIN_VERSION=$(ksadmin --ksadmin-version || true) 424 if ksadmin_supports_tagpath_tagkey ; then
342 if [ -n "${KSADMIN_VERSION}" ] ; then 425 ksadmin --register \
343 # If ksadmin recognizes --ksadmin-version, it will recognize --tag. 426 -P "${PRODUCT_ID}" \
427 --version "${NEW_VERSION_KS}" \
428 --xcpath "${DEST}" \
429 --url "${URL}" \
430 --tag "${CHANNEL_ID}" \
431 --tag-path "${DEST}/Contents/Info.plist" \
432 --tag-key "${CHANNEL_ID_KEY}" || exit 11
433 elif ksadmin_supports_tag ; then
344 ksadmin --register \ 434 ksadmin --register \
345 -P "${PRODUCT_ID}" \ 435 -P "${PRODUCT_ID}" \
346 --version "${NEW_VERSION_KS}" \ 436 --version "${NEW_VERSION_KS}" \
347 --xcpath "${DEST}" \ 437 --xcpath "${DEST}" \
348 --url "${URL}" \ 438 --url "${URL}" \
349 --tag "${CHANNEL_ID}" || exit 11 439 --tag "${CHANNEL_ID}" || exit 11
350 else 440 else
351 # Older versions of ksadmin don't recognize --tag. The application will
352 # set the tag when it runs.
353 ksadmin --register \ 441 ksadmin --register \
354 -P "${PRODUCT_ID}" \ 442 -P "${PRODUCT_ID}" \
355 --version "${NEW_VERSION_KS}" \ 443 --version "${NEW_VERSION_KS}" \
356 --xcpath "${DEST}" \ 444 --xcpath "${DEST}" \
357 --url "${URL}" || exit 11 445 --url "${URL}" || exit 11
358 fi 446 fi
359 447
360 # The remaining steps are not considered critical. 448 # The remaining steps are not considered critical.
361 set +e 449 set +e
362 450
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 ([ ${OS_MAJOR} -eq 10 ] && [ ${OS_MINOR} -ge 6 ]) ; then 592 ([ ${OS_MAJOR} -eq 10 ] && [ ${OS_MINOR} -ge 6 ]) ; then
505 # On 10.6, xattr supports -r for recursive operation. 593 # On 10.6, xattr supports -r for recursive operation.
506 xattr -d -r "${QUARANTINE_ATTR}" "${DEST}" >& /dev/null 594 xattr -d -r "${QUARANTINE_ATTR}" "${DEST}" >& /dev/null
507 else 595 else
508 # On earlier systems, xattr doesn't support -r, so run xattr via find. 596 # On earlier systems, xattr doesn't support -r, so run xattr via find.
509 find "${DEST}" -exec xattr -d "${QUARANTINE_ATTR}" {} + >& /dev/null 597 find "${DEST}" -exec xattr -d "${QUARANTINE_ATTR}" {} + >& /dev/null
510 fi 598 fi
511 599
512 # Great success! 600 # Great success!
513 exit 0 601 exit 0
OLDNEW
« no previous file with comments | « chrome/chrome.gyp ('k') | chrome/tools/build/mac/keystone_install_test.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698