Allow variables in ENV_PASSTHRU to be used by cros_sdk itself.
Before patch:
$ rm -rf /tmp/foo
$ mkdir -p /tmp/foo
$ CROS_CACHEDIR=/tmp/foo cros_sdk -- du -hsc /var/cache/chromeos-cache
24G /var/cache/chromeos-cache
24G total
After patch:
$ rm -rf /tmp/foo
$ mkdir -p /tmp/foo
$ CROS_CACHEDIR=/tmp/foo cros_sdk -- du -hsc /var/cache/chromeos-cache
40K /var/cache/chromeos-cache
40K total
BUG=chromium-os:39695
TEST=CROS_CACHEDIR works now.
TEST=Also run a ton of trybots.
Change-Id: I95f808962f0cfe97ae56ac35a5e9014fdf2133b1
Reviewed-on: https://gerrit.chromium.org/gerrit/44849
Reviewed-by: Ryan Cui <rcui@chromium.org>
Reviewed-by: Brian Harring <ferringb@chromium.org>
Commit-Queue: David James <davidjames@chromium.org>
Tested-by: David James <davidjames@chromium.org>
diff --git a/scripts/cros_sdk.py b/scripts/cros_sdk.py
index e4a2291..93101d1 100644
--- a/scripts/cros_sdk.py
+++ b/scripts/cros_sdk.py
@@ -167,10 +167,10 @@
def _SudoCommand():
"""Get the 'sudo' command, along with all needed environment variables."""
- # Pass in the ENVIRONMENT_WHITELIST variable so that scripts in the chroot
- # know what variables to pass through.
+ # Pass in the ENVIRONMENT_WHITELIST and ENV_PASSTHRU variables so that
+ # scripts in the chroot know what variables to pass through.
cmd = ['sudo']
- for key in constants.CHROOT_ENVIRONMENT_WHITELIST:
+ for key in constants.CHROOT_ENVIRONMENT_WHITELIST + constants.ENV_PASSTHRU:
value = os.environ.get(key)
if value is not None:
cmd += ['%s=%s' % (key, value)]