#533 Replace rpmUtils with equivalent dnf api
Closed: Fixed 6 years ago Opened 7 years ago by lsedlar.

Instead of always relying on rpmUtils which is part of yum-utils package, we need to have an abstraction layer over the module so that we can use whatever is available: either yum or dnf. This applies mostly to pungi.arch module, but there are a few other places that use it.


After some testing, I think replacing the rpmUtils APIs with dnf APIs is not so practicable, since dnf only has one API 'basearch' which is similar to rpmUtils.arch.getBaseArch but doesn't support detecting the current os arch, dnf is using hawkey.detect_arch while rpmUtils has lots of python tricky code on this, and since we can't easy test this (replacing with hawkey) to avoid any regression, I think copy the tricky code from rpmUtils to support this is much safer. rpmUtils.arch also has some tricky code on multilib checking, which is not available from dnf.

APIs we need in rpmUtils.arch:

  1. rpmUtils.arch.getBaseArch: dnf has dnf.rpm.basearch(arch) which doesn't
    support to be called without 'arch' argument, which means doesn't support
    detecting the current os arch. dnf is using hawkey.detect_arch.

  2. rpmUtils.arch.arches: dnf has a similar dict, we can invert it but it
    still has some differences in the result, for example we will need to
    add 'noarch' mappings for some arches.

  3. rpmUtils.arch.getArchList: dnf doesn't have an alternative API for
    this, due to #2, it will get different result by retrieving from the
    dict.

  4. rpmUtils.arch.getMultiArchInfo: dnf doesn't have an alternative API.

So I go with the solution of copying necessary parts from rpmUtils to pungi to remove the dependency of rpmUtils in https://pagure.io/pungi/pull-request/576 .

There are still some places in gather.py and multilib.py using yum.rpmUtils, we can't simply change that, the DNF depsolving porting will do that to support switching the backend from yum to dnf.

Metadata Update from @lsedlar:
- Issue close_status updated to: Fixed
- Issue status updated to: Closed (was: Open)
- Issue tagged with: 4.1.18

6 years ago

Login to comment on this ticket.

Metadata