sysupdate: display all component documentation URLs in table output

Component definitions may contain multiple Documentation= URLs, but the
components command previously displayed only the first URL in text output.

Use TABLE_STRV_WRAPPED to display all component documentation URLs in the
table, making the full documentation list visible to users.
Add integration test coverage for multiple Documentation= assignments.
This commit is contained in:
dongshengyuan
2026-09-08 16:05:39 +02:00
committed by Zbigniew Jędrzejewski-Szmek
parent a6f7ded859
commit e1ae3a43d3
2 changed files with 13 additions and 6 deletions
+4 -6
View File
@@ -3092,14 +3092,11 @@ static int verb_components(int argc, char *argv[], uintptr_t _data, void *userda
if (r < 0)
return table_log_add_error(r);
const char *doc = cc.component_documentation ? cc.component_documentation[0] : NULL;
r = table_add_many(
t,
TABLE_STRING, *i,
TABLE_STRING, cc.component_description,
TABLE_STRING, doc,
TABLE_SET_URL, doc);
TABLE_STRV_WRAPPED, cc.component_documentation);
if (r < 0)
return table_log_add_error(r);
}
@@ -3108,8 +3105,9 @@ static int verb_components(int argc, char *argv[], uintptr_t _data, void *userda
} else {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *json = NULL;
r = sd_json_buildo(&json, SD_JSON_BUILD_PAIR_BOOLEAN("default", has_default_component),
SD_JSON_BUILD_PAIR_STRV("components", component_names));
r = sd_json_buildo(&json,
SD_JSON_BUILD_PAIR_BOOLEAN("default", has_default_component),
SD_JSON_BUILD_PAIR_STRV("components", component_names));
if (r < 0)
return log_error_errno(r, "Failed to create JSON: %m");
+9
View File
@@ -699,6 +699,11 @@ done
# that a ‘default’ component is only listed by sysupdate if it’s fully configured
mv "$CONFIGDIR" "$CONFIGDIR.backup"
mkdir -p /run/sysupdate.some-component.d
cat >/run/sysupdate.some-component.component <<EOF
[Component]
Documentation=https://example.com/some-component
Documentation=https://example.com/some-component-more
EOF
tee /run/sysupdate.some-component.d/portable.transfer << EOF
[Transfer]
ChangeLog=https://example.com/changelog/@v
@@ -716,6 +721,9 @@ MatchPattern=some-component_@v
CurrentSymlink=some-component
EOF
"$SYSUPDATE" --json=short components | grep -F '{"default":false,"components":["some-component"]}' >/dev/null
component_output="$("$SYSUPDATE" components)"
grep -F "https://example.com/some-component" <<<"$component_output" >/dev/null
grep -F "https://example.com/some-component-more" <<<"$component_output" >/dev/null
varlinkctl call "$VARLINK_SOCKET" io.systemd.SysUpdate.ListTargets | jq -e '.targets | all(.id.class != "host")' >/dev/null
mkdir /run/sysupdate.d
"$SYSUPDATE" --json=short components | grep -F '{"default":false,"components":["some-component"]}' >/dev/null
@@ -734,6 +742,7 @@ varlinkctl call "$VARLINK_SOCKET" io.systemd.SysUpdate.ListTargets | jq -e '.tar
# Clean up regression test
rmdir /run/sysupdate.d
rm -rf /run/sysupdate.some-component.d
rm -f /run/sysupdate.some-component.component
mv "$CONFIGDIR.backup" "$CONFIGDIR"
# Make sure the processing of compressed streams still handles uncompressed streams shorter than