Chromium Code Reviews| Index: update_kernel.sh |
| diff --git a/update_kernel.sh b/update_kernel.sh |
| index d1b735daea471962299589722f609598307d39e7..f8c84ba7debeab34f0b5150fab7a28f378636b40 100755 |
| --- a/update_kernel.sh |
| +++ b/update_kernel.sh |
| @@ -16,7 +16,9 @@ |
| restart_in_chroot_if_needed $* |
| DEFINE_string board "" "Override board reported by target" |
| +DEFINE_string device "" "Override boot device reported by target" |
| DEFINE_string partition "" "Override kernel partition reported by target" |
| +DEFINE_string arch "" "Override architecture reported by target" |
| DEFINE_boolean modules false "Update modules on target" |
| DEFINE_boolean firmware false "Update firmware on target" |
| @@ -33,14 +35,21 @@ function cleanup { |
| rm -rf "${TMP}" |
| } |
| +function learn_device() { |
| + [ -n "${FLAGS_device}" ] && return |
| + remote_sh df /mnt/stateful_partition |
| + FLAGS_device=$(echo "${REMOTE_OUT}" | awk '/dev/ {print $1}' | sed s/1\$//) |
| + info "Target reports root partition is at ${FLAGS_device}<x>" |
| +} |
| + |
| # Ask the target what the kernel partition is |
| function learn_partition() { |
| [ -n "${FLAGS_partition}" ] && return |
| remote_sh cat /proc/cmdline |
| - if echo "${REMOTE_OUT}" | grep -q "/dev/sda3"; then |
| - FLAGS_partition="/dev/sda2" |
| + if echo "${REMOTE_OUT}" | egrep -q "${FLAGS_device}3"; then |
| + FLAGS_partition="${FLAGS_device}2" |
| else |
| - FLAGS_partition="/dev/sda4" |
| + FLAGS_partition="${FLAGS_device}4" |
| fi |
| if [ -z "${FLAGS_partition}" ]; then |
| error "Partition required" |
| @@ -49,6 +58,23 @@ function learn_partition() { |
| info "Target reports kernel partition is ${FLAGS_partition}" |
| } |
| +function make_kernelimage() { |
| + |
| + if [[ "${FLAGS_arch}" == "arm" ]]; then |
| + ./build_kernel_image.sh --arch=arm \ |
| + --root='/dev/${devname}${rootpart}' \ |
| + --vmlinuz=/build/${FLAGS_board}/boot/vmlinux.uimg --to new_kern.bin |
| + else |
| + vbutil_kernel --pack new_kern.bin \ |
| + --keyblock /usr/share/vboot/devkeys/kernel.keyblock \ |
| + --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \ |
| + --version 1 \ |
| + --config ../build/images/${FLAGS_board}/latest/config.txt \ |
| + --bootloader /lib64/bootstub/bootstub.efi \ |
| + --vmlinuz /build/${FLAGS_board}/boot/vmlinuz |
| + fi |
| +} |
| + |
| function main() { |
| trap cleanup EXIT |
| @@ -56,31 +82,31 @@ function main() { |
| remote_access_init |
| + learn_arch |
| + |
| learn_board |
| remote_sh uname -r -v |
| old_kernel="${REMOTE_OUT}" |
| - vbutil_kernel --pack new_kern.bin \ |
| - --keyblock /usr/share/vboot/devkeys/kernel.keyblock \ |
| - --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \ |
| - --version 1 \ |
| - --config ../build/images/"${FLAGS_board}"/latest/config.txt \ |
| - --bootloader /lib64/bootstub/bootstub.efi \ |
| - --vmlinuz /build/"${FLAGS_board}"/boot/vmlinuz |
| + make_kernelimage |
| + |
| + learn_device |
| learn_partition |
| + make_kernelimage |
| + |
| remote_cp_to new_kern.bin /tmp |
| remote_sh dd if=/tmp/new_kern.bin of="${FLAGS_partition}" |
| if [[ ${FLAGS_modules} -eq ${FLAGS_TRUE} ]]; then |
| echo "copying modules" |
| - tar -C /build/"${FLAGS_board}"/lib/modules -cjf new_modules.tar . |
| + 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
|
| - remote_cp_to new_modules.tar /tmp/ |
| + remote_cp_to /tmp/new_modules.tar /tmp/ |
| remote_sh mount -o remount,rw / |
| remote_sh tar -C /lib/modules -xjf /tmp/new_modules.tar |
| @@ -88,9 +114,9 @@ function main() { |
| if [[ ${FLAGS_firmware} -eq ${FLAGS_TRUE} ]]; then |
| echo "copying firmware" |
| - tar -C /build/"${FLAGS_board}"/lib/firmware -cjf new_firmware.tar . |
| + 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
|
| - remote_cp_to new_firmware.tar /tmp/ |
| + remote_cp_to /tmp/new_firmware.tar /tmp/ |
| remote_sh mount -o remount,rw / |
| remote_sh tar -C /lib/firmware -xjf /tmp/new_firmware.tar |
| @@ -103,4 +129,4 @@ function main() { |
| info "new kernel: ${REMOTE_OUT}" |
| } |
| -main $@ |
| +main "$@" |