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

Side by Side Diff: update_kernel.sh

Issue 6249004: update_kernel.sh: modify to work inside chroot (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 2
3 # Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2009-2010 The Chromium OS 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 # Script to update the kernel on a live running ChromiumOS instance. 7 # Script to update the kernel on a live running ChromiumOS instance.
8 8
9 # Load common constants. This should be the first executable line. 9 # Load common constants. This should be the first executable line.
10 # The path to common.sh should be relative to your script's location. 10 # The path to common.sh should be relative to your script's location.
11 11
12 . "$(dirname $0)/common.sh" 12 . "$(dirname $0)/common.sh"
13 . "$(dirname $0)/remote_access.sh" 13 . "$(dirname $0)/remote_access.sh"
14 14
15 # Script must be run inside the chroot.
16 restart_in_chroot_if_needed $*
17
15 DEFINE_string board "" "Override board reported by target" 18 DEFINE_string board "" "Override board reported by target"
16 DEFINE_string partition "" "Override kernel partition reported by target" 19 DEFINE_string partition "" "Override kernel partition reported by target"
17 DEFINE_boolean modules false "Update modules on target" 20 DEFINE_boolean modules false "Update modules on target"
18 DEFINE_boolean firmware false "Update firmware on target" 21 DEFINE_boolean firmware false "Update firmware on target"
19 22
23 # Parse command line.
24 FLAGS "$@" || exit 1
25 eval set -- "${FLAGS_ARGV}"
26
27 # Only now can we die on error. shflags functions leak non-zero error codes,
28 # so will die prematurely if 'set -e' is specified before now.
29 set -e
30
20 function cleanup { 31 function cleanup {
21 cleanup_remote_access 32 cleanup_remote_access
22 rm -rf "${TMP}" 33 rm -rf "${TMP}"
23 } 34 }
24 35
25 # Ask the target what the kernel partition is 36 # Ask the target what the kernel partition is
26 function learn_partition() { 37 function learn_partition() {
27 [ -n "${FLAGS_partition}" ] && return 38 [ -n "${FLAGS_partition}" ] && return
28 remote_sh cat /proc/cmdline 39 remote_sh cat /proc/cmdline
29 if echo "${REMOTE_OUT}" | grep -q "/dev/sda3"; then 40 if echo "${REMOTE_OUT}" | grep -q "/dev/sda3"; then
30 FLAGS_partition="/dev/sda2" 41 FLAGS_partition="/dev/sda2"
31 else 42 else
32 FLAGS_partition="/dev/sda4" 43 FLAGS_partition="/dev/sda4"
33 fi 44 fi
34 if [ -z "${FLAGS_partition}" ]; then 45 if [ -z "${FLAGS_partition}" ]; then
35 error "Partition required" 46 error "Partition required"
36 exit 1 47 exit 1
37 fi 48 fi
38 info "Target reports kernel partition is ${FLAGS_partition}" 49 info "Target reports kernel partition is ${FLAGS_partition}"
39 } 50 }
40 51
41 function main() { 52 function main() {
42 assert_outside_chroot
43
44 cd $(dirname "$0")
45
46 FLAGS "$@" || exit 1
47 eval set -- "${FLAGS_ARGV}"
48
49 set -e
50
51 trap cleanup EXIT 53 trap cleanup EXIT
52 54
53 TMP=$(mktemp -d /tmp/image_to_live.XXXX) 55 TMP=$(mktemp -d /tmp/image_to_live.XXXX)
54 56
55 remote_access_init 57 remote_access_init
56 58
57 learn_board 59 learn_board
58 60
59 remote_sh uname -r -v 61 remote_sh uname -r -v
60 62
61 old_kernel="${REMOTE_OUT}" 63 old_kernel="${REMOTE_OUT}"
62 64
63 cmd="vbutil_kernel --pack new_kern.bin \ 65 vbutil_kernel --pack new_kern.bin \
64 --keyblock /usr/share/vboot/devkeys/kernel.keyblock \ 66 --keyblock /usr/share/vboot/devkeys/kernel.keyblock \
65 --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \ 67 --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
66 --version 1 \ 68 --version 1 \
67 --config ../build/images/${FLAGS_board}/latest/config.txt \ 69 --config ../build/images/"${FLAGS_board}"/latest/config.txt \
68 --bootloader /lib64/bootstub/bootstub.efi \ 70 --bootloader /lib64/bootstub/bootstub.efi \
69 --vmlinuz /build/${FLAGS_board}/boot/vmlinuz" 71 --vmlinuz /build/"${FLAGS_board}"/boot/vmlinuz
70
71 ./enter_chroot.sh -- ${cmd}
72 72
73 learn_partition 73 learn_partition
74 74
75 remote_cp_to new_kern.bin /tmp 75 remote_cp_to new_kern.bin /tmp
76 76
77 remote_sh dd if=/tmp/new_kern.bin of="${FLAGS_partition}" 77 remote_sh dd if=/tmp/new_kern.bin of="${FLAGS_partition}"
78 78
79 if [[ ${FLAGS_modules} -eq ${FLAGS_TRUE} ]]; then 79 if [[ ${FLAGS_modules} -eq ${FLAGS_TRUE} ]]; then
80 echo "copying modules" 80 echo "copying modules"
81 cmd="tar -C /build/${FLAGS_board}/lib/modules -cjf new_modules.tar ." 81 tar -C /build/"${FLAGS_board}"/lib/modules -cjf new_modules.tar .
82 ./enter_chroot.sh -- ${cmd}
83 82
84 remote_cp_to new_modules.tar /tmp/ 83 remote_cp_to new_modules.tar /tmp/
85 84
86 remote_sh mount -o remount,rw / 85 remote_sh mount -o remount,rw /
87 remote_sh tar -C /lib/modules -xjf /tmp/new_modules.tar 86 remote_sh tar -C /lib/modules -xjf /tmp/new_modules.tar
88 fi 87 fi
89 88
90 if [[ ${FLAGS_firmware} -eq ${FLAGS_TRUE} ]]; then 89 if [[ ${FLAGS_firmware} -eq ${FLAGS_TRUE} ]]; then
91 echo "copying firmware" 90 echo "copying firmware"
92 cmd="tar -C /build/${FLAGS_board}/lib/firmware -cjf new_firmware.tar ." 91 tar -C /build/"${FLAGS_board}"/lib/firmware -cjf new_firmware.tar .
93 ./enter_chroot.sh -- ${cmd}
94 92
95 remote_cp_to new_firmware.tar /tmp/ 93 remote_cp_to new_firmware.tar /tmp/
96 94
97 remote_sh mount -o remount,rw / 95 remote_sh mount -o remount,rw /
98 remote_sh tar -C /lib/firmware -xjf /tmp/new_firmware.tar 96 remote_sh tar -C /lib/firmware -xjf /tmp/new_firmware.tar
99 fi 97 fi
100 98
101 remote_reboot 99 remote_reboot
102 100
103 remote_sh uname -r -v 101 remote_sh uname -r -v
104
105 info "old kernel: ${old_kernel}" 102 info "old kernel: ${old_kernel}"
106
107 info "new kernel: ${REMOTE_OUT}" 103 info "new kernel: ${REMOTE_OUT}"
108 } 104 }
109 105
110 main $@ 106 main $@
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698