From 5598dbf9d700e10492b230209ee64429e78a058d Mon Sep 17 00:00:00 2001 From: Claudius Volz Date: Tue, 27 Jun 2023 00:17:48 +0200 Subject: [PATCH] RPM spec: Only run fixup code if the package is being upgraded, to avoid a scenario where the coreutils (mkdir, cp) are not available yet during a fresh system installation. Signed-off-by: Claudius Volz --- packaging/rpm/SPECS/nvidia-container-toolkit.spec | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packaging/rpm/SPECS/nvidia-container-toolkit.spec b/packaging/rpm/SPECS/nvidia-container-toolkit.spec index 98130aa5..608d3403 100644 --- a/packaging/rpm/SPECS/nvidia-container-toolkit.spec +++ b/packaging/rpm/SPECS/nvidia-container-toolkit.spec @@ -53,12 +53,14 @@ mkdir -p %{buildroot}/usr/share/containers/oci/hooks.d install -m 644 -t %{buildroot}/usr/share/containers/oci/hooks.d oci-nvidia-hook.json %post -mkdir -p %{_localstatedir}/lib/rpm-state/nvidia-container-toolkit -cp -af %{_bindir}/nvidia-container-runtime-hook %{_localstatedir}/lib/rpm-state/nvidia-container-toolkit +if [ $1 -gt 1 ]; then # only on package upgrade + mkdir -p %{_localstatedir}/lib/rpm-state/nvidia-container-toolkit + cp -af %{_bindir}/nvidia-container-runtime-hook %{_localstatedir}/lib/rpm-state/nvidia-container-toolkit +fi %posttrans if [ ! -e %{_bindir}/nvidia-container-runtime-hook ]; then - # reparing lost file nvidia-container-runtime-hook + # repairing lost file nvidia-container-runtime-hook cp -avf %{_localstatedir}/lib/rpm-state/nvidia-container-toolkit/nvidia-container-runtime-hook %{_bindir} fi rm -rf %{_localstatedir}/lib/rpm-state/nvidia-container-toolkit