diskimage-builder/diskimage_builder/elements/gentoo/finalise.d/99-cleanup
Matthew Thode f1d7e902e3
support alternate portage directories
The 17.1 profile changed the defaults used in portage for where we store
our repo, distfiles and binpkgs.  Some portage related variables need to
be set deterministically.  17.1 is no enabled for Systemd's profile.

Change-Id: Ib55f6875c5cb461c3c530b51d7420ce3dc8da360
2019-07-26 19:30:01 -05:00

52 lines
1.4 KiB
Bash
Executable file

#!/bin/bash
if [[ ${DIB_DEBUG_TRACE:-0} -gt 0 ]]; then
set -x
fi
set -eu
set -o pipefail
if mountpoint -q /dev/shm; then
echo "/dev/shm found in /proc/self/mountinfo"
elif [[ -k /dev/shm ]]; then
echo "/dev/shm exists and is stickied"
else
fix_shm
fi
# sync if needed
[[ ! -e ${PORTDIR}/profiles ]] && emerge-webrsync
# make world consistent
emerge ${GENTOO_EMERGE_DEFAULT_OPTS} --complete-graph=y --update --newuse --deep @world
# rebuild packages that might need it
emerge ${GENTOO_EMERGE_DEFAULT_OPTS} --usepkg=n @preserved-rebuild
# remove unneeded packages
emerge --verbose=n --depclean
# rebuild packages that might have somehow depended on the unneeded packages
emerge ${GENTOO_EMERGE_DEFAULT_OPTS} --usepkg=n @preserved-rebuild
# update config files
etc-update --automode -5
# clean up portage files
emerge --verbose=n --depclean
emaint all -f
eselect news read all
if [[ "${GENTOO_PORTAGE_CLEANUP}" != "False" ]]; then
# remove the overlays
if [[ ${GENTOO_OVERLAYS} != '' ]]; then
for OVERLAY in ${GENTOO_OVERLAYS}; do
layman -d "${OVERLAY}"
done
fi
fi
unfix_shm
# remove within the chroot since /var/run is a symlink
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