update_kernel: Learn arch from board build

The boot.desc file in a build contains the information about what arch
the build is for. Parse this file for the architecture and pass it along
to vbutil. This avoids SSH to the DUT just to run uname.

BUG=None
TEST=update kernel on Cheza works

Change-Id: Ia9a43dff54943ee18360631b25a35c832743eea5
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1720708
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/remote_access.sh b/remote_access.sh
index 251621f..4e9f548 100644
--- a/remote_access.sh
+++ b/remote_access.sh
@@ -177,17 +177,6 @@
   info "Target reports board is ${FLAGS_board}"
 }
 
-learn_arch() {
-  [ -n "${FLAGS_arch}" ] && return
-  remote_sh uname -m
-  FLAGS_arch=$(echo "${REMOTE_OUT}" | sed -e s/armv7l/arm/ -e s/i686/x86/ )
-  if [ -z "${FLAGS_arch}" ]; then
-    error "Arch required"
-    exit 1
-  fi
-  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)
diff --git a/update_kernel.sh b/update_kernel.sh
index 4944535..98165ef 100755
--- a/update_kernel.sh
+++ b/update_kernel.sh
@@ -139,6 +139,17 @@
   fi
 }
 
+learn_arch() {
+  [ -n "${FLAGS_arch}" ] && return
+  FLAGS_arch=$(sed -n -E 's/^ *--arch="(.*)"/\1/p' \
+         "${SRC_ROOT}/build/images/${FLAGS_board}/latest/boot.desc")
+  if [ -z "${FLAGS_arch}" ]; then
+    error "Arch required"
+    exit 1
+  fi
+  info "Target reports arch is ${FLAGS_arch}"
+}
+
 make_kernelimage() {
   local bootloader_path
   local kernel_image
@@ -271,10 +282,10 @@
 
   remote_access_init
 
-  learn_arch
-
   learn_board
 
+  learn_arch
+
   learn_device
 
   learn_partition_layout