cros_setup_toolchains: check for root after processing flags
There's no need to require root just to process flags (like --help).
BUG=None
TEST=`./bin/cros_setup_toolchains --help` works as non-root
TEST=`./bin/cros_setup_toolchains` requires root
Change-Id: I324c27427476e2d14ec04d0443690ea30a8bf1fd
Reviewed-on: https://gerrit.chromium.org/gerrit/18655
Reviewed-by: Zdenek Behan <zbehan@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/cros_setup_toolchains.py b/scripts/cros_setup_toolchains.py
index 7b5bd76..fcbec81 100644
--- a/scripts/cros_setup_toolchains.py
+++ b/scripts/cros_setup_toolchains.py
@@ -19,10 +19,6 @@
if not cros_build_lib.IsInsideChroot():
print '%s: This needs to be run inside the chroot' % sys.argv[0]
sys.exit(1)
-# This has to be always ran as root.
-if not os.getuid() == 0:
- print "This script must be run as root!"
- sys.exit(1)
# Only import portage after we've checked that we're inside the chroot.
# Outside may not have portage, in which case the above may not happen.
import portage
@@ -598,5 +594,10 @@
(options, _remaining_arguments) = parser.parse_args(argv)
+ # This has to be always ran as root.
+ if not os.getuid() == 0:
+ print "%s: This script must be run as root!" % sys.argv[0]
+ sys.exit(1)
+
targets = set(options.targets.split(','))
UpdateToolchains(options.usepkg, options.deleteold, options.hostonly, targets)