Use Portage config directly from src dir

Instead of copying the Portage configuration files to `/etc/portage` and
`/usr/${target}/etc/portage`, the build scripts now use the
configuration directories from the source directory.  This avoids issues
with changes (especially removal of files) getting propagated to the
actual configuration paths.
This commit is contained in:
2023-03-07 10:30:06 -06:00
parent 3ca750f495
commit 5f62193247
59 changed files with 41 additions and 48 deletions

View File

@@ -13,16 +13,16 @@ fi
chown portage: "$(portageq envvar DISTDIR)"
ARCH=$(PORTAGE_CONFIGROOT=/usr/${target} portageq envvar ARCH)
PKGDIR=$(portageq envvar PKGDIR)
FEATURES="${FEATURES} binpkg-multi-instance"
if [ -f /usr/${target}/etc/portage/make.conf ]; then
sed -i '/PKGDIR=/d' /usr/${target}/etc/portage/make.conf
fi
# For some reason, libcap installs its pkg-config files in the wrong
# place. More strangely, even though `PKG_CONFIG_PATH` contains that
# directory, `pkg-config` does not find the `.pc` files for libcap.
# We work around this by merging /usr/lib64/pkgconfig and
# /usr/lib/pkgconfig.
FEATURES="${FEATURES} binpkg-multi-instance" \
FEATURES="${FEATURES}" \
PKGDIR="${PKGDIR}" \
${target}-emerge -kb1vnj sys-libs/libcap
if [ -d /usr/${target}/usr/lib/pkgconfig ] \
&& [ ! -d /usr/${target}/usr/lib64/pkgconfig ]; then
@@ -30,32 +30,35 @@ if [ -d /usr/${target}/usr/lib/pkgconfig ] \
ln -snf ../lib64/pkgconfig /usr/${target}/usr/lib/pkgconfig
fi
if [ ! -d /usr/${target}/etc/portage/make.conf ]; then
mv /usr/${target}/etc/portage/make.conf \
/usr/${target}/etc/portage/make.conf.orig
sed -ri 's: ?-pam::' /usr/${target}/etc/portage/make.conf.orig
ls -l /usr/${target}/etc/portage
mkdir /usr/${target}/etc/portage/make.conf
mv /usr/${target}/etc/portage/make.conf.orig \
/usr/${target}/etc/portage/make.conf/10-base.conf
fi
if [ ! -d /etc/portage/make.conf ]; then
mv /etc/portage/make.conf \
/etc/portage/make.conf.orig
mkdir /etc/portage/make.conf
mv /etc/portage/make.conf.orig \
/etc/portage/make.conf/10-base.conf
if [ ! -f portage/make.conf/10-crossdev.conf ]; then
sed -r \
-e 's: ?-pam::' \
-e '/PKGDIR=/d' \
/usr/${target}/etc/portage/make.conf \
> portage/config/target/etc/portage/make.conf/10-crossdev.conf
fi
ln -snf /var/db/repos/gentoo/profiles/default/linux/${ARCH}/17.0 \
/usr/${target}/etc/portage/make.profile
FEATURES="${FEATURES}" \
PKGDIR="${PKGDIR}" \
${target}-emerge -bk1nvj sys-libs/glibc
FEATURES="${FEATURES}" \
PKGDIR=$(portageq envvar PKGDIR) \
USE=pam \
${target}-emerge -bknvj sys-apps/util-linux
# Migrate to the merged-usr layout
mkdir -p /usr/${target}/bin
emerge -bknv --quiet-build=y merge-usr
merge-usr --root=/usr/${target}
# Set the Portage profile
ln -snf \
/var/db/repos/gentoo/profiles/${profile} \
portage/config/target/etc/portage/make.profile
ln -snf \
$(realpath /etc/portage/make.profile) \
portage/config/host/etc/portage/make.profile