Rebuild initramfs on initial install to include GSP firmware

The open modules load GSP firmware (nvidia/<ver>/gsp_*.bin) early from the
initramfs. On a fresh install the initramfs is regenerated before that
firmware is on disk, so the first boot fails with
"gsp_*.bin failed with error -2" until a manual "dracut -f".

Add a %posttrans that rebuilds the initramfs after every payload in the
transaction has landed, guaranteeing the firmware is captured. Gate it to
the initial install with a %ghost stamp file, since $1 cannot distinguish
install from upgrade in %posttrans.
This commit is contained in:
Jonathan Wright 2026-07-19 13:57:01 -05:00
parent 4e919f3558
commit eda7530990

View File

@ -22,7 +22,7 @@
Name: %{kmodname}-kmod
Version: 610.43.02
Release: 5%{?dist}
Release: 6%{?dist}
Summary: Kernel module (kmod) for NVIDIA GPU hardware
License: GPL-2.0-only and MIT
@ -65,6 +65,28 @@ and newer models of GPU hardware.
%files
%license COPYING
%doc README.md
%dir %{_sharedstatedir}/%{name}
%ghost %{_sharedstatedir}/%{name}/initramfs-rebuilt
%posttrans
# The open modules need the GSP firmware (shipped by nvidia-kmod-common) inside
# the initramfs, or early load fails with "gsp_*.bin failed with error -2".
# Some packages regenerate the initramfs before that firmware is on disk; this
# scriptlet runs after every payload has been unpacked, so a rebuild here is
# guaranteed to capture it. Equivalent to the manual "dracut -f".
#
# Only required on the initial install. The stamp below is a ghost file (absent
# from the payload), so it exists only once we create it here; it persists
# across upgrades (the new package owns it too) and is removed on erase. Net
# effect: the rebuild runs on a first install and again after a full
# removal+reinstall, but not on plain upgrades or reinstalls.
if [ ! -e %{_sharedstatedir}/%{name}/initramfs-rebuilt ]; then
if [ -x %{_bindir}/dracut ]; then
%{_bindir}/dracut --force --regenerate-all --quiet || :
touch %{_sharedstatedir}/%{name}/initramfs-rebuilt
fi
fi
%prep
@ -107,8 +129,18 @@ for flavor in %{flavors_to_build}; do
popd
done
# Own the state directory and pre-create the stamp so the ghost entry is
# registered correctly. The stamp is a ghost file, so its contents are not
# shipped; it is (re)created by the posttrans scriptlet on the target system.
install -d %{buildroot}%{_sharedstatedir}/%{name}
touch %{buildroot}%{_sharedstatedir}/%{name}/initramfs-rebuilt
%changelog
* Sun Jul 19 2026 Jonathan Wright <jonathan@almalinux.org> - 610.43.02-6
- Rebuild the initramfs on initial install so the GSP firmware is included,
avoiding a manual dracut -f after install
* Mon Jul 13 2026 Eduard Abdullin <eabdullin@almalinux.org> - 610.43.02-5
- Rebuild for new kernel