kernel-install.eclass: Remove initramfs in postrm
authorMichał Górny <mgorny@gentoo.org>
Sat, 25 Jan 2020 18:01:50 +0000 (19:01 +0100)
committerMichał Górny <mgorny@gentoo.org>
Sat, 25 Jan 2020 18:29:17 +0000 (19:29 +0100)
Closes: https://bugs.gentoo.org/706332
Signed-off-by: Michał Górny <mgorny@gentoo.org>
eclass/kernel-install.eclass

index 7e64f44c8c33c07943df5d8202032a11be0943c6..1fdeb1bf4dc7b1b1fd8661c5e5dd54e451abc5a9 100644 (file)
@@ -302,7 +302,13 @@ kernel-install_pkg_prerm() {
 kernel-install_pkg_postrm() {
        debug-print-function ${FUNCNAME} "${@}"
 
-       # (no-op at the moment)
+       if [[ -z ${ROOT} ]] && use initramfs; then
+               local image_path=$(kernel-install_get_image_path)
+               ebegin "Removing initramfs"
+               rm -f "${EROOT}/usr/src/linux-${PV}/${image_path%/*}/initrd" &&
+                       find "${EROOT}/usr/src/linux-${PV}" -depth -type d -empty -delete
+               eend ${?}
+       fi
 }
 
 _KERNEL_INSTALL_ECLASS=1