[CentOS-devel] packaging DPDK 21.11 in RPM in CentOS 7 (elftools not found)

Fri Apr 29 11:50:08 UTC 2022
Stefan Puiu <stefan.puiu at gmail.com>

Hi,

I've already asked this on the dpdk-users list
(https://mails.dpdk.org/archives/users/2022-April/006395.html) without
getting any answer, so I thought maybe I'd also try centos-devel,
since this is a CentOS and dpdk question.

We're using a CentOS 7 based distro that is obviously RPM-based, and
we package the DPDK with it, in order to run on some of our x86-64
hardware boards. Now, we currently have DPDK 20.11 in our image and
are looking to upgrade to 21.11, and I'm hitting a build error about
elftools not being found:

Program python3 found: YES (/usr/bin/python3)

../buildtools/meson.build:49:8: ERROR: Problem encountered: missing
python module: elftools

The fix seems to be to install pyelftools from pip:

pip3 install pyelftools

But that only works for building directly with meson / ninja. That
doesn't work when building through rpmbuild. I've struggled to
understand this, until I found this RedHat bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1937494. It seems Fedora
changed the python3 search path so that /usr/local/lib/python is not
taken into account if RPM_BUILD_ROOT is defined (see
https://fedoraproject.org/wiki/Changes/Making_sudo_pip_safe); so
basically, when building with rpmbuild, pip-installed packages are
ignored.

I think I can understand the rationale of the Fedora change when you
want to ensure that dependencies are properly set: packages installed
using pip are not recorded as RPM dependencies, and the package might
break at runtime. However, as far as I can tell, pyelftools seems to
be a *build-time dependency*; removing the elftools check in the meson
script leads to a build failure. There's no pyelftools RPM for CentOS
7
that I could find, so I don't see another option than installing the package
from pip. Also, the python change in Fedora doesn't seem to allow for
any workaround. The only thing that I can think of is ugly as hell:
symlink everything under /usr/local/python in /usr/lib/python for the
DPDK build. I'm not even sure we need pyelftools at runtime; in our
build of DPDK-20.11, dpdk-pmdinfo.py doesn't even run (because of
missing pyelftools :) ).

Are there any other people struggling with this? Is there any more
elegant approach that I haven't thought of?

Thanks,
Stefan.