mirror of
https://github.com/flatcar/scripts.git
synced 2026-05-04 11:51:14 +02:00
update_chroot: remove dependency on complex 'chromeos-cache' links
The distfiles cache is always under .cache in the repo tree but there is a lot of extra logic to make that configurable along with compatibility symlinks for previous locations. Just yank it all out.
This commit is contained in:
parent
611ed7698e
commit
1fa7ef236b
@ -26,7 +26,7 @@ DEFINE_string chrome_root "" \
|
||||
"The root of your chrome browser source. Should contain a 'src' subdir."
|
||||
DEFINE_string chrome_root_mount "/home/${SUDO_USER}/chrome_root" \
|
||||
"The mount point of the chrome broswer source in the chroot."
|
||||
DEFINE_string cache_dir "" "Directory to use for caching."
|
||||
DEFINE_string cache_dir "" "unused"
|
||||
|
||||
DEFINE_boolean official_build $FLAGS_FALSE \
|
||||
"Set COREOS_OFFICIAL=1 for release builds."
|
||||
@ -70,9 +70,6 @@ if [ $FLAGS_official_build -eq $FLAGS_TRUE ]; then
|
||||
COREOS_OFFICIAL=1
|
||||
fi
|
||||
|
||||
[ -z "${FLAGS_cache_dir}" ] && \
|
||||
die "--cache_dir is required"
|
||||
|
||||
# Only now can we die on error. shflags functions leak non-zero error codes,
|
||||
# so will die prematurely if 'switch_to_strict_mode' is specified before now.
|
||||
# TODO: replace shflags with something less error-prone, or contribute a fix.
|
||||
@ -281,27 +278,6 @@ setup_env() {
|
||||
fi
|
||||
unset REFERENCE_DIR
|
||||
|
||||
chroot_cache='/var/cache/chromeos-cache'
|
||||
debug "Setting up shared cache dir directory."
|
||||
user_mkdir "${FLAGS_cache_dir}"/distfiles/{target,host}
|
||||
user_mkdir "${FLAGS_chroot}/${chroot_cache}"
|
||||
setup_mount "${FLAGS_cache_dir}" "--bind" "${chroot_cache}"
|
||||
# TODO(build): remove this as of 12/01/12.
|
||||
# Because of how distfiles -> cache_dir was deployed, if this isn't
|
||||
# a symlink, we *know* the ondisk pathways aren't compatible- thus
|
||||
# fix it now.
|
||||
distfiles_path="${FLAGS_chroot}/var/cache/distfiles"
|
||||
if [ ! -L "${distfiles_path}" ]; then
|
||||
# While we're at it, ensure the var is exported w/in the chroot; it
|
||||
# won't exist if distfiles isn't a symlink.
|
||||
p="${FLAGS_chroot}/etc/profile.d/chromeos-cachedir.sh"
|
||||
rm -rf "${distfiles_path}"
|
||||
ln -s chromeos-cache/distfiles "${distfiles_path}"
|
||||
mkdir -p -m 775 "${p%/*}"
|
||||
echo 'export CHROMEOS_CACHEDIR=${chroot_cache}' > "${p}"
|
||||
chmod 0644 "${p}"
|
||||
fi
|
||||
|
||||
user_mkdir "${FLAGS_chroot}/home/${SUDO_USER}/.ssh"
|
||||
if [ $FLAGS_ssh_agent -eq $FLAGS_TRUE ]; then
|
||||
# Clean up previous ssh agents.
|
||||
@ -376,17 +352,6 @@ setup_env() {
|
||||
warn "-- Note: modprobe fuse failed. gmergefs will not work"
|
||||
fi
|
||||
|
||||
# Fix permissions on ccache tree. If this is a fresh chroot, then they
|
||||
# might not be set up yet. Or if the user manually `rm -rf`-ed things,
|
||||
# we need to reset it. Otherwise, gcc itself takes care of fixing things
|
||||
# on demand, but only when it updates.
|
||||
ccache_dir="${FLAGS_chroot}/var/cache/distfiles/ccache"
|
||||
if [[ ! -d ${ccache_dir} ]]; then
|
||||
mkdir -p -m 2775 "${ccache_dir}"
|
||||
fi
|
||||
find -H "${ccache_dir}" -type d -exec chmod 2775 {} + &
|
||||
find -H "${ccache_dir}" -gid 0 -exec chgrp 250 {} + &
|
||||
|
||||
# Certain files get copied into the chroot when entering.
|
||||
for fn in "${FILES_TO_COPY_TO_CHROOT[@]}"; do
|
||||
copy_into_chroot_if_exists "${SUDO_HOME}/${fn}" "/home/${SUDO_USER}/${fn}"
|
||||
|
||||
@ -45,7 +45,7 @@ DEFINE_integer jobs "${NUM_JOBS}" \
|
||||
"How many packages to build in parallel at maximum."
|
||||
DEFINE_string stage3_path "" \
|
||||
"Use the stage3 located on this path."
|
||||
DEFINE_string cache_dir "" "Directory to store caches within."
|
||||
DEFINE_string cache_dir "" "unused"
|
||||
|
||||
# Parse command line flags.
|
||||
FLAGS_HELP="usage: $SCRIPT_NAME [flags]"
|
||||
@ -64,10 +64,6 @@ umask 022
|
||||
# TODO: replace shflags with something less error-prone, or contribute a fix.
|
||||
switch_to_strict_mode
|
||||
|
||||
[[ "${FLAGS_delete}" == "${FLAGS_FALSE}" ]] && \
|
||||
[[ -z "${FLAGS_cache_dir}" ]] && \
|
||||
die "--cache_dir is required"
|
||||
|
||||
ENTER_CHROOT_ARGS=(
|
||||
CROS_WORKON_SRCROOT="$CHROOT_TRUNK"
|
||||
PORTAGE_USERNAME="${SUDO_USER}"
|
||||
@ -75,15 +71,13 @@ ENTER_CHROOT_ARGS=(
|
||||
|
||||
# Invoke enter_chroot. This can only be used after sudo has been installed.
|
||||
enter_chroot() {
|
||||
"$ENTER_CHROOT" --cache_dir "${FLAGS_cache_dir}" --chroot "$FLAGS_chroot" \
|
||||
-- "${ENTER_CHROOT_ARGS[@]}" "$@"
|
||||
"$ENTER_CHROOT" --chroot "$FLAGS_chroot" -- "${ENTER_CHROOT_ARGS[@]}" "$@"
|
||||
}
|
||||
|
||||
# Invoke enter_chroot running the command as root, and w/out sudo.
|
||||
# This should be used prior to sudo being merged.
|
||||
early_enter_chroot() {
|
||||
"$ENTER_CHROOT" --chroot "$FLAGS_chroot" --early_make_chroot \
|
||||
--cache_dir "${FLAGS_cache_dir}" \
|
||||
-- "${ENTER_CHROOT_ARGS[@]}" "$@"
|
||||
}
|
||||
|
||||
@ -169,29 +163,6 @@ EOF
|
||||
|
||||
chmod 0440 "${FLAGS_chroot}/etc/sudoers.d/90_cros"
|
||||
|
||||
# Create directories referred to by our conf files.
|
||||
mkdir -p -m 775 "${FLAGS_chroot}/var/lib/portage/pkgs" \
|
||||
"${FLAGS_chroot}/var/cache/"chromeos-{cache,chrome} \
|
||||
"${FLAGS_chroot}/etc/profile.d"
|
||||
|
||||
echo "export CHROMEOS_CACHEDIR=/var/cache/chromeos-cache" > \
|
||||
"${FLAGS_chroot}/etc/profile.d/chromeos-cachedir.sh"
|
||||
chmod 0644 "${FLAGS_chroot}/etc/profile.d/chromeos-cachedir.sh"
|
||||
rm -rf "${FLAGS_chroot}/var/cache/distfiles"
|
||||
ln -s chromeos-cache/distfiles "${FLAGS_chroot}/var/cache/distfiles"
|
||||
|
||||
# Run this from w/in the chroot so we use whatever uid/gid
|
||||
# these are defined as w/in the chroot.
|
||||
bare_chroot chown "${SUDO_USER}:portage" /var/cache/chromeos-chrome
|
||||
|
||||
# These are created for compatibility while transitioning
|
||||
# make.conf and friends over to the new location.
|
||||
# TODO(ferringb): remove this 01/13 or so.
|
||||
ln -s ../../cache/chromeos-cache/distfiles/host \
|
||||
"${FLAGS_chroot}/var/lib/portage/distfiles"
|
||||
ln -s ../../cache/chromeos-cache/distfiles/target \
|
||||
"${FLAGS_chroot}/var/lib/portage/distfiles-target"
|
||||
|
||||
# Add chromite/bin into the path globally
|
||||
# We rely on 'env-update' getting called below.
|
||||
target="${FLAGS_chroot}/etc/env.d/99coreos"
|
||||
|
||||
@ -50,19 +50,33 @@ CROSSDEV_OVERLAY="/usr/local/portage/crossdev"
|
||||
COREOS_OVERLAY="${REPO_ROOT}/src/third_party/coreos-overlay"
|
||||
COREOS_CONFIG="${COREOS_OVERLAY}/coreos/config"
|
||||
|
||||
# PORTAGE_USERNAME may already be in the env but set just to be safe.
|
||||
: ${PORTAGE_USERNAME:=${USER}}
|
||||
|
||||
# Clean up old distfiles cache. It used to be split for 'host' and
|
||||
# 'target' but that just duplicates files. Also a ccache was in there.
|
||||
if [[ -d "${REPO_CACHE_DIR}/distfiles/host" ]]; then
|
||||
info "Cleaning up old distfiles cache..."
|
||||
sudo mv "${REPO_CACHE_DIR}"/{distfiles/host,distfiles.host}
|
||||
sudo rm -rf "${REPO_CACHE_DIR}/distfiles"
|
||||
sudo mv "${REPO_CACHE_DIR}"/{distfiles.host,distfiles}
|
||||
fi
|
||||
|
||||
info "Setting up portage..."
|
||||
sudo mkdir -p "/etc/portage/repos.conf/"
|
||||
sudo rm -f "/etc/portage/make.conf"
|
||||
sudo touch "/etc/portage/make.conf.user"
|
||||
sudo mkdir -p "${REPO_CACHE_DIR}/distfiles"
|
||||
sudo chown "${PORTAGE_USERNAME}:portage" "${REPO_CACHE_DIR}/distfiles"
|
||||
sudo mkdir -p /etc/portage/repos.conf /var/lib/portage/pkgs
|
||||
sudo touch /etc/portage/make.conf.user
|
||||
|
||||
sudo_clobber "/etc/portage/make.conf" <<EOF
|
||||
# Created by update_chroot
|
||||
PORTDIR="${PORTAGE_STABLE_OVERLAY}"
|
||||
PORTDIR_OVERLAY="${CROSSDEV_OVERLAY} ${COREOS_OVERLAY}"
|
||||
DISTDIR="/var/lib/portage/distfiles"
|
||||
DISTDIR="${REPO_CACHE_DIR}/distfiles"
|
||||
PKGDIR="/var/lib/portage/pkgs"
|
||||
PORT_LOGDIR="/var/log/portage"
|
||||
PORTAGE_BINHOST="$(get_sdk_binhost)"
|
||||
PORTAGE_USERNAME="${PORTAGE_USERNAME}"
|
||||
MAKEOPTS="--jobs=${NUM_JOBS} --load-average=$((NUM_JOBS * 2))"
|
||||
|
||||
# Generally there isn't any need to add packages to @world by default.
|
||||
|
||||
@ -50,7 +50,7 @@ update_local_mirror() {
|
||||
emirrordist --mirror --verbose $extra_flags \
|
||||
--jobs=${NUM_JOBS} --repo="${repo_name}" \
|
||||
--distfiles="${repo_mirror}/distfiles" \
|
||||
--distfiles-local="/var/lib/portage/distfiles" \
|
||||
--distfiles-local="$(portageq envvar DISTDIR)" \
|
||||
--fetch-log-dir="${repo_mirror}/log" \
|
||||
--failure-log="${repo_mirror}/log/failure.log" \
|
||||
--success-log="${repo_mirror}/log/success.log" \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user