sysupdate: Split context_apply() into acquire and install steps
This introduces no functional changes at the moment, but will be used in upcoming commits. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Helps: https://github.com/systemd/systemd/issues/34814
This commit is contained in:
+36
-11
@@ -982,10 +982,9 @@ static int context_on_acquire_progress(const Transfer *t, const Instance *inst,
|
||||
overall, n - i, i, inst->metadata.version, overall);
|
||||
}
|
||||
|
||||
static int context_apply(
|
||||
static int context_acquire(
|
||||
Context *c,
|
||||
const char *version,
|
||||
UpdateSet **ret_applied) {
|
||||
const char *version) {
|
||||
|
||||
UpdateSet *us = NULL;
|
||||
int r;
|
||||
@@ -1000,9 +999,6 @@ static int context_apply(
|
||||
if (!c->candidate) {
|
||||
log_info("No update needed.");
|
||||
|
||||
if (ret_applied)
|
||||
*ret_applied = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1014,9 +1010,6 @@ static int context_apply(
|
||||
else if (FLAGS_SET(us->flags, UPDATE_INSTALLED)) {
|
||||
log_info("Selected update '%s' is already installed. Skipping update.", us->version);
|
||||
|
||||
if (ret_applied)
|
||||
*ret_applied = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1075,7 +1068,34 @@ static int context_apply(
|
||||
if (arg_sync)
|
||||
sync();
|
||||
|
||||
(void) sd_notifyf(/* unset_environment= */ false,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int context_install(
|
||||
Context *c,
|
||||
const char *version,
|
||||
UpdateSet **ret_applied) {
|
||||
|
||||
UpdateSet *us = NULL;
|
||||
int r;
|
||||
|
||||
assert(c);
|
||||
|
||||
if (version) {
|
||||
us = context_update_set_by_version(c, version);
|
||||
if (!us)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ENOENT), "Update '%s' not found.", version);
|
||||
} else {
|
||||
if (!c->candidate) {
|
||||
log_info("No update needed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
us = c->candidate;
|
||||
}
|
||||
|
||||
(void) sd_notifyf(/* unset_environment=*/ false,
|
||||
"STATUS=Installing '%s'.", us->version);
|
||||
|
||||
for (size_t i = 0; i < c->n_transfers; i++) {
|
||||
@@ -1443,7 +1463,12 @@ static int verb_update(int argc, char **argv, void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = context_apply(context, version, &applied);
|
||||
r = context_acquire(context, version);
|
||||
if (r < 0)
|
||||
return r; /* error */
|
||||
|
||||
if (r > 0) /* update needed */
|
||||
r = context_install(context, version, &applied);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user