| OLD | NEW |
| 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 fi | 300 fi |
| 301 else | 301 else |
| 302 chown -Rh root:wheel "${DEST}" >& /dev/null | 302 chown -Rh root:wheel "${DEST}" >& /dev/null |
| 303 fi | 303 fi |
| 304 | 304 |
| 305 chmod -R "${CHMOD_MODE}" "${DEST}" >& /dev/null | 305 chmod -R "${CHMOD_MODE}" "${DEST}" >& /dev/null |
| 306 | 306 |
| 307 # On the Mac, or at least on HFS+, symbolic link permissions are significant, | 307 # On the Mac, or at least on HFS+, symbolic link permissions are significant, |
| 308 # but chmod -R and -h can't be used together on the Mac. Do another pass to | 308 # but chmod -R and -h can't be used together on the Mac. Do another pass to |
| 309 # fix the permissions on any symbolic links. | 309 # fix the permissions on any symbolic links. |
| 310 find "${DEST}" -type l -exec chmod -h "${CHMOD_MODE}" {} \; >& /dev/null | 310 find "${DEST}" -type l -exec chmod -h "${CHMOD_MODE}" {} + >& /dev/null |
| 311 |
| 312 # Host OS version check, to be able to take advantage of features on newer |
| 313 # systems and fall back to slow ways of doing things on older systems. |
| 314 OS_VERSION=$(sw_vers -productVersion) |
| 315 OS_MAJOR=$(sed -Ene 's/^([0-9]+).*/\1/p' <<< ${OS_VERSION}) |
| 316 OS_MINOR=$(sed -Ene 's/^([0-9]+)\.([0-9]+).*/\2/p' <<< ${OS_VERSION}) |
| 317 |
| 318 # If an update is triggered from within the application itself, the update |
| 319 # process inherits the quarantine bit (LSFileQuarantineEnabled). Any files or |
| 320 # directories created during the update will be quarantined in that case, |
| 321 # which may cause Launch Services to display quarantine UI. That's bad, |
| 322 # especially if it happens when the outer .app launches a quarantined inner |
| 323 # helper. If the application is already on the system and is being updated, |
| 324 # then it can be assumed that it should not be quarantined. Use xattr to drop |
| 325 # the quarantine attribute. |
| 326 # |
| 327 # TODO(mark): Instead of letting the quarantine attribute be set and then |
| 328 # dropping it here, figure out a way to get the update process to run without |
| 329 # LSFileQuarantineEnabled even when triggering an update from within the |
| 330 # application. |
| 331 QUARANTINE_ATTR=com.apple.quarantine |
| 332 if [ ${OS_MAJOR} -gt 10 ] || |
| 333 ([ ${OS_MAJOR} -eq 10 ] && [ ${OS_MINOR} -ge 6 ]) ; then |
| 334 # On 10.6, xattr supports -r for recursive operation. |
| 335 xattr -d -r "${QUARANTINE_ATTR}" "${DEST}" >& /dev/null |
| 336 else |
| 337 # On earlier systems, xattr doesn't support -r, so run xattr via find. |
| 338 find "${DEST}" -exec xattr -d "${QUARANTINE_ATTR}" {} + >& /dev/null |
| 339 fi |
| 311 | 340 |
| 312 # Great success! | 341 # Great success! |
| 313 exit 0 | 342 exit 0 |
| OLD | NEW |