Slim down the pre-built DIB IPA images

* Move remove-extra-packages to post-install since finalise.d
  is running on the final image and the DIB documentation
  recommends avoiding unnecessary actions there.
* Remove a few packages that used to be removed only for Fedora;
  do not try to remove those that aren't on the cloud image.
* Do all uninstallations in pre-install phase, so that it doesn't try
  to remove dependencies of already installed packages.
* Exclude more locale files from the image.
* Exclude the content of /var/log.

Change-Id: Idb7819b1d783f4f5f390cc7621019d3be2fa576f
This commit is contained in:
Dmitry Tantsur 2019-09-26 15:38:21 +02:00
parent cecbc860dd
commit f45996c192
6 changed files with 69 additions and 35 deletions

View File

@ -33,15 +33,18 @@ sudo find . -xdev \
-path './tmp/*' -prune -o \
-path './boot/*' -prune -o \
-path './root/.cache' -prune -o \
-path "*site-packages/babel/locale-data/*" -prune -o \
-path './usr/include/*' -prune -o \
-path './usr/lib/locale/*' -prune -o \
-path './usr/share/doc/*' -prune -o \
-path './usr/share/man/*' -prune -o \
-path './usr/share/info/*' -prune -o \
-path './usr/share/licenses/*' -prune -o \
-path './usr/share/locale/*' -prune -o \
-path './usr/share/misc/m*' -prune -o \
-path './usr/src/kernels/*' -prune -o \
-path './var/cache/*' -prune -o \
-path './var/log/*' -prune -o \
-name '*.pyc' -prune -o \
-name '*.pyo' -prune -o \
-print | sudo cpio -o -H newc | ${DIB_IPA_COMPRESS_CMD} > ${IMAGE_PATH}.initramfs

View File

@ -0,0 +1,6 @@
# TODO(dtantsur): verify if opensuse can be added here
if [[ $DISTRO_NAME =~ (fedora|centos|centos7|rhel|rhel7) ]]; then
export IPA_DISTRO_FAMILY=rh
else
export IPA_DISTRO_FAMILY=other
fi

View File

@ -1,31 +0,0 @@
#!/bin/bash
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# TODO(lucasagomes): optimize the ramdisk for other OSs
if [ $DISTRO_NAME = 'fedora' ] ; then
_remove_yum=''
if [ $DIB_RELEASE -ge 22 ]; then
# if we are on F22, we can remove yum if there, because it has
# been superseeded by dnf
_remove_yum='yum'
fi
install-packages -e kernel-debug-devel gcc fedora-logos \
rsync pykickstart \
genisoimage tcpdump \
man-db kbd-misc \
plymouth cronie ${_remove_yum}
${YUM:-yum} clean all
# Rebuilding the rpm database after removing packages will reduce
# its size
rpm --rebuilddb
fi

View File

@ -18,3 +18,44 @@ kmod:
psmisc:
dosfstools:
mdadm:
# Unnecessary packages to remove. We run all removals in pre-install phase, to
# avoid breaking installs that happen in install phase.
cloud-init:
phase: pre-install.d
uninstall: true
git:
phase: pre-install.d
uninstall: true
kbd:
phase: pre-install.d
uninstall: true
man-db:
phase: pre-install.d
uninstall: true
rsync:
phase: pre-install.d
uninstall: true
# Distro-specific uninstalls
cronie:
phase: pre-install.d
uninstall: true
when: IPA_DISTRO_FAMILY = rh
kernel-debug-devel:
phase: pre-install.d
uninstall: true
when: IPA_DISTRO_FAMILY = rh
plymouth:
phase: pre-install.d
uninstall: true
when: IPA_DISTRO_FAMILY = rh
teamd:
phase: pre-install.d
uninstall: true
when: IPA_DISTRO_FAMILY = rh
yum:
phase: pre-install.d
uninstall: true
when: DISTRO_NAME = fedora

View File

@ -8,10 +8,6 @@ set -o pipefail
DIB_IPA_ENABLE_RESCUE=${DIB_IPA_ENABLE_RESCUE:-true}
install-packages -e cloud-init
rm -rf /tmp/ironic-python-agent
if $DIB_IPA_ENABLE_RESCUE; then
# Make sure rescue works
mkdir -p /etc/ipa-rescue-config

View File

@ -0,0 +1,19 @@
#!/bin/bash
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
rm -rf /tmp/ironic-python-agent
# TODO(dtantsur): implement the same for debian-based systems
case "$DISTRO_NAME" in
fedora|centos|centos7|rhel|rhel7)
${YUM:-yum} clean all
# Rebuilding the rpm database after removing packages will reduce
# its size
rpm --rebuilddb
;;
esac