openSUSE / libsolv

Library for solving packages and reading repositories
http://en.opensuse.org/openSUSE:Libzypp_satsolver
Other
509 stars 151 forks source link

Obsoletes is not honored while solving #535

Closed sshedi closed 11 months ago

sshedi commented 1 year ago

Hi,

We are seeing something unusual while updating our postgresql rpms. Here is the link to our spec: https://github.com/vmware/photon/blob/4.0/SPECS/postgresql/postgresql14.spec#L54

root@ph4dev:~ # rpm -q --provides postgresql
libpqwalreceiver.so()(64bit)
postgresql = 14.5-1.ph4
postgresql(x86-64) = 14.5-1.ph4

root@ph4dev:~ # rpm -q --obsoletes postgresql14-14.8-1.ph4.x86_64.rpm
postgresql <= 14.5-1

root@ph4dev:~ # rpm -q --provides postgresql14-14.8-1.ph4.x86_64.rpm
libecpg.so.6()(64bit)
libecpg_compat.so.3()(64bit)
libpgtypes.so.3()(64bit)
libpq.so.5()(64bit)
libpqwalreceiver.so()(64bit)
postgresql = 14.8-1.ph4
postgresql14 = 14.8-1.ph4
postgresql14(x86-64) = 14.8-1.ph4

But after installing pgsql-14.5-1 and doing tdnf update -y postgresql, pgsql-14.8-1 is not coming in.

And rpm -Uvh postgresql-14*.rpm also doesn't yield in removing the older 14.5-1 version.

Here is a sample program showing solver checking the version:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include <solv/evr.h>
#include <solv/pool.h>

int main(int argc, char *argv[])
{
    Pool* pPool = NULL;
    const char *evr1 = argv[1];
    const char *evr2 = argv[2];
    int ret;

    pPool = pool_create();
    pool_setdisttype(pPool, DISTTYPE_RPM);

    ret = pool_evrcmp_str(pPool, evr1, evr2, EVRCMP_COMPARE);

    printf("%d\n", ret);
}
root@ph4dev:~ # ./a.out 14.8-1.ph4 14.5-1
1

root@ph4dev:~ # ./a.out 14.8-1 14.5-1.ph4
1

It's recognized properly but, tdnf and rpm are not doing the expected.

tdnf github link: https://github.com/sshedi/tdnf https://github.com/vmware/tdnf

libsolv version: libsolv-0.7.19 rpm version: rpm-4.16.1.3

mlschroe commented 11 months ago

I think that 14.5-1.ph4 is greater than 14.5-1, thus your obsoletes postgresql <= 14.5-1 does not match it. A fix would be to obsolete postgresql <= 14.5, as this matches all release numbers.

sshedi commented 11 months ago

Thanks @mlschroe this solved the problem.

sshedi commented 11 months ago

Sorry, I'm reopening this. I have another query.

Why does solv consider %{dist} tag while comparing versions? Is there a way to ignore the dist tag while comparing versions? Please let me know if there is any rpm or solv setting I can modify.

mlschroe commented 11 months ago

The solver needs to match exactly what rpm does. The %dist tag is most likely used in the version/release specification in the spec file, thus is part of the version/release. There's nothing you can do on the rpm/libsolv side, you need to change the specfile.