flatcar-scripts/build_library/catalyst_toolchains.sh
James Le Cuirot 1d7d53fad9
Upgrade to Catalyst 4
Catalyst 4 has totally changed the way repositories are handled. It only
works when the name of the directory containing the repository matches
the configured name of that repository. This was not the case for us,
with the coreos repository residing in the coreos-overlay directory. We
wanted to move and rename our repositories anyway, but this is a big
change, so we'll do separately. For now, this just renames coreos to
coreos-overlay.

Catalyst 4 also ingests the main repository snapshot as a squashfs
rather than a tarball. It features a utility to generate such a
snapshot, but it doesn't fit Flatcar well, particularly because it
expects each ebuild repository to reside at the top level of its own git
repository. It was very easy to call tar2sqfs manually though.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
2024-07-15 14:27:59 +01:00

48 lines
1.5 KiB
Bash

#!/bin/bash
set -e
source /tmp/chroot-functions.sh
source /tmp/toolchain_util.sh
# A note on packages:
# The default PKGDIR is /usr/portage/packages
# To make sure things are uploaded to the correct places we split things up:
# crossdev build packages use ${PKGDIR}/crossdev (uploaded to SDK location)
# build deps in crossdev's sysroot use ${PKGDIR}/cross/${CHOST} (no upload)
# native toolchains use ${PKGDIR}/target/${BOARD} (uploaded to board location)
configure_target_root() {
local board="$1"
local cross_chost=$(get_board_chost "$1")
local profile=$(get_board_profile "${board}")
CBUILD="$(portageq envvar CBUILD)" \
CHOST="${cross_chost}" \
ROOT="/build/${board}" \
SYSROOT="/build/${board}" \
_configure_sysroot "${profile}"
}
build_target_toolchain() {
local board="$1"
local ROOT="/build/${board}"
local SYSROOT="/usr/$(get_board_chost "${board}")"
mkdir -p "${ROOT}/usr"
cp -at "${ROOT}" "${SYSROOT}"/lib*
cp -at "${ROOT}"/usr "${SYSROOT}"/usr/include "${SYSROOT}"/usr/lib*
# --root is required because run_merge overrides ROOT=
PORTAGE_CONFIGROOT="$ROOT" \
run_merge -u --root="$ROOT" --sysroot="$ROOT" "${TOOLCHAIN_PKGS[@]}"
}
configure_crossdev_overlay / /usr/local/portage/crossdev
for board in $(get_board_list); do
echo "Building native toolchain for ${board}"
target_pkgdir="$(portageq envvar PKGDIR)/target/${board}"
PKGDIR="${target_pkgdir}" configure_target_root "${board}"
PKGDIR="${target_pkgdir}" build_target_toolchain "${board}"
done