Merge "support alternate portage directories"

This commit is contained in:
Zuul 2019-07-29 06:29:02 +00:00 committed by Gerrit Code Review
commit 3d7cea125f
10 changed files with 75 additions and 38 deletions

View File

@ -20,6 +20,25 @@ fi
set -eu set -eu
set -o pipefail set -o pipefail
# 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
declare -a GENTOO_EMERGE_ENV
GENTOO_EMERGE_ENV+=("USE=\"-build\"")
GENTOO_EMERGE_ENV+=("FEATURES=\"binpkg-multi-instance buildpkg parallel-fetch parallel-install\"")
GENTOO_EMERGE_ENV+=("PKGDIR=\"/tmp/portage-pkgdir\"")
GENTOO_EMERGE_ENV+=("DISTDIR=\"/tmp/portage-distdir\"")
GENTOO_EMERGE_ENV+=("PORTDIR=\"/tmp/portage-portdir\"")
export GENTOO_EMERGE_ENV
#export GENTOO_EMERGE_ENV=('USE="-build"' 'FEATURES="binpkg-multi-instance buildpkg parallel-fetch parallel-install"')
fi
# itterate over the array, exporting each 'line'
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"}
ACTION='install' ACTION='install'
SCRIPTNAME="$(basename $0)" SCRIPTNAME="$(basename $0)"
@ -55,7 +74,7 @@ eval set -- "${TEMP}"
while true; do while true; do
case "${1}" in case "${1}" in
-u ) -u )
if [[ ! -f /usr/portage/profiles ]]; then if [[ ! -f ${PORTDIR}/profiles ]]; then
emerge-webrsync -q emerge-webrsync -q
fi fi
install_gentoo_packages --update --deep --newuse --complete-graph=y @world install_gentoo_packages --update --deep --newuse --complete-graph=y @world
@ -100,12 +119,12 @@ if [[ -z "${PKGS}" ]]; then
echo "Not running install-packages ${ACTION} with empty packages list" echo "Not running install-packages ${ACTION} with empty packages list"
else else
if [[ "${ACTION}" == 'install' ]]; then if [[ "${ACTION}" == 'install' ]]; then
if [[ ! -f /usr/portage/profiles ]]; then if [[ ! -f ${PORTDIR}/profiles ]]; then
emerge-webrsync -q emerge-webrsync -q
fi fi
install_gentoo_packages -q --jobs=2 --changed-use "${PKGS}" install_gentoo_packages -q --jobs=2 --changed-use "${PKGS}"
elif [[ "${ACTION}" == 'remove' ]]; then elif [[ "${ACTION}" == 'remove' ]]; then
if [[ ! -f /usr/portage/profiles ]]; then if [[ ! -f ${PORTDIR}/profiles ]]; then
emerge-webrsync -q emerge-webrsync -q
fi fi
install_gentoo_packages -C "${PKGS}" install_gentoo_packages -C "${PKGS}"

View File

@ -8,15 +8,15 @@ set -o pipefail
[[ -n "${TMP_MOUNT_PATH}" ]] [[ -n "${TMP_MOUNT_PATH}" ]]
sudo umount -f "${TMP_MOUNT_PATH}"/usr/portage/distfiles sudo umount -f "${TMP_MOUNT_PATH}${DISTDIR}"
sudo umount -f "${TMP_MOUNT_PATH}"/usr/portage/packages sudo umount -f "${TMP_MOUNT_PATH}${PKGDIR}"
sudo umount -f "${TMP_MOUNT_PATH}"/usr/portage sudo umount -f "${TMP_MOUNT_PATH}${PORTDIR}"
sudo rm -Rf "${TMP_MOUNT_PATH}"/root/.ccache/* "${TMP_MOUNT_PATH}"/usr/src/* "${TMP_MOUNT_PATH}"/var/cache/edb/dep/* "${TMP_MOUNT_PATH}"/var/cache/genkernel/* "${TMP_MOUNT_PATH}"/var/empty/* "${TMP_MOUNT_PATH}"/var/state/* "${TMP_MOUNT_PATH}"/var/tmp/* sudo rm -Rf "${TMP_MOUNT_PATH}"/root/.ccache/* "${TMP_MOUNT_PATH}"/usr/src/* "${TMP_MOUNT_PATH}"/var/cache/edb/dep/* "${TMP_MOUNT_PATH}"/var/cache/genkernel/* "${TMP_MOUNT_PATH}"/var/empty/* "${TMP_MOUNT_PATH}"/var/state/* "${TMP_MOUNT_PATH}"/var/tmp/*
sudo rm -Rf "${TMP_MOUNT_PATH}"/etc/*- "${TMP_MOUNT_PATH}"/etc/*.old "${TMP_MOUNT_PATH}"/etc/ssh/ssh_host_* "${TMP_MOUNT_PATH}"/root/.*history "${TMP_MOUNT_PATH}"/root/.lesshst "${TMP_MOUNT_PATH}"/root/.ssh/known_hosts "${TMP_MOUNT_PATH}"/root/.viminfo "${TMP_MOUNT_PATH}"/usr/share/genkernel "${TMP_MOUNT_PATH}"/usr/lib64/python*/site-packages/gentoolkit/test/eclean/testdistfiles.tar.gz sudo rm -Rf "${TMP_MOUNT_PATH}"/etc/*- "${TMP_MOUNT_PATH}"/etc/*.old "${TMP_MOUNT_PATH}"/etc/ssh/ssh_host_* "${TMP_MOUNT_PATH}"/root/.*history "${TMP_MOUNT_PATH}"/root/.lesshst "${TMP_MOUNT_PATH}"/root/.ssh/known_hosts "${TMP_MOUNT_PATH}"/root/.viminfo "${TMP_MOUNT_PATH}"/usr/share/genkernel "${TMP_MOUNT_PATH}"/usr/lib64/python*/site-packages/gentoolkit/test/eclean/testdistfiles.tar.gz
if [[ "${GENTOO_PORTAGE_CLEANUP}" != "False" ]]; then if [[ "${GENTOO_PORTAGE_CLEANUP}" != "False" ]]; then
# remove portage files # remove portage files
sudo rm -Rf "${TMP_MOUNT_PATH}"/usr/portage/* "${TMP_MOUNT_PATH}"/usr/portage/.git "${TMP_MOUNT_PATH}"/var/cache/portage/distfiles sudo rm -Rf "${TMP_MOUNT_PATH}${PORTDIR}"/* "${TMP_MOUNT_PATH}${PORTDIR}"/.git "${TMP_MOUNT_PATH}"/var/cache/portage/distfiles "${TMP_MOUNT_PATH}"/usr/portage/*
fi fi
# shrink a bit # shrink a bit

View File

@ -1,15 +1,21 @@
export DIB_RELEASE=gentoo export DIB_RELEASE=gentoo
export DISTRO_NAME=gentoo export DISTRO_NAME=gentoo
export GENTOO_PROFILE=${GENTOO_PROFILE:-'default/linux/amd64/17.0'} export GENTOO_PROFILE=${GENTOO_PROFILE:-'default/linux/amd64/17.1'}
export GENTOO_PORTAGE_CLEANUP=${GENTOO_PORTAGE_CLEANUP:-'True'} export GENTOO_PORTAGE_CLEANUP=${GENTOO_PORTAGE_CLEANUP:-'True'}
export GENTOO_PYTHON_TARGETS=${GENTOO_PYTHON_TARGETS:-'python2_7 python3_6'} export GENTOO_PYTHON_TARGETS=${GENTOO_PYTHON_TARGETS:-'python2_7 python3_6'}
export GENTOO_PYTHON_ACTIVE_VERSION=${GENTOO_PYTHON_ACTIVE_VERSION:-'python3.6'} export GENTOO_PYTHON_ACTIVE_VERSION=${GENTOO_PYTHON_ACTIVE_VERSION:-'python3.6'}
export GENTOO_OVERLAYS=${GENTOO_OVERLAYS:-''} export GENTOO_OVERLAYS=${GENTOO_OVERLAYS:-''}
export 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"} export 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"}
# set the default bash array if GENTOO_EMERGE_ENV is not defined as an array # 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 if ! declare -p GENTOO_EMERGE_ENV 2> /dev/null | grep -q '^declare \-a'; then
export GENTOO_EMERGE_ENV=('USE="-build"' 'FEATURES="binpkg-multi-instance buildpkg parallel-fetch parallel-install"' 'EMERGE_DEFAULT_OPTS="--autounmask=n"') declare -a GENTOO_EMERGE_ENV
GENTOO_EMERGE_ENV+=("USE=\"-build\"")
GENTOO_EMERGE_ENV+=("FEATURES=\"binpkg-multi-instance buildpkg parallel-fetch parallel-install\"")
GENTOO_EMERGE_ENV+=("PKGDIR=\"/tmp/portage-pkgdir\"")
GENTOO_EMERGE_ENV+=("DISTDIR=\"/tmp/portage-distdir\"")
GENTOO_EMERGE_ENV+=("PORTDIR=\"/tmp/portage-portdir\"")
export GENTOO_EMERGE_ENV
fi fi
# itterate over the array, exporting each 'line' # itterate over the array, exporting each 'line'
for (( i=0; i<${#GENTOO_EMERGE_ENV[@]}; i++ )); do for (( i=0; i<${#GENTOO_EMERGE_ENV[@]}; i++ )); do

View File

@ -15,7 +15,7 @@ else
fi fi
# sync if needed # sync if needed
[[ ! -e /usr/portage/profiles ]] && emerge-webrsync [[ ! -e ${PORTDIR}/profiles ]] && emerge-webrsync
# make world consistent # make world consistent
emerge ${GENTOO_EMERGE_DEFAULT_OPTS} --complete-graph=y --update --newuse --deep @world emerge ${GENTOO_EMERGE_DEFAULT_OPTS} --complete-graph=y --update --newuse --deep @world
@ -47,3 +47,6 @@ unfix_shm
# remove within the chroot since /var/run is a symlink # remove within the chroot since /var/run is a symlink
rm -Rf /var/run/* /run/* rm -Rf /var/run/* /run/*
# after updating, set profile to where PORTDIR actually is (varies by profile)
ln -sf ../.."$(env -u PORTDIR portageq get_repo_path / gentoo)/profiles/${GENTOO_PROFILE}" /etc/portage/make.profile

View File

@ -10,8 +10,9 @@ GENTOO_PORTAGE_DISTFILES_DIR="${DIB_IMAGE_CACHE}/gentoo/distfiles"
GENTOO_PORTAGE_PACKAGE_DIR="${DIB_IMAGE_CACHE}/gentoo/packages/${GENTOO_PROFILE}" GENTOO_PORTAGE_PACKAGE_DIR="${DIB_IMAGE_CACHE}/gentoo/packages/${GENTOO_PROFILE}"
GENTOO_PORTAGE_DIR="${DIB_IMAGE_CACHE}/gentoo/portage" GENTOO_PORTAGE_DIR="${DIB_IMAGE_CACHE}/gentoo/portage"
sudo mount --bind "${GENTOO_PORTAGE_DIR}" "${TMP_MOUNT_PATH}"/usr/portage mkdir -p "${TMP_MOUNT_PATH}${PORTDIR}"
mkdir -p "${TMP_MOUNT_PATH}"/usr/portage/distfiles sudo mount --bind "${GENTOO_PORTAGE_DIR}" "${TMP_MOUNT_PATH}${PORTDIR}"
sudo mount --bind "${GENTOO_PORTAGE_DISTFILES_DIR}" "${TMP_MOUNT_PATH}"/usr/portage/distfiles mkdir -p "${TMP_MOUNT_PATH}${DISTDIR}"
mkdir -p "${TMP_MOUNT_PATH}"/usr/portage/packages sudo mount --bind "${GENTOO_PORTAGE_DISTFILES_DIR}" "${TMP_MOUNT_PATH}${DISTDIR}"
sudo mount --bind "${GENTOO_PORTAGE_PACKAGE_DIR}" "${TMP_MOUNT_PATH}"/usr/portage/packages mkdir -p "${TMP_MOUNT_PATH}${PKGDIR}"
sudo mount --bind "${GENTOO_PORTAGE_PACKAGE_DIR}" "${TMP_MOUNT_PATH}${PKGDIR}"

View File

@ -0,0 +1,10 @@
#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# set profile symlink to the hardcoded PORDIR
ln -sf ../.."${PORTDIR}/profiles/${GENTOO_PROFILE}" /etc/portage/make.profile

View File

@ -15,7 +15,7 @@ if [[ ${GENTOO_OVERLAYS} != '' ]]; then
fix_shm fix_shm
fi fi
if [[ ! -f /usr/portage/profiles ]]; then if [[ ! -f ${PORTDIR}/profiles ]]; then
emerge-webrsync -q emerge-webrsync -q
fi fi

View File

@ -14,9 +14,7 @@ else
fix_shm fix_shm
fi fi
if [[ ! -f /usr/portage/profiles ]]; then [[ ! -f ${PORTDIR}/profiles ]] && emerge-webrsync -q
emerge-webrsync -q
fi
echo "PYTHON_TARGETS=\"${GENTOO_PYTHON_TARGETS}\"" >> /etc/portage/make.conf echo "PYTHON_TARGETS=\"${GENTOO_PYTHON_TARGETS}\"" >> /etc/portage/make.conf
[[ "${GENTOO_PYTHON_TARGETS}" == *"python3_6"* ]] && [[ ! -e /usr/lib64/libpython3.6m.so ]] && emerge ${GENTOO_EMERGE_DEFAULT_OPTS} --oneshot dev-lang/python:3.6 [[ "${GENTOO_PYTHON_TARGETS}" == *"python3_6"* ]] && [[ ! -e /usr/lib64/libpython3.6m.so ]] && emerge ${GENTOO_EMERGE_DEFAULT_OPTS} --oneshot dev-lang/python:3.6
@ -24,12 +22,11 @@ echo "PYTHON_TARGETS=\"${GENTOO_PYTHON_TARGETS}\"" >> /etc/portage/make.conf
[[ "${GENTOO_PYTHON_TARGETS}" == *"python3_4"* ]] && [[ ! -e /usr/lib64/libpython3.4m.so ]] && emerge ${GENTOO_EMERGE_DEFAULT_OPTS} --oneshot dev-lang/python:3.4 [[ "${GENTOO_PYTHON_TARGETS}" == *"python3_4"* ]] && [[ ! -e /usr/lib64/libpython3.4m.so ]] && emerge ${GENTOO_EMERGE_DEFAULT_OPTS} --oneshot dev-lang/python:3.4
[[ "${GENTOO_PYTHON_TARGETS}" == *"python2_7"* ]] && [[ ! -e /usr/lib64/libpython2.7.so ]] && emerge ${GENTOO_EMERGE_DEFAULT_OPTS} --oneshot dev-lang/python:2.7 [[ "${GENTOO_PYTHON_TARGETS}" == *"python2_7"* ]] && [[ ! -e /usr/lib64/libpython2.7.so ]] && emerge ${GENTOO_EMERGE_DEFAULT_OPTS} --oneshot dev-lang/python:2.7
# disable python in git if we have to, it only supports python-2.7 # disable python in git if we have to, it only supports python-2.7
if [[ "${GENTOO_PYTHON_TARGETS}" != *"python2_7"* ]]; then [[ "${GENTOO_PYTHON_TARGETS}" != *"python2_7"* ]] && echo 'dev-vcs/git -python' >> /etc/portage/package.use/git
echo 'dev-vcs/git -python' >> /etc/portage/package.use/git
fi
# make sure we have the new python for portage bevore we possibly remove python 2.7 # make sure we have the new python for portage bevore we possibly remove python 2.7
# this is done one by one with nodeps because it can sometimes have dependency loops # this is done one by one with nodeps because it can sometimes have dependency loops
PYTHON_PACKAGES="dev-python/six dev-python/packaging dev-python/pyparsing dev-python/appdirs dev-python/setuptools dev-python/certifi" PYTHON_PACKAGES="dev-python/six dev-python/packaging dev-python/appdirs dev-python/setuptools dev-python/pyparsing dev-python/certifi"
for PACKAGE in ${PYTHON_PACKAGES}; do for PACKAGE in ${PYTHON_PACKAGES}; do
emerge ${GENTOO_EMERGE_DEFAULT_OPTS} --oneshot --update --newuse --deep --nodeps "${PACKAGE}" emerge ${GENTOO_EMERGE_DEFAULT_OPTS} --oneshot --update --newuse --deep --nodeps "${PACKAGE}"
done done

View File

@ -38,17 +38,17 @@ fi
# default/linux/amd64/13.0/no-multilib # default/linux/amd64/13.0/no-multilib
# hardened/linux/amd64 # hardened/linux/amd64
# hardened/linux/amd64/no-multilib # hardened/linux/amd64/no-multilib
GENTOO_PROFILE=${GENTOO_PROFILE:-'default/linux/amd64/17.0'} GENTOO_PROFILE=${GENTOO_PROFILE:-'default/linux/amd64/17.1'}
if [[ "${GENTOO_PROFILE}" == "default/linux/amd64/17.0" ]]; then if [[ "${GENTOO_PROFILE}" == "default/linux/amd64/17.1" ]]; then
FILENAME_BASE='gentoo-stage4' FILENAME_BASE='gentoo-stage4'
SIGNED_SOURCE_SUFFIX='minimal' SIGNED_SOURCE_SUFFIX='minimal'
elif [[ "${GENTOO_PROFILE}" == "default/linux/amd64/17.0/no-multilib" ]]; then elif [[ "${GENTOO_PROFILE}" == "default/linux/amd64/17.1/no-multilib" ]]; then
FILENAME_BASE='gentoo-stage4-nomultilib' FILENAME_BASE='gentoo-stage4-nomultilib'
SIGNED_SOURCE_SUFFIX='minimal-nomultilib' SIGNED_SOURCE_SUFFIX='minimal-nomultilib'
elif [[ "${GENTOO_PROFILE}" == "default/linux/amd64/17.0/hardened" ]]; then elif [[ "${GENTOO_PROFILE}" == "default/linux/amd64/17.1/hardened" ]]; then
FILENAME_BASE='gentoo-stage4-hardened' FILENAME_BASE='gentoo-stage4-hardened'
SIGNED_SOURCE_SUFFIX='hardened+minimal' SIGNED_SOURCE_SUFFIX='hardened+minimal'
elif [[ "${GENTOO_PROFILE}" == "default/linux/amd64/17.0/no-multilib/hardened" ]]; then elif [[ "${GENTOO_PROFILE}" == "default/linux/amd64/17.1/no-multilib/hardened" ]]; then
FILENAME_BASE='gentoo-stage4-hardened-nomultilib' FILENAME_BASE='gentoo-stage4-hardened-nomultilib'
SIGNED_SOURCE_SUFFIX='hardened+minimal-nomultilib' SIGNED_SOURCE_SUFFIX='hardened+minimal-nomultilib'
elif [[ "${GENTOO_PROFILE}" == "default/linux/amd64/17.0/systemd" ]]; then elif [[ "${GENTOO_PROFILE}" == "default/linux/amd64/17.0/systemd" ]]; then
@ -56,10 +56,10 @@ elif [[ "${GENTOO_PROFILE}" == "default/linux/amd64/17.0/systemd" ]]; then
SIGNED_SOURCE_SUFFIX='systemd' SIGNED_SOURCE_SUFFIX='systemd'
else else
echo 'invalid profile, please select from the following profiles' echo 'invalid profile, please select from the following profiles'
echo 'default/linux/amd64/17.0' echo 'default/linux/amd64/17.1'
echo 'default/linux/amd64/17.0/no-multilib' echo 'default/linux/amd64/17.1/no-multilib'
echo 'default/linux/amd64/17.0/hardened' echo 'default/linux/amd64/17.1/hardened'
echo 'default/linux/amd64/17.0/no-multilib/hardened' echo 'default/linux/amd64/17.1/no-multilib/hardened'
echo 'default/linux/amd64/17.0/systemd' echo 'default/linux/amd64/17.0/systemd'
exit 1 exit 1
fi fi

View File

@ -13,8 +13,9 @@ GENTOO_PORTAGE_PACKAGE_DIR="${DIB_IMAGE_CACHE}/gentoo/packages/${GENTOO_PROFILE}
GENTOO_PORTAGE_DIR="${DIB_IMAGE_CACHE}/gentoo/portage" GENTOO_PORTAGE_DIR="${DIB_IMAGE_CACHE}/gentoo/portage"
mkdir -p "${GENTOO_PORTAGE_DIR}" "${GENTOO_PORTAGE_PACKAGE_DIR}" "${GENTOO_PORTAGE_DISTFILES_DIR}" mkdir -p "${GENTOO_PORTAGE_DIR}" "${GENTOO_PORTAGE_PACKAGE_DIR}" "${GENTOO_PORTAGE_DISTFILES_DIR}"
sudo mount --bind "${GENTOO_PORTAGE_DIR}" "${TMP_MOUNT_PATH}"/usr/portage mkdir -p "${TMP_MOUNT_PATH}${PORTDIR}"
mkdir -p "${TMP_MOUNT_PATH}"/usr/portage/distfiles sudo mount --bind "${GENTOO_PORTAGE_DIR}" "${TMP_MOUNT_PATH}${PORTDIR}"
sudo mount --bind "${GENTOO_PORTAGE_DISTFILES_DIR}" "${TMP_MOUNT_PATH}"/usr/portage/distfiles mkdir -p "${TMP_MOUNT_PATH}${DISTDIR}"
mkdir -p "${TMP_MOUNT_PATH}"/usr/portage/packages sudo mount --bind "${GENTOO_PORTAGE_DISTFILES_DIR}" "${TMP_MOUNT_PATH}${DISTDIR}"
sudo mount --bind "${GENTOO_PORTAGE_PACKAGE_DIR}" "${TMP_MOUNT_PATH}"/usr/portage/packages mkdir -p "${TMP_MOUNT_PATH}${PKGDIR}"
sudo mount --bind "${GENTOO_PORTAGE_PACKAGE_DIR}" "${TMP_MOUNT_PATH}${PKGDIR}"