Skip to content

Commit

Permalink
sysupdate: fix features and vaccum if all features are disabled
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
thkukuk authored and yuwata committed Mar 5, 2025
1 parent c22948f commit 54cd851
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/sysupdate/sysupdate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 54cd851

Please sign in to comment.