dev_install: catch people who run `sudo su`
We need the full environment from a login shell. Barf if we don't.
BUG=None
TEST=`sudo dev_install` works
TEST=`sudo su -; dev_install` works
TEST=`sudo su; dev_install` aborts
Change-Id: I96647c342f6f47dc5657ad8688b7ee784fd3054d
Reviewed-on: https://gerrit.chromium.org/gerrit/59111
Reviewed-by: Ronald G. Minnich <rminnich@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
diff --git a/dev-install/dev_install b/dev-install/dev_install
index cd10175..1020124 100755
--- a/dev-install/dev_install
+++ b/dev-install/dev_install
@@ -193,6 +193,19 @@
return 1
fi
+ # Sanity check. People often run `su` or `sudo su` and leave off that final
+ # - which means they don't get a proper environment. Catch them here rather
+ # than fail randomly midway through the process.
+ case :${PATH}: in
+ *:/usr/local/bin:*) ;;
+ *)
+ error "Your environment appears to be incomplete. When changing to root,"
+ error "did you remember to run the full command (don't forget the dash):"
+ error " $ sudo su -"
+ return 1
+ ;;
+ esac
+
# This script should only run in developer mode or for developer images.
if crossystem "cros_debug?0"; then
error "Can not run dev_install."