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.
This commit is contained in:
Philip Withnall
2026-07-14 15:03:35 +01:00
parent a8a88fc3ba
commit 75a247d4de
2 changed files with 8 additions and 3 deletions
+2 -2
View File
@@ -36,8 +36,8 @@ static SD_VARLINK_DEFINE_STRUCT_TYPE(
SD_VARLINK_DEFINE_FIELD(id, SD_VARLINK_STRING, 0),
SD_VARLINK_FIELD_COMMENT("A short human readable description of the feature."),
SD_VARLINK_DEFINE_FIELD(description, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("A URL to documentation for the feature."),
SD_VARLINK_DEFINE_FIELD(documentation, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("URLs to documentation for the feature."),
SD_VARLINK_DEFINE_FIELD(documentation, SD_VARLINK_STRING, SD_VARLINK_NULLABLE|SD_VARLINK_ARRAY),
SD_VARLINK_FIELD_COMMENT("A URL to an AppStream catalog XML file describing the feature."),
SD_VARLINK_DEFINE_FIELD(appstream, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Whether the feature is enabled."),
+6 -1
View File
@@ -2414,6 +2414,7 @@ static int verb_enable_feature(int argc, char *argv[], uintptr_t _data, void *us
static int feature_to_json(Context *context, const Feature *f, sd_json_variant **ret) {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
_cleanup_strv_free_ char **transfers = NULL;
const char *documentation_strv[2] = { NULL, };
int r;
assert(context);
@@ -2424,11 +2425,15 @@ static int feature_to_json(Context *context, const Feature *f, sd_json_variant *
if (r < 0)
return r;
/* FIXME: Long term we’d like to support an array of documentation, but currently the D-Bus interface
* doesn’t support that and neither do the internals of sysupdate. So just expose 0 or 1 URLs for now. */
documentation_strv[0] = f->documentation;
r = sd_json_variant_merge_objectbo(
&v,
SD_JSON_BUILD_PAIR_STRING("id", f->id),
JSON_BUILD_PAIR_STRING_NON_EMPTY("description", f->description),
JSON_BUILD_PAIR_STRING_NON_EMPTY("documentation", f->documentation),
JSON_BUILD_PAIR_STRV_NON_EMPTY("documentation", (char **) documentation_strv),
JSON_BUILD_PAIR_STRING_NON_EMPTY("appstream", f->appstream),
SD_JSON_BUILD_PAIR_BOOLEAN("isEnabled", f->enabled),
JSON_BUILD_PAIR_STRV_NON_EMPTY("transfers", transfers));