Commit Graph

456 Commits

Author SHA1 Message Date
Yu Watanabe
929ce35f8d meson: rework include_directories() and finding of tools (#39956)
This is a cleanup in preparation for later additions.
2025-12-02 20:07:37 +09:00
Zbigniew Jędrzejewski-Szmek
322f6adbcd meson: add tools/meson.build
Previously, we looked for scripts in the tools/ directory ad hoc,
wherever they were needed. Let's do those checks in one place.
The main meson.build file is shrunk somewhat, which is always nice.
2025-12-01 16:18:11 +01:00
Daan De Meyer
fb514c2f8f mkosi: Rework how the pkgenv environment variables are set
Instead of including distribution specific files in the subimages,
let's have one common mkosi.pkgenv/ directory that handles all the
matching which is then included in the subimages.

This gives us more control on exactly how we do the matching.
2025-11-25 11:02:34 +01:00
Daan De Meyer
7336f2c748 meson: Still build libshared even if libmount is disabled
Currently, if the libmount feature is disabled, we don't build
libshared and as a result skip building every other executable as
well. Among other things, this makes our nodeps CI builds kind of
pointless since hardly any code will be compiled.

Let's improve on the situation by making libmount properly optional
in libshared. Then, we only skip building the executables that
actually need libmount.
2025-11-24 13:09:41 +01:00
Daan De Meyer
3f0fc93219 tools: Add script to detect unused symbols in libshared
Symbols exported by libshared can't get pruned by the linker, so
every unused exported symbol is effectively dead code we ship to users
for no good reason. Let's add a script to analyze how many such symbols
we have.

We also add a meson test to run the script on all of our binaries.
Since it detects unused symbols and still has a few false positives,
don't enable the test by default similar to the clang-tidy tests.

The script was 100% vibe coded by Github Copilot with Claude Sonnet 4.5
as the model.

Current results are (without the unused symbols list):

Analysis of libsystemd-shared-259.so
======================================================================
Total exported symbols: 4830
  (excluding public API symbols starting with 'sd_')
Used symbols: 4672
Unused symbols: 158
Usage rate: 96.7%
2025-11-19 13:14:15 +01:00
Zbigniew Jędrzejewski-Szmek
31d3b96293 musl: split out script to setup build
This makes it easier to set up a local build with musl:
$ tools/setup-musl-build.sh build-meson
$ ninja -C build-meson
2025-11-17 17:02:23 +01:00
Masanari Iida
036100d745 systemd-logind: Add signal section in man systemd-logind
This patch adds signal setion in man systemd-logind
2025-11-12 08:45:55 +09:00
Yu Watanabe
a736d4ec9c oss-fuzz: install libcrypt-dev in i386 image
This is preparation for bumping base image of oss-fuzz to Ubuntu 24.04.

Closes #39395.

Co-authored-by: Evgeny Vereshchagin <evvers@ya.ru>
2025-11-10 10:45:42 +09:00
Yu Watanabe
9b414a38fa tree-wide: drop unused libcap dependencies 2025-10-24 01:52:59 +09:00
Zbigniew Jędrzejewski-Szmek
675bfef837 Stop specifying license for generated file, instead mark as generated
I exclude generated files from license check, and I noticed
that this file was marked with a license header, which doesn't
make much sense, it is not copyrightable.
2025-10-04 18:13:27 +02:00
Jörg Behrmann
1dcbb0b4ca tools: ignore root element explicitly in check-version-history
Currently these messages (broken for length)

    2025-08-20T12:04:15.9609277Z
    /home/runner/work/systemd/systemd/tools/check-version-history.py:26:
    FutureWarning: This search incorrectly ignores the root element, and will be fixed in a future version.
    If you rely on the current behaviour, change it to './/funcprototype/funcdef/function'

can be seen in CI output. So let's apply the suggestion.
2025-08-25 14:38:00 +02:00
Jörg Behrmann
09a89190bb man: add note about extending machine-info to man page 2025-08-25 14:38:00 +02:00
Zbigniew Jędrzejewski-Szmek
8aedfd979f tools: make all .py program files executable
All those files are standalone programs that can be executed directly.
Some .py files were marked executable, others weren't, probably accidentally.
Mark them all as executable in preparation for subsequent changes.
2025-07-25 12:33:13 +02:00
Zbigniew Jędrzejewski-Szmek
0bf9bbecae tools: consistently use #!/usr/bin/env python3
It's ugly, but it's better to be consistently ugly.
2025-07-25 12:33:13 +02:00
Luca Boccassi
6235121abf netdev-util: allow setting local address based on dhcp-pd addresses as well (#38211)
This extends the functionality introduced in #21648 to allow using
addresses chosen from a delegated prefix as well as the existing
SLAAC/LL/DHCP functionality.
2025-07-17 14:14:49 +01:00
Sam James
e65455fead elf2efi: ignore .sframe
SFrames are a new format for stack unwinding information. Ignore it if
preset as is done for .eh_frame.
2025-07-16 14:57:30 +02:00
Linus Heckemann
8a7a33ab1e vcs-tag.sh: use more compatible shebang 2025-07-14 13:56:07 +02:00
Yu Watanabe
e58ba80a40 units: drop runlevel[0-6].target 2025-07-13 05:49:09 +09:00
Yu Watanabe
8ba48d4bf8 core,initctl,systemctl: kill /dev/initctl support
This also kills support for controlling system state through
/sbin/init, initctl, and telinit.
2025-07-13 05:38:14 +09:00
Yu Watanabe
af925f7eb3 systemctl: kill SysV compat 'runlevel' command 2025-07-13 05:38:13 +09:00
Yu Watanabe
2b912d2066 tree-wide: several cleanups for generating symbol lists and gperf files
- pass our system include directories to make generators use our libc
  wrappers and latest kernel headers,
- include relevant headers in generated gperf file,
- use files() rather than find_program(), as the result of
  find_program() cannot be passed to 'input' of custom_target(),
- move generate-bpf-delegate-configs.py to src/core/, as it is only used
  by libcore.
2025-07-11 13:05:42 +09:00
Matteo Croce
ea9826eb94 core: add options to delegate BPFFS token creation
Add four new options BPFDelegate{Commands,Maps,Programs,Attachments}=
in order to delegate to a BPFFS instance the permission to create tokens.

The value is a list of options taken from:
https://github.com/torvalds/linux/blob/v6.14/include/uapi/linux/bpf.h#L922-L1121
The special value "any" means to allow every possible values.

More informations about BPF tokens here:
https://lwn.net/Articles/947173/
2025-07-08 22:35:29 +02:00
Lennart Poettering
7478fbb0af core: fixes for RandomizedOffsetSec= feature (#37981)
Fixes: #37870
Follow-up for: #36437
2025-06-26 22:58:22 +02:00
Lennart Poettering
99fd08224f man: add proper version info for RandomizedOffsetUSec
Follow-up for: #36437
Fixes: #37870
2025-06-26 17:28:49 +02:00
Daan De Meyer
1095865d26 tools: Fix fetch-mkosi changelog generation 2025-06-26 13:28:15 +02:00
Lennart Poettering
279962a9e8 core/timer: Introduce RandomOffsetSec= knob (#36437)
This is like RandomDelaySec, but it doesn't reset whenever the manager
restarts.

Fixes https://github.com/systemd/systemd/issues/21166
2025-06-17 16:05:12 +02:00
Daan De Meyer
d1ee3889cf meson: Add libmount feature
Let's reduce the dependencies required to build just libsystemd by
making libmount optional. The meson disabler feature makes this quite
trivial.
2025-06-05 14:51:03 +02:00
Yu Watanabe
0436240dd2 udevadm: allow to specify device by device ID (#37636) 2025-06-02 18:02:36 +09:00
Luca Boccassi
90b0222091 sync-docs: add '(latest stable)' next to the latest version in the menu
Add visual indicator of what is the latest version in the
version menu
2025-05-30 11:54:01 +01:00
Luca Boccassi
1cd995185b sync-docs: fix selection menu when opening 'latest' man
'devel' will always sort first, so the highest version is the second
entry, not the first one
2025-05-30 11:54:01 +01:00
Luca Boccassi
34d63ac879 sync-docs: fix syntax warning
sync-docs.py:94: SyntaxWarning: invalid escape sequence '\d'
  m = re.match("v?(\d+).*", tag)
2025-05-30 11:54:01 +01:00
Yu Watanabe
d0ba749e8c udevadm: allow to specify device by device ID
We have already exposed device ID in the output of device ID in J
fields. Also sd_device_get_device_id() and sd_device_new_from_device_id()
are already public. Hence, making udevadm accept device IDs may be
useful.

With this change, as we save several data in /run/udev with device ID,
we can call udevadm something like the following:
```
udevadm info $(ls /run/udev/tags/uaccess)
```
Then, we can show all devices that has uaccess tag.
2025-05-29 04:04:22 +09:00
Yu Watanabe
6a907a00be man/udevadm: update command arguments 2025-05-29 04:04:22 +09:00
Daan De Meyer
1fa170b9d2 oss-fuzz: Add comment on why we build with --auto-features=disabled 2025-05-20 10:29:59 +02:00
Mike Yuan
7d71b23304 man: don't duplicate version in History section 2025-05-15 02:19:16 +02:00
Zbigniew Jędrzejewski-Szmek
c730fd7ddd elf2efi: make code more pythonic
Follow-up for 53628612b7.

With 'or', we ignore the empty string (but not '0'), and we only call
time.time() lazily. So this works the same as the code that is replaced,
but avoids the ugly repetition.
2025-05-14 18:35:21 +02:00
Daan De Meyer
6350d2dbd9 meson: Extract objects instead of creating intermediate static libraries
Currently, when we want to add unit tests for code that is compiled into
an executable, we either compile the code at least twice (once for the
executable, and once for each test that uses it) or we create a static
library which is then used by both the executable and all the tests.

Both of these options are not ideal, compiling source files more than
once slows down the build for no reason and creating the intermediate
static libraries takes a lot of boilerplate.

Instead, let's use the extract_objects() method that meson exposes on
build targets. This allows us to extract the objects corresponding to
specific source files and use them in other executables. Because we
define all executables upfront into a dictionary, we integrate this into
the dictionary approach by adding two new fields:

- 'extract' takes a list of files for which objects should be extracted.
  The extracted objects are stored in a dict keyed by the executable name
  from which they were extracted.
- 'objects' takes the name of an executable from which the extracted
  objects should be added to the current executable.

One side effect of this approach is that we can't build test executables
anymore without building the main executable, so we stop building test
executables unless we're also building the main executable. This allows
us to switch to using subdir_done() in all of these subdirectories to skip
parsing them if the corresponding component is disabled.

These changes get me down from 2439 => 2403 ninja targets on a full rebuild
from scratch.
2025-05-12 13:35:50 +02:00
Itxaka
03eae2a402 boot: add an option to control action after SecureBoot enrollment (#36684)
This PR provides a new option for systemd-boot
`secure-boot-enroll-action` which allows to configure the behavior after
SecureBoot keys are enrolled.

Provides the option to either reboot or power off.

The current behavior is not changed, it will by default reboot as it did
before.

It also provides a small message about the action its going to take with
a small delay so the user can read it.
2025-05-08 13:28:41 +09:00
Daan De Meyer
c09ce222b6 hashmap: Drop debug params
Passing in the func, file and line information complicates the
interface. On top of that, it prevents forward declaring Hashmap in
strv.h, as we need to pass the macros everywhere that we allocate a
hashmap, which means we have to include the hashmap header everywhere
we have a function that allocates a hashmap instead of just having to
forward declare Hashmap.

Let's drop the file, func and line information from the debug information.
Instead, in the future we can add a description field to hashmaps like we
already have in various other structs to describe the purpose of the hashmap
which should be much more useful than having the file, line and function where
the hashmap was allocated.
2025-05-06 10:14:26 +02:00
Daan De Meyer
95f87834f5 shared: Make sure ip-protocol-xxx.h headers include <netinet/in.h>
These headers use macros from <netinet/in.h> so let's make sure they
include the header.
2025-05-01 16:58:10 +02:00
Daan De Meyer
d06abcf68e meson: Implement duplicate includes check with clang-tidy
Instead of doing this with our own script, let's use clang-tidy
instead.
2025-04-24 12:36:38 +02:00
Daan De Meyer
9e3d048bd0 ci: Use mkosi in linter workflow
Let's reuse the mkosi tools tree to get all the tools we need instead
of pulling them from pypi.
2025-04-23 15:27:49 +02:00
Yu Watanabe
97b2e136eb man/systemd: drop explanation about SysV compatibilities
Sooner or later, we will drop the explained SysV compatibilities.
Let's remove them from the man page now to make not people rely on that.
2025-04-22 10:24:42 +09:00
Daan De Meyer
53628612b7 elf2efi: Add back python 3.7 compat
The walrus operator was introduced in python 3.9 so using it
accidentally bumped the minimum python version to 3.9 from 3.7 and
bluca still cares about keeping this working on 3.8 so let's remove
the usage of the walrus operator.

Follow up for d6a29eee2b
2025-04-16 13:06:27 +02:00
Daan De Meyer
d6a29eee2b elf2efi: Deal properly with empty $SOURCE_DATE_EPOCH 2025-04-09 16:21:13 +02:00
Daan De Meyer
b2634bde3c meson: Use custom_target() instead of vcs_tag()
vsc_tag() always reruns even if the vcs-tag option is disabled. Let's
use custom_target() instead so that we can only enable build_always_stale
if the vcs-tag option is enabled.
2025-04-09 16:21:08 +02:00
Daan De Meyer
278d5bfd7e mkosi: Make MinimumVersion= a git commit
With the latest mkosi it's possible for MinimumVersion= to be a git
commit so let's start making use of that. This will make mkosi fail
if it's executed within the systemd repository and the checked out
commit is too old.

Putting the mkosi commit sha in mkosi/mkosi.conf also allows retrieving
it without having the full source tree available.

We also make a bunch of improvements to the fetch-mkosi.py script.
2025-04-08 18:35:04 +02:00
Daan De Meyer
342d21ef19 mkosi: Move all mkosi configuration into mkosi/ subdirectory
Now that mkosi can automatically pick up its main configuration from
a mkosi/ subdirectory if it exists and there is no configuration in the
top level directory, let's make use of it  to reduce the amount of clutter
in the top level directory of the repository.

This will also make it easier to install the mkosi configuration files as
part of the testing packages later on.
2025-04-03 09:59:15 +02:00
Daan De Meyer
ce68d4349e mkosi: Stop passing package environment variables to tools image
The tools image is not guaranteed to be the same distribution as the
target distribution and so might have different package environment
variables than the main image yet we currently unconditionally use the
same package environment variables for both of them.

Let's fix this by not passing the package environment variables to the
tools image and subimages anymore, and instead having the main, tools and
build images separately include a config file with the required environment
variables.
2025-04-02 10:34:03 +02:00
Daan De Meyer
1b49fb9aaa mkosi: Use build image prepare scripts for tools tree as well
Instead of listing dependencies manually for the default tools tree,
let's reuse the prepare scripts from the build image. To make this work,
the sync script has to be configured for the tools tree as well so that
it's invoked both when building the tools tree and for the regular image,
otherwise, when doing the first build in a fresh checkout, the sync script
won't have executed yet as sync scripts for the regular images are executed
after building the default tools tree.
2025-03-28 12:29:09 +01:00