Some follow-up checks of recent firmware fixes caused me to realize
we've mixxed up the firmware cleanup even more and our defensiveness
on the removal resulted in some confusion.
Ultimately, I guess this is... my second attempt to improve this, but
also attempt to heavily restrict our automatic glob expansion usage.
2025-11-12 18:58:43.824 | + rm -rf /usr/lib/firmware/vicam
2025-11-12 18:58:43.824 | + for item in ${IPA_REMOVE_FIRMWARE//,/ }
2025-11-12 18:58:43.824 | + [[ iwlwifi != '' ]]
2025-11-12 18:58:43.824 | + [[ iwlwifi =~ / ]]
2025-11-12 18:58:43.824 | + rm -rf /usr/lib/firmware/iwlwifi
2025-11-12 18:58:43.824 | + for item in ${IPA_REMOVE_FIRMWARE//,/ }
2025-11-12 18:58:43.824 | + [[ intel/ibt != '' ]]
2025-11-12 18:58:43.824 | + [[ intel/ibt =~ / ]]
2025-11-12 18:58:43.824 | + rm -r -f '/usr/lib/firmware/intel/ibt*'
The net result before this change was the IPA Centos10 build initramfs
files were running around 533 MB, and with this change the file sizes
are down to 464MB.
Change-Id: Ie420a192fbf9ed2fa246c31d799078186a5ca8e7
Signed-off-by: Julia Kreger <juliaashleykreger@gmail.com>
72 lines
3.0 KiB
Bash
Executable File
72 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
|
|
set -x
|
|
fi
|
|
set -eu
|
|
set -o pipefail
|
|
|
|
rm -rf /tmp/ironic-python-agent
|
|
# In Centos Stream, /lib is linked to /lib/firmware, so the first
|
|
# loop will likely go ahead and remove everything, but the || true
|
|
# below will keep it from erroring.
|
|
KNOWN_FIRMWARE_PATH="/lib/firmware/ /usr/lib/firmware/"
|
|
for folder in $KNOWN_FIRMWARE_PATH; do
|
|
if [[ ! -d $folder ]]; then
|
|
echo "Skipping firmware removal for $folder as it is not found."
|
|
fi
|
|
for item in ${IPA_REMOVE_FIRMWARE//,/ }; do
|
|
# NOTE(TheJulia): The original idea here has been delete whole folders
|
|
# but the patterns have shifted and evolved, and it we need to remove
|
|
# files in the main folder as well, or subsections their of. Also, due
|
|
# to perception of risk on the build process, the code is intended
|
|
# to be *very* defensive here.
|
|
|
|
# tl;dr Attempt removal of item, but don't error
|
|
# if it is not present already.
|
|
if [[ "$item" != "" ]]; then
|
|
if [[ "$item" =~ "/" ]]; then
|
|
# We're deleting targetted contents in a folder,
|
|
# and not an entire folder. Since we're checking for an
|
|
# an empty string, we should be fine letting it do the
|
|
# expansion.
|
|
rm -r -f $folder$item*
|
|
elif [[ -d "$folder$item" ]]; then
|
|
# This was the original deletion code path where we
|
|
# are attempting to delete a folder.
|
|
# This is normally not handled with the glob expansion
|
|
# expansion even though it could be due to management
|
|
# the host's contents as it is constructed.
|
|
rm -rf $folder$item || true
|
|
elif [[ $(ls $folder$item* | wc -l) -gt 0 ]]; then
|
|
# In this case, we have to use glob expansion because we
|
|
# have objects which are only available via glob expansion.
|
|
# NOTE(TheJulia): Fun factoid, these folders can have
|
|
# subfolders as well, and recursive is thus required becuase
|
|
# otherwise rm errors and aborts the deletion.
|
|
rm -rf $folder$item*
|
|
fi
|
|
fi
|
|
done
|
|
done
|
|
|
|
# TODO(dtantsur): implement the same for debian-based systems
|
|
case "$DISTRO_NAME" in
|
|
fedora|centos|rhel)
|
|
${YUM:-yum} remove -y postfix gcc make
|
|
# Remove webkit... Save ~26MB. This is a ramdisk, not a web browser.
|
|
${YUM:-yum} remove -y webkit2gtk3-jsc libproxy-webkitgtk4 || true
|
|
# Remove polkit... Save ~23 MB. This is a ramdisk, not a desktop.
|
|
${YUM:-yum} remove -y polkit polkit-libs PackageKit polkit-pkla-compat || true
|
|
|
|
${YUM:-yum} clean all
|
|
# Rebuilding the rpm database after removing packages will reduce
|
|
# its size
|
|
rpm --rebuilddb
|
|
;;
|
|
esac
|
|
|
|
# NOTE(TheJulia): remove any excess temporary files from /var/tmp
|
|
# In particular, dracut may leave some items we don't need/want.
|
|
rm -r -f /var/tmp/*
|