feat(dracut-strip-trigger): use config files instead (#6549) (#6550)

Instead of spending the double amount of time regenerating the initramfs
twice by adding a transaction trigger in the RPM, a better way is to
simply just add a Dracut config file to set up aggressive stripping.

Also adds a conflict to `dracut-config-generic` since that does the
opposite of what this package does. If you wanted to install this
package you'd not want this installed anyway, since both conflict with
each other.

(cherry picked from commit f361f18b3d)

Co-authored-by: Pornpipat Popum <cappy@cappuchino.xyz>
This commit is contained in:
Raboneko
2025-09-28 06:11:31 -07:00
committed by GitHub
parent 73b8ecab1d
commit 990445f42d
2 changed files with 13 additions and 6 deletions
@@ -0,0 +1,3 @@
do_strip=yes
aggressive_strip=yes
hostonly=yes
@@ -1,10 +1,12 @@
Name: dracut-strip-trigger
Version: 0
Release: 4%?dist
Release: 5%?dist
Summary: Strip initramfs aggressively
License: GPL-3.0-only
Requires: dracut installonlypkg(kernel)
Conflicts: dracut-config-generic
Source0: LICENSE
Source1: 01-aggressive-strip.conf
%global _desc %{expand:
Strip initramfs automatically for each kernel update using --hostonly --aggressive-strip.
@@ -19,19 +21,21 @@ cat<<EOF > README
EOF
cp %{S:0} .
%install
mkdir -p %{buildroot}/usr/lib/dracut/dracut.conf.d/
cp %{S:1} %{buildroot}/usr/lib/dracut/dracut.conf.d/
%files
/usr/lib/dracut/dracut.conf.d/01-aggressive-strip.conf
%doc README
%license LICENSE
%post
echo 'Regenerating all initramfs…'
dracut --force --parallel --regenerate-all --hostonly --strip --aggressive-strip
dracut --force --parallel --regenerate-all
echo 'All non-rescue initramfs have been regenerated.'
echo 'If you have problems booting up, use the rescue image, then uninstall `%name`.'
%transfiletriggerin -P 1 -- /boot
dracut --force --hostonly --strip --aggressive-strip $(stat --format '%Y %y $%n' /boot/initramfs* | sort -nr | cut -d$ -f2- | head -n1)
%postun
[ $1 = 0 ] && echo 'Regenerating all initramfs…'
[ $1 = 0 ] && dracut --force --parallel --regenerate-all --no-hostonly --strip
[ $1 = 0 ] && dracut --force --parallel --regenerate-all