From 0bc7a465e7083fcf2f52cdab3205c2bfa3a2b7a3 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Sat, 24 Oct 2026 10:39:50 +0100 Subject: [PATCH] meson: add feature flag for battery-check battery-check builds and installs binaries, docs, units, etc. Add a feature flag to make it easier to avoid shipping it. --- man/rules/meson.build | 5 ++++- man/systemd-battery-check.service.xml | 3 ++- meson.build | 3 +++ meson_options.txt | 2 ++ src/battery-check/meson.build | 1 + test/units/TEST-74-AUX-UTILS.battery-check.sh | 5 +++++ units/meson.build | 2 +- 7 files changed, 18 insertions(+), 3 deletions(-) diff --git a/man/rules/meson.build b/man/rules/meson.build index 4445ef296e9..17fccb0b7fe 100644 --- a/man/rules/meson.build +++ b/man/rules/meson.build @@ -1030,7 +1030,10 @@ manpages = [ ''], ['systemd-ask-password', '1', [], ''], ['systemd-backlight@.service', '8', ['systemd-backlight'], 'ENABLE_BACKLIGHT'], - ['systemd-battery-check.service', '8', ['systemd-battery-check'], ''], + ['systemd-battery-check.service', + '8', + ['systemd-battery-check'], + 'ENABLE_BATTERY_CHECK'], ['systemd-binfmt.service', '8', ['systemd-binfmt'], 'ENABLE_BINFMT'], ['systemd-bless-boot-generator', '8', [], 'ENABLE_BOOTLOADER'], ['systemd-bless-boot.service', diff --git a/man/systemd-battery-check.service.xml b/man/systemd-battery-check.service.xml index 2824797c043..4d6ceb9e426 100644 --- a/man/systemd-battery-check.service.xml +++ b/man/systemd-battery-check.service.xml @@ -3,7 +3,8 @@ "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> - + systemd-battery-check diff --git a/meson.build b/meson.build index db4219b6511..03a79059434 100644 --- a/meson.build +++ b/meson.build @@ -1793,6 +1793,8 @@ conf.set10('ENABLE_NSPAWN', feature.allowed()) conf.set10('DEFAULT_MOUNTFSD_TRUSTED_DIRECTORIES', get_option('default-mountfsd-trusted-directories')) +conf.set10('ENABLE_BATTERY_CHECK', get_option('battery-check').allowed()) + foreach tuple : [ ['analyze'], ['backlight'], @@ -3434,6 +3436,7 @@ foreach tuple : [ # components ['backlight'], + ['battery-check'], ['binfmt'], ['bootloader'], ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1], diff --git a/meson_options.txt b/meson_options.txt index a2028ec8801..8980e0ca04e 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -163,6 +163,8 @@ option('analyze', type: 'boolean', value: true, description : 'install systemd-analyze') option('backlight', type : 'boolean', description : 'install systemd-backlight') +option('battery-check', type : 'feature', + description : 'install systemd-battery-check and associated files') option('binfmt', type : 'boolean', description : 'support for custom binary formats') option('coredump', type : 'boolean', diff --git a/src/battery-check/meson.build b/src/battery-check/meson.build index b9cd5000e35..18131e7fc8f 100644 --- a/src/battery-check/meson.build +++ b/src/battery-check/meson.build @@ -3,6 +3,7 @@ executables += [ libexec_template + { 'name' : 'systemd-battery-check', + 'conditions' : ['ENABLE_BATTERY_CHECK'], 'sources' : files('battery-check.c'), }, ] diff --git a/test/units/TEST-74-AUX-UTILS.battery-check.sh b/test/units/TEST-74-AUX-UTILS.battery-check.sh index 52a92b80b88..50a3ca0b0c9 100755 --- a/test/units/TEST-74-AUX-UTILS.battery-check.sh +++ b/test/units/TEST-74-AUX-UTILS.battery-check.sh @@ -3,6 +3,11 @@ set -eux set -o pipefail +if [[ ! -x /usr/lib/systemd/systemd-battery-check ]]; then + echo "systemd-battery-check is not installed, skipping test." + exit 77 +fi + /usr/lib/systemd/systemd-battery-check --help /usr/lib/systemd/systemd-battery-check --version diff --git a/units/meson.build b/units/meson.build index 5c643c6e3a7..0a447c4dedd 100644 --- a/units/meson.build +++ b/units/meson.build @@ -65,7 +65,7 @@ units = [ }, { 'file' : 'systemd-battery-check.service.in', - 'conditions' : ['ENABLE_INITRD'], + 'conditions' : ['ENABLE_BATTERY_CHECK', 'ENABLE_INITRD'], 'symlinks' : ['initrd.target.wants/'], }, {