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

Side by Side Diff: src/platform/installer/chromeos-setimage

Issue 2090006: Use new grub2 variables to boot from the device with the bootloader (Closed) Base URL: ssh://git@chromiumos-git//chromeos
Patch Set: respond to feedback Created 10 years, 7 months 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
« no previous file with comments | « src/platform/installer/chromeos-install ('k') | src/scripts/build_image » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/bin/sh -u
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
4 # found in the LICENSE file.
5 #
6 # A script to display or change the preferred image
7
8 # Load functions and constants for chromeos-install.
9 . "$(dirname "$0")/chromeos-common.sh" || exit 1
10 . /usr/lib/shflags || exit 1
11
12
13 # The default device is the one we booted from.
14 ROOTDEV=$(rootdev)
15 # From root partition to root block device.
16 DEFAULT_DST=$(get_block_dev_from_partition_dev ${ROOTDEV})
17
18 DEFINE_string dst "${DEFAULT_DST}" "Boot device to update"
19 DEFINE_boolean run_as_root ${FLAGS_FALSE} \
20 "Allow root to run this script (Careful, it won't prompt for a password!)"
21
22 # Parse command line
23 FLAGS "$@" || exit 1
24 eval set -- "${FLAGS_ARGV}"
25
26 set -e
27
28 # Validate args.
29 if [ -n "${@:-}" ]; then
30 if [ "$1" = "0" ] || [ "$1" = "A" ] || [ "$1" = "a" ]; then
31 newimg=0
32 elif [ "$1" = "1" ] || [ "$1" = "B" ] || [ "$1" = "b" ]; then
33 newimg=1
34 else
35 echo "Usage: $0 [A|B]" 1>&2
36 exit 1
37 fi
38 fi
39
40
41 # Don't run this as root
42 dont_run_as_root
43
44 # Check out the dst device.
45 if [ ! -b "$FLAGS_dst" ]
46 then
47 echo "Error: Unable to find block device: $FLAGS_dst"
48 exit 1
49 fi
50
51
52 # Mount the EFI System Partition
53 mountpoint=$(mktemp -d /tmp/mountesp_XXXXXXXXX)
54 tempfile=$(mktemp /tmp/grubcfg_XXXXXXXXX)
55 sudo mount ${FLAGS_dst}12 ${mountpoint}
56
57 # Make the change
58 if [ -n "${newimg:-}" ]; then
59 sed -e "s/^set default=.*/set default=$newimg/" \
60 ${mountpoint}/efi/boot/grub.cfg > ${tempfile}
61 sudo cp ${tempfile} ${mountpoint}/efi/boot/grub.cfg
62 fi
63
64 # Print the [new] default choice
65 grep -qs '^set default=0' ${mountpoint}/efi/boot/grub.cfg && echo "A"
66 grep -qs '^set default=1' ${mountpoint}/efi/boot/grub.cfg && echo "B"
67
68 # Clean up
69 sudo umount ${mountpoint}
70 rm -f ${tempfile}
71 rmdir ${mountpoint}
OLDNEW
« no previous file with comments | « src/platform/installer/chromeos-install ('k') | src/scripts/build_image » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698