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

Side by Side Diff: update_kernel.sh

Issue 6031005: update_kernel: first cut at arm support (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git@master
Patch Set: Fixed comments from first round 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 | « remote_access.sh ('k') | 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. 15 # Script must be run inside the chroot.
16 restart_in_chroot_if_needed $* 16 restart_in_chroot_if_needed $*
17 17
18 DEFINE_string board "" "Override board reported by target" 18 DEFINE_string board "" "Override board reported by target"
19 DEFINE_string device "" "Override boot device reported by target"
19 DEFINE_string partition "" "Override kernel partition reported by target" 20 DEFINE_string partition "" "Override kernel partition reported by target"
21 DEFINE_string arch "" "Override architecture reported by target"
20 DEFINE_boolean modules false "Update modules on target" 22 DEFINE_boolean modules false "Update modules on target"
21 DEFINE_boolean firmware false "Update firmware on target" 23 DEFINE_boolean firmware false "Update firmware on target"
22 24
23 # Parse command line. 25 # Parse command line.
24 FLAGS "$@" || exit 1 26 FLAGS "$@" || exit 1
25 eval set -- "${FLAGS_ARGV}" 27 eval set -- "${FLAGS_ARGV}"
26 28
27 # Only now can we die on error. shflags functions leak non-zero error codes, 29 # 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. 30 # so will die prematurely if 'set -e' is specified before now.
29 set -e 31 set -e
30 32
31 function cleanup { 33 function cleanup {
32 cleanup_remote_access 34 cleanup_remote_access
33 rm -rf "${TMP}" 35 rm -rf "${TMP}"
34 } 36 }
35 37
38 function learn_device() {
39 [ -n "${FLAGS_device}" ] && return
40 remote_sh df /mnt/stateful_partition
41 FLAGS_device=$(echo "${REMOTE_OUT}" | awk '/dev/ {print $1}' | sed s/1\$//)
42 info "Target reports root partition is at ${FLAGS_device}<x>"
43 }
44
36 # Ask the target what the kernel partition is 45 # Ask the target what the kernel partition is
37 function learn_partition() { 46 function learn_partition() {
38 [ -n "${FLAGS_partition}" ] && return 47 [ -n "${FLAGS_partition}" ] && return
39 remote_sh cat /proc/cmdline 48 remote_sh cat /proc/cmdline
40 if echo "${REMOTE_OUT}" | grep -q "/dev/sda3"; then 49 if echo "${REMOTE_OUT}" | egrep -q "${FLAGS_device}3"; then
41 FLAGS_partition="/dev/sda2" 50 FLAGS_partition="${FLAGS_device}2"
42 else 51 else
43 FLAGS_partition="/dev/sda4" 52 FLAGS_partition="${FLAGS_device}4"
44 fi 53 fi
45 if [ -z "${FLAGS_partition}" ]; then 54 if [ -z "${FLAGS_partition}" ]; then
46 error "Partition required" 55 error "Partition required"
47 exit 1 56 exit 1
48 fi 57 fi
49 info "Target reports kernel partition is ${FLAGS_partition}" 58 info "Target reports kernel partition is ${FLAGS_partition}"
50 } 59 }
51 60
61 function make_kernelimage() {
62
63 if [[ "${FLAGS_arch}" == "arm" ]]; then
64 ./build_kernel_image.sh --arch=arm \
65 --root='/dev/${devname}${rootpart}' \
66 --vmlinuz=/build/${FLAGS_board}/boot/vmlinux.uimg --to new_kern.bin
67 else
68 vbutil_kernel --pack new_kern.bin \
69 --keyblock /usr/share/vboot/devkeys/kernel.keyblock \
70 --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
71 --version 1 \
72 --config ../build/images/${FLAGS_board}/latest/config.txt \
73 --bootloader /lib64/bootstub/bootstub.efi \
74 --vmlinuz /build/${FLAGS_board}/boot/vmlinuz
75 fi
76 }
77
52 function main() { 78 function main() {
53 trap cleanup EXIT 79 trap cleanup EXIT
54 80
55 TMP=$(mktemp -d /tmp/image_to_live.XXXX) 81 TMP=$(mktemp -d /tmp/image_to_live.XXXX)
56 82
57 remote_access_init 83 remote_access_init
58 84
85 learn_arch
86
59 learn_board 87 learn_board
60 88
61 remote_sh uname -r -v 89 remote_sh uname -r -v
62 90
63 old_kernel="${REMOTE_OUT}" 91 old_kernel="${REMOTE_OUT}"
64 92
65 vbutil_kernel --pack new_kern.bin \ 93 make_kernelimage
66 --keyblock /usr/share/vboot/devkeys/kernel.keyblock \ 94
67 --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \ 95 learn_device
68 --version 1 \
69 --config ../build/images/"${FLAGS_board}"/latest/config.txt \
70 --bootloader /lib64/bootstub/bootstub.efi \
71 --vmlinuz /build/"${FLAGS_board}"/boot/vmlinuz
72 96
73 learn_partition 97 learn_partition
74 98
99 make_kernelimage
100
75 remote_cp_to new_kern.bin /tmp 101 remote_cp_to new_kern.bin /tmp
76 102
77 remote_sh dd if=/tmp/new_kern.bin of="${FLAGS_partition}" 103 remote_sh dd if=/tmp/new_kern.bin of="${FLAGS_partition}"
78 104
79 if [[ ${FLAGS_modules} -eq ${FLAGS_TRUE} ]]; then 105 if [[ ${FLAGS_modules} -eq ${FLAGS_TRUE} ]]; then
80 echo "copying modules" 106 echo "copying modules"
81 tar -C /build/"${FLAGS_board}"/lib/modules -cjf new_modules.tar . 107 sudo tar -C /build/"${FLAGS_board}"/lib/modules -cjf /tmp/new_modules.tar .
Mandeep Singh Baines 2011/01/21 21:59:09 Maybe scp the tar file to the target to avoid runn
82 108
83 remote_cp_to new_modules.tar /tmp/ 109 remote_cp_to /tmp/new_modules.tar /tmp/
84 110
85 remote_sh mount -o remount,rw / 111 remote_sh mount -o remount,rw /
86 remote_sh tar -C /lib/modules -xjf /tmp/new_modules.tar 112 remote_sh tar -C /lib/modules -xjf /tmp/new_modules.tar
87 fi 113 fi
88 114
89 if [[ ${FLAGS_firmware} -eq ${FLAGS_TRUE} ]]; then 115 if [[ ${FLAGS_firmware} -eq ${FLAGS_TRUE} ]]; then
90 echo "copying firmware" 116 echo "copying firmware"
91 tar -C /build/"${FLAGS_board}"/lib/firmware -cjf new_firmware.tar . 117 sudo tar -C /build/"${FLAGS_board}"/lib/firmware -cjf /tmp/new_firmware.tar .
Mandeep Singh Baines 2011/01/21 21:59:09 Maybe scp the tar file to the target to avoid runn
92 118
93 remote_cp_to new_firmware.tar /tmp/ 119 remote_cp_to /tmp/new_firmware.tar /tmp/
94 120
95 remote_sh mount -o remount,rw / 121 remote_sh mount -o remount,rw /
96 remote_sh tar -C /lib/firmware -xjf /tmp/new_firmware.tar 122 remote_sh tar -C /lib/firmware -xjf /tmp/new_firmware.tar
97 fi 123 fi
98 124
99 remote_reboot 125 remote_reboot
100 126
101 remote_sh uname -r -v 127 remote_sh uname -r -v
102 info "old kernel: ${old_kernel}" 128 info "old kernel: ${old_kernel}"
103 info "new kernel: ${REMOTE_OUT}" 129 info "new kernel: ${REMOTE_OUT}"
104 } 130 }
105 131
106 main $@ 132 main "$@"
OLDNEW
« no previous file with comments | « remote_access.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698