[CentOS-devel] How to compile modular SRPMs for CentOS 8?

Thu Apr 14 08:04:58 UTC 2022
Nico Kadel-Garcia <nkadel at gmail.com>

On Wed, Apr 13, 2022 at 10:06 AM aleksander.baranowski via
CentOS-devel <centos-devel at centos.org> wrote:

> **Lastly and the most important:**
>
> **Maybe you don't need to create the modular RPMs at all.** Ansible-core
> requires python38-resolvelib that is "normal" RPMs and wasn't put into
> the python38 or python38-devel module. You can also build it with the
> standard mock even without the `module_enable` config in the mock. Specfile:

I *wish* I could get away with just python39-devel and python39. The
BuildRequires includes "python%{python3_pkgvesion}-pytest", to tun
pytest as part of the %check stanza, I

   https://github.com/nkadel/ansiblerepo/blob/master/ansible-core-2.12.x-srpm/ansible-core.spec

I suppose.... I could personally live without running the python
checks, but other dependencies include:

    python39-jinja2 is needed by ansible-core-2.12.4-0.el8.noarch
    python39-mock is needed by ansible-core-2.12.4-0.el8.noarch
    python39-nose is needed by ansible-core-2.12.4-0.el8.noarch

And unfortunately other bits of the dependency chain require those as well

Updating ansible is going to be a problem for RHEL and CentOS, by the
way. The current ansible package in RHEL is obsolete and predates the
split of "ansible" into "ansible-core", The ansible package doesn't
contain ansible anymore. The ansible-core package contains the woking
scripts and critical python modules, the modern "ansible" package is a
curated collection of "ansible collection" third party modules, which
is quite builky and frankly mislabeled. It has a dependeny on
ansible-core, it does not include it, despite the documentation.

> https://git.centos.org/rpms/python-resolvelib/blob/c8s/f/SPECS/python-resolvelib.spec
>
> it uses clever macros like:
> ```
> %global python3_pkgversion 38
> %global python38_sitelib /usr/lib/python3.8/site-packages/

Umm. That spec file has issues. It has the "Requires:" commented out
manually, and no %check stage, and generate an SRPM called
"python-resolvelib" that is only compatible with building
"python38-resolvelib".  If I need to build up a suite that satisfies
other dependencies, I do that sort of thing at:

I think this works better:

    # Force python39 for RHEL 8, which has python 3.6 by default
    %if 0%{?el8}
    %global python3_version 3.9
    %global python3_pkgversion 39
    %endif

It also needs some macros enabled:

    %if 0%{?el8}
    BuildRequires:  python%{python3_pkgversion}-rpm-macros
    %endif

With those, you don't need to set the sitelib, and scripts with the
"-%{python3_version}" should be set consistently

Sadly, the dependency chain for python39 has other adventures, such as
lacking a python39-resolvelib and the dependency chain to install
*that*.