mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-21 21:51:57 +02:00
sdk_lib/*: Make --cache_dir option required.
This is forced by cros_sdk; in conjunction w/ this, drop --distfiles and mangle the chroot on during entrance dropping a symlink in the old /var/cache/distfiles location pointing to the new mounted cache_dir location. Additionally, thread CHROMEOS_CACHEDIR down through the end. Do this without relying on a version upgrade script- we can't require they be run before entering, thus we exploit the fact that cros_sdk explicitly forces a write lock to do the upgrade, if we see the old form we know we can do the upgrade w/out worrying about collisions. CQ-DEPEND=CL:33871 BUG=chromium-os:34457 TEST=manual testing. Change-Id: I6805266e3ec683f05d3ba615f9e8840642a28e48 Reviewed-on: https://gerrit.chromium.org/gerrit/33868 Commit-Ready: Brian Harring <ferringb@chromium.org> Reviewed-by: Brian Harring <ferringb@chromium.org> Tested-by: Brian Harring <ferringb@chromium.org>
This commit is contained in:
parent
acff376525
commit
7b6f377c58
@ -27,8 +27,7 @@ DEFINE_string chrome_root "" \
|
|||||||
"The root of your chrome browser source. Should contain a 'src' subdir."
|
"The root of your chrome browser source. Should contain a 'src' subdir."
|
||||||
DEFINE_string chrome_root_mount "/home/$USER/chrome_root" \
|
DEFINE_string chrome_root_mount "/home/$USER/chrome_root" \
|
||||||
"The mount point of the chrome broswer source in the chroot."
|
"The mount point of the chrome broswer source in the chroot."
|
||||||
DEFINE_string distfiles "" \
|
DEFINE_string cache_dir "" "Directory to use for caching."
|
||||||
"Override the destination dir used for distfiles."
|
|
||||||
|
|
||||||
DEFINE_boolean official_build $FLAGS_FALSE \
|
DEFINE_boolean official_build $FLAGS_FALSE \
|
||||||
"Set CHROMEOS_OFFICIAL=1 for release builds."
|
"Set CHROMEOS_OFFICIAL=1 for release builds."
|
||||||
@ -73,8 +72,8 @@ if [ $FLAGS_official_build -eq $FLAGS_TRUE ]; then
|
|||||||
CHROMEOS_OFFICIAL=1
|
CHROMEOS_OFFICIAL=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -z "${FLAGS_distfiles}" ] && \
|
[ -z "${FLAGS_cache_dir}" ] && \
|
||||||
FLAGS_distfiles="${FLAGS_trunk}/distfiles"
|
die "--cache_dir is required"
|
||||||
|
|
||||||
# Only now can we die on error. shflags functions leak non-zero error codes,
|
# 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.
|
# so will die prematurely if 'switch_to_strict_mode' is specified before now.
|
||||||
@ -359,10 +358,25 @@ setup_env() {
|
|||||||
fi
|
fi
|
||||||
unset REFERENCE_DIR
|
unset REFERENCE_DIR
|
||||||
|
|
||||||
debug "Setting up shared distfiles directory."
|
chroot_cache='/var/cache/chromeos-cache'
|
||||||
mkdir -p "${FLAGS_distfiles}"/{target,host}
|
debug "Setting up shared cache dir directory."
|
||||||
sudo mkdir -p "${FLAGS_chroot}/var/cache/distfiles/"
|
mkdir -p "${FLAGS_cache_dir}"/distfiles/{target,host}
|
||||||
queue_mount "${FLAGS_distfiles}" "--bind" "/var/cache/distfiles"
|
sudo mkdir -p "${FLAGS_chroot}/${chroot_cache}"
|
||||||
|
queue_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-cache.sh"
|
||||||
|
sudo_multi "rm -rf '${distfiles_path}'" \
|
||||||
|
"ln -s chromeos-cache/distfiles '${distfiles_path}'" \
|
||||||
|
"echo 'export CHROMEOS_CACHEDIR=${chroot_cache}' > '${p}'" \
|
||||||
|
"chmod 0644 '${p}'"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $FLAGS_ssh_agent -eq $FLAGS_TRUE ]; then
|
if [ $FLAGS_ssh_agent -eq $FLAGS_TRUE ]; then
|
||||||
if [ -n "${SSH_AUTH_SOCK}" -a -d "${HOME}/.ssh" ]; then
|
if [ -n "${SSH_AUTH_SOCK}" -a -d "${HOME}/.ssh" ]; then
|
||||||
|
@ -45,6 +45,7 @@ DEFINE_string stage3_date "2010.03.09" \
|
|||||||
"Use the stage3 with the given date."
|
"Use the stage3 with the given date."
|
||||||
DEFINE_string stage3_path "" \
|
DEFINE_string stage3_path "" \
|
||||||
"Use the stage3 located on this path."
|
"Use the stage3 located on this path."
|
||||||
|
DEFINE_string cache_dir "" "Directory to store caches within."
|
||||||
|
|
||||||
# Parse command line flags.
|
# Parse command line flags.
|
||||||
FLAGS_HELP="usage: $SCRIPT_NAME [flags]"
|
FLAGS_HELP="usage: $SCRIPT_NAME [flags]"
|
||||||
@ -63,6 +64,10 @@ umask 022
|
|||||||
# TODO: replace shflags with something less error-prone, or contribute a fix.
|
# TODO: replace shflags with something less error-prone, or contribute a fix.
|
||||||
switch_to_strict_mode
|
switch_to_strict_mode
|
||||||
|
|
||||||
|
[[ "${FLAGS_delete}" == "${FLAGS_FALSE}" ]] && \
|
||||||
|
[[ -z "${FLAGS_cache_dir}" ]] && \
|
||||||
|
die "--cache_dir is required"
|
||||||
|
|
||||||
. "${SCRIPT_ROOT}"/sdk_lib/make_conf_util.sh
|
. "${SCRIPT_ROOT}"/sdk_lib/make_conf_util.sh
|
||||||
|
|
||||||
FULLNAME="ChromeOS Developer"
|
FULLNAME="ChromeOS Developer"
|
||||||
@ -93,7 +98,8 @@ ENTER_CHROOT_ARGS=(
|
|||||||
|
|
||||||
# Invoke enter_chroot. This can only be used after sudo has been installed.
|
# Invoke enter_chroot. This can only be used after sudo has been installed.
|
||||||
enter_chroot() {
|
enter_chroot() {
|
||||||
"$ENTER_CHROOT" --chroot "$FLAGS_chroot" -- "${ENTER_CHROOT_ARGS[@]}" "$@"
|
"$ENTER_CHROOT" --cache_dir "${FLAGS_cache_dir}" --chroot "$FLAGS_chroot" \
|
||||||
|
-- "${ENTER_CHROOT_ARGS[@]}" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Invoke enter_chroot running the command as root, and w/out sudo.
|
# Invoke enter_chroot running the command as root, and w/out sudo.
|
||||||
@ -101,6 +107,7 @@ enter_chroot() {
|
|||||||
early_env=()
|
early_env=()
|
||||||
early_enter_chroot() {
|
early_enter_chroot() {
|
||||||
"$ENTER_CHROOT" --chroot "$FLAGS_chroot" --early_make_chroot \
|
"$ENTER_CHROOT" --chroot "$FLAGS_chroot" --early_make_chroot \
|
||||||
|
--cache_dir "${FLAGS_cache_dir}" \
|
||||||
-- "${ENTER_CHROOT_ARGS[@]}" "${early_env[@]}" "$@"
|
-- "${ENTER_CHROOT_ARGS[@]}" "${early_env[@]}" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,8 +215,15 @@ init_setup () {
|
|||||||
|
|
||||||
# Create directories referred to by our conf files.
|
# Create directories referred to by our conf files.
|
||||||
sudo mkdir -p -m 775 "${FLAGS_chroot}/var/lib/portage/pkgs" \
|
sudo mkdir -p -m 775 "${FLAGS_chroot}/var/lib/portage/pkgs" \
|
||||||
"${FLAGS_chroot}/var/cache/distfiles" \
|
"${FLAGS_chroot}/var/cache/"chromeos-{cache,chrome} \
|
||||||
"${FLAGS_chroot}/var/cache/chromeos-chrome"
|
"${FLAGS_chroot}/etc/profile.d"
|
||||||
|
|
||||||
|
echo "export CHROMEOS_CACHEDIR=/var/cache/chromeos-cache" | \
|
||||||
|
sudo_clobber "${FLAGS_chroot}/etc/profile.d/chromeos-cachedir.sh"
|
||||||
|
sudo_multi \
|
||||||
|
"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
|
# Run this from w/in the chroot so we use whatever uid/gid
|
||||||
# these are defined as w/in the chroot.
|
# these are defined as w/in the chroot.
|
||||||
@ -217,10 +231,10 @@ init_setup () {
|
|||||||
|
|
||||||
# These are created for compatibility while transitioning
|
# These are created for compatibility while transitioning
|
||||||
# make.conf and friends over to the new location.
|
# make.conf and friends over to the new location.
|
||||||
# TODO(ferringb): remove this 03/12 or so.
|
# TODO(ferringb): remove this 01/13 or so.
|
||||||
sudo ln -s ../../cache/distfiles/host \
|
sudo ln -s ../../cache/chromeos-cache/distfiles/host \
|
||||||
"${FLAGS_chroot}/var/lib/portage/distfiles"
|
"${FLAGS_chroot}/var/lib/portage/distfiles"
|
||||||
sudo ln -s ../../cache/distfiles/target \
|
sudo ln -s ../../cache/chromeos-cache/distfiles/target \
|
||||||
"${FLAGS_chroot}/var/lib/portage/distfiles-target"
|
"${FLAGS_chroot}/var/lib/portage/distfiles-target"
|
||||||
|
|
||||||
# Add chromite/bin and depot_tools into the path globally; note that the
|
# Add chromite/bin and depot_tools into the path globally; note that the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user