mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-22 06:01:41 +02:00
fix(update_chroot): Consolidate more portage configuration
To behave more like setup_board/build_packages update_chroot should fully configure portage to make sure everything is accurate. Now binhosts are defined in make.conf.host_setup so the static config in coreos-overlays doesn't need to refer to version.txt. setup_board already made this change in 7a43a07f. Define path locations to reduce dependency between static configs in coreos-overlays and the behavior of the scripts repo. Spreading configuration across two repos makes everything harder to understand. Eventually everything should either be defined in profiles in coreos-overlays or minimal auto-generated config files here in scripts.
This commit is contained in:
parent
57d19d0f06
commit
68a8a67081
@ -127,6 +127,28 @@ get_board_binhost() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_sdk_arch() {
|
||||||
|
get_portage_arch $(uname -m)
|
||||||
|
}
|
||||||
|
|
||||||
|
get_sdk_profile() {
|
||||||
|
echo "coreos:coreos/$(get_sdk_arch)/sdk"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Usage: get_sdk_binhost [version...]
|
||||||
|
# If no versions are specified the current and SDK versions are used.
|
||||||
|
get_sdk_binhost() {
|
||||||
|
local arch=$(get_sdk_arch) ver
|
||||||
|
if [[ $# -eq 0 ]]; then
|
||||||
|
set -- "${COREOS_SDK_VERSION}" "${COREOS_VERSION_ID}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
for ver in "$@"; do
|
||||||
|
echo "${COREOS_DOWNLOAD_ROOT}/sdk/${arch}/${ver}/pkgs/"
|
||||||
|
echo "${COREOS_DOWNLOAD_ROOT}/sdk/${arch}/${ver}/toolchain/"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# Usage: get_cross_pkgs chost [chost2...]
|
# Usage: get_cross_pkgs chost [chost2...]
|
||||||
get_cross_pkgs() {
|
get_cross_pkgs() {
|
||||||
local cross_chost native_pkg
|
local cross_chost native_pkg
|
||||||
|
@ -149,8 +149,6 @@ init_setup () {
|
|||||||
mkdir -p -m 755 "${FLAGS_chroot}/usr" \
|
mkdir -p -m 755 "${FLAGS_chroot}/usr" \
|
||||||
"${FLAGS_chroot}/usr/local/portage" \
|
"${FLAGS_chroot}/usr/local/portage" \
|
||||||
"${FLAGS_chroot}"/"${CROSSDEV_OVERLAY}"
|
"${FLAGS_chroot}"/"${CROSSDEV_OVERLAY}"
|
||||||
ln -sf "${CHROOT_TRUNK_DIR}/src/third_party/portage" \
|
|
||||||
"${FLAGS_chroot}/usr/portage"
|
|
||||||
ln -sf "${CHROOT_TRUNK_DIR}/src/third_party/coreos-overlay" \
|
ln -sf "${CHROOT_TRUNK_DIR}/src/third_party/coreos-overlay" \
|
||||||
"${FLAGS_chroot}"/"${CHROOT_OVERLAY}"
|
"${FLAGS_chroot}"/"${CHROOT_OVERLAY}"
|
||||||
ln -sf "${CHROOT_TRUNK_DIR}/src/third_party/portage-stable" \
|
ln -sf "${CHROOT_TRUNK_DIR}/src/third_party/portage-stable" \
|
||||||
@ -197,19 +195,6 @@ EOF
|
|||||||
cp /etc/{hosts,resolv.conf} "$FLAGS_chroot/etc/"
|
cp /etc/{hosts,resolv.conf} "$FLAGS_chroot/etc/"
|
||||||
chmod 0644 "$FLAGS_chroot"/etc/{hosts,resolv.conf}
|
chmod 0644 "$FLAGS_chroot"/etc/{hosts,resolv.conf}
|
||||||
|
|
||||||
# Setup host make.conf. This includes any overlay that we may be using
|
|
||||||
# and a pointer to pre-built packages.
|
|
||||||
# TODO: This should really be part of a profile in the portage.
|
|
||||||
info "Setting up /etc/make.*..."
|
|
||||||
ln -sf "${CHROOT_CONFIG}/make.conf.amd64-host" \
|
|
||||||
"${FLAGS_chroot}/etc/portage/make.conf"
|
|
||||||
ln -sf "${CHROOT_OVERLAY}/profiles/default/linux/amd64/10.0" \
|
|
||||||
"${FLAGS_chroot}/etc/portage/make.profile"
|
|
||||||
|
|
||||||
# Create make.conf.user .
|
|
||||||
touch "${FLAGS_chroot}"/etc/portage/make.conf.user
|
|
||||||
chmod 0644 "${FLAGS_chroot}"/etc/portage/make.conf.user
|
|
||||||
|
|
||||||
# Create directories referred to by our conf files.
|
# Create directories referred to by our conf files.
|
||||||
mkdir -p -m 775 "${FLAGS_chroot}/var/lib/portage/pkgs" \
|
mkdir -p -m 775 "${FLAGS_chroot}/var/lib/portage/pkgs" \
|
||||||
"${FLAGS_chroot}/var/cache/"chromeos-{cache,chrome} \
|
"${FLAGS_chroot}/var/cache/"chromeos-{cache,chrome} \
|
||||||
@ -242,6 +227,7 @@ PATH=${CHROOT_TRUNK_DIR}/chromite/bin:${DEPOT_TOOLS_DIR}
|
|||||||
CROS_WORKON_SRCROOT="${CHROOT_TRUNK_DIR}"
|
CROS_WORKON_SRCROOT="${CHROOT_TRUNK_DIR}"
|
||||||
PORTAGE_USERNAME=${SUDO_USER}
|
PORTAGE_USERNAME=${SUDO_USER}
|
||||||
EOF
|
EOF
|
||||||
|
early_enter_chroot env-update
|
||||||
|
|
||||||
# Add chromite into python path.
|
# Add chromite into python path.
|
||||||
for python_path in "${FLAGS_chroot}/usr/lib/"python2.*; do
|
for python_path in "${FLAGS_chroot}/usr/lib/"python2.*; do
|
||||||
@ -249,19 +235,6 @@ EOF
|
|||||||
sudo ln -s "${CHROOT_TRUNK_DIR}"/chromite "${python_path}"
|
sudo ln -s "${CHROOT_TRUNK_DIR}"/chromite "${python_path}"
|
||||||
done
|
done
|
||||||
|
|
||||||
# TODO(zbehan): Configure stuff that is usually configured in postinst's,
|
|
||||||
# but wasn't. Fix the postinst's.
|
|
||||||
info "Running post-inst configuration hacks"
|
|
||||||
early_enter_chroot env-update
|
|
||||||
|
|
||||||
|
|
||||||
# This is basically a sanity check of our chroot. If any of these
|
|
||||||
# don't exist, then either bind mounts have failed, an invocation
|
|
||||||
# from above is broke, or some assumption about the stage3 is no longer
|
|
||||||
# true.
|
|
||||||
early_enter_chroot ls -l /etc/portage/make.{conf,profile} \
|
|
||||||
/usr/local/portage/coreos/profiles/default/linux/amd64/10.0
|
|
||||||
|
|
||||||
target="${FLAGS_chroot}/etc/profile.d"
|
target="${FLAGS_chroot}/etc/profile.d"
|
||||||
mkdir -p "${target}"
|
mkdir -p "${target}"
|
||||||
cat << EOF > "${target}/coreos-niceties.sh"
|
cat << EOF > "${target}/coreos-niceties.sh"
|
||||||
@ -333,10 +306,6 @@ if [[ $FLAGS_delete -eq $FLAGS_TRUE || \
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
CHROOT_TRUNK="${CHROOT_TRUNK_DIR}"
|
CHROOT_TRUNK="${CHROOT_TRUNK_DIR}"
|
||||||
PORTAGE="${SRC_ROOT}/third_party/portage"
|
|
||||||
OVERLAY="${SRC_ROOT}/third_party/coreos-overlay"
|
|
||||||
CONFIG_DIR="${OVERLAY}/coreos/config"
|
|
||||||
CHROOT_CONFIG="${CHROOT_TRUNK_DIR}/src/third_party/coreos-overlay/coreos/config"
|
|
||||||
PORTAGE_STABLE_OVERLAY="/usr/local/portage/stable"
|
PORTAGE_STABLE_OVERLAY="/usr/local/portage/stable"
|
||||||
CROSSDEV_OVERLAY="/usr/local/portage/crossdev"
|
CROSSDEV_OVERLAY="/usr/local/portage/crossdev"
|
||||||
CHROOT_OVERLAY="/usr/local/portage/coreos"
|
CHROOT_OVERLAY="/usr/local/portage/coreos"
|
||||||
|
@ -49,13 +49,27 @@ switch_to_strict_mode
|
|||||||
|
|
||||||
PORTAGE_STABLE_OVERLAY="/usr/local/portage/stable"
|
PORTAGE_STABLE_OVERLAY="/usr/local/portage/stable"
|
||||||
CROSSDEV_OVERLAY="/usr/local/portage/crossdev"
|
CROSSDEV_OVERLAY="/usr/local/portage/crossdev"
|
||||||
CHROOT_OVERLAY="/usr/local/portage/coreos"
|
COREOS_OVERLAY="/usr/local/portage/coreos"
|
||||||
|
COREOS_CONFIG="${COREOS_OVERLAY}/coreos/config"
|
||||||
|
|
||||||
info "Setting up portage..."
|
info "Setting up portage..."
|
||||||
sudo mkdir -p "/etc/portage/repos.conf/"
|
sudo mkdir -p "/etc/portage/repos.conf/"
|
||||||
|
sudo ln -sf "${COREOS_CONFIG}/make.conf.amd64-host" "/etc/portage/make.conf"
|
||||||
|
sudo touch "/etc/portage/make.conf.user"
|
||||||
|
|
||||||
sudo_clobber "/etc/portage/make.conf.host_setup" <<EOF
|
sudo_clobber "/etc/portage/make.conf.host_setup" <<EOF
|
||||||
# Created by update_chroot
|
# Created by update_chroot
|
||||||
|
PORTDIR="${PORTAGE_STABLE_OVERLAY}"
|
||||||
|
PORTDIR_OVERLAY="${CROSSDEV_OVERLAY} ${COREOS_OVERLAY}"
|
||||||
|
DISTDIR="/var/lib/portage/distfiles"
|
||||||
|
PKGDIR="/var/lib/portage/pkgs"
|
||||||
|
PORT_LOGDIR="/var/log/portage"
|
||||||
|
PORTAGE_BINHOST="$(get_sdk_binhost)"
|
||||||
MAKEOPTS="--jobs=${NUM_JOBS} --load-average=$((NUM_JOBS * 2))"
|
MAKEOPTS="--jobs=${NUM_JOBS} --load-average=$((NUM_JOBS * 2))"
|
||||||
|
|
||||||
|
# Generally there isn't any need to add packages to @world by default.
|
||||||
|
# You can use --select to override this.
|
||||||
|
EMERGE_DEFAULT_OPTS="--oneshot"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
sudo_clobber "/etc/portage/repos.conf/coreos.conf" <<EOF
|
sudo_clobber "/etc/portage/repos.conf/coreos.conf" <<EOF
|
||||||
@ -66,12 +80,14 @@ main-repo = portage-stable
|
|||||||
disabled = true
|
disabled = true
|
||||||
|
|
||||||
[coreos]
|
[coreos]
|
||||||
location = ${CHROOT_OVERLAY}
|
location = ${COREOS_OVERLAY}
|
||||||
|
|
||||||
[portage-stable]
|
[portage-stable]
|
||||||
location = ${PORTAGE_STABLE_OVERLAY}
|
location = ${PORTAGE_STABLE_OVERLAY}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
sudo eselect profile set --force "$(get_sdk_profile)"
|
||||||
|
|
||||||
# Create crossdev repo_name and metadata
|
# Create crossdev repo_name and metadata
|
||||||
info "Setting up crossdev..."
|
info "Setting up crossdev..."
|
||||||
sudo mkdir -p "${FLAGS_chroot}/${CROSSDEV_OVERLAY}/profiles"
|
sudo mkdir -p "${FLAGS_chroot}/${CROSSDEV_OVERLAY}/profiles"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user