cros_choose_profile: use the sysroot configuration.

Instead of using the board name or brick name, get ARCH and the overlay
stack from the sysroot's configuration file.

BUG=brillo:661
TEST=trybots.
TEST=manual: can select the minimal profile on panther.

CQ-DEPEND=CL:262921

Change-Id: I6f5300a79aa59582bb0580ee234b9c945458a437
Reviewed-on: https://chromium-review.googlesource.com/262767
Tested-by: Bertrand Simonnet <bsimonnet@chromium.org>
Reviewed-by: Steve Fung <stevefung@chromium.org>
Commit-Queue: Bertrand Simonnet <bsimonnet@chromium.org>
Trybot-Ready: Bertrand Simonnet <bsimonnet@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/host/cros_choose_profile b/host/cros_choose_profile
index 712d777..99a1255 100755
--- a/host/cros_choose_profile
+++ b/host/cros_choose_profile
@@ -28,7 +28,8 @@
 
 # Flags
 DEFINE_string board "$DEFAULT_BOARD" "The name of the board to set up."
-DEFINE_string board_overlay "" "Location of the board overlay."
+# TODO(bsimonnet): Remove this once setup_board has been updated.
+DEFINE_string board_overlay "" "Deprecated. DO NOT USE THIS."
 DEFINE_string variant "" "Board variant."
 DEFINE_string profile "" "The portage configuration profile to use."
 DEFINE_string board_root "" "Board root where the profile should be created."
@@ -42,8 +43,9 @@
 # so will die prematurely if 'set -e' is specified before now.
 set -e
 
-if [[ -z "${FLAGS_board}" ]] && [[ -z "${FLAGS_brick}" ]]; then
-  error "--board or --brick required."
+if [[ -z "${FLAGS_board}" ]] && [[ -z "${FLAGS_brick}" ]] && \
+  [[ -z "${FLAGS_board_root}" ]]; then
+  error "--board, --brick or --board_root required."
   exit 1
 elif [[ -n "${FLAGS_board}" ]] && [[ -n "${FLAGS_brick}" ]]; then
   error "--board and --brick are incompatible."
@@ -63,20 +65,14 @@
 fi
 
 #
-# Construct board overlay list.
+# Get board overlay list.
 #
-if [[ -n "${FLAGS_brick}" ]]; then
-  BOARD_OVERLAY_LIST=$(cros_list_overlays --brick "${FLAGS_brick}")
-else
-  BOARD_OVERLAY_LIST=$(cros_list_overlays \
-    --board "${BOARD_VARIANT}" \
-    --board_overlay "${FLAGS_board_overlay}")
-fi
+BOARD_OVERLAY_LIST="$(get_sysroot_config "${BOARD_ROOT}" "BOARD_OVERLAY")"
 
 #
-# Compute ARCH
+# Get ARCH
 #
-ARCH=$(get_board_arch "${FLAGS_brick:-${BOARD}}") || exit 1
+ARCH=$(get_sysroot_config "${BOARD_ROOT}" "ARCH") || exit 1
 
 # The profile directory comes from many possible locations, the <overlay>
 # values below can be any of the board overlays, public, private, primary