#!/bin/bash # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. . "$(dirname "$0")/common.sh" || exit 1 . "${BUILD_LIBRARY_DIR}/toolchain_util.sh" . "${BUILD_LIBRARY_DIR}/update_chroot_util.sh" # Script must run inside the chroot assert_inside_chroot "$@" # Do not run as root assert_not_root_user DEFINE_boolean usepkg "${FLAGS_TRUE}" \ "Use binary packages when possible." DEFINE_boolean getbinpkg "${FLAGS_TRUE}" \ "Download binary packages from remote repository." DEFINE_boolean usepkgonly "${FLAGS_FALSE}" \ "Only use/download binary packages. Implies --noworkon" DEFINE_boolean workon "${FLAGS_TRUE}" \ "Automatically rebuild updated cros-workon packages." DEFINE_boolean skip_toolchain_update "${FLAGS_FALSE}" \ "Don't update the toolchains." DEFINE_boolean setuponly "${FLAGS_FALSE}" \ "Only configure portage, without updating packages. Useful when only boostrap_sdk/build_toolchains will be called" DEFINE_string toolchain_boards "" \ "Extra toolchains to setup for the specified boards." DEFINE_string dev_builds_sdk "" \ "Set FLATCAR_DEV_BUILDS_SDK which defaults to FLATCAR_DEV_BUILDS/sdk" DEFINE_string binhost "" \ "Use binary packages from a specific location (like $(get_sdk_binhost | tr '\n' ' '}))" FLAGS_HELP="usage: $(basename $0) [flags] Performs an update of the chroot. This script is called as part of build_packages, so there is typically no need to call this script directly. " # Parse command line flags FLAGS "$@" || exit 1 eval set -- "${FLAGS_ARGV}" # 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. switch_to_strict_mode if [[ "${FLAGS_usepkgonly}" -eq "${FLAGS_TRUE}" ]]; then for flag in usepkg getbinpkg; do fvar="FLAGS_${flag}" if [[ "${!fvar}" -ne "${FLAGS_TRUE}" ]]; then die_notrace "--usepkgonly is incompatible with --no${flag}" fi done FLAGS_workon="${FLAGS_FALSE}" fi if [[ -n "${FLAGS_dev_builds_sdk}" ]]; then FLATCAR_DEV_BUILDS_SDK="${FLAGS_dev_builds_sdk}" fi PORTAGE_STABLE_OVERLAY="${REPO_ROOT}/src/third_party/portage-stable" CROSSDEV_OVERLAY="/usr/local/portage/crossdev" COREOS_OVERLAY="${REPO_ROOT}/src/third_party/coreos-overlay" COREOS_CONFIG="${COREOS_OVERLAY}/coreos/config" PORTAGE_BINHOST="$FLAGS_binhost $(get_sdk_binhost)" # 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. 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 "${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 ln -sfT "${COREOS_OVERLAY}/coreos/user-patches" '/etc/portage/patches' sudo touch /etc/portage/make.conf.user sudo_clobber "/etc/portage/make.conf" <=dev-libs/gmp-4.3.2:0/10.4=, >=dev-libs/gmp-4.3.2:0= # cross-aarch64-cros-linux-gnu/gdb-13.2-r1 requires dev-libs/gmp:=, dev-libs/gmp:0/10.4= # cross-x86_64-cros-linux-gnu/gcc-12.3.1_p20230526 requires >=dev-libs/gmp-4.3.2:0/10.4=, >=dev-libs/gmp-4.3.2:0= # cross-x86_64-cros-linux-gnu/gdb-13.2-r1 requires dev-libs/gmp:0/10.4=, dev-libs/gmp:= # dev-libs/mpc-1.2.1 requires >=dev-libs/gmp-5.0.0:0=[abi_x86_64(-)], >=dev-libs/gmp-5.0.0:0/10.4=[abi_x86_64(-)] # dev-libs/mpfr-4.1.0-r1 requires >=dev-libs/gmp-5.0.0:=[abi_x86_64(-)], >=dev-libs/gmp-5.0.0:0/10.4=[abi_x86_64(-)] # dev-libs/nettle-3.9.1 requires >=dev-libs/gmp-6.1:0/10.4=[abi_x86_64(-)], >=dev-libs/gmp-6.1:=[abi_x86_64(-)] # net-libs/gnutls-3.8.0 requires >=dev-libs/gmp-5.1.3-r1:0/10.4=[abi_x86_64(-)], >=dev-libs/gmp-5.1.3-r1:=[abi_x86_64(-)] # sys-devel/gcc-12.3.1_p20230526 requires >=dev-libs/gmp-4.3.2:0=, >=dev-libs/gmp-4.3.2:0/10.4= # # >>> No packages selected for removal by depclean # # Which gives you completely no reason for returning with non-zero # status. Ignore emerge failures here. # # Well, actually, technically the reason for failure is that we asked # for a removal of the unavailable packages and emerge found that # dev-libs/gmp-6.3.0 is not available but didn't remove it, because # it's pulled as a dependency by other packages. Question is why # emerge thinks that dev-libs/gmp-6.3.0 is not available. sudo -E ${EMERGE_CMD} --verbose --depclean @unavailable || : if portageq list_preserved_libs / >/dev/null; then info "Rebuilding packages linked against old libraries" sudo -E ${EMERGE_CMD} "${REBUILD_FLAGS[@]}" @preserved-rebuild fi # Automatically discard all CONFIG_PROTECT'ed files. Those that are # protected should not be overwritten until the variable is changed. # Autodiscard is option "-9" followed by the "YES" confirmation. printf '%s\nYES\n' -9 | sudo etc-update # If the user still has old perl modules installed, update them. PERL_VERSIONS=$(find /usr/lib*/perl5/vendor_perl/ -maxdepth 1 -mindepth 1 \ -type d -printf '%P\n' | sort -u | wc -w) if [ "$PERL_VERSIONS" -gt 1 ] ; then sudo perl-cleaner --all -- --quiet fi # Old $PS1 customization that doesn't work any more if [[ -e /etc/profile.d/coreos-niceties.sh ]]; then sudo rm -f /etc/profile.d/coreos-niceties.sh fi command_completed