update_kernel.sh: Learn partition layout from target

Don't depend on chromeos-common.sh or disk_layout_util.sh
for these constants, since they are going away.
Instead, learn them from the target.

BUG=b:35045101
TEST=`update_kernel`

Change-Id: I8ad6e73ab08a0b7baf5f66f8bed89e0e25742a5c
Reviewed-on: https://chromium-review.googlesource.com/451543
Commit-Ready: Ian Coolidge <icoolidge@google.com>
Tested-by: Ian Coolidge <icoolidge@google.com>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/remote_access.sh b/remote_access.sh
index f6c7fa6..1cf1437 100644
--- a/remote_access.sh
+++ b/remote_access.sh
@@ -110,6 +110,7 @@
 
 # Wrapper for ssh that runs the commmand given by the args on the remote host
 # If an ssh error occurs, re-runs the ssh command.
+# Output is stored in REMOTE_OUT.
 remote_sh() {
   local ssh_status=0
   _remote_sh "$@" || ssh_status=$?
@@ -172,6 +173,12 @@
   info "Target reports arch is ${FLAGS_arch}"
 }
 
+# Discover partition numbers from the target.
+learn_partition_layout() {
+  source <(remote_sh_raw cat /usr/sbin/write_gpt.sh)
+  load_base_vars
+}
+
 # Checks whether a remote device has rebooted successfully.
 #
 # This uses a rapidly-retried SSH connection, which will wait for at most
diff --git a/update_kernel.sh b/update_kernel.sh
index d4d5465..e55e440 100755
--- a/update_kernel.sh
+++ b/update_kernel.sh
@@ -9,8 +9,6 @@
 SCRIPT_ROOT=$(dirname $(readlink -f "$0"))
 . "${SCRIPT_ROOT}/common.sh" || exit 1
 . "${SCRIPT_ROOT}/remote_access.sh" || exit 1
-# This file is sourced for partition constants.
-. "${BUILD_LIBRARY_DIR}/disk_layout_util.sh" || exit 1
 
 # Script must be run inside the chroot.
 restart_in_chroot_if_needed "$@"
@@ -192,6 +190,8 @@
 
   learn_device
 
+  learn_partition_layout
+
   learn_partition_and_ro
 
   remote_sh uname -r -v