| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 echo "Error: Unable to find block device: $FLAGS_dst" | 106 echo "Error: Unable to find block device: $FLAGS_dst" |
| 107 exit 1 | 107 exit 1 |
| 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 # Cleans up a device and unmount if required. |
| 116 cleanup_loop() { | 117 cleanup_loop() { |
| 117 local dev="$1" | 118 local dev="$1" |
| 118 if [ -z "$dev" ]; then | 119 local need_umount="$2" |
| 120 if [ -z "${dev}" ]; then |
| 119 return 0 | 121 return 0 |
| 120 fi | 122 fi |
| 121 (sudo umount "$dev" || true) | 123 if [ ${need_umount} -eq ${FLAGS_TRUE} ]; then |
| 122 (sudo losetup -d "$dev" || true) | 124 sudo umount -d "${dev}" || true |
| 125 elif [ ${need_umount} -eq ${FLAGS_FALSE} ]; then |
| 126 sudo losetup -d "${dev}" || true |
| 127 else |
| 128 echo "INTERNAL ERROR: unknown parameter for cleanup_loop: ${need_umount}" >&
2 |
| 129 fi |
| 123 } | 130 } |
| 124 | 131 |
| 125 cleanup() { | 132 cleanup() { |
| 126 cleanup_loop "${ESP_LOOP}" | 133 # Currently only ESP may be mounted. KERN and ROOT are never mounted. |
| 134 cleanup_loop "${ESP_LOOP}" "${FLAGS_TRUE}" |
| 127 ESP_LOOP= | 135 ESP_LOOP= |
| 128 cleanup_loop "${KERN_LOOP}" | 136 cleanup_loop "${KERN_LOOP}" "${FLAGS_FALSE}" |
| 129 KERN_LOOP= | 137 KERN_LOOP= |
| 130 cleanup_loop "${ROOT_LOOP}" | 138 cleanup_loop "${ROOT_LOOP}" "${FLAGS_FALSE}" |
| 131 ROOT_LOOP= | 139 ROOT_LOOP= |
| 132 | 140 |
| 133 # Failing to clean this up isn't the worst. | 141 # Failing to clean this up isn't the worst. |
| 134 if [ -n "${ESP_TMP_DIR}" ]; then | 142 if [ -n "${ESP_TMP_DIR}" ]; then |
| 135 rmdir "${ESP_TMP_DIR}" || true | 143 rmdir "${ESP_TMP_DIR}" || true |
| 136 fi | 144 fi |
| 137 | 145 |
| 138 rm -f ${tempfile} || true | 146 rm -f ${tempfile} || true |
| 139 } | 147 } |
| 140 | 148 |
| (...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)" | 360 grep -qs '^set default=3' ${mountpoint}/efi/boot/grub.cfg && echo "B (verified)" |
| 353 | 361 |
| 354 echo "Current legacy boot default is:" | 362 echo "Current legacy boot default is:" |
| 355 # Print the [new] default choice | 363 # Print the [new] default choice |
| 356 grep -qs 's-hd\.A$' ${mountpoint}/syslinux/default.cfg && echo "A" | 364 grep -qs 's-hd\.A$' ${mountpoint}/syslinux/default.cfg && echo "A" |
| 357 grep -qs 's-hd\.B$' ${mountpoint}/syslinux/default.cfg && echo "B" | 365 grep -qs 's-hd\.B$' ${mountpoint}/syslinux/default.cfg && echo "B" |
| 358 grep -qs 'vhd\.A$' ${mountpoint}/syslinux/default.cfg && echo "A (verified)" | 366 grep -qs 'vhd\.A$' ${mountpoint}/syslinux/default.cfg && echo "A (verified)" |
| 359 grep -qs 'vhd\.B$' ${mountpoint}/syslinux/default.cfg && echo "B (verified)" | 367 grep -qs 'vhd\.B$' ${mountpoint}/syslinux/default.cfg && echo "B (verified)" |
| 360 | 368 |
| 361 exit $EXIT_CODE | 369 exit $EXIT_CODE |
| OLD | NEW |