From: Philip Withnall Date: Thu, 21 May 2026 10:17:56 +0000 (+0100) Subject: sysupdate: Add a flag to control error behaviour in internal function X-Git-Tag: v261-rc1~6^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7a1bc8678050ae922d6de688bfa6ea5f241b44f;p=thirdparty%2Fsystemd.git sysupdate: Add a flag to control error behaviour in internal function Optionally prevent `context_read_definitions()` erroring out if zero transfer definitions were found. This commit makes no functional changes (the flag is always passed to calls to `context_make_offline()` for the moment), but the new flag will be used in the following commit. Signed-off-by: Philip Withnall Helps: https://github.com/systemd/systemd/issues/41501 --- diff --git a/src/sysupdate/sysupdate.c b/src/sysupdate/sysupdate.c index 159755e8b47..7852ac38784 100644 --- a/src/sysupdate/sysupdate.c +++ b/src/sysupdate/sysupdate.c @@ -173,6 +173,7 @@ static int read_definitions( typedef enum ReadDefinitionsFlags { READ_DEFINITIONS_REQUIRES_ENABLED_TRANSFERS = 1 << 0, + READ_DEFINITIONS_REQUIRES_ANY_TRANSFERS = 1 << 1, } ReadDefinitionsFlags; static int context_read_definitions(Context *c, const char* node, ReadDefinitionsFlags flags) { @@ -248,7 +249,8 @@ static int context_read_definitions(Context *c, const char* node, ReadDefinition log_warning("As of v257, transfer definitions should have the '.transfer' extension."); } - if (c->n_transfers + (FLAGS_SET(flags, READ_DEFINITIONS_REQUIRES_ENABLED_TRANSFERS) ? 0 : c->n_disabled_transfers) == 0) { + if (FLAGS_SET(flags, READ_DEFINITIONS_REQUIRES_ANY_TRANSFERS) && + c->n_transfers + (FLAGS_SET(flags, READ_DEFINITIONS_REQUIRES_ENABLED_TRANSFERS) ? 0 : c->n_disabled_transfers) == 0) { if (arg_component) return log_error_errno(SYNTHETIC_ERRNO(ENOENT), "No transfer definitions for component '%s' found.", @@ -963,7 +965,8 @@ static int context_make_online(Context **ret, const char *node) { /* Like context_make_offline(), but also communicates with the update source looking for new * versions (as long as --offline is not specified on the command line). */ - r = context_make_offline(&context, node, READ_DEFINITIONS_REQUIRES_ENABLED_TRANSFERS); + r = context_make_offline(&context, node, + READ_DEFINITIONS_REQUIRES_ENABLED_TRANSFERS | READ_DEFINITIONS_REQUIRES_ANY_TRANSFERS); if (r < 0) return r; @@ -1369,7 +1372,8 @@ static int verb_features(int argc, char *argv[], uintptr_t _data, void *userdata if (r < 0) return r; - r = context_make_offline(&context, loop_device ? loop_device->node : NULL, 0); + r = context_make_offline(&context, loop_device ? loop_device->node : NULL, + READ_DEFINITIONS_REQUIRES_ANY_TRANSFERS); if (r < 0) return r; @@ -1637,7 +1641,8 @@ static int verb_vacuum(int argc, char *argv[], uintptr_t _data, void *userdata) if (r < 0) return r; - r = context_make_offline(&context, loop_device ? loop_device->node : NULL, 0); + r = context_make_offline(&context, loop_device ? loop_device->node : NULL, + READ_DEFINITIONS_REQUIRES_ANY_TRANSFERS); if (r < 0) return r; @@ -1659,7 +1664,8 @@ static int verb_pending_or_reboot(int argc, char *argv[], uintptr_t _data, void return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "The --root=/--image= switches may not be combined with the '%s' operation.", argv[0]); - r = context_make_offline(&context, /* node= */ NULL, READ_DEFINITIONS_REQUIRES_ENABLED_TRANSFERS); + r = context_make_offline(&context, /* node= */ NULL, + READ_DEFINITIONS_REQUIRES_ENABLED_TRANSFERS | READ_DEFINITIONS_REQUIRES_ANY_TRANSFERS); if (r < 0) return r;