Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/bin/sh -u | 1 #!/bin/sh -u |
| 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 # | 5 # |
| 6 # A script to display or change the preferred image | 6 # A script to display or change the preferred image |
| 7 | 7 |
| 8 # Load functions and constants for chromeos-install. | 8 # Load functions and constants for chromeos-install. |
| 9 . "$(dirname "$0")/chromeos-common.sh" || exit 1 | 9 . "$(dirname "$0")/chromeos-common.sh" || exit 1 |
| 10 if [ -e /usr/lib/shflags ]; then | 10 if [ -e /usr/lib/shflags ]; then |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 fi | 108 fi |
| 109 | 109 |
| 110 # Setup loop devices so that we don't get burned by the kernel not knowing | 110 # Setup loop devices so that we don't get burned by the kernel not knowing |
| 111 # about updated partition changes. | 111 # about updated partition changes. |
| 112 ESP_LOOP= | 112 ESP_LOOP= |
| 113 ROOT_LOOP= | 113 ROOT_LOOP= |
| 114 KERN_LOOP= | 114 KERN_LOOP= |
| 115 | 115 |
| 116 cleanup_loop() { | 116 cleanup_loop() { |
| 117 local dev="$1" | 117 local dev="$1" |
| 118 local cleanup_command="$2" | |
| 118 if [ -z "$dev" ]; then | 119 if [ -z "$dev" ]; then |
| 119 return 0 | 120 return 0 |
| 120 fi | 121 fi |
| 121 (sudo umount "$dev" || true) | 122 if [ -n "$cleanup_command" ]; then |
| 123 (sudo "$cleanup_command" "$dev" || true) | |
| 124 fi | |
| 122 (sudo losetup -d "$dev" || true) | 125 (sudo losetup -d "$dev" || true) |
| 123 } | 126 } |
| 124 | 127 |
| 125 cleanup() { | 128 cleanup() { |
| 126 cleanup_loop "${ESP_LOOP}" | 129 # Currently only ESP may be mounted. KERN and ROOT are never mounted. |
| 130 cleanup_loop "${ESP_LOOP}" "umount" | |
| 127 ESP_LOOP= | 131 ESP_LOOP= |
| 128 cleanup_loop "${KERN_LOOP}" | 132 cleanup_loop "${KERN_LOOP}" "" |
|
Will Drewry
2010/11/18 09:20:15
Do you need to specify empty $2s here?
Hung-Te
2010/11/18 09:49:02
Although it may be not necessary, I think an expli
| |
| 129 KERN_LOOP= | 133 KERN_LOOP= |
| 130 cleanup_loop "${ROOT_LOOP}" | 134 cleanup_loop "${ROOT_LOOP}" "" |
| 131 ROOT_LOOP= | 135 ROOT_LOOP= |
| 132 | 136 |
| 133 # Failing to clean this up isn't the worst. | 137 # Failing to clean this up isn't the worst. |
| 134 if [ -n "${ESP_TMP_DIR}" ]; then | 138 if [ -n "${ESP_TMP_DIR}" ]; then |
| 135 rmdir "${ESP_TMP_DIR}" || true | 139 rmdir "${ESP_TMP_DIR}" || true |
| 136 fi | 140 fi |
| 137 | 141 |
| 138 rm -f ${tempfile} || true | 142 rm -f ${tempfile} || true |
| 139 } | 143 } |
| 140 | 144 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 grep -qs '^set default=3' ${mountpoint}/efi/boot/grub.cfg && echo "B (verified)" | 356 grep -qs '^set default=3' ${mountpoint}/efi/boot/grub.cfg && echo "B (verified)" |
| 353 | 357 |
| 354 echo "Current legacy boot default is:" | 358 echo "Current legacy boot default is:" |
| 355 # Print the [new] default choice | 359 # Print the [new] default choice |
| 356 grep -qs 's-hd\.A$' ${mountpoint}/syslinux/default.cfg && echo "A" | 360 grep -qs 's-hd\.A$' ${mountpoint}/syslinux/default.cfg && echo "A" |
| 357 grep -qs 's-hd\.B$' ${mountpoint}/syslinux/default.cfg && echo "B" | 361 grep -qs 's-hd\.B$' ${mountpoint}/syslinux/default.cfg && echo "B" |
| 358 grep -qs 'vhd\.A$' ${mountpoint}/syslinux/default.cfg && echo "A (verified)" | 362 grep -qs 'vhd\.A$' ${mountpoint}/syslinux/default.cfg && echo "A (verified)" |
| 359 grep -qs 'vhd\.B$' ${mountpoint}/syslinux/default.cfg && echo "B (verified)" | 363 grep -qs 'vhd\.B$' ${mountpoint}/syslinux/default.cfg && echo "B (verified)" |
| 360 | 364 |
| 361 exit $EXIT_CODE | 365 exit $EXIT_CODE |
| OLD | NEW |