Create separate standalone packages for tmpfiles and sysusers

These packages include binaries that link to a static version of
libsystemd-shared, so they don't depend on the systemd-libs package at
runtime.

These packages are intended to expose systemd-tmpfiles and systemd-sysusers
to non-systemd systems, such as container images.

Note that static linking only pulls in the small subset of functions from
libsystemd-shared that are actually used by the binaries, so the total size of
a statically linked binary is much smaller than the sum of the shared binary
with the shared library. The resulting binaries on an x86_64 build have 272KB
(tmpfiles) and 180KB (sysusers).

This commit relies on the -Dstandalone-binaries=true build configuration that
was pushed upstream in PR 16061 and released in systemd v246.
This commit is contained in:
Filipe Brandenburger 2020-06-03 14:40:09 -07:00 committed by Zbigniew Jędrzejewski-Szmek
parent f455b2249a
commit b50e9d7f29
2 changed files with 37 additions and 1 deletions

View File

@ -21,9 +21,11 @@ o_pam = open('.file-list-pam', 'w')
o_rpm_macros = open('.file-list-rpm-macros', 'w') o_rpm_macros = open('.file-list-rpm-macros', 'w')
o_devel = open('.file-list-devel', 'w') o_devel = open('.file-list-devel', 'w')
o_container = open('.file-list-container', 'w') o_container = open('.file-list-container', 'w')
o_networkd = open('.file-list-networkd', 'w')
o_remote = open('.file-list-remote', 'w') o_remote = open('.file-list-remote', 'w')
o_tests = open('.file-list-tests', 'w') o_tests = open('.file-list-tests', 'w')
o_networkd = open('.file-list-networkd', 'w') o_standalone_tmpfiles = open('.file-list-standalone-tmpfiles', 'w')
o_standalone_sysusers = open('.file-list-standalone-sysusers', 'w')
o_rest = open('.file-list-rest', 'w') o_rest = open('.file-list-rest', 'w')
for file in files(buildroot): for file in files(buildroot):
n = file.path[1:] n = file.path[1:]
@ -112,6 +114,13 @@ for file in files(buildroot):
/modprobe.d /modprobe.d
''', n, re.X): ''', n, re.X):
o = o_udev o = o_udev
elif n.endswith('.standalone'):
if 'tmpfiles' in n:
o = o_standalone_tmpfiles
elif 'sysusers' in n:
o = o_standalone_sysusers
else:
assert False, 'Found .standalone not belonging to known packages'
else: else:
o = o_rest o = o_rest

View File

@ -334,6 +334,24 @@ License: LGPLv2+
"Installed tests" that are usually run as part of the build system. "Installed tests" that are usually run as part of the build system.
They can be useful to test systemd internals. They can be useful to test systemd internals.
%package standalone-tmpfiles
Summary: Standalone tmpfiles binary for use in non-systemd systems
RemovePathPostfixes: .standalone
%description standalone-tmpfiles
Standalone tmpfiles binary with no dependencies on the systemd-shared library
or other libraries from systemd-libs. This package conflicts with the main
systemd package and is meant for use in non-systemd systems.
%package standalone-sysusers
Summary: Standalone sysusers binary for use in non-systemd systems
RemovePathPostfixes: .standalone
%description standalone-sysusers
Standalone sysusers binary with no dependencies on the systemd-shared library
or other libraries from systemd-libs. This package conflicts with the main
systemd package and is meant for use in non-systemd systems.
%prep %prep
%autosetup -n %{?commit:%{name}%{?stable:-stable}-%{commit}}%{!?commit:%{name}%{?stable:-stable}-%{github_version}} -p1 %autosetup -n %{?commit:%{name}%{?stable:-stable}-%{commit}}%{!?commit:%{name}%{?stable:-stable}-%{github_version}} -p1
@ -388,6 +406,7 @@ CONFIGURE_OPTS=(
-Dtpm=true -Dtpm=true
-Dhwdb=true -Dhwdb=true
-Dsysusers=true -Dsysusers=true
-Dstandalone-binaries=true
-Ddefault-kill-user-processes=false -Ddefault-kill-user-processes=false
-Dtests=unsafe -Dtests=unsafe
-Dinstall-tests=true -Dinstall-tests=true
@ -829,7 +848,15 @@ fi
%files tests -f .file-list-tests %files tests -f .file-list-tests
%files standalone-tmpfiles -f .file-list-standalone-tmpfiles
%files standalone-sysusers -f .file-list-standalone-sysusers
%changelog %changelog
* Thu Sep 24 2020 Filipe Brandenburger <filbranden@gmail.com> - 246.6-2
- Build a package with standalone binaries for non-systemd systems.
For now, only systemd-sysusers is included.
* Thu Sep 24 2020 Christian Glombek <lorbus@fedoraproject.org> - 246.6-2 * Thu Sep 24 2020 Christian Glombek <lorbus@fedoraproject.org> - 246.6-2
- Split out networkd sub-package and add to main package as recommended dependency - Split out networkd sub-package and add to main package as recommended dependency