Warn if kernel build directory is fresher than installed image

update_kernel will silently run and report no errors if the user
runs cros_workon_make instead of cros_workon_make --install.  As
there are times where the 'uname -a' output doesn't change between
builds (modifying modules or devicetree entries), its not always
obvious that the most recently modified kernel wasn't what was deployed.

This doesn't catch the case where the user first cros_workon's a package
but hasn't done an install (either through emerge or cros_workon_make).

BUG=None
TEST=While cros_workon:
  cros_workon_make chromeos-kernel
  - observe update_kernel warns
  cros_workon_make --install chromeos-kernel
  - no warning
  cros_workon stop chromeos-kernel
  emerge-${BOARD} -g chromeos-kernel
  - no warning
  emerge-${BOARD} chromeos-kernel
  - no warning

Change-Id: I25caa44dc82e00c9bf8703b72d09f76df3db1251
Reviewed-on: https://gerrit.chromium.org/gerrit/30214
Reviewed-by: Olof Johansson <olofj@chromium.org>
Commit-Ready: Jon Kliegman <kliegs@chromium.org>
Tested-by: Jon Kliegman <kliegs@chromium.org>
This commit is contained in:
Jonathan Kliegman 2012-08-14 12:30:49 -04:00 committed by Gerrit
parent b6fa1b32f3
commit 775bc8e3c1

View File

@ -95,6 +95,16 @@ copy_kernelimage() {
remote_sh dd if=/tmp/new_kern.bin of="${FLAGS_partition}"
}
check_kernelbuildtime() {
local version=$(readlink "/build/${FLAGS_board}/boot/vmlinuz" | cut -d- -f2-)
local build_dir="/build/${FLAGS_board}/lib/modules/${version}/build"
if [ "${build_dir}/Makefile" -nt "/build/${FLAGS_board}/boot/vmlinuz" ]; then
warn "Your build directory has been built more recently than"
warn "the installed kernel being updated to. Did you forget to"
warn "run 'cros_workon_make chromeos-kernel --install'?"
fi
}
main() {
trap cleanup EXIT
@ -114,6 +124,8 @@ main() {
old_kernel="${REMOTE_OUT}"
check_kernelbuildtime
make_kernelimage
if [[ ${REMOTE_VERITY} -eq ${FLAGS_FALSE} ]]; then