2016-01-28 22:24:12 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [[ ${DIB_DEBUG_TRACE:-0} -gt 0 ]]; then
|
|
|
|
set -x
|
|
|
|
fi
|
|
|
|
set -eu
|
|
|
|
set -o pipefail
|
|
|
|
|
2017-09-13 21:57:12 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
# make world consistant
|
|
|
|
USE="-build" emerge -q --complete-graph=y --jobs=2 --update --newuse --deep --with-bdeps=y @world
|
2017-04-23 00:31:18 +00:00
|
|
|
# rebuild packages that might need it
|
|
|
|
USE="-build" emerge -q --jobs=2 --usepkg=n @preserved-rebuild
|
|
|
|
# remove unneeded packages
|
2016-01-28 22:24:12 +00:00
|
|
|
USE="-build" emerge --verbose=n --depclean
|
2017-04-23 00:31:18 +00:00
|
|
|
# rebuild packages that might have somehow depended on the unneeded packages
|
|
|
|
USE="-build" emerge -q --jobs=2 --usepkg=n @preserved-rebuild
|
2016-01-28 22:24:12 +00:00
|
|
|
|
|
|
|
# update config files
|
|
|
|
etc-update --automode -5
|
|
|
|
|
|
|
|
# clean up portage files
|
|
|
|
emerge --verbose=n --depclean
|
|
|
|
emaint all -f
|
|
|
|
eselect news read all
|
|
|
|
|
2016-07-28 20:11:43 +00:00
|
|
|
rm -Rf /root/.ccache/* /usr/src/* /var/cache/edb/dep/* /var/cache/genkernel/* /var/empty/* /var/run/* /var/state/* /var/tmp/*
|
2016-01-28 22:24:12 +00:00
|
|
|
rm -Rf /etc/*- /etc/*.old /etc/ssh/ssh_host_* /root/.*history /root/.lesshst /root/.ssh/known_hosts /root/.viminfo /usr/share/genkernel /usr/lib64/python*/site-packages/gentoolkit/test/eclean/testdistfiles.tar.gz
|
2016-07-28 20:11:43 +00:00
|
|
|
if [[ "${GENTOO_PORTAGE_CLEANUP}" != "False" ]]; then
|
2017-11-01 03:04:29 +00:00
|
|
|
# remove the overlays
|
|
|
|
if [[ ${GENTOO_OVERLAYS} != '' ]]; then
|
|
|
|
for OVERLAY in ${GENTOO_OVERLAYS}; do
|
|
|
|
layman -d "${OVERLAY}"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
# remove portage files
|
2018-03-16 23:29:40 +00:00
|
|
|
rm -Rf /usr/portage/* /usr/portage/.git /var/cache/portage/distfiles
|
2016-07-28 20:11:43 +00:00
|
|
|
fi
|
2016-01-28 22:24:12 +00:00
|
|
|
|
|
|
|
# shrink a bit
|
|
|
|
for i in $(find /var/log -type f); do echo > $i; done
|
|
|
|
find /usr/share/man/ -mindepth 1 -maxdepth 1 -path "/usr/share/man/man*" -prune -o -exec rm -rf {} \;
|
|
|
|
|
|
|
|
# make it so we don't have to reinstall grub
|
|
|
|
if [[ -a /usr/sbin/grub2-install ]]; then
|
|
|
|
mkdir -p /tmp/grub
|
|
|
|
touch /tmp/grub/install
|
|
|
|
fi
|
2017-09-13 21:57:12 +00:00
|
|
|
|
|
|
|
unfix_shm
|
2018-03-22 18:57:57 +00:00
|
|
|
|
|
|
|
# systemd id
|
|
|
|
if [[ "${GENTOO_PROFILE}" == *"systemd"* ]]; then
|
|
|
|
cp /dev/null /etc/machine-id
|
|
|
|
fi
|