cros_choose_profile: do nothing if selected profile is the same

This lets us not worry about calling this script if the computed
path hasn't changed which simplifies calling code.

TEST=running multiple times doesn't warn:
	cros_choose_profile --board stumpy --profile ''
TEST=running warns:
	cros_choose_profile --board stumpy --profile ''
	cros_choose_profile --board stumpy --profile 'kernel-next'

Change-Id: Ib052b4a6163a013739dea22abc30c32d3b4c4fc8
Reviewed-by: Chris Sosa <>
Commit-Ready: Mike Frysinger <>
Tested-by: Mike Frysinger <>
diff --git a/host/cros_choose_profile b/host/cros_choose_profile
index 0b2476f..0ba1c08 100755
--- a/host/cros_choose_profile
+++ b/host/cros_choose_profile
@@ -136,7 +136,8 @@
   warn "will fail"
-if [ -e "${MAKE_PROFILE}" ]; then
+CURR_PROFILE=$(readlink "${MAKE_PROFILE}" 2>/dev/null)
+if [[ ${CURR_PROFILE} != "${PROFILES_DIR}" ]]; then
   warn "You are switching profiles for a board that is already setup.  This"
   warn "can cause trouble for Portage.  If you experience problems with"
   warn "build_packages you may need to run:"
@@ -147,6 +148,5 @@
   warn "'emerge-${BOARD_VARIANT} -c' or 'emerge-${BOARD_VARIANT} -C <ebuild>'"
   sudo rm -f "${MAKE_PROFILE}"
+  sudo ln -sf "${PROFILES_DIR}" "${MAKE_PROFILE}"
-sudo ln -sf "${PROFILES_DIR}" "${MAKE_PROFILE}"