build_library/dev_container_util.sh: Fix setting up portage

With PORTDIR and PORTDIR_OVERLAY environment variables being gone as
overrides, setting up a profile for the developer container broke. The
overrides were a hack already, as eselect does not seem to have
support for setting a profile based on repos.conf with repo locations
that are valid only after chrooting into the root directory. So
instead of invoking eselect, we set up the symlink ourselves.
This commit is contained in:
Krzesimir Nowak 2023-02-20 17:07:06 +01:00
parent a76292c7d5
commit a0208a706a

View File

@ -14,18 +14,22 @@ get_binhost_url() {
} }
configure_dev_portage() { configure_dev_portage() {
local root_fs_dir="${1}"; shift
local binhost="${1}"; shift
local update_group="${1}"; shift
# Need profiles at the bare minimum # Need profiles at the bare minimum
local repo local repo
for repo in portage-stable coreos-overlay; do for repo in portage-stable coreos-overlay; do
sudo mkdir -p "$1/var/lib/portage/${repo}" sudo mkdir -p "${root_fs_dir}/var/lib/portage/${repo}"
sudo rsync -rtl --exclude=md5-cache \ sudo rsync -rtl --exclude=md5-cache \
"${SRC_ROOT}/third_party/${repo}/metadata" \ "${SRC_ROOT}/third_party/${repo}/metadata" \
"${SRC_ROOT}/third_party/${repo}/profiles" \ "${SRC_ROOT}/third_party/${repo}/profiles" \
"$1/var/lib/portage/${repo}" "${root_fs_dir}/var/lib/portage/${repo}"
done done
sudo mkdir -p "$1/etc/portage/repos.conf" sudo mkdir -p "${root_fs_dir}/etc/portage/repos.conf"
sudo_clobber "$1/etc/portage/make.conf" <<EOF sudo_clobber "${root_fs_dir}/etc/portage/make.conf" <<EOF
# make.conf for Flatcar dev images # make.conf for Flatcar dev images
ARCH=$(get_board_arch $BOARD) ARCH=$(get_board_arch $BOARD)
CHOST=$(get_board_chost $BOARD) CHOST=$(get_board_chost $BOARD)
@ -34,11 +38,11 @@ CHOST=$(get_board_chost $BOARD)
DISTDIR="/var/lib/portage/distfiles" DISTDIR="/var/lib/portage/distfiles"
PKGDIR="/var/lib/portage/pkgs" PKGDIR="/var/lib/portage/pkgs"
PORT_LOGDIR="/var/log/portage" PORT_LOGDIR="/var/log/portage"
PORTAGE_BINHOST="$(get_binhost_url "$2" "$3" 'pkgs') PORTAGE_BINHOST="$(get_binhost_url "${binhost}" "${update_group}" 'pkgs')
$(get_binhost_url "$2" "$3" 'toolchain')" $(get_binhost_url "${binhost}" "${update_group}" 'toolchain')"
EOF EOF
sudo_clobber "$1/etc/portage/repos.conf/coreos.conf" <<EOF sudo_clobber "${root_fs_dir}/etc/portage/repos.conf/coreos.conf" <<EOF
[DEFAULT] [DEFAULT]
main-repo = portage-stable main-repo = portage-stable
@ -53,9 +57,18 @@ sync-type = git
sync-uri = https://github.com/flatcar/portage-stable.git sync-uri = https://github.com/flatcar/portage-stable.git
EOF EOF
# Now set the correct profile # Now set the correct profile, we do not use the eselect tool - it
sudo PORTAGE_CONFIGROOT="$1" ROOT="$1" \ # does not seem to be usable outside of the chroot without using
eselect profile set --force $(get_board_profile $BOARD)/dev # deprecated PORTDIR and PORTDIR_OVERLAY environment variables.
local profile_name=$(get_board_profile "${BOARD}")
# Turn coreos:coreos/amd64/generic into coreos/amd64/generic/dev
profile_name="${profile_name#*:}/dev"
local profile_directory="${root_fs_dir}/var/lib/portage/coreos-overlay/profiles/${profile_name}"
if [[ ! -d "${profile_directory}" ]]; then
die "Not a valid profile: ${profile_name}"
fi
local profile_link="${root_fs_dir}/etc/portage/make.profile"
sudo ln -sfrT "${profile_directory}" "${profile_link}"
} }
create_dev_container() { create_dev_container() {