Skip to content

Commit

Permalink
meson: decouple session tracking mechanism from unit and sysusers
Browse files Browse the repository at this point in the history
Session tracking build options are about whether logind or other APIs
are used in the polkit code, at compilation and linking time.

units and sysusers files have nothing to do with code changes or APIs,
they simply install config files, that can just be ignored if they are
not needed. Unconditionally require a systemd.pc pkg-config file and
install these config files. When not available a stub that points all
variables to /dev/null can be used, which works everywhere and for all
settings without needing custom options on each project and variable.

This also fixes another bug,  'systemdsystemunitdir' is specified as
an option the systemd_dep variable is not defined, but the sysusers.d
directory lookup uses it, causing a build failure:

dh_auto_configure -- \
	-Dexamples=false \
	-Dintrospection=true \
	-Dman=true \
	-Dsystemdsystemunitdir=/usr/lib/systemd/system \
	-Dtests=true \
	-Dgtk_doc=true -Dsession_tracking=libsystemd-login
	cd obj-x86_64-linux-gnu && DEB_PYTHON_INSTALL_LAYOUT=deb LC_ALL=C.UTF-8 meson setup .. --wrap-mode=nodownload --buildtype=plain --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=lib/x86_64-linux-gnu -Dpython.bytecompile=-1 -Dexamples=false -Dintrospection=true -Dman=true -Dsystemdsystemunitdir=/usr/lib/systemd/system -Dtests=true -Dgtk_doc=true -Dsession_tracking=libsystemd-login
The Meson build system
Version: 1.3.1
Source dir: /builds/bluca/polkit/debian/output/source_dir
Build dir: /builds/bluca/polkit/debian/output/source_dir/obj-x86_64-linux-gnu
Build type: native build
Project name: polkit
Project version: 124

<...>

Run-time dependency libsystemd found: YES 255
Checking for function "sd_uid_get_display" with dependency libsystemd: YES
Checking for function "sd_pidfd_get_session" with dependency libsystemd: YES
../meson.build:222:37: ERROR: Unknown variable "systemd_dep".

Follow-up for 24f1e0a
  • Loading branch information
bluca committed May 22, 2024
1 parent 042897e commit bbfce4d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
30 changes: 14 additions & 16 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,21 @@ if enable_pam
)
endif

if session_tracking == 'logind'
configure_file(
input: 'polkit.service.in',
output: '@BASENAME@',
configuration: service_conf,
install: true,
install_dir: systemd_systemdsystemunitdir,
)
configure_file(
input: 'polkit.service.in',
output: '@BASENAME@',
configuration: service_conf,
install: true,
install_dir: systemd_systemdsystemunitdir,
)

configure_file(
input: 'polkit.conf.in',
output: '@BASENAME@',
configuration: service_conf,
install: true,
install_dir: systemd_sysusers_dir,
)
endif
configure_file(
input: 'polkit.conf.in',
output: '@BASENAME@',
configuration: service_conf,
install: true,
install_dir: systemd_sysusers_dir,
)

install_data(
'policyconfig-1.dtd',
Expand Down
20 changes: 10 additions & 10 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,6 @@ enable_logind = (session_tracking != 'ConsoleKit')
if enable_logind
if session_tracking == 'logind'
logind_dep = dependency('libsystemd', not_found_message: 'logind support requested but libsystemd library not found')

# systemd unit / service files
systemd_systemdsystemunitdir = get_option('systemdsystemunitdir')
if systemd_systemdsystemunitdir == ''
systemd_dep = dependency('systemd', not_found_message: 'systemd required but not found, please provide a valid systemd user unit dir or disable it')
# FIXME: systemd.pc file does not use variables with relative paths, so `define_variable` cannot be used
systemd_systemdsystemunitdir = systemd_dep.get_pkgconfig_variable('systemdsystemunitdir')
endif

systemd_sysusers_dir = systemd_dep.get_pkgconfig_variable('sysusers_dir', default: '/usr/lib/sysusers.d')
else
logind_dep = dependency('libelogind', not_found_message: 'elogind support requested but libelogind library not found')
endif
Expand All @@ -222,6 +212,16 @@ config_h.set('HAVE_LIBSYSTEMD', enable_logind)

config_h.set('HAVE_PIDFD_OPEN', cc.get_define('SYS_pidfd_open', prefix: '#include <sys/syscall.h>') != '')

# systemd unit / sysuser file installation directories
systemd_dep = dependency('systemd', not_found_message: 'systemd.pc pkg-config file required but not found')
systemd_systemdsystemunitdir = get_option('systemdsystemunitdir')
if systemd_systemdsystemunitdir == ''
# FIXME: systemd.pc file does not use variables with relative paths, so `define_variable` cannot be used
systemd_systemdsystemunitdir = systemd_dep.get_pkgconfig_variable('systemdsystemunitdir')
endif

systemd_sysusers_dir = systemd_dep.get_pkgconfig_variable('sysusers_dir')

# User for running polkitd
polkitd_user = get_option('polkitd_user')
config_h.set_quoted('POLKITD_USER', polkitd_user)
Expand Down

0 comments on commit bbfce4d

Please sign in to comment.