mirror of
https://github.com/clearlinux/swupd-server.git
synced 2026-08-19 04:57:43 +00:00
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:
+3
-1
@@ -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
@@ -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
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user