flatcar-scripts/build_toolchains
Krzesimir Nowak 4d81a04be8 build_toolchains: Break dep loop and handle more dependencies
Switching to a selinux profile caused more USE flags to be enabled
(selinux, audit, caps), thus more dependencies to be pulled. More
dependencies caused two things:

- cyclic dependencies appeared
- sys-apps/baselayout is being pulled in

Cyclic dependencies need to be handled in a similar way it was done in
build_packages, thus factor out the code doing it into a separate and
reusable part.

The dependency on baselayout needs to be handled by installing the
package as a first thing in $ROOT, followed by a more careful way of
copying things from $SYSROOT to $ROOT (due to split-usr differences),
followed by installing the rest of the packages.

Signed-off-by: Krzesimir Nowak <knowak@microsoft.com>
2025-11-24 16:26:29 +01:00

60 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
#
# Copyright (c) 2013 The CoreOS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
SCRIPT_ROOT=$(dirname $(readlink -f "$0"))
. "${SCRIPT_ROOT}/common.sh" || exit 1
TYPE="coreos-toolchains"
FORCE_STAGES="stage4"
. "${BUILD_LIBRARY_DIR}/catalyst.sh" || exit 1
# include upload options
. "${BUILD_LIBRARY_DIR}/release_util.sh" || exit 1
## Define the stage4 config template
catalyst_stage4() {
cat <<EOF
pkgcache_path: $BINPKGS
stage4/packages: @system
stage4/fsscript: ${BUILD_LIBRARY_DIR}/catalyst_toolchains.sh
stage4/root_overlay: ${ROOT_OVERLAY}
EOF
catalyst_stage_default 4
}
create_provenance_overlay() {
local root_overlay="$1"
local f d scripts_hash
while read f; do
d="${f%/*}"
mkdir -p "${root_overlay}${d}/"
cp "${f}" "${root_overlay}${d}/"
done < <(find /mnt/host/source/src/scripts -name HEAD)
local scripts_git=/mnt/host/source/src/scripts/.git
# `git rev-parse` fails due to the safe.directory setting in SDK container.
# Open-code the ref lookup
read scripts_hash <"${scripts_git}/HEAD"
if [[ "${scripts_hash}" == "ref:"* ]]; then
read scripts_hash<"${scripts_git}/${scripts_hash#ref: }"
echo "${scripts_hash}" >"${root_overlay}${scripts_git}/HEAD"
fi
mkdir -p "${root_overlay}/mnt/host/source/.repo/manifests"
cp "${REPO_MANIFESTS_DIR}/version.txt" "${root_overlay}/mnt/host/source/.repo/manifests"
}
catalyst_init "$@"
ROOT_OVERLAY="${TEMPDIR}/stage4-${ARCH}-$FLAGS_version-overlay"
# toolchain_util.sh and break_dep_loop.sh are required by
# catalyst_toolchains.sh
mkdir -p "${ROOT_OVERLAY}/tmp"
cp "${BUILD_LIBRARY_DIR}/toolchain_util.sh" "${BUILD_LIBRARY_DIR}/break_dep_loop.sh" "${ROOT_OVERLAY}/tmp"
create_provenance_overlay "${ROOT_OVERLAY}"
catalyst_build
command_completed