diff --git a/include/swupd.h b/include/swupd.h index 7e8e9dc..1d492bd 100644 --- a/include/swupd.h +++ b/include/swupd.h @@ -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); diff --git a/src/analyze_fs.c b/src/analyze_fs.c index 67935ca..de926a8 100644 --- a/src/analyze_fs.c +++ b/src/analyze_fs.c @@ -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); diff --git a/src/create_update.c b/src/create_update.c index 137a932..0fe67e6 100644 --- a/src/create_update.c +++ b/src/create_update.c @@ -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); diff --git a/src/manifest.c b/src/manifest.c index eab6349..0cb7bb7 100644 --- a/src/manifest.c +++ b/src/manifest.c @@ -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 */ @@ -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);