images/elements/rocky-minimal-yum/post-install.d/99-cleanup-locales-etc

54 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# Stay compatible
echo 'container' > /etc/dnf/vars/infra
#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
find /usr/lib* -type d -name __pycache__ -print0 | xargs --null -I {} rm -frv {}
rm -fr /var/cache/dnf/*
rm -fr /var/lib/dnf/repos/*
rm -fr /run
rm -fr /home/ansible/
# systemd fixes
:> /etc/machine-id
# We're not bundling systemd, so this isn't actually here, nor does it matter if these are masked..
#
# systemd-tmpfiles --create --boot
#
# # mask mounts and login bits
# systemctl mask \
# console-getty.service \
# dev-hugepages.mount \
# getty.target \
# sys-fs-fuse-connections.mount \
# systemd-logind.service \
# systemd-remount-fs.service
# 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