Skip to content

Commit

Permalink
spec: If DNF5 obsoletes DNF, do not build dnf and yum packages
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ppisar authored and jan-kolarik committed Sep 6, 2024
1 parent a1aa8d0 commit f519e60
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions dnf.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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-*

Expand All @@ -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
Expand All @@ -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
Expand All @@ -266,6 +273,7 @@ ctest -VV
popd


%if %{without dnf5_obsoletes_dnf}
%post
%systemd_post dnf-makecache.timer

Expand All @@ -274,6 +282,7 @@ popd

%postun
%systemd_postun_with_restart dnf-makecache.timer
%endif


%post automatic
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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*
Expand All @@ -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
Expand Down

0 comments on commit f519e60

Please # to comment.