Fix scriptlet

This is an installonlypkg() package, > 1 packages can be left ($1 is the number of left packages of the same name)
if multiple are installed as installonlypkg().
-r is unique.
This commit is contained in:
Mikhail Novosyolov 2022-10-05 07:41:30 +03:00
parent 9d4548bee4
commit 87c11fc407
2 changed files with 8 additions and 7 deletions

View file

@ -3,7 +3,7 @@ Name: auto-krokodil
Group: System/Kernel and hardware
License: GPLv3
Url: https://abf.io/import/auto-krokodil
Version: 0.12
Version: 0.13
Release: 1
BuildArch: noarch
%ifarch %{ix86} %{x86_64}

View file

@ -52,9 +52,8 @@ Requires: kernel-abi(%{-p*}) \
# modules dependencies must be installed when depmod is run \
Requires(post): kernel-abi(%{-p*}) \
Requires(post): update-alternatives \
Requires(post): %{_sbindir}/depmod \
Requires(postun): update-alternatives \
Requires(postun): %{_sbindir}/depmod \
Requires(posttrans): %{_sbindir}/depmod \
%description -n %{pkg} \
Binary modules of Nvidia %{-j*}.%{-n*} for kernel-%{-k*}-%{-f*} \
Built from %{-s*} \
@ -68,11 +67,13 @@ update-alternatives --install \\
/lib/modules/%{-p*}/kernel/drivers/video/nvidia%{-j*} \\
kmods-nvidia%{-j*} \\
%{kroko_kmods_dir}/nvidia%{-j*}.%{-r*}-%{-p*} \\
%(echo %{-r*} | awk -F '.' '{print $1}')
%{_sbindir}/depmod -a %{-p*} \
%(echo %{-r*} | awk -F '.' '{print $1}') \
%postun -n %{pkg} \
[ $1 = 0 ] || exit 0 \
update-alternatives --remove kmods-nvidia%{-j*} %{kroko_kmods_dir}/nvidia%{-j*}.%{-r*}-%{-p*} \
# updated version of pkg always has another -r \
update-alternatives --remove \\
kmods-nvidia%{-j*} \\
%{kroko_kmods_dir}/nvidia%{-j*}.%{-r*}-%{-p*} \
%posttrans -n %{pkg} \
if [ -d /lib/modules/%{-p*} ]; then %{_sbindir}/depmod -a %{-p*} || : ; fi
}