From deba09525a8c162ea92fd4a20e22a0552ba331db Mon Sep 17 00:00:00 2001 From: William Douglas Date: Fri, 11 Mar 2016 18:13:51 +0000 Subject: [PATCH] Allow manifests to contain includes Start handling the case where a manifest has an includes line. This line will be used to specify other manifests that are to be installed with the containing manifest. --- include/swupd.h | 1 + src/manifest.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/swupd.h b/include/swupd.h index fe32dbe9..179d9aab 100644 --- a/include/swupd.h +++ b/include/swupd.h @@ -51,6 +51,7 @@ struct manifest { struct list *files; struct list *manifests; /* struct file for possible manifests */ struct list *submanifests; /* struct manifest for subscribed manifests */ + struct list *includes; /* manifest names included in manifest */ char *component; }; diff --git a/src/manifest.c b/src/manifest.c index f45a107f..7d7f4e51 100644 --- a/src/manifest.c +++ b/src/manifest.c @@ -156,6 +156,7 @@ static struct manifest *manifest_from_file(int version, char *component) int count = 0; int deleted = 0; struct manifest *manifest; + struct list *includes = NULL; char *filename; uint64_t contentsize = 0; int manifest_hdr_version; @@ -219,6 +220,12 @@ static struct manifest *manifest_from_file(int version, char *component) if (strncmp(line, "contentsize:", 12) == 0) { contentsize = strtoull(c, NULL, 10); } + if (strncmp(line, "includes:", 9) == 0) { + includes = list_prepend_data(includes, strdup(c)); + if (!includes->data) { + abort(); + } + } } manifest = alloc_manifest(version, component); @@ -228,6 +235,7 @@ static struct manifest *manifest_from_file(int version, char *component) manifest->contentsize = contentsize; manifest->manifest_version = manifest_enc_version; + manifest->includes = includes; /* empty line */ while (!feof(infile)) { @@ -387,6 +395,9 @@ void free_manifest(struct manifest *manifest) if (manifest->submanifests) { list_free_list_and_data(manifest->submanifests, free_manifest_data); } + if (manifest->includes) { + list_free_list_and_data(manifest->includes, free); + } free(manifest->component); free(manifest); }