Fix upgrades from non-alternativized versions

Both of the same package and of other packages (wodim from cdrkit).

Inspired by https://src.fedoraproject.org/rpms/mandoc/pull-request/4

Resolves: RHEL-74135
This commit is contained in:
Pavel Cahyna 2025-01-14 20:15:25 +01:00
parent df3c329491
commit 7ac595b3ee

View File

@ -51,6 +51,7 @@ for developing applications that use %{name}.
%package -n cdrskin%{?variant}
Summary: Limited cdrecord compatibility wrapper to ease migration to %{name}
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires(pre): %{_sbindir}/alternatives, coreutils
Requires(post): %{_sbindir}/alternatives, coreutils
Requires(preun): %{_sbindir}/alternatives
Provides: cdrecord
@ -106,6 +107,16 @@ touch $RPM_BUILD_ROOT{%{_bindir}/wodim,%{_mandir}/man1/wodim.1.gz}
%ldconfig_scriptlets
%pre -n cdrskin%{?variant}
# remove alternativized files if they are not symlinks
# otherwise upgrades from non-alternativized versions do not work
# the list of files should be kept in sync with the "alternatives"
# commands in %%post
for f in cdrecord wodim ; do
[ -L %{_bindir}/$f ] || %{__rm} -f %{_bindir}/$f || :
[ -L %{_mandir}/man1/$f.1.gz ] || %{__rm} -f %{_mandir}/man1/$f.1.gz || :
done
%post -n cdrskin%{?variant}
%{_sbindir}/alternatives --install %{_bindir}/cdrecord cdrecord %{_bindir}/cdrskin%{?variant} 60 \
--slave %{_mandir}/man1/cdrecord.1.gz cdrecord-cdrecordman %{_mandir}/man1/cdrskin%{?variant}.1.gz \