mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-10 06:26:57 +02:00
cleanup: remove source location migration code
This code is not applicable to us, it predates CoreOS and is a weird thing for common.sh to be doing as well. Instead always define CHROOT_TRUNK_DIR to /mnt/host/source, create ~/trunk in make_chroot.
This commit is contained in:
parent
09e720e821
commit
81ce75300f
57
common.sh
57
common.sh
@ -172,61 +172,8 @@ cmp_ver() {
|
|||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
# Directory locations inside the dev chroot; try the new default,
|
# repo source root inside the chroot, usually mounted from the outside.
|
||||||
# falling back to user specific paths if the upgrade has yet to
|
CHROOT_TRUNK_DIR="/mnt/host/source"
|
||||||
# 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
|
|
||||||
|
|
||||||
# Construct a list of possible locations for the source tree. This list is
|
# 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
|
# based on various environment variables and globals that may have been set
|
||||||
|
@ -99,10 +99,6 @@ FUSE_DEVICE="/dev/fuse"
|
|||||||
LOCKFILE="${FLAGS_chroot}/.enter_chroot.lock"
|
LOCKFILE="${FLAGS_chroot}/.enter_chroot.lock"
|
||||||
MOUNTED_PATH=$(readlink -f "$FLAGS_chroot")
|
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() {
|
setup_mount() {
|
||||||
# If necessary, mount $source in the host FS at $target inside the
|
# 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).
|
# Do this early as it's slow and only needs basic mounts (above).
|
||||||
generate_locales &
|
generate_locales &
|
||||||
|
|
||||||
|
mkdir -p "${FLAGS_chroot}/${CHROOT_TRUNK_DIR}"
|
||||||
setup_mount "${FLAGS_trunk}" "--rbind" "${CHROOT_TRUNK_DIR}"
|
setup_mount "${FLAGS_trunk}" "--rbind" "${CHROOT_TRUNK_DIR}"
|
||||||
|
|
||||||
debug "Setting up referenced repositories if required."
|
debug "Setting up referenced repositories if required."
|
||||||
|
@ -236,6 +236,9 @@ en_US.UTF-8 UTF-8
|
|||||||
EOF
|
EOF
|
||||||
fi
|
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.
|
# Automatically change to scripts directory.
|
||||||
echo 'cd ${CHROOT_CWD:-~/trunk/src/scripts}' \
|
echo 'cd ${CHROOT_CWD:-~/trunk/src/scripts}' \
|
||||||
| user_append "$FLAGS_chroot/home/${SUDO_USER}/.bash_profile"
|
| user_append "$FLAGS_chroot/home/${SUDO_USER}/.bash_profile"
|
||||||
@ -317,11 +320,6 @@ else
|
|||||||
# Set up users, if needed, before mkdir/mounts below.
|
# Set up users, if needed, before mkdir/mounts below.
|
||||||
init_users
|
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.
|
# Run all the init stuff to setup the env.
|
||||||
init_setup
|
init_setup
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user