Add actions field to Manifest.MoM for format bumps

When a format bump occurs and the new format is greater than the old
format, an actions field is written to the Manifest.MoM containing the
string "update". This "update" action tells the client that it is
necessary to re-execute swupd update to bring the client to the latest
version within the new format.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
This commit is contained in:
Matthew Johnson
2017-07-27 13:16:10 -07:00
committed by tmarcu
parent a0c7025a9b
commit 31bb949b9b
4 changed files with 26 additions and 7 deletions
+3 -1
View File
@@ -85,6 +85,8 @@ struct manifest {
GList *submanifests; /* as struct manifest */
GList *includes; /* struct manifests for all bundles included into this one */
GList *actions; /* post-update actions */
};
struct file;
@@ -184,7 +186,7 @@ extern GList *get_last_versions_list(int next_version, int max_versions);
extern char *file_type_to_string(struct file *file);
extern struct manifest *manifest_from_file(int version, char *module);
extern void free_manifest(struct manifest *manifest);
extern struct manifest *alloc_manifest(int version, char *module);
extern struct manifest *alloc_manifest(int version, char *module, GList *actions);
extern int match_manifests(struct manifest *m1, struct manifest *m2);
extern void sort_manifest_by_version(struct manifest *manifest);
extern bool manifest_includes(struct manifest *manifest, char *component);
+2 -2
View File
@@ -481,7 +481,7 @@ struct manifest *full_manifest_from_directory(int version)
LOG(NULL, "Computing hashes", "for %i/full", version);
manifest = alloc_manifest(version, "full");
manifest = alloc_manifest(version, "full", NULL);
string_or_die(&dir, "%s/%i/full", image_dir, version);
@@ -557,7 +557,7 @@ struct manifest *sub_manifest_from_directory(char *component, int version)
LOG(NULL, "Creating component manifest", "for %i/%s", version, component);
manifest = alloc_manifest(version, component);
manifest = alloc_manifest(version, component, NULL);
string_or_die(&dir, "%s/%i/%s", image_dir, version, component);
+8 -1
View File
@@ -351,7 +351,14 @@ int main(int argc, char **argv)
goto exit;
}
new_MoM = alloc_manifest(newversion, "MoM");
/* Detect a format bump and add the "update" action to the manifest
* "actions:" field */
GList *actions = NULL;
if (format > old_MoM->format) {
actions = g_list_prepend(actions, "update");
}
new_MoM = alloc_manifest(newversion, "MoM", actions);
old_core = manifest_from_file(manifest_subversion(old_MoM, "os-core"), "os-core");
new_core = sub_manifest_from_directory("os-core", newversion);
add_component_hashes_to_manifest(new_core, new_full);
+13 -3
View File
@@ -92,7 +92,7 @@ int file_sort_filename(gconstpointer a, gconstpointer b)
return 0;
}
struct manifest *alloc_manifest(int version, char *component)
struct manifest *alloc_manifest(int version, char *component, GList *actions)
{
struct manifest *manifest;
@@ -104,6 +104,7 @@ struct manifest *alloc_manifest(int version, char *component)
manifest->version = version;
manifest->component = strdup(component);
manifest->format = format;
manifest->actions = actions;
return manifest;
}
@@ -133,7 +134,7 @@ struct manifest *manifest_from_file(int version, char *component)
if (infile == NULL) {
LOG(NULL, "Cannot read manifest", "%s (%s)\n", filename, strerror(errno));
free(filename);
return alloc_manifest(version, component);
return alloc_manifest(version, component, NULL);
}
/* line 1: MANIFEST\t<version> */
@@ -193,7 +194,7 @@ struct manifest *manifest_from_file(int version, char *component)
}
}
manifest = alloc_manifest(version, component);
manifest = alloc_manifest(version, component, NULL);
manifest->format = format_number;
manifest->prevversion = previous;
manifest->includes = includes;
@@ -714,6 +715,7 @@ static int write_manifest_plain(struct manifest *manifest)
{
GList *includes;
GList *list;
GList *actions;
struct file *file;
FILE *out = NULL;
char *base = NULL, *dir;
@@ -763,6 +765,14 @@ static int write_manifest_plain(struct manifest *manifest)
includes = g_list_next(includes);
fprintf(out, "includes:\t%s\n", sub->component);
}
actions = manifest->actions;
while (actions) {
char *action = actions->data;
fprintf(out, "actions:\t%s\n", action);
actions = g_list_next(actions);
}
fprintf(out, "\n");
list = g_list_first(manifest->files);