diff --git a/.github/workflows/unit-tests.sh b/.github/workflows/unit-tests.sh index 1e0ee40089a..7e8636c67ad 100755 --- a/.github/workflows/unit-tests.sh +++ b/.github/workflows/unit-tests.sh @@ -170,7 +170,7 @@ for phase in "${PHASES[@]}"; do MESON_ARGS+=(-Db_lundef=false -Dfuzz-tests=true) if [[ "$phase" == "RUN_CLANG_ASAN_UBSAN_NO_DEPS" ]]; then - MESON_ARGS+=(--auto-features=disabled -Dnspawn=enabled) + MESON_ARGS+=(--auto-features=disabled -Dhibernate=false -Dnspawn=enabled) fi fi MESON_ARGS+=(--fatal-meson-warnings) diff --git a/man/rules/meson.build b/man/rules/meson.build index f8c8bd0b76f..11501fb5dc2 100644 --- a/man/rules/meson.build +++ b/man/rules/meson.build @@ -1276,7 +1276,7 @@ manpages = [ ['systemd-run-generator', '8', [], ''], ['systemd-run', '1', [], ''], ['systemd-sbsign', '1', [], ''], - ['systemd-sleep.conf', '5', ['sleep.conf.d'], ''], + ['systemd-sleep.conf', '5', ['sleep.conf.d'], 'ENABLE_SLEEP'], ['systemd-socket-activate', '1', [], ''], ['systemd-socket-proxyd', '8', [], ''], ['systemd-soft-reboot.service', '8', [], ''], @@ -1303,7 +1303,7 @@ manpages = [ 'systemd-hybrid-sleep.service', 'systemd-sleep', 'systemd-suspend-then-hibernate.service'], - ''], + 'ENABLE_SLEEP'], ['systemd-sysctl.service', '8', ['systemd-sysctl'], ''], ['systemd-sysext', '8', diff --git a/man/systemd-sleep.conf.xml b/man/systemd-sleep.conf.xml index 476e5ef21f4..db670bee2a8 100644 --- a/man/systemd-sleep.conf.xml +++ b/man/systemd-sleep.conf.xml @@ -3,7 +3,7 @@ "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> - systemd-sleep.conf diff --git a/man/systemd-suspend.service.xml b/man/systemd-suspend.service.xml index c5833b23159..6a8d6f74183 100644 --- a/man/systemd-suspend.service.xml +++ b/man/systemd-suspend.service.xml @@ -3,7 +3,7 @@ "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> - diff --git a/meson.build b/meson.build index 25f064a8e46..b1e002ea16b 100644 --- a/meson.build +++ b/meson.build @@ -1796,6 +1796,7 @@ conf.set10('DEFAULT_MOUNTFSD_TRUSTED_DIRECTORIES', get_option('default-mountfsd- conf.set10('ENABLE_BATTERY_CHECK', get_option('battery-check').allowed()) conf.set10('ENABLE_CLONESETUP', get_option('clonesetup').allowed()) conf.set10('ENABLE_GROWFS', get_option('growfs').allowed()) +conf.set10('ENABLE_SLEEP', get_option('sleep').allowed()) have = get_option('integritysetup').require( conf.get('HAVE_LIBCRYPTSETUP') == 1, @@ -1813,7 +1814,7 @@ foreach tuple : [ ['environment-d'], ['firstboot'], ['gshadow', get_option('libc') != 'musl', 'musl does not support it'], - ['hibernate'], + ['hibernate', conf.get('ENABLE_SLEEP') == 1, 'sleep support is disabled'], ['hostnamed'], ['hwdb'], ['idn', conf.get('HAVE_NI_IDN') == 1, 'NI_IDN is not defined'], @@ -3484,6 +3485,7 @@ foreach tuple : [ ['resolve'], ['rfkill'], ['rust', have_rust], + ['sleep'], ['sysext'], ['sysinstall'], ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1], diff --git a/meson_options.txt b/meson_options.txt index 24bad66f0cf..06b5ceaa637 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -184,7 +184,7 @@ option('firstboot', type : 'boolean', option('growfs', type : 'feature', description : 'install systemd-growfs, systemd-makefs, and associated files') option('hibernate', type : 'boolean', - description : 'support for hibernation') + description : 'support for hibernation (requires sleep support)') option('homed', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' }, description : 'install the systemd-homed stack') option('hostnamed', type : 'boolean', @@ -251,6 +251,8 @@ option('resolve', type : 'boolean', description : 'systemd-resolved stack') option('rfkill', type : 'boolean', description : 'support for the rfkill tools') +option('sleep', type : 'feature', + description : 'install systemd-sleep and associated files') option('storagetm', type : 'boolean', description : 'support for Storage Target Mode') option('sysext', type : 'boolean', diff --git a/src/sleep/meson.build b/src/sleep/meson.build index 663a36e038d..7aeaed3bb3b 100644 --- a/src/sleep/meson.build +++ b/src/sleep/meson.build @@ -1,5 +1,9 @@ # SPDX-License-Identifier: LGPL-2.1-or-later +if conf.get('ENABLE_SLEEP') != 1 + subdir_done() +endif + executables += [ libexec_template + { 'name' : 'systemd-sleep', diff --git a/test/units/TEST-35-LOGIN.sh b/test/units/TEST-35-LOGIN.sh index 1b2507467b7..819afefe7d9 100755 --- a/test/units/TEST-35-LOGIN.sh +++ b/test/units/TEST-35-LOGIN.sh @@ -134,6 +134,11 @@ teardown_suspend() ( testcase_suspend_on_lid() { local pid input_name lid_dev + if [[ ! -x /usr/lib/systemd/systemd-sleep ]]; then + echo "systemd-sleep is not installed, skipping suspend test" + return + fi + if systemd-detect-virt --quiet --container; then echo "Skipping suspend test in container" return diff --git a/units/meson.build b/units/meson.build index b6a38ea83c5..b7a7e023961 100644 --- a/units/meson.build +++ b/units/meson.build @@ -217,7 +217,10 @@ units = [ { 'file' : 'serial-getty@.service.in' }, { 'file' : 'shutdown.target' }, { 'file' : 'sigpwr.target' }, - { 'file' : 'sleep.target' }, + { + 'file' : 'sleep.target', + 'conditions' : ['ENABLE_SLEEP'], + }, { 'file' : 'slices.target' }, { 'file' : 'smartcard.target' }, { 'file' : 'sockets.target' }, @@ -228,7 +231,10 @@ units = [ 'file' : 'suspend-then-hibernate.target', 'conditions' : ['ENABLE_HIBERNATE'], }, - { 'file' : 'suspend.target' }, + { + 'file' : 'suspend.target', + 'conditions' : ['ENABLE_SLEEP'], + }, { 'file' : 'swap.target' }, { 'file' : 'sys-fs-fuse-connections.mount', @@ -923,7 +929,10 @@ units = [ 'file' : 'systemd-suspend-then-hibernate.service.in', 'conditions' : ['ENABLE_HIBERNATE'], }, - { 'file' : 'systemd-suspend.service.in' }, + { + 'file' : 'systemd-suspend.service.in', + 'conditions' : ['ENABLE_SLEEP'], + }, { 'file' : 'systemd-sysctl.service.in', 'symlinks' : ['sysinit.target.wants/'],