From f519e602a70ce6d3494a9d9d70464187eb9c263e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= Date: Tue, 13 Aug 2024 14:08:13 +0200 Subject: [PATCH] spec: If DNF5 obsoletes DNF, do not build dnf and yum packages Fedora CI installability and rpmdeplint tests failed on Fedoras where dnf5 obsoletes dnf and yum packages because the tests attempt to install just built dnf and yum packages, but DNF5 refuses installing them because they are obsoleted by an already installed dnf5: -------------------------------------------------------- | | | Running install test for dnf-0:4.21.0-3.fc41.noarch | | | -------------------------------------------------------- Updating and loading repositories: Repo for 121841198 Brew build 100% | 4.7 MiB/s | 4.8 KiB | 00m00s Repositories loaded. Failed to resolve the transaction: Problem: problem with installed package - installed package dnf5-5.2.5.0-2.fc41.x86_64 obsoletes dnf < 5 provided by dnf-4.21.0-3.fc41.noarch from brew-121841198 - package dnf5-5.2.5.0-2.fc41.x86_64 from fedora obsoletes dnf < 5 provided by dnf-4.21.0-3.fc41.noarch from brew-121841198 - package dnf5-5.2.5.0-2.fc41.x86_64 from updates obsoletes dnf < 5 provided by dnf-4.21.0-3.fc41.noarch from brew-121841198 - package dnf5-5.2.5.0-2.fc41.x86_64 from rawhide obsoletes dnf < 5 provided by dnf-4.21.0-3.fc41.noarch from brew-121841198 - package dnf5-5.2.5.0-2.fc41.x86_64 from fedora-41-buildroot obsoletes dnf < 5 provided by dnf-4.21.0-3.fc41.noarch from brew-121841198 - package dnf5-5.2.5.0-2.fc41.x86_64 from testing-farm-tag-repository obsoletes dnf < 5 provided by dnf-4.21.0-3.fc41.noarch from brew-121841198 - conflicting requests (The same happesn for yum package.) Solution this patch implements is not building the two obsolete packages. At the end, they cannot be installed. --- dnf.spec | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/dnf.spec b/dnf.spec index bc6232e9bb..c4cb2a3061 100644 --- a/dnf.spec +++ b/dnf.spec @@ -219,15 +219,17 @@ mkdir -p %{buildroot}%{py3pluginpath}/__pycache__/ mkdir -p %{buildroot}%{_localstatedir}/log/ mkdir -p %{buildroot}%{_var}/cache/dnf/ touch %{buildroot}%{_localstatedir}/log/%{name}.log +%if %{without dnf5_obsoletes_dnf} ln -sr %{buildroot}%{_bindir}/dnf-3 %{buildroot}%{_bindir}/dnf -ln -sr %{buildroot}%{_bindir}/dnf-3 %{buildroot}%{_bindir}/dnf4 -ln -sr %{buildroot}%{_datadir}/bash-completion/completions/dnf-3 %{buildroot}%{_datadir}/bash-completion/completions/dnf4 ln -sr %{buildroot}%{_datadir}/bash-completion/completions/dnf-3 %{buildroot}%{_datadir}/bash-completion/completions/dnf for file in %{buildroot}%{_mandir}/man[578]/dnf4[-.]*; do dir=$(dirname $file) filename=$(basename $file) ln -sr $file $dir/${filename/dnf4/dnf} done +%endif +ln -sr %{buildroot}%{_bindir}/dnf-3 %{buildroot}%{_bindir}/dnf4 +ln -sr %{buildroot}%{_datadir}/bash-completion/completions/dnf-3 %{buildroot}%{_datadir}/bash-completion/completions/dnf4 mv %{buildroot}%{_bindir}/dnf-automatic-3 %{buildroot}%{_bindir}/dnf-automatic rm -vf %{buildroot}%{_bindir}/dnf-automatic-* @@ -238,6 +240,7 @@ mv -f %{buildroot}%{confdir}/%{name}-strict.conf %{buildroot}%{confdir}/%{name}. rm -vf %{buildroot}%{confdir}/%{name}-strict.conf %endif +%if %{without dnf5_obsoletes_dnf} # YUM compat layer ln -sr %{buildroot}%{confdir}/%{name}.conf %{buildroot}%{_sysconfdir}/yum.conf ln -sr %{buildroot}%{_bindir}/dnf-3 %{buildroot}%{_bindir}/yum @@ -247,10 +250,14 @@ ln -sr %{buildroot}%{pluginconfpath} %{buildroot}%{_sysconfdir}/yum/pluginconf. ln -sr %{buildroot}%{confdir}/protected.d %{buildroot}%{_sysconfdir}/yum/protected.d ln -sr %{buildroot}%{confdir}/vars %{buildroot}%{_sysconfdir}/yum/vars %endif +%endif %if %{with dnf5_obsoletes_dnf} rm %{buildroot}%{confdir}/%{name}.conf -rm %{buildroot}%{_mandir}/man5/%{name}.conf.5* +rm %{buildroot}%{_datadir}/locale/*/LC_MESSAGES/%{name}.mo +rm %{buildroot}%{_mandir}/man8/yum2dnf.8* +rm %{buildroot}%{_unitdir}/%{name}-makecache.service +rm %{buildroot}%{_unitdir}/%{name}-makecache.timer %endif %if 0%{?fedora} >= 41 || 0%{?rhel} >= 10 @@ -266,6 +273,7 @@ ctest -VV popd +%if %{without dnf5_obsoletes_dnf} %post %systemd_post dnf-makecache.timer @@ -274,6 +282,7 @@ popd %postun %systemd_postun_with_restart dnf-makecache.timer +%endif %post automatic @@ -286,6 +295,7 @@ popd %systemd_postun_with_restart dnf-automatic.timer dnf-automatic-notifyonly.timer dnf-automatic-download.timer dnf-automatic-install.timer +%if %{without dnf5_obsoletes_dnf} %files -f %{name}.lang %{_bindir}/%{name} %if 0%{?rhel} && 0%{?rhel} <= 7 @@ -299,6 +309,7 @@ popd %{_mandir}/man5/dnf-transaction-json.5* %{_unitdir}/%{name}-makecache.service %{_unitdir}/%{name}-makecache.timer +%endif %files data %license COPYING PACKAGE-LICENSING @@ -333,6 +344,7 @@ popd %endif %{_tmpfilesdir}/%{name}.conf +%if %{without dnf5_obsoletes_dnf} %files -n %{yum_subpackage_name} %{_bindir}/yum %{_mandir}/man8/yum.8* @@ -342,20 +354,20 @@ popd %{_mandir}/man5/yum.conf.5.* %{_mandir}/man8/yum-shell.8* %{_mandir}/man1/yum-aliases.1* -%if %{without dnf5_obsoletes_dnf} # If DNF5 does not obsolete DNF, protected.d/yum.conf should be owned by DNF %config(noreplace) %{confdir}/protected.d/yum.conf %else -# If DNF5 obsoletes DNF -# No longer using `noreplace` here. Older versions of DNF 4 marked `yum` as a -# protected package, but since Fedora 39, DNF needs to be able to update itself -# to DNF 5, so we need to replace the old /etc/dnf/protected.d/yum.conf. -%config %{confdir}/protected.d/yum.conf +%exclude %{_sysconfdir}/yum.conf +%exclude %{confdir}/protected.d/yum.conf +%exclude %{_mandir}/man5/yum.conf.5.* +%exclude %{_mandir}/man8/yum-shell.8* +%exclude %{_mandir}/man1/yum-aliases.1* %endif %else -%exclude %{_sysconfdir}/yum.conf +# No %%{yum_subpackage_name} package %exclude %{confdir}/protected.d/yum.conf %exclude %{_mandir}/man5/yum.conf.5.* +%exclude %{_mandir}/man8/yum.8* %exclude %{_mandir}/man8/yum-shell.8* %exclude %{_mandir}/man1/yum-aliases.1* %endif