Fix various minor issues with Gentoo; make CI pass

This patch contains the known set of changes needed to make a gentoo
image build successfully.

- Standardize use of GENTOO_EMERGE_DEFAULT_OPTS, reduce duplication of
  options set there.
- Correct the cleanup commands to reflect standard Gentoo good
  practices by omitting --complete-graph, which is unneeded with --deep,
  and using --changed-use instead of --newuse to reduce unneeded package
  churn.
- Stop using deprecated layman command to manage reposiotry overlays,
  instead use new supported eselect-repository
- Set new USE flags required for LVM and installkernel. This was
  communicated via a Gentoo news item and is a required cleanup.
- Remove now-invalid skip of gpg if using musl

This is the set of changes needed to get the CI job passing and make DIB
build images at all, and we'd like to land them, but there are still
items we'd like to complete to enhance Gentoo support in DIB:
- Optional, built-in support for Gentoo binhosts -- where you can set a
  DIB_GENTOO_BINHOST=true (or similar) and have the binhost enabled by
  default.
- Make the default configuration of EMERGE_DEFAULT_OPTS more easily
  managed in a DIB-style manner, e.g. setting --quiet vs --verbose based
  on the value of DIB_DEBUG_TRACE.

Signed-Off-By: Jay Faulkner <jay@jvf.cc>
Signed-Off-By: Sam James <sam@gentoo.org>
Co-Authored-By: Sam James <sam@gentoo.org>
Change-Id: Idab82a9fa986fcc56fe4e1e1bf0445c7306b2858
This commit is contained in:
Sam James
2024-02-04 22:25:36 +00:00
committed by Jay Faulkner
parent 6fa80234bc
commit 9e0ff1f5b3
5 changed files with 15 additions and 13 deletions

View File

@@ -20,6 +20,12 @@ fi
set -eu
set -o pipefail
# note(JayF): YACC and LEX are both set by gentoo alternatives handling if you want to
# use alternative implementations of them. Since whatever alternative
# implementation is opted-for may not availabe inside the image, we need to
# unset the environment to ensure default behavior.
unset YACC LEX
# env is not sourced with user specified package inclusions
# set the default bash array if GENTOO_EMERGE_ENV is not defined as an array
if ! declare -p GENTOO_EMERGE_ENV 2> /dev/null | grep -q '^declare \-a'; then
@@ -36,7 +42,7 @@ for (( i=0; i<${#GENTOO_EMERGE_ENV[@]}; i++ )); do
eval export "${GENTOO_EMERGE_ENV[i]}"
done
# set default opts
GENTOO_EMERGE_DEFAULT_OPTS=${GENTOO_EMERGE_DEFAULT_OPTS:-"--binpkg-respect-use --rebuilt-binaries=y --usepkg=y --with-bdeps=y --binpkg-changed-deps=y --quiet --jobs=2 --autounmask=n"}
GENTOO_EMERGE_DEFAULT_OPTS=${GENTOO_EMERGE_DEFAULT_OPTS:-"--binpkg-respect-use --rebuilt-binaries=y --usepkg=y --with-bdeps=y --binpkg-changed-deps=y --jobs=2 --verbose --autounmask=n"}
ACTION='install'
@@ -76,7 +82,7 @@ while true; do
if [[ ! -f ${PORTDIR}/profiles ]]; then
emerge-webrsync -q
fi
install_gentoo_packages --update --deep --newuse --complete-graph=y @world
install_gentoo_packages --update --deep --changed-use @world
install_gentoo_packages --verbose=n --depclean
install_gentoo_packages --usepkg=n @preserved-rebuild
etc-update --automode -5
@@ -121,7 +127,7 @@ else
if [[ ! -f ${PORTDIR}/profiles ]]; then
emerge-webrsync -q
fi
install_gentoo_packages -q --jobs=2 --changed-use "${PKGS}"
install_gentoo_packages --changed-use "${PKGS}"
elif [[ "${ACTION}" == 'remove' ]]; then
if [[ ! -f ${PORTDIR}/profiles ]]; then
emerge-webrsync -q
@@ -143,3 +149,4 @@ else
echo 'something went really wrong, install action is not install or remove'
fi
fi

View File

@@ -18,7 +18,7 @@ fi
[[ ! -e ${PORTDIR}/profiles ]] && emerge-webrsync
# make world consistent
emerge ${GENTOO_EMERGE_DEFAULT_OPTS} --complete-graph=y --update --newuse --deep @world
emerge ${GENTOO_EMERGE_DEFAULT_OPTS} --update --changed-use --deep @world
# rebuild packages that might need it
emerge ${GENTOO_EMERGE_DEFAULT_OPTS} --usepkg=n @preserved-rebuild
# remove unneeded packages

View File

@@ -19,7 +19,8 @@ mkdir -p /etc/portage/package.use
# needed in order to install pip packages as root
echo 'dev-python/pip vanilla' >> /etc/portage/package.use/pip
# needed to create disk images
echo 'sys-fs/lvm2 -thin' >> /etc/portage/package.use/grub
echo 'sys-fs/lvm2 lvm -thin' >> /etc/portage/package.use/grub
echo 'sys-kernel/installkernel dracut' >> /etc/portage/package.use/kernel
echo 'sys-boot/grub device-mapper' >> /etc/portage/package.use/grub
echo 'sys-boot/grub grub_platforms_efi-64' >> /etc/portage/package.use/grub # always enable efi-64
if [[ 'amd64' == "${ARCH}" ]]; then
@@ -36,6 +37,5 @@ echo "~sys-block/open-isns-0.101 ~${ARCH}" >> /etc/portage/package.accept_keywor
# musl only valid for amd64 for now
if [[ "${GENTOO_PROFILE}" == *"musl"* ]]; then
echo "dev-vcs/git -gpg" >> /etc/portage/package.use/musl # gpg doesn't build on musl profiles
echo "sys-libs/pam cracklib" >> /etc/portage/package.use/musl
fi

View File

@@ -20,16 +20,11 @@ if [[ ${GENTOO_OVERLAYS} != '' ]]; then
fi
emerge ${GENTOO_EMERGE_DEFAULT_OPTS} --oneshot openssl openssh
# install layman
emerge ${GENTOO_EMERGE_DEFAULT_OPTS} --deep --ignore-built-slot-operator-deps=y layman
# set layman config options
sed -i 's/^check_official.*/check_official : No/g' /etc/layman/layman.cfg # allow unoffical repos
# sync the initial overlay list
layman -S
emerge ${GENTOO_EMERGE_DEFAULT_OPTS} --oneshot eselect-repository
# enable the various overlays, ignore failures (overlay my already be enabled)
set +e
for OVERLAY in ${GENTOO_OVERLAYS}; do
layman -a "${OVERLAY}"
eselect repository enable "${OVERLAY}"
done
set -e

0
diskimage_builder/lib/disk-image-create Normal file → Executable file
View File