Commit Graph
365 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek efd63ddfbf shared/verbs: turn verb argument specification into nulstr
Like the command-level CommandDescription.argspec, a verb's argspec is now
a nulstr, so that a verb may declare multiple alternative usage lines. The
verbs help table renders one synopsis line per nulstr entry in the
synopsis cell.

All verb argument specifications must gain an explicit NUL suffix. This
is a lot of churn, but I think this needs to be done. For now, there'll
be only one user of the new functionality (i.e. a verb with more than
one argspec), but I think we'll eventually want to use this in other
places too.
2026-08-28 09:29:04 +02:00
felix h a11144d0a9 tree-wide: format man page references as foo(1) 2026-08-28 06:34:45 +09:00
Luca Boccassi 35530fcf94 sysupdate: move back to libexecdir to mark as experimental
Fixes https://github.com/systemd/systemd/issues/43498
2026-08-26 19:51:31 +01:00
Zbigniew Jędrzejewski-Szmek 65510d4cba services: convert to VERB_COMMAND and add --introspect-cli
This converts systemd-homed, -hostnamed, -importd, -localed, -logind,
-machined, -networkd, -portebled, -resolved, -sysupdated, -timedated,
and -timesyncd.

The service name and description move from service_parse_argv() arguments
into a COMMAND() description that each daemon now defines. The
service_parse_argv() macro captures the calling binary's verb section,
where that COMMAND is found, while the options are still defined and
parsed in libshared, in the new "service" option namespace that each
COMMAND references. (The named namespace makes sure that options defined
by other translation units in libshared can never leak into the
services' parsers.)

The supported features are declared via option group filtering: each
COMMAND lists "Options" plus "Bus introspection" and/or "Runtime scope".
Unsupported options are now rejected by the parser as unknown options
(and are not shown in --help), replacing the runtime "This service does
not support …" errors.

The help output changes slightly: the "Bus introspection" and "Runtime
scope" option groups now get their own headings, and some descriptions
were reworded to the imperative form used elsewhere.
2026-08-26 12:15:25 +02:00
Zbigniew Jędrzejewski-Szmek 1cf40c9c72 shared/verbs: stop requiring an explicit program name
Almost all programs are simple and have only a single command. When
printing options, let's just use the first COMMAND block found by default.
This means we can drop the explicit program-name argument and reduce
copy&paste boilerplate.
2026-08-24 13:45:07 +02:00
Zbigniew Jędrzejewski-Szmek f969973b90 Another batch of conversions to COMMAND and additions of --introspect-cli (#43428) 2026-08-18 18:32:55 +02:00
Zbigniew Jędrzejewski-Szmek 0cbeceaea2 updatectl: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. The odd "Verbs" option group marker is dropped,
so that all options are listed in one section after the verbs, with --help
and --version first. The synopsis now uses the generic "[OPTION…] COMMAND …"
form: a bare VERSION is not accepted as the first argument, and the man
page does not list it either. --help now goes through the pager, like
other commands with --no-pager.
2026-08-18 16:54:09 +02:00
Zbigniew Jędrzejewski-Szmek adc83f020a sysupdate: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. The "Options" group marker after --help/--version
is dropped, so that all options are listed in one section after the verbs.
The synopsis now uses the generic "[OPTION…] COMMAND …" form: a bare
VERSION is not accepted as the first argument, and the man page does not
list it either. --help now goes through the pager, like other commands
with --no-pager.
2026-08-18 16:54:09 +02:00
Yu Watanabe 90481c0b1b tree-wide: add missing assertions
Found by coccinelle.
2026-08-18 06:30:10 +09:00
dongshengyuan a3839ade4e sysupdate: allow long CurrentSymlink= paths
CurrentSymlink= accepts a symlink path, but the parser used NAME_MAX
for specifier expansion. Absolute and target-relative paths can be
longer than one filename component while still staying below PATH_MAX.

Reproducer: configure CurrentSymlink= to a path longer than NAME_MAX
and run systemd-sysupdate list with debug logging.

Before: sysupdate logged that CurrentSymlink= specifier expansion
failed and ignored the setting.

After: the transfer parses cleanly and list emits no CurrentSymlink=
specifier expansion warning.

Follow-up for: 43cc7a3ef4
2026-08-06 10:06:00 +08:00
dongshengyuan 215c438372 sysupdate: allow long metadata URLs
138829b784 moved Documentation=, AppStream=, and related URL parsing
into sysupdate-config.c, but kept NAME_MAX as the specifier expansion
limit. These settings are URLs, not filenames.

Reproducer: configure a feature Documentation= URL longer than
NAME_MAX and run systemd-sysupdate features FEATURE.

Before: the URL was ignored after ENAMETOOLONG during specifier
expansion.

After: features FEATURE prints the long Documentation URL.

Follow-up for: 138829b784
2026-08-06 10:06:00 +08:00
dongshengyuan 753b0a6e24 sysupdate: allow resetting version filters
systemd drop-ins use an empty assignment to reset list and scalar
settings. MinVersion= and ProtectVersion= treated an empty assignment
as an invalid version and kept the earlier value active.

Reproducer: define MinVersion=v2 and ProtectVersion=v1, then add a
drop-in with empty MinVersion= and ProtectVersion= assignments.

Before: sysupdate logged invalid-version warnings for the empty values.

After: list logs no invalid-version warnings and shows both v1 and v2.

Follow-up for: 43cc7a3ef4
2026-08-06 10:06:00 +08:00
dongshengyuan 073965ab2f sysupdate: parse PartitionFlags= as hexadecimal
sysupdate.d(5) documents PartitionFlags= as a hexadecimal integer, and
sysupdate patterns format partition flags with PRIx64. The parser used
safe_atou64(), which rejected values such as abcdef.

Reproducer: set PartitionFlags=abcdef in a partition target transfer
and run systemd-sysupdate list with debug logging.

Before: sysupdate logged:
Failed to parse partition flags, ignoring: abcdef

After: the transfer parses cleanly and list emits no partition-flags
parse warning.

Follow-up for: 43cc7a3ef4
2026-08-06 10:06:00 +08:00
dongshengyuan 09f8b59ac3 sysupdate: remove current partial instance names
48fff6a27a switched filesystem transfers to predictable
.sysupdate.partial.* names, but transfer_remove_temporary()
still only scanned the legacy .# prefix.

Remove the current partial prefix there too. Pending instances
are deliberately left for transfer_vacuum(), so ProtectVersion=
can still spare protected pending versions.

Follow-up for: 48fff6a27a
2026-08-06 10:06:00 +08:00
dongshengyuan a3ab9d2c1a sysupdate: honor default MatchPartitionType= for partitions
sysupdate.d(5) documents linux-generic as the default
MatchPartitionType= for partition targets. After 10eaca4159,
omitting the option left partition_type_set false and update failed
before acquiring the image.

Reproducer: create a partition target transfer without
MatchPartitionType= and run systemd-sysupdate update.

Before: update failed with:
Partition type must be set for partition targets.

After: update succeeds on a linux-generic slot and installs the
version, leaving the GPT label as part-v1.

Follow-up for: 10eaca4159
2026-08-06 10:06:00 +08:00
Kai Lüke 3cf8ab36a8 sysupdate: Change disabling with --component-suggested/--feature-suggested
The disabling of features or components with the flag
--component-suggested/--feature-suggested didn't disable the suggested
ones but instead disabled all other ones. This is rather unintuitive due
to how the flags are named and also not really needed because the
intended reconciliation outcome can instead be done by first disabling
everything and then enabling the suggested ones again which is easier to
reason about. For components the tricky part is that they default to
enabled and thus it's better to have the disable/enable commands with
--component-suggested operate only on suggested ones instead of touching
others like "legacy" components that don't explicity say whether they
are enabled and suggested or not.

Make running disablement of components/features with
--component-suggested/--feature-suggested undo a previous enablement
with the same flags. Document how one can align the system to only use
suggested components/features and not anything else by doing it in two
steps, first disabling everything and then enabling suggested ones. This
also makes it clearer now that all components that are not explicitly
enabled nor suggested will be disabled then.
2026-07-28 16:24:29 +09:00
dongshengyuan bbe99a925b sysupdate: include default component for feature-all
--component-all is documented to include the default component-less
installation. Do not drop it merely because the context operates on a
root/image, or because all its transfers are currently disabled by
features.

This lets --component-all --feature-all enable-feature write the
default component feature drop-ins instead of succeeding with no
components selected.

TEST-72-SYSUPDATE covers both all transfers disabled by features and
the same default component feature operation under --root=.

Repro: create a default feata.feature plus a transfer gated by feata,
then run:
build/systemd-sysupdate --root="$root" --component-all --feature-all enable-feature

Before: no drop-in was written.

Follow-up for: 4481661a75
2026-07-26 15:26:06 +08:00
dongshengyuan b03503a116 sysupdate: keep root-relative installdb paths absolute
When recording installdb entries under --root=, keep the leading slash
after stripping the root. Compare current transfer target paths in the
same root-relative form during cleanup.

This prevents cleanup from treating still-owned resources below --root=
as orphaned.

TEST-72-SYSUPDATE covers --root= cleanup keeping a still-owned file and
its matching installdb entry.

Repro: create a rooted transfer for /target/foo-@v.bin, add a
matching installdb entry for /target/./foo-@v.bin, then run:
build/systemd-sysupdate --root="$root" --verify=no cleanup

Before: foo-1.bin and the installdb entry were removed.

Follow-up for: d82e256bb9
2026-07-26 15:26:06 +08:00
dongshengyuan 414777a108 sysupdate: don't double-prefix definitions with --root=
Definitions enumerated under --root= are already rooted. Passing those
paths to the config parsers with the same root prefixes the root again,
so feature and transfer files are parsed from the wrong path.

Repro: create root/etc/sysupdate.d/rootfeat.feature and
01-root.transfer, then run:
build/systemd-sysupdate --root="$root" --verify=no --offline features rootfeat

Before: parsing failed at line 1 with a bogus Source Type= error.

Fixes #42783.
Follow-up for: e1384cfb09
2026-07-26 14:40:05 +09:00
Yu Watanabe bda98358d2 tools: reject invalid inputs and align machine-readable output (#43040) 2026-07-21 12:23:00 +09:00
Yu Watanabe 4476d35081 sysupdate: fix typo
Follow-up for d82e256bb9.
2026-07-20 16:22:40 +09:00
dongshengyuan 928cc86772 sysupdate: keep JSON check-new exit status consistent
Return failure for --json check-new when no candidate is available.
Let sysupdated accept that exact JSON no-update result from workers.

Reproducer: systemd-sysupdate --verify=no --json=short check-new

Before: the command printed {"available":null} and exited successfully.

Follow-up: 42c0b689a8
2026-07-18 15:53:00 +08:00
Yu Watanabe 661ab8b6fd tree-wide: drop DLOPEN_FOO() macros
Since 4c0d8d9673, most dlopen notes are
set at the beginning of the executables. Let's manage all dlopen notes
there, rather than setting them where dlopen is called.

Note that the only exceptions are the LIBBPF_NOTE for networkd and
nsresource. Since dlopen_bpf() is wrapped in an `#if` guard, the notes
are instead set within the corresponding functionality.

As a result, the DLOPEN_FOO() wrapper macros are no longer needed and
can be dropped completely.
2026-07-18 04:56:32 +09:00
Lennart Poettering 921f63447b sysupdate: add support for 'update --component-all'
Let's add a way to quickly update all components that are enabled.
2026-07-15 13:27:48 +02:00
Luca Boccassi bd612520e4 bcd, id128, sysupdate: tighten edge-case handling (#43018) 2026-07-15 00:03:03 +01:00
Lennart Poettering d26de063cd version_is_valid() tweaks (#43025)
We have two validators, and neither really makes sense. Let's unify and
clean things up.
2026-07-14 23:46:40 +02:00
Lennart Poettering 64a3846ced sysupdate: Add ListFeatures() and ListTargets() varlink methods (#42900)
Following on from adding the basic varlink scaffolding to sysupdate,
let’s varlinkify a couple of the D-Bus methods. Because varlink doesn’t
have a concept of object paths, the D-Bus path structure which allows a
target to be selected has been squashed down to a target argument for
each relevant method.

Varlinkify the way to list targets, and also the way to list features
because that was simple to do at the same time.

More methods need varlinkifying in the future, but let’s do it in small
and manageable chunks.
2026-07-14 23:14:22 +02:00
Lennart Poettering 093cac3fe8 string-util: replace version_is_valid()/version_is_valid_version_spec() by a common call
Let's take inspiration from string_is_safe() and take a flags field that
allows fine tuning the validation.

Then port over all current users of either function to the new logic.
Note that this *does* change behaviour in various cases:

1. Generally: we'll now always accept the full UAPI.10 alphabet,
   including the "~" and "^" characters. As far as I can see there's no
   downside to this liberalization as none of the current consumers of
   the two functions uses these characters for anything else.

2. systemd-analyze compare-version will now accept version strings with
   "_" and "+" without complaining. I see no downside here, it just
   normalizes these debugging tools, to make them accept what most our
   other tools accept.

3. "bootctl link" will not accept empty version strings anymore
   Which is a bugfix I guess.

4. vpick will now refuse "_" and "+" in version strings. It kinda
   already did, because when parsing versions from filenames it uses "_"
   and "+" as name, architecture and attempt counter separators. We now
   systematically refuse it everywhere else in vpick too. This is hence
   a clean-up.

Fixes: #28906
Replaces: #42815 #41937
2026-07-14 22:32:27 +02:00
Lennart Poettering b14e60c983 sysupdate: use strverscmp_improved() like everywhere else
At one location we accidentally called strverscmp() instead of
strverscmp_improved()
2026-07-14 22:32:27 +02:00
Yu Watanabe 01e1303f9c Rename basic-forward.h, sd-forward.h, and shared-forward.h to forward.h
Follow-up for 74d392ed1b.
2026-07-15 02:18:05 +09:00
Philip Withnall 75a247d4de sysupdate: Allow multiple documentation URLs for a feature
Change the varlink API for Feature structs to allow multiple
documentation URLs for them, to match what systemd already does for
units etc.

This is a deviation from what the sysupdated D-Bus API allows and, for
the moment, from what’s supported internally by sysupdate. Internally it
continues to support 0-1 URLs for now.

But by defining the API as a strv, multiple URLs can be supported in
future without API breaks.
2026-07-14 15:03:35 +01:00
Philip Withnall a8a88fc3ba sysupdate: Run ListFeatures in offline mode
Historically, the ListFeatures API (in both D-Bus and now varlink) was
run without an `--offline` flag. This appears like it’s an oversight, but
actually `verb_features()` always unconditionally loaded in offline
mode.

In any case, there doesn’t appear to be a reason for the context to be
online (i.e. for it to check sources for available updates). Features are
defined in local config files and are loaded by `read_features()`, which
is called in both offline and online mode.

When the varlink ListFeatures API was added, it was put into online mode
in order to match the lack of `--offline` argument in the existing D-Bus
API implementation. Change both of them to be explicitly in offline mode.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2026-07-14 14:58:02 +01:00
Philip Withnall 8c166bc35e sysupdate: Downgrade an info to a debug log message
Since we now enumerate all targets on a varlink call (to validate the
requested target), this message gets printed multiple times in the log.
It’s not really necessary, so downgrade it to a debug message.
2026-07-14 14:57:35 +01:00
Philip Withnall 8cb7531390 sysupdate: Add varlink ListTargets() method
And add integration tests for it using `jq`.
2026-07-14 14:57:31 +01:00
Philip Withnall 3e34ccf6df sysupdate: Add varlink ListFeatures() method
And add integration tests for it using `jq`.
2026-07-14 14:57:13 +01:00
Philip Withnall 8085a05f86 sysupdate: Factor out core of features verb
This will be used in the following commit to add a varlink interface for
it.

This introduces no functional changes.
2026-07-14 14:57:00 +01:00
Philip Withnall f8f92584db sysupdate: Improve empty table when printing features
Rather than just printing out the table header and then exiting, print
“No features” similarly to what `loginctl` or `storagectl` do.
2026-07-14 12:09:23 +01:00
dongshengyuan 9ed8392a3c sysupdate: print version details once
list VERSION printed the version status header twice in plain output.

Keep the complete later header and add a regression check.

Follow-up for: 42c0b689a8.
2026-07-14 18:52:52 +08:00
Lennart Poettering 4481661a75 sysupdate: add support for --component-all + --feature-all + --feature-suggested to enable-feature verb
This adds similar concepts as we already have for enable-component:
let's add a way to enable all features or the suggeste dones, and
possibly on all components.

Or in other words, with this:

  systemd-sysupdate enable-component -S
  systemd-sysupdate enable-feature -A -s

We'll automatically enable all suggested components, and all features of
them.
2026-07-13 17:36:11 +02:00
Lennart Poettering 9f3b604d64 sysupdate: validate feature name syntax before using it
Let's tighten the rules on features, and enforce a sensible naming
policy.
2026-07-13 17:36:10 +02:00
Lennart Poettering f23224a7ca sysupdate: add feature select
Prepartion for the next commit: also allow selecting the all or
suggested features.
2026-07-13 17:36:10 +02:00
Lennart Poettering 52d9906a54 sysupdate: implement --component-all and --component-suggested for enable-component and disable-component
Let's now introduce "systemd-sysupdate enable-component
--component-suggested" and systemd-sysupdate enable-component
--component-all" for enabling all or all suggested components at once.
Similar, if used for disable-component will disable all components or
those not suggested.
2026-07-13 17:36:10 +02:00
Lennart Poettering 8f9a2f0c82 sysupdate: introduce --component-suggested similar to --component-all
While --component-all really picks all components --component-suggested
picks only the suggested ones.

Note that none of the verbs currently implement the concept, they will
all refuse the option. Hooking this up is going to be added next.
2026-07-13 17:36:10 +02:00
Lennart Poettering 40e727c93b sysupdate: add a "suggests" concept to features and components
Let's make it possible to "suggest" that certain features or components
are enabled under some conditions.

For this, both features and components gain two things:

1. A Suggested= field which takes a boolean. If true the
   feature/component will be suggested for installation, if false it
   will not.

2. A set of SuggestedOnXYZ= settings are modelled after ConditionXYZ= in
   unit files (and implement a subset of them), will suggest some
   component/feature under specific conditions.

The result of the condition is shown in the various output tools.
2026-07-13 17:36:10 +02:00
Lennart Poettering 0d889c48f5 sysupdate: move cleanup verb up close to "vacuum"
These are philosophically similar concepts: one deletes old versions
based on whether they are old, and the other deletes old files based on
whether they are orphaned, let's list them together.
2026-07-10 14:37:17 +02:00
Lennart Poettering 14d914ac7f sysupdate: tighten component_name_valid() mildly
Let's make sure that we can still generate a component enablement
drop-in for any component that might be defined.
2026-07-10 14:37:17 +02:00
Lennart Poettering 779c328a79 sysupdate: add new enable-component/disable-component verb
This mimics the enable-feature/disable-feature verbs, but operates on
whole components, not features.
2026-07-10 14:37:17 +02:00
Lennart Poettering 0c7992f674 sysupdate: add enable-feature/disable-feature verbs
These do what updatectl's verbs of the same name does, but are
implemented as low-level concepts in sysupdate itself.

(The idea is to eventually wrap this in Varlink IPC, and make updatectl
use them that way.)
2026-07-10 14:37:17 +02:00
Lennart Poettering d298f9bc8e sysupdate: generalize feature name validity check
Let's switch to string_is_safe(), and make this available to the rest of
the sysupdate sources too.

This both relaxes and tighten the rules slightly. i.e. control character
and stuff are no longer allowed, but valid UTF-8 (as opposed to ASCII)
now is.
2026-07-10 14:37:17 +02:00
Lennart Poettering 058cbd2aba sysupdate: explicitly refuse --root=/--image= in conjunction with --definitions=
This is currently effectively not supported (as we sometimes prefix the
definitions path with root and sometimes not), let's make this official
for now and refuse it. We could in theory support the combination but I
don't see the big benefit of it for now, hence let's just refuse it.
2026-07-10 14:27:11 +02:00