Compare commits

...

3 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek d5da3ada8e
Merge pull request #16061 from filbranden/standalone1
meson: add a new -Dstandalone-binaries=true option
2020-06-18 00:09:42 +02:00
Filipe Brandenburger db64ba81c6 meson: build standalone version of systemd-tmpfiles
Use -Dstandalone-binaries=yes to enable building and installing this standalone
version of the binary without a dependency on the systemd-shared solib.

Also move the list of sources for systemd-tmpfiles to its own meson.build file.
2020-06-10 10:54:29 -07:00
Filipe Brandenburger 8ef8f3d5a7 meson: add a new -Dstandalone-binaries=true option
This adds an option to build standalone binaries that do not depend on the
systemd-shared library. This option can be handy to build binaries that can be
useful on a non-systemd system, binaries such as systemd-sysusers and
systemd-tmpfiles have been previously requested, but installing them with all
the required dependencies pulls in too much code that isn't really relevant for
those use cases. The standalone use case is also relevant in containers, where
minimizing the size of the container image is quite relevant.

For now, only `systemd-sysusers` is also built as a standalone binary.

The standalone binaries are installed as `/usr/bin/%{name}.standalone`, the
packaging system is reponsible for renaming those into the correct names
during the packaging step. RPM is able to do so with RemovePathPostfixes:

The default behavior is to build shared binaries only, since this option is
mainly intended for building distribution packages.

Tested that a proper separate binary is built when using this option and
that having it disabled (or using the default Meson configuration) does not
produce a binary for this option.
2020-06-10 10:54:29 -07:00
3 changed files with 42 additions and 3 deletions

View File

@ -85,6 +85,8 @@ if rootprefixdir == ''
endif endif
rootprefixdir_noslash = rootprefixdir == '/' ? '' : rootprefixdir rootprefixdir_noslash = rootprefixdir == '/' ? '' : rootprefixdir
have_standalone_binaries = get_option('standalone-binaries')
sysvinit_path = get_option('sysvinit-path') sysvinit_path = get_option('sysvinit-path')
sysvrcnd_path = get_option('sysvrcnd-path') sysvrcnd_path = get_option('sysvrcnd-path')
conf.set10('HAVE_SYSV_COMPAT', sysvinit_path != '' and sysvrcnd_path != '', conf.set10('HAVE_SYSV_COMPAT', sysvinit_path != '' and sysvrcnd_path != '',
@ -1635,6 +1637,7 @@ subdir('src/nspawn')
subdir('src/resolve') subdir('src/resolve')
subdir('src/timedate') subdir('src/timedate')
subdir('src/timesync') subdir('src/timesync')
subdir('src/tmpfiles')
subdir('src/vconsole') subdir('src/vconsole')
subdir('src/boot/efi') subdir('src/boot/efi')
@ -2931,14 +2934,26 @@ if conf.get('ENABLE_SYSUSERS') == 1
install_rpath : rootlibexecdir, install_rpath : rootlibexecdir,
install : true, install : true,
install_dir : rootbindir) install_dir : rootbindir)
if have_standalone_binaries
public_programs += executable(
'systemd-sysusers.standalone',
'src/sysusers/sysusers.c',
include_directories : includes,
link_with : [libshared_static,
libbasic,
libbasic_gcrypt,
libsystemd_static,
libjournal_client],
install : true,
install_dir : rootbindir)
endif
endif endif
if conf.get('ENABLE_TMPFILES') == 1 if conf.get('ENABLE_TMPFILES') == 1
exe = executable( exe = executable(
'systemd-tmpfiles', 'systemd-tmpfiles',
'src/tmpfiles/tmpfiles.c', systemd_tmpfiles_sources,
'src/tmpfiles/offline-passwd.c',
'src/tmpfiles/offline-passwd.h',
include_directories : includes, include_directories : includes,
link_with : [libshared], link_with : [libshared],
dependencies : [libacl], dependencies : [libacl],
@ -2953,6 +2968,21 @@ if conf.get('ENABLE_TMPFILES') == 1
# https://github.com/mesonbuild/meson/issues/2681 # https://github.com/mesonbuild/meson/issues/2681
args : exe.full_path()) args : exe.full_path())
endif endif
if have_standalone_binaries
public_programs += executable(
'systemd-tmpfiles.standalone',
systemd_tmpfiles_sources,
include_directories : includes,
link_with : [libshared_static,
libbasic,
libbasic_gcrypt,
libsystemd_static,
libjournal_client],
dependencies : [libacl],
install : true,
install_dir : rootbindir)
endif
endif endif
if conf.get('ENABLE_HWDB') == 1 if conf.get('ENABLE_HWDB') == 1

View File

@ -26,6 +26,8 @@ option('static-libsystemd', type : 'combo',
option('static-libudev', type : 'combo', option('static-libudev', type : 'combo',
choices : ['false', 'true', 'pic', 'no-pic'], choices : ['false', 'true', 'pic', 'no-pic'],
description : '''install a static library for libudev''') description : '''install a static library for libudev''')
option('standalone-binaries', type : 'boolean', value : 'false',
description : '''also build standalone versions of supported binaries''')
option('sysvinit-path', type : 'string', value : '/etc/init.d', option('sysvinit-path', type : 'string', value : '/etc/init.d',
description : 'the directory where the SysV init scripts are located') description : 'the directory where the SysV init scripts are located')

7
src/tmpfiles/meson.build Normal file
View File

@ -0,0 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1+
systemd_tmpfiles_sources = [
'src/tmpfiles/tmpfiles.c',
'src/tmpfiles/offline-passwd.c',
'src/tmpfiles/offline-passwd.h',
]