diff --git a/build_library/build_image_util.sh b/build_library/build_image_util.sh index 742116e4ac..25a59225bc 100755 --- a/build_library/build_image_util.sh +++ b/build_library/build_image_util.sh @@ -39,7 +39,7 @@ delete_prompt() { # Only prompt if both stdin and stdout are a tty. If either is not a tty, # then the user may not be present, so we shouldn't bother prompting. - if [ -t 0 -a -t 1 -a "${USER}" != 'chrome-bot' ]; then + if [ -t 0 -a -t 1 ]; then read -p "Would you like to delete the output directory (y/N)? " SURE SURE="${SURE:0:1}" # Get just the first character. else diff --git a/common.sh b/common.sh index 5693dc1464..2550069620 100644 --- a/common.sh +++ b/common.sh @@ -172,61 +172,8 @@ cmp_ver() { return $? } -# Directory locations inside the dev chroot; try the new default, -# falling back to user specific paths if the upgrade has yet to -# happen. -_user="${USER}" -[[ ${USER} == "root" ]] && _user="${SUDO_USER}" -_CHROOT_TRUNK_DIRS=( "/home/${_user}/trunk" /mnt/host/source ) -unset _user - -_process_mount_pt() { - # Given 4 arguments; the root path, the variable to set, - # the old location, and the new; finally, forcing the upgrade is doable - # via if a 5th arg is provided. - # This will then try to migrate the old to new if we can do so right now - # (else leaving symlinks in place w/in the new), and will set $1 to the - # new location. - local base=${1:-/} var=$2 old=$3 new=$4 force=${5:-false} - local _sudo=$([[ ${USER} != "root" ]] && echo sudo) - local val=${new} - if [[ -L ${base}/${new} ]] || [[ ! -e ${base}/${new} ]]; then - # Ok, it's either a symlink or this is the first run. Upgrade if we can- - # specifically, if we're outside the chroot and we can rmdir the old. - # If we cannot rmdir the old, that's due to a mount being bound to that - # point (even if we can't see it, it's there)- thus fallback to adding - # compat links. - if ${force} || ( [[ ${INSIDE_CHROOT} -eq 0 ]] && \ - ${_sudo} rmdir "${base}/${old}" 2>/dev/null ); then - ${_sudo} rm -f "${base}/${new}" || : - ${_sudo} mkdir -p "${base}/${new}" "$(dirname "${base}/${old}" )" - ${_sudo} ln -s "${new}" "${base}/${old}" - else - if [[ ! -L ${base}/${new} ]]; then - # We can't do the upgrade right now; install compatibility links. - ${_sudo} mkdir -p "$(dirname "${base}/${new}")" "${base}/${old}" - ${_sudo} ln -s "${old}" "${base}/${new}" - fi - val=${old} - fi - fi - eval "${var}=\"${val}\"" -} - -set_chroot_trunk_dir() { - # This takes two optional arguments; the first being the path to the chroot - # base; this is only used by enter_chroot. The second argument is whether - # or not to force the new pathways; this is only used by make_chroot. Passing - # a non-null value for $2 forces the new paths. - if [[ ${INSIDE_CHROOT} -eq 0 ]] && [[ -z ${1-} ]]; then - # Can't do the upgrade, thus skip trying to do so. - CHROOT_TRUNK_DIR="${_CHROOT_TRUNK_DIRS[1]}" - return - fi - _process_mount_pt "$1" CHROOT_TRUNK_DIR "${_CHROOT_TRUNK_DIRS[@]}" ${2:+true} -} - -set_chroot_trunk_dir +# repo source root inside the chroot, usually mounted from the outside. +CHROOT_TRUNK_DIR="/mnt/host/source" # Construct a list of possible locations for the source tree. This list is # based on various environment variables and globals that may have been set diff --git a/sdk_lib/enter_chroot.sh b/sdk_lib/enter_chroot.sh index 3e1603b897..a31855cc67 100755 --- a/sdk_lib/enter_chroot.sh +++ b/sdk_lib/enter_chroot.sh @@ -99,10 +99,6 @@ FUSE_DEVICE="/dev/fuse" LOCKFILE="${FLAGS_chroot}/.enter_chroot.lock" MOUNTED_PATH=$(readlink -f "$FLAGS_chroot") -# Reset the depot tools/internal trunk pathways to what they'll -# be w/in the chroot. -set_chroot_trunk_dir "${FLAGS_chroot}" - setup_mount() { # If necessary, mount $source in the host FS at $target inside the @@ -235,6 +231,7 @@ setup_env() { # Do this early as it's slow and only needs basic mounts (above). generate_locales & + mkdir -p "${FLAGS_chroot}/${CHROOT_TRUNK_DIR}" setup_mount "${FLAGS_trunk}" "--rbind" "${CHROOT_TRUNK_DIR}" debug "Setting up referenced repositories if required." diff --git a/sdk_lib/make_chroot.sh b/sdk_lib/make_chroot.sh index 60ed1edcba..5057aedfd2 100755 --- a/sdk_lib/make_chroot.sh +++ b/sdk_lib/make_chroot.sh @@ -154,15 +154,9 @@ init_setup () { ln -sf "${CHROOT_TRUNK_DIR}/src/third_party/portage-stable" \ "${FLAGS_chroot}"/"${PORTAGE_STABLE_OVERLAY}" - # Some operations need an mtab. - ln -sfT /proc/mounts "${FLAGS_chroot}/etc/mtab" - # Set up sudoers. Inside the chroot, the user can sudo without a password. # (Safe enough, since the only way into the chroot is to 'sudo chroot', so # the user's already typed in one sudo password...) - # Make sure the sudoers.d subdir exists as older stage3 base images lack it. - mkdir -p "${FLAGS_chroot}/etc/sudoers.d" - # Setup proxied vars. load_environment_whitelist local extended_whitelist=( @@ -173,14 +167,10 @@ init_setup () { cat > "${FLAGS_chroot}/etc/sudoers.d/90_cros" <> "${localegen}" -en_US ISO-8859-1 -en_US.UTF-8 UTF-8 -EOF - fi + # Create ~/trunk symlink, it must point to CHROOT_TRUNK_DIR + ln -sfT "${CHROOT_TRUNK_DIR}" "$FLAGS_chroot/home/${SUDO_USER}/trunk" # Automatically change to scripts directory. echo 'cd ${CHROOT_CWD:-~/trunk/src/scripts}' \ @@ -244,11 +223,6 @@ EOF echo ". ~/trunk/src/scripts/bash_completion" \ | user_append "$FLAGS_chroot/home/${SUDO_USER}/.bashrc" - if [[ "${SUDO_USER}" = "chrome-bot" ]]; then - # Copy ssh keys, so chroot'd chrome-bot can scp files from chrome-web. - cp -rp ~/.ssh "$FLAGS_chroot/home/${SUDO_USER}/" - fi - if [[ -f ${SUDO_HOME}/.gitconfig ]]; then # Copy .gitconfig into chroot so repo and git can be used from inside. # This is required for repo to work since it validates the email address. @@ -322,11 +296,6 @@ else # Set up users, if needed, before mkdir/mounts below. init_users - # Reset internal vars to force them to the 'inside the chroot' value; - # since user directories now exist, this can do the upgrade in place. - set_chroot_trunk_dir "${FLAGS_chroot}" poppycock - mkdir -p "${FLAGS_chroot}/${CHROOT_TRUNK_DIR}" "${FLAGS_chroot}/run" - # Run all the init stuff to setup the env. init_setup fi