2023-11-21 21:29:12 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then
|
|
|
|
set -x
|
|
|
|
fi
|
|
|
|
set -eu
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
# Stay compatible
|
2023-11-22 02:06:58 +00:00
|
|
|
echo "container-${DIB_YUM_ROCKY_CONTAINER_TYPE}" > /etc/dnf/vars/infra
|
2023-11-21 21:29:12 +00:00
|
|
|
|
|
|
|
#Generate installtime file record
|
|
|
|
/bin/date +%Y%m%d_%H%M > /etc/BUILDTIME
|
|
|
|
|
|
|
|
# Limit languages to help reduce size.
|
|
|
|
LANG="en_US"
|
|
|
|
echo "%_install_langs $LANG" > /etc/rpm/macros.image-language-conf
|
|
|
|
|
|
|
|
# https://bugzilla.redhat.com/show_bug.cgi?id=1727489
|
|
|
|
echo 'LANG="C.UTF-8"' > /etc/locale.conf
|
|
|
|
|
|
|
|
for dir in $(ls -d /usr/share/locale/* | grep -v 'en_US\|all_languages\|locale\.alias'); do rm -fr $dir; done
|
|
|
|
|
|
|
|
rm -fr /usr/share/man
|
|
|
|
|
|
|
|
# Cleanup caches left by chroot
|
2023-11-22 02:06:58 +00:00
|
|
|
find /usr/lib* -type d -name __pycache__ -print0 | xargs --null -I {} rm -fr {}
|
2023-11-21 21:29:12 +00:00
|
|
|
rm -fr /var/cache/dnf/*
|
2023-11-22 01:56:36 +00:00
|
|
|
rm -fr /var/lib/dnf/repos/*
|
2023-11-21 21:29:12 +00:00
|
|
|
rm -fr /run
|
|
|
|
rm -fr /home/ansible/
|
|
|
|
|
|
|
|
# systemd fixes
|
|
|
|
:> /etc/machine-id
|
|
|
|
|
|
|
|
# Cleanup the image
|
|
|
|
rm -fv /etc/udev/hwdb.bin
|
|
|
|
rm -rfv /usr/lib/udev/hwdb.d/ \
|
|
|
|
/boot /var/lib/dnf/history.* \
|
|
|
|
"/tmp/*" "/tmp/.*" /var/log/* || true
|