update_kernel: Allow you to specify the "root offset"

If you're using a nonstandard kernel partition you'll probably want to
modify where the root partition is relative to it.  Ideally
update_kernel could do this automatically, but since this script is
officially deprecated (see http://crosreview.com/203165) we'll just
add a flag.

BUG=None
TEST=update_kernel.sh --partition=/dev/mmcblk0p4 --rootoff=-1 \
  --remote=${HOST} --bootonce

Change-Id: I2a3d1abe4fca92ccaaa7d32730866dc51da723da
Reviewed-on: https://chromium-review.googlesource.com/207166
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
Commit-Queue: Doug Anderson <dianders@chromium.org>
Tested-by: Doug Anderson <dianders@chromium.org>
diff --git a/update_kernel.sh b/update_kernel.sh
index c255388..93a44d9 100755
--- a/update_kernel.sh
+++ b/update_kernel.sh
@@ -16,6 +16,7 @@
 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 rootoff "" "Override root offset"
 DEFINE_string arch "" "Override architecture reported by target"
 DEFINE_boolean reboot $FLAGS_TRUE "Reboot system after update"
 DEFINE_boolean vboot $FLAGS_TRUE "Update the vboot kernel"
@@ -78,7 +79,12 @@
     info "Using remote bootargs"
     remote_sh cat /proc/cmdline && echo "${REMOTE_OUT}"
   else
-    cat "${SRC_ROOT}/build/images/${FLAGS_board}/latest/config.txt"
+    if [ -n "${FLAGS_rootoff}" ]; then
+      sed "s/PARTNROFF=1/PARTNROFF=${FLAGS_rootoff}/" \
+          "${SRC_ROOT}/build/images/${FLAGS_board}/latest/config.txt"
+    else
+      cat "${SRC_ROOT}/build/images/${FLAGS_board}/latest/config.txt"
+    fi
   fi
 }