From 47d237ecab83e65ed376d547f7da3bfb9eaee6b4 Mon Sep 17 00:00:00 2001 From: Alex Crawford Date: Mon, 30 Nov 2015 18:14:40 -0800 Subject: [PATCH] sdk_lib: cleanup to support non-standard environs --- sdk_lib/enter_chroot.sh | 13 +++++++------ sdk_lib/make_chroot.sh | 7 ++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/sdk_lib/enter_chroot.sh b/sdk_lib/enter_chroot.sh index 236a0beb86..a8ec3f230e 100755 --- a/sdk_lib/enter_chroot.sh +++ b/sdk_lib/enter_chroot.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be @@ -185,9 +185,9 @@ generate_locales() { # with long multibyte strings. Newer setups have this fixed, # but locale-gen doesn't need to be run in any locale in the # first place, so just go with C to keep it fast. - PATH="/usr/sbin:/usr/bin:/sbin:/bin" LC_ALL=C \ - chroot "${FLAGS_chroot}" locale-gen -q -u \ - -G "$(printf '%s\n' "${gen_locales[@]}")" + chroot "${FLAGS_chroot}" /usr/bin/env \ + PATH="/usr/sbin:/usr/bin:/sbin:/bin" LC_ALL=C \ + locale-gen -q -u -G "$(printf '%s\n' "${gen_locales[@]}")" fi } @@ -398,15 +398,16 @@ fi # the source trunk for scripts that may need to print it (e.g. # build_image.sh). +cmd=( /usr/bin/env PATH="/usr/sbin:/usr/bin:/sbin:/bin" LC_ALL=C ) if [ $FLAGS_early_make_chroot -eq $FLAGS_TRUE ]; then - cmd=( /bin/bash -l -c 'env "$@"' -- ) + cmd+=( /bin/bash -l -c 'env "$@"' -- ) elif [ ! -x "${FLAGS_chroot}/usr/bin/sudo" ]; then # Complain that sudo is missing. error "Failing since the chroot lacks sudo." error "Requested enter_chroot command was: $@" exit 127 else - cmd=( sudo -i -u "${SUDO_USER}" ) + cmd+=( sudo -i -u "${SUDO_USER}" ) fi cmd+=( "${CHROOT_PASSTHRU[@]}" "$@" ) diff --git a/sdk_lib/make_chroot.sh b/sdk_lib/make_chroot.sh index fac370d763..90db639017 100755 --- a/sdk_lib/make_chroot.sh +++ b/sdk_lib/make_chroot.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be @@ -85,8 +85,9 @@ early_enter_chroot() { # the overhead of enter_chroot, and do not need access to the source tree, # don't need the actual chroot profile env, and can run the command as root. bare_chroot() { - PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \ - chroot "${FLAGS_chroot}" "$@" + chroot "${FLAGS_chroot}" /usr/bin/env \ + PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \ + "$@" } cleanup() {