rpm-software-management / microdnf

Lightweight implementation of dnf in C
GNU General Public License v2.0
217 stars 34 forks source link

microdnf cannot reinstall curl-minimal #137

Closed dwmarshall closed 5 months ago

dwmarshall commented 1 year ago

with regular dnf:

$ podman run --rm registry.access.redhat.com/ubi9/ubi dnf reinstall -q -y curl-minimal

Reinstalled:
  curl-minimal-7.76.1-23.el9_2.2.x86_64

with microdnf:

$ podman run --rm registry.access.redhat.com/ubi9/ubi-minimal microdnf reinstall -y curl-minimal

(microdnf:1): librhsm-WARNING **: 16:56:00.224: Found 0 entitlement certificates

(microdnf:1): librhsm-WARNING **: 16:56:00.225: Found 0 entitlement certificates
Downloading metadata...
Downloading metadata...
Downloading metadata...
Package                                            Repository            Size
Reinstalling:
 curl-minimal-7.76.1-23.el9_2.2.x86_64             ubi-9-baseos-rpms 132.3 kB
   replacing curl-minimal-7.76.1-23.el9_2.2.x86_64
Transaction Summary:
 Installing:        0 packages
 Reinstalling:      1 packages
 Upgrading:         0 packages
 Obsoleting:        0 packages
 Removing:          0 packages
 Downgrading:       0 packages
Downloading packages...
Running transaction test...
error: Error running transaction: curl conflicts with curl-minimal-7.76.1-23.el9_2.2.x86_64
curl conflicts with (installed) curl-minimal-7.76.1-23.el9_2.2.x86_64
$ podman run --rm registry.access.redhat.com/ubi9/ubi-minimal rpm -q microdnf
microdnf-3.9.1-3.el9.x86_64
robbmanes commented 1 year ago

This appears to be caused by any package that has a Conflicts tag in the spec that has the exact same name configured in Provides. The above curl package provided above does this:

$ curl -o curl-minimal-7.76.1-23.el9_2.2.x86_64.rpm https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi9/9/x86_64/baseos/os/Packages/c/curl-minimal-7.76.1-23.el9_2.2.x86_64.rpm

$ rpm -qp --conflicts curl-minimal-7.76.1-23.el9_2.2.x86_64.rpm
curl

$ rpm -qp --provides curl-minimal-7.76.1-23.el9_2.2.x86_64.rpm
curl = 7.76.1-23.el9_2.2
curl-minimal = 7.76.1-23.el9_2.2
curl-minimal(x86-64) = 7.76.1-23.el9_2.2

And if I make my own package, host it, and then try to reinstall it it fails in the same way. My specfile:

Name:           hello
Version:        0.0.1
Release:        1%{?dist}
Summary:        Hello World

License:        GPL
Source0:        %{name}-%{version}.tar.gz

Requires:       bash
Conflicts:      hello
Provides:       hello

%description
A demo RPM build

%prep
%autosetup

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{_bindir}
cp %{name}.sh $RPM_BUILD_ROOT/%{_bindir}

%clean
rm -rf $RPM_BUILD_ROOT

%files
%{_bindir}/%{name}.sh

%changelog
* Mon Aug 07 2023 Robb Manes <robbmanes@myemail.com>
- First change

And note that plain dnf or yum (really yum2) have no problems, but microdnf does upon trying to reinstall:

# dnf reinstall /home/rmanes/rpmbuild/RPMS/x86_64/hello-0.0.1-1.el9.x86_64.rpm -y
[...]
Reinstalled:
  hello-0.0.1-1.el9.x86_64

# microdnf reinstall hello -y
[...]
error: Error running transaction: hello conflicts with hello-0.0.1-1.el9.x86_64
hello conflicts with (installed) hello-0.0.1-1.el9.x86_64
robbmanes commented 1 year ago

Filed as bz2229809 internally for Red Hat.

dmnks commented 1 year ago

Works fine with RPM:

# rpm -U --reinstall /root/rpmbuild/RPMS/x86_64/hello-0.0.1-1.el9.x86_64.rpm

Is microdnf using rpmtsAddReinstallElement() here?

j-mracek commented 1 year ago

Thank you Michal, I think this is the issue.