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 0146e9d6da..6a710a1667 100755 --- a/sdk_lib/make_chroot.sh +++ b/sdk_lib/make_chroot.sh @@ -236,6 +236,9 @@ 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}' \ | user_append "$FLAGS_chroot/home/${SUDO_USER}/.bash_profile" @@ -317,11 +320,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