From 54cd851bd953473d73e7b10f72ebcf3583d2c985 Mon Sep 17 00:00:00 2001 From: Thorsten Kukuk Date: Fri, 28 Feb 2025 14:01:16 +0100 Subject: [PATCH] sysupdate: fix features and vaccum if all features are disabled If all transfer definitions are features and disabled, a wrong error is reported that there are no transfer definitions. This breaks the features and vaccum verb, as they work on disabled features, too. --- src/sysupdate/sysupdate.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sysupdate/sysupdate.c b/src/sysupdate/sysupdate.c index 2bdd71e74272e..9ced67429ac2b 100644 --- a/src/sysupdate/sysupdate.c +++ b/src/sysupdate/sysupdate.c @@ -172,7 +172,7 @@ static int read_definitions( return 0; } -static int context_read_definitions(Context *c, const char* node) { +static int context_read_definitions(Context *c, const char* node, bool requires_enabled_transfers) { _cleanup_strv_free_ char **dirs = NULL, **files = NULL; int r; @@ -241,7 +241,7 @@ static int context_read_definitions(Context *c, const char* node) { log_warning("As of v257, transfer definitions should have the '.transfer' extension."); } - if (c->n_transfers == 0) { + if (c->n_transfers + (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.", @@ -899,7 +899,7 @@ static int context_vacuum( return 0; } -static int context_make_offline(Context **ret, const char *node) { +static int context_make_offline(Context **ret, const char *node, bool requires_enabled_transfers) { _cleanup_(context_freep) Context* context = NULL; int r; @@ -912,7 +912,7 @@ static int context_make_offline(Context **ret, const char *node) { if (!context) return log_oom(); - r = context_read_definitions(context, node); + r = context_read_definitions(context, node, requires_enabled_transfers); if (r < 0) return r; @@ -933,7 +933,7 @@ 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); + r = context_make_offline(&context, node, /* requires_enabled_transfers= */ true); if (r < 0) return r; @@ -1217,7 +1217,7 @@ static int verb_features(int argc, char **argv, void *userdata) { if (r < 0) return r; - r = context_make_offline(&context, loop_device ? loop_device->node : NULL); + r = context_make_offline(&context, loop_device ? loop_device->node : NULL, /* requires_enabled_transfers= */ false); if (r < 0) return r; @@ -1392,7 +1392,7 @@ static int verb_vacuum(int argc, char **argv, void *userdata) { if (r < 0) return r; - r = context_make_offline(&context, loop_device ? loop_device->node : NULL); + r = context_make_offline(&context, loop_device ? loop_device->node : NULL, /* requires_enabled_transfers= */ false); if (r < 0) return r; @@ -1469,7 +1469,7 @@ static int verb_pending_or_reboot(int argc, char **argv, void *userdata) { 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, NULL); + r = context_make_offline(&context, /* node= */ NULL, /* requires_enabled_transfers= */ true); if (r < 0) return r;