mirror of
https://github.com/clearlinux/swupd-client.git
synced 2026-09-07 22:21:32 +00:00
Update to support new state if system is on a mix
This patch adds the logic required to handle files and manifests differently if it is detected that the system is on a mix, or the content being provided is local mix content. Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
This commit is contained in:
committed by
Matthew Johnson
parent
e9cb557676
commit
e18eb6917f
+1
-1
@@ -21,6 +21,6 @@ void terminate_signature(void);
|
||||
* @param data_url - the URL from which the data came
|
||||
* @param data_filename - the file containing the data
|
||||
*/
|
||||
bool download_and_verify_signature(const char *data_url, const char *data_filename);
|
||||
bool download_and_verify_signature(const char *data_url, const char *data_filename, int version, bool mix_exists);
|
||||
|
||||
#endif /* SIGNATURE_H_ */
|
||||
|
||||
+17
-6
@@ -21,6 +21,8 @@ extern "C" {
|
||||
#define SWUPD_VERSION_IS_DEVEL(v) (((v) % SWUPD_VERSION_INCR) == 8)
|
||||
#define SWUPD_VERSION_IS_RESVD(v) (((v) % SWUPD_VERSION_INCR) == 9)
|
||||
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
#ifndef LINE_MAX
|
||||
#define LINE_MAX _POSIX2_LINE_MAX
|
||||
#endif
|
||||
@@ -33,6 +35,9 @@ extern "C" {
|
||||
#define MAX_TRIES 3
|
||||
|
||||
#define SWUPD_HASH_DIRNAME "DIRECTORY"
|
||||
#define MIX_DIR "/usr/share/mix/"
|
||||
#define MIX_STATE_DIR MIX_DIR "update/www/"
|
||||
#define MIX_BUNDLES_DIR MIX_STATE_DIR "mix-bundles/"
|
||||
|
||||
struct sub {
|
||||
/* name of bundle/component/subscription */
|
||||
@@ -57,6 +62,7 @@ struct manifest {
|
||||
struct list *submanifests; /* struct manifest for subscribed manifests */
|
||||
struct list *includes; /* manifest names included in manifest */
|
||||
char *component;
|
||||
unsigned int is_mix : 1;
|
||||
};
|
||||
|
||||
struct version_container {
|
||||
@@ -111,6 +117,7 @@ struct file {
|
||||
unsigned int is_boot : 1;
|
||||
unsigned int is_rename : 1;
|
||||
unsigned int is_orphan : 1;
|
||||
unsigned int is_mix : 1;
|
||||
unsigned int do_not_update : 1;
|
||||
|
||||
struct file *peer; /* same file in another manifest */
|
||||
@@ -192,8 +199,9 @@ 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 struct manifest *load_mom(int version, bool latest);
|
||||
extern struct manifest *load_mom(int version, bool latest, bool mix_exists);
|
||||
extern struct manifest *load_manifest(int current, int version, struct file *file, struct manifest *mom, bool header_only);
|
||||
extern struct manifest *load_manifest_full(int version, bool mix);
|
||||
extern struct list *create_update_list(struct manifest *current, struct manifest *server);
|
||||
extern void link_manifests(struct manifest *m1, struct manifest *m2);
|
||||
extern void link_submanifests(struct manifest *m1, struct manifest *m2, struct list *subs1, struct list *subs2, bool server);
|
||||
@@ -214,7 +222,7 @@ static inline int bsearch_helper(const void *A, const void *B)
|
||||
|
||||
static inline int bsearch_file_helper(const void *A, const void *B)
|
||||
{
|
||||
struct file *key = (struct file *) A;
|
||||
struct file *key = (struct file *)A;
|
||||
struct file *elem = (*(struct file **)B);
|
||||
return strcmp(key->filename, elem->filename);
|
||||
}
|
||||
@@ -262,7 +270,7 @@ static inline void account_delta_miss(void)
|
||||
|
||||
extern void print_statistics(int version1, int version2);
|
||||
|
||||
extern int download_subscribed_packs(struct list *subs, bool required);
|
||||
extern int download_subscribed_packs(struct list *subs, struct manifest *mom, bool required);
|
||||
|
||||
extern void try_delta(struct file *file);
|
||||
extern void full_download(struct file *file);
|
||||
@@ -292,8 +300,7 @@ extern int swupd_curl_get_file(const char *url, char *filename, struct file *fil
|
||||
extern CURLcode swupd_curl_set_basic_options(CURL *curl, const char *url);
|
||||
|
||||
extern void free_subscriptions(struct list **subs);
|
||||
extern void read_subscriptions(void);
|
||||
extern void read_subscriptions_alt(struct list **subs);
|
||||
extern void read_subscriptions_alt(struct list **subs, bool is_mix);
|
||||
extern int component_subscribed(struct list *subs, char *component);
|
||||
extern void set_subscription_versions(struct manifest *latest, struct manifest *current, struct list **subs);
|
||||
|
||||
@@ -381,7 +388,11 @@ extern void telemetry(telem_prio_t level, const char *class, const char *fmt, ..
|
||||
|
||||
extern struct file **manifest_files_to_array(struct manifest *manifest);
|
||||
extern void print_manifest_array(struct file **array, int filecount);
|
||||
int enforce_compliant_manifest(struct file **a, struct file **b, int size);
|
||||
extern int enforce_compliant_manifest(struct file **a, struct file **b, int searchsize, int size);
|
||||
extern void free_manifest_array(struct file **array);
|
||||
|
||||
extern bool check_mix_exists(void);
|
||||
extern int check_mix_versions(int *current_version, int *server_version, char *path_prefix);
|
||||
|
||||
/* some disk sizes constants for the various features:
|
||||
* ...consider adding build automation to catch at build time
|
||||
|
||||
+12
-10
@@ -74,7 +74,7 @@ int list_installable_bundles()
|
||||
|
||||
swupd_curl_set_current_version(current_version);
|
||||
|
||||
MoM = load_mom(current_version, false);
|
||||
MoM = load_mom(current_version, false, false);
|
||||
if (!MoM) {
|
||||
v_lockfile(lock_fd);
|
||||
return EMOM_NOTFOUND;
|
||||
@@ -108,7 +108,7 @@ static int load_bundle_manifest(const char *bundle_name, struct list *subs, int
|
||||
*submanifest = NULL;
|
||||
|
||||
swupd_curl_set_current_version(version);
|
||||
mom = load_mom(version, false);
|
||||
mom = load_mom(version, false, false);
|
||||
if (!mom) {
|
||||
return EMOM_NOTFOUND;
|
||||
}
|
||||
@@ -224,7 +224,7 @@ int show_included_bundles(char *bundle_name)
|
||||
goto out;
|
||||
}
|
||||
|
||||
mom = load_mom(current_version, false);
|
||||
mom = load_mom(current_version, false, false);
|
||||
if (!mom) {
|
||||
fprintf(stderr, "Cannot load official manifest MoM for version %i\n", current_version);
|
||||
ret = EMOM_NOTFOUND;
|
||||
@@ -322,7 +322,7 @@ int show_bundle_reqd_by(const char *bundle_name, bool server)
|
||||
goto out;
|
||||
}
|
||||
|
||||
current_manifest = load_mom(version, server);
|
||||
current_manifest = load_mom(version, server, false);
|
||||
if (!current_manifest) {
|
||||
fprintf(stderr, "Unable to download/verify %d Manifest.MoM\n", version);
|
||||
ret = EMOM_NOTFOUND;
|
||||
@@ -345,7 +345,7 @@ int show_bundle_reqd_by(const char *bundle_name, bool server)
|
||||
|
||||
} else {
|
||||
/* load all tracked bundles into memory */
|
||||
read_subscriptions_alt(&subs);
|
||||
read_subscriptions(&subs);
|
||||
/* now popout the one to be processed */
|
||||
ret = unload_tracked_bundle(bundle_name, &subs);
|
||||
if (ret != 0) {
|
||||
@@ -462,7 +462,7 @@ int remove_bundle(const char *bundle_name)
|
||||
|
||||
swupd_curl_set_current_version(current_version);
|
||||
|
||||
current_mom = load_mom(current_version, false);
|
||||
current_mom = load_mom(current_version, false, false);
|
||||
if (!current_mom) {
|
||||
fprintf(stderr, "Unable to download/verify %d Manifest.MoM\n", current_version);
|
||||
ret = EMOM_NOTFOUND;
|
||||
@@ -476,7 +476,7 @@ int remove_bundle(const char *bundle_name)
|
||||
}
|
||||
|
||||
/* load all tracked bundles into memory */
|
||||
read_subscriptions_alt(&subs);
|
||||
read_subscriptions_alt(&subs, false);
|
||||
/* now popout the one to be removed */
|
||||
ret = unload_tracked_bundle(bundle_name, &subs);
|
||||
if (ret != 0) {
|
||||
@@ -601,6 +601,7 @@ int add_subscriptions(struct list *bundles, struct list **subs, int current_vers
|
||||
}
|
||||
|
||||
retry_manifest_download:
|
||||
printf("add_subscriptions: load_manifest(): %s %d\n", file->filename, file->is_mix);
|
||||
manifest = load_manifest(current_version, file->last_change, file, mom, true);
|
||||
if (!manifest) {
|
||||
if (retries < MAX_TRIES) {
|
||||
@@ -692,7 +693,7 @@ static int install_bundles(struct list *bundles, struct list **subs, int current
|
||||
(void)rm_staging_dir_contents("download");
|
||||
|
||||
download_subscribed_packs:
|
||||
if (download_subscribed_packs(*subs, true)) {
|
||||
if (download_subscribed_packs(*subs, mom, true)) {
|
||||
if (retries < MAX_TRIES) {
|
||||
increment_retries(&retries, &timeout);
|
||||
printf("\nRetry #%d downloading subscribed packs\n", retries);
|
||||
@@ -703,7 +704,7 @@ download_subscribed_packs:
|
||||
|
||||
/* step 3: Add tracked bundles */
|
||||
grabtime_start(×, "Add tracked bundles");
|
||||
read_subscriptions_alt(subs);
|
||||
read_subscriptions_alt(subs, false);
|
||||
set_subscription_versions(mom, NULL, subs);
|
||||
mom->submanifests = recurse_manifest(mom, *subs, NULL, false);
|
||||
if (!mom->submanifests) {
|
||||
@@ -854,7 +855,7 @@ int install_bundles_frontend(char **bundles)
|
||||
|
||||
swupd_curl_set_current_version(current_version);
|
||||
|
||||
mom = load_mom(current_version, false);
|
||||
mom = load_mom(current_version, false, false);
|
||||
if (!mom) {
|
||||
fprintf(stderr, "Cannot load official manifest MoM for version %i\n", current_version);
|
||||
ret = EMOM_NOTFOUND;
|
||||
@@ -929,3 +930,4 @@ void read_local_bundles(struct list **list_bundles)
|
||||
|
||||
free(path);
|
||||
}
|
||||
| ||||