Building systemd from source fails

Issues related to applications and software problems and general support
Post Reply
gsmolnycki
Posts: 2
Joined: 2022/05/16 05:11:34

Building systemd from source fails

Post by gsmolnycki » 2022/05/16 05:28:51

Hi all,

Currently trying to build systemd-250-4.el9 from source, to add FIDO2 support. For one reason or another, the build ships with FIDO2 disabled, but it seems like it should be easy enough to enable, rebuild, and install. I am starting with the systemd-250-4.el9.src.rpm in the repo "CentOS Stream 9 BaseOS - Source", and I have installed all the build dependencies using dnf builddep systemd-250-4.el9. The relevant option is -Dlibfido2=false on line 445 of the .spec file, which I have changed to -Dlibfido2=true, and installed libfido2-devel. However, I cannot build systemd, and it gives the error shown below:

Code: Select all

[1691/2051] /root/rpmbuild/BUILD/systemd-250/tools/dbus_exporter.py interfaces /root/rpmbuild/BUILD/systemd-250/redhat-linux-build/systemd /ro
ot/rpmbuild/BUILD/systemd-250/redhat-linux-build/systemd-resolved /root/rpmbuild/BUILD/systemd-250/redhat-linux-build/systemd-logind /root/rpm
build/BUILD/systemd-250/redhat-linux-build/systemd-hostnamed /root/rpmbuild/BUILD/systemd-250/redhat-linux-build/systemd-localed /root/rpmbuil
d/BUILD/systemd-250/redhat-linux-build/systemd-timedated /root/rpmbuild/BUILD/systemd-250/redhat-linux-build/systemd-machined /root/rpmbuild/B
UILD/systemd-250/redhat-linux-build/systemd-importd /root/rpmbuild/BUILD/systemd-250/redhat-linux-build/systemd-oomd
FAILED: interfaces
/root/rpmbuild/BUILD/systemd-250/tools/dbus_exporter.py interfaces /root/rpmbuild/BUILD/systemd-250/redhat-linux-build/systemd /root/rpmbuild/
BUILD/systemd-250/redhat-linux-build/systemd-resolved /root/rpmbuild/BUILD/systemd-250/redhat-linux-build/systemd-logind /root/rpmbuild/BUILD/
systemd-250/redhat-linux-build/systemd-hostnamed /root/rpmbuild/BUILD/systemd-250/redhat-linux-build/systemd-localed /root/rpmbuild/BUILD/syst
emd-250/redhat-linux-build/systemd-timedated /root/rpmbuild/BUILD/systemd-250/redhat-linux-build/systemd-machined /root/rpmbuild/BUILD/systemd
-250/redhat-linux-build/systemd-importd /root/rpmbuild/BUILD/systemd-250/redhat-linux-build/systemd-oomd
/root/rpmbuild/BUILD/systemd-250/redhat-linux-build/systemd: error while loading shared libraries: libsystemd-shared-250.so: cannot open share
d object file: No such file or directory
Traceback (most recent call last):
  File "/root/rpmbuild/BUILD/systemd-250/tools/dbus_exporter.py", line 61, in <module>
    main()
  File "/root/rpmbuild/BUILD/systemd-250/tools/dbus_exporter.py", line 57, in main
    iterate_executables(args.output, args.executables)
  File "/root/rpmbuild/BUILD/systemd-250/tools/dbus_exporter.py", line 38, in iterate_executables
    extract_interfaces_xml(output_dir, exe)
  File "/root/rpmbuild/BUILD/systemd-250/tools/dbus_exporter.py", line 9, in extract_interfaces_xml
    list_interfaces_process = run(
  File "/usr/lib64/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '[PosixPath('/root/rpmbuild/BUILD/systemd-250/redhat-linux-build/systemd'), '--bus-introspect', 'list']
' returned non-zero exit status 127.
It appears to be missing the file libsystemd-shared-250.so. However, checking the build directories, it does appear that this file is built and resides at /root/rpmbuild/BUILD/systemd-250/redhat-linux-build/src/shared/libsystemd-shared-250.so.

I'm not sure where to go from here. This is a clean CentOS Stream 9 install, and I tried reverting to the stock .spec file but get the same error. Is there something special about the build environment I'm missing?

User avatar
TrevorH
Site Admin
Posts: 33191
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Building systemd from source fails

Post by TrevorH » 2022/05/16 11:08:51

I don't use Stream at all but some things in your post spring out.

First, don't build as root.

Second, use mock

Third, don't build as root!
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

u297b
Posts: 13
Joined: 2019/10/06 17:04:29

Re: Building systemd from source fails

Post by u297b » 2022/05/18 10:58:42

Following on what TrevorH said.

Building with mock, should in theory be as easy as:

1. dnf install mock
2. <extract .spec file from src rpm you want to build>
3. Make changes to spec file
4. mock --spec <spec-file> --rebuild /path/to/src.rpm

It should then create a chroot in /var/lib/mock/<profile-name>, install all needed build dependencies and rebuild the package, placing the rpm's in /var/lib/mock/<profile-name>/results/

(Notes)
* If you need to modify the chroot for some reason (ie. a missing package not included in Centos-9-Stream that you install directly from koji). After step 4 you can run: mock -n --enable-networking --shell
* Included in your modification of .spec file you should modify the Release tag (put your initials or whatever) so you can identify it was installed
* Lastly install versionlock dnf plugin, and then versionlock this specific version so its not immediately replaced on next update

User avatar
TrevorH
Site Admin
Posts: 33191
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Building systemd from source fails

Post by TrevorH » 2022/05/18 11:34:02

Step 1a) Add your user to the mock group
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

gsmolnycki
Posts: 2
Joined: 2022/05/16 05:11:34

Re: Building systemd from source fails

Post by gsmolnycki » 2022/05/19 05:06:45

Nice, that was it! I'm not nearly as familiar with RPM builds as I maybe should be and I didn't really understand mock initially but it seems simple enough. I was able to add FIDO2 support, add the build dependency, and it worked without a hitch.

As far as building as root, you're correct and normally I don't. I tried a fresh VM with nothing else to see if it made a difference, which it didn't. I tried a build as root last.

TYVM for the help

u297b
Posts: 13
Joined: 2019/10/06 17:04:29

Re: Building systemd from source fails

Post by u297b » 2022/05/19 11:33:26

gsmolnycki wrote:
2022/05/19 05:06:45
TYVM for the help
No worries.

If you now go sign up for a COPR fedora account, you can upload your custom .spec file and the service will autobuild for a variety of RPM-based platforms.

It will also create a custom repo for you, so that you / others can include in /etc/yum.repos.d and thus deploy / update using standard system tools.

Also its possible to include a "priority" line in this new repo to make your system prefer this COPR repo for said packages or alternatively just versionlock the specific package name glob with a "somepackage-version-*" regex

Post Reply