manifest: Remove code from load_mom() that is unrleated to loading the mom

Saving mom for autocompletion is something we should do in another function.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
This commit is contained in:
Otavio Pontes
2019-09-19 08:49:12 -07:00
parent 15be9a7f09
commit 635dbf707d
6 changed files with 33 additions and 29 deletions
+7 -7
View File
@@ -59,7 +59,7 @@ enum swupd_code list_installable_bundles()
}
mix_exists = (check_mix_exists() & system_on_mix());
MoM = load_mom(current_version, false, mix_exists, NULL);
MoM = load_mom(current_version, mix_exists, NULL);
if (!MoM) {
return SWUPD_COULDNT_LOAD_MOM;
}
@@ -92,7 +92,7 @@ static int load_bundle_manifest(const char *bundle_name, struct list *subs, int
*submanifest = NULL;
mom = load_mom(version, false, false, NULL);
mom = load_mom(version, false, NULL);
if (!mom) {
return SWUPD_COULDNT_LOAD_MOM;
}
@@ -208,7 +208,7 @@ enum swupd_code show_included_bundles(char *bundle_name)
goto out;
}
mom = load_mom(current_version, false, false, NULL);
mom = load_mom(current_version, false, NULL);
if (!mom) {
error("Cannot load official manifest MoM for version %i\n", current_version);
ret = SWUPD_COULDNT_LOAD_MOM;
@@ -308,7 +308,7 @@ enum swupd_code show_bundle_reqd_by(const char *bundle_name, bool server)
goto out;
}
current_manifest = load_mom(version, server, false, NULL);
current_manifest = load_mom(version, false, NULL);
if (!current_manifest) {
error("Unable to download/verify %d Manifest.MoM\n", version);
ret = SWUPD_COULDNT_LOAD_MOM;
@@ -564,7 +564,7 @@ enum swupd_code remove_bundles(char **bundles)
info("Removing bundle: %s\n", bundle);
}
current_mom = load_mom(current_version, false, mix_exists, NULL);
current_mom = load_mom(current_version, mix_exists, NULL);
if (!current_mom) {
error("Unable to download/verify %d Manifest.MoM\n", current_version);
ret = SWUPD_COULDNT_LOAD_MOM;
@@ -1130,7 +1130,7 @@ enum swupd_code install_bundles_frontend(char **bundles)
mix_exists = (check_mix_exists() & system_on_mix());
mom = load_mom(current_version, false, mix_exists, NULL);
mom = load_mom(current_version, mix_exists, NULL);
if (!mom) {
error("Cannot load official manifest MoM for version %i\n", current_version);
ret = SWUPD_COULDNT_LOAD_MOM;
@@ -1203,7 +1203,7 @@ enum swupd_code list_local_bundles()
}
mix_exists = (check_mix_exists() & system_on_mix());
MoM = load_mom(current_version, false, mix_exists, NULL);
MoM = load_mom(current_version, mix_exists, NULL);
if (!MoM) {
warn("Could not determine which installed bundles are experimental\n");
}
+1 -15
View File
@@ -400,7 +400,7 @@ out:
* loaded into memory, this function will return NULL. If err is passed, it is set
* with the error code.
*/
struct manifest *load_mom(int version, bool latest, bool mix_exists, int *err)
struct manifest *load_mom(int version, bool mix_exists, int *err)
{
struct manifest *manifest = NULL;
int ret = 0;
@@ -465,20 +465,6 @@ retry_load:
}
}
/* Make a copy of the Manifest for the completion code */
if (latest) {
char *momdir;
char *momfile;
string_or_die(&momdir, "%s/var/tmp/swupd", globals.path_prefix);
string_or_die(&momfile, "%s/Manifest.MoM", momdir);
swupd_rm(momfile);
mkdir_p(momdir);
copy(filename, momfile);
free_string(&momdir);
free_string(&momfile);
}
free_string(&filename);
free_string(&url);
return manifest;
+1 -1
View File
@@ -621,7 +621,7 @@ enum swupd_code search_file_main(int argc, char **argv)
progress_complete_step();
progress_set_step(2, "load_manifests"); // will be closed within download_all_manifests
mom = load_mom(current_version, false, false, NULL);
mom = load_mom(current_version, false, NULL);
if (!mom) {
error("Cannot load official manifest MoM for version %i\n", current_version);
return SWUPD_COULDNT_LOAD_MOM;
+1 -1
View File
@@ -173,7 +173,7 @@ extern void apply_heuristics(struct file *file);
extern int file_sort_filename(const void *a, const void *b);
extern int file_sort_filename_reverse(const void *a, const void *b);
extern int file_sort_hash(const void *a, const void *b);
extern struct manifest *load_mom(int version, bool latest, bool mix_exists, int *err);
extern struct manifest *load_mom(int version, bool mix_exists, int *err);
extern struct manifest *load_manifest(int version, struct file *file, struct manifest *mom, bool header_only, int *err);
extern struct manifest *load_manifest_full(int version, bool mix);
extern struct list *create_update_list(struct manifest *server);
+21 -3
View File
@@ -240,6 +240,23 @@ static enum swupd_code check_versions(int *current_version, int *server_version,
return SWUPD_OK;
}
/* Make a copy of the Manifest for the completion code */
static void save_manifest(int version)
{
char *momdir, *momfile, *original;
string_or_die(&momdir, "%s/var/tmp/swupd", globals.path_prefix);
string_or_die(&momfile, "%s/Manifest.MoM", momdir);
string_or_die(&original, "%s/%i/Manifest.MoM", globals.state_dir, version);
swupd_rm(momfile);
mkdir_p(momdir);
copy(original, momfile);
free_string(&momdir);
free_string(&momfile);
free_string(&original);
}
static enum swupd_code main_update()
{
int current_version = -1, server_version = -1;
@@ -364,9 +381,9 @@ version_check:
/* get the from/to MoM manifests */
if (system_on_mix()) {
current_manifest = load_mom(current_version, false, mix_exists, &manifest_err);
current_manifest = load_mom(current_version, mix_exists, &manifest_err);
} else {
current_manifest = load_mom(current_version, false, false, &manifest_err);
current_manifest = load_mom(current_version, false, &manifest_err);
}
if (!current_manifest) {
/* TODO: possibly remove this as not getting a "from" manifest is not fatal
@@ -375,11 +392,12 @@ version_check:
goto clean_exit;
}
server_manifest = load_mom(server_version, true, mix_exists, &manifest_err);
server_manifest = load_mom(server_version, mix_exists, &manifest_err);
if (!server_manifest) {
ret = SWUPD_COULDNT_LOAD_MOM;
goto clean_exit;
}
save_manifest(server_version);
timelist_timer_stop(globals.global_times); // closing: Load MoM manifests
timelist_timer_start(globals.global_times, "Recurse and consolidate bundle manifests");
+2 -2
View File
@@ -903,9 +903,9 @@ enum swupd_code verify_main(void)
* disable checks for mixer state so the user can easily switch back to their
* normal update stream */
if (version != sys_version) {
official_manifest = load_mom(version, false, false, NULL);
official_manifest = load_mom(version, false, NULL);
} else {
official_manifest = load_mom(version, false, system_on_mix(), NULL);
official_manifest = load_mom(version, system_on_mix(), NULL);
}
if (!official_manifest) {