diskimage-builder/diskimage_builder/elements/gentoo/finalise.d/99-cleanup
Matthew Thode 89f95a5351
enable caching for gentoo builds
To facilitate this I've created two new environment variables to set
the environment and default options for package actions.

eval is needed for the export as it preserves quotes.

Change-Id: Ib03651ee8dacd48cd1c135afd57cd31101356056
Signed-off-by: Matthew Thode <mthode@mthode.org>
2018-10-15 23:17:37 -05:00

50 lines
1.2 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 /usr/portage/profiles ]] && emerge-webrsync
# make world consistant
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/*