Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/bin/sh -p | 1 #!/bin/sh -p |
| 2 | 2 |
| 3 # Copyright 2016 The Chromium Authors. All rights reserved. | 3 # Copyright 2016 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 # This script will be called by the installer application to copy Google | 7 # This script will be called by the installer application to copy Google |
| 8 # Chrome.app into the proper /Applications folder. This script may run as root. | 8 # Chrome.app into the proper /Applications folder. This script may run as root. |
| 9 # | 9 # |
| 10 # When running as root, this script will be invoked with the real user ID set | 10 # When running as root, this script will be invoked with the real user ID set |
| 11 # to the user's ID, but the effective user ID set to 0 (root). bash -p is | 11 # to the user's ID, but the effective user ID set to 0 (root). bash -p is |
| 12 # used on the first line to prevent bash from setting the effective user ID to | 12 # used on the first line to prevent bash from setting the effective user ID to |
| 13 # the real user ID (dropping root privileges). | 13 # the real user ID (dropping root privileges). |
| 14 | 14 |
| 15 # The 'e' flag causes the script to terminate if it comes across an error while | 15 # 'e': terminate if error arises |
| 16 # running. The 'u' flag will raise an error if a variable isn't set. | 16 # 'u': raise an error if a variable isn't set |
| 17 # 'u pipefail' will set the return exit code to the last non-zero error code. | 17 # 'o pipefail': set the return exit code to the last non-zero error code |
| 18 set -euo pipefail | 18 set -euo pipefail |
| 19 | 19 |
| 20 # Waits for the main app to pass the path to the app bundle inside the mounted | 20 # Waits for the main app to pass the path to the app bundle inside the mounted |
| 21 # disk image. | 21 # disk image. |
| 22 read -r SRC | 22 read -r SRC |
| 23 | 23 |
| 24 DEST="${1}" | 24 DEST="${1}" |
| 25 APPBUNDLENAME=$(basename "${SRC}") | 25 APPBUNDLENAME=$(basename "${SRC}") |
| 26 FULL_DEST="${DEST}"/"${APPBUNDLENAME}" | 26 FULL_DEST="${DEST}"/"${APPBUNDLENAME}" |
| 27 | 27 |
| 28 # Starts the copy | 28 # Starts the copy |
| 29 # The 'l' flag tells rsync to copy symlinks as symlinks. 'r' is for recursive, | 29 # 'l': copy symlinks as symlinks |
| 30 # so copy all files, 'p' is to preserve permisisons. 't' is to preserve times. | 30 # 'r': recursive copy |
| 31 # 'q' is for quiet mode so rynsc will only log to console if an error occurs. | 31 # 'p': preserve permissions |
| 32 # 't': preserve times | |
| 33 # 'q': quiet mode, so rynsc will only log to console if an error occurs | |
|
Sidney San Martín
2016/08/31 21:20:16
I really like these comments which describe each f
| |
| 32 rsync -lrptq "${SRC}" "${DEST}" | 34 rsync -lrptq "${SRC}" "${DEST}" |
| 33 | 35 |
| 34 # If this script is run as root, change ownership to root and set elevated | 36 # If this script is run as root, change ownership to root and set elevated |
| 35 # permissions. | 37 # permissions. |
| 36 if [ "${EUID}" -eq 0 ] ; then | 38 if [ "${EUID}" -eq 0 ] ; then |
| 37 chown -Rh root:admin "${FULL_DEST}" | 39 chown -Rh root:admin "${FULL_DEST}" |
| 38 chmod -R a+rX,ug+w,o-w "${FULL_DEST}" | 40 chmod -R a+rX,ug+w,o-w "${FULL_DEST}" |
| 39 fi | 41 fi |
| 40 | 42 |
| 41 exit 0 | 43 exit 0 |
| OLD | NEW |