mixin: Remove mixin support from update

And some other leftovers

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
This commit is contained in:
Otavio Pontes
2020-04-08 09:03:56 -07:00
parent e4fdfaa81a
commit 66e06cd455
7 changed files with 3 additions and 246 deletions
+2 -6
View File
@@ -386,12 +386,8 @@ void set_cert_path(char *path)
static void set_default_cert_path()
{
if (system_on_mix()) {
set_cert_path(MIX_CERT);
} else {
// CERT_PATH is guaranteed to be valid at this point.
set_cert_path(CERT_PATH);
}
// CERT_PATH is guaranteed to be valid at this point.
set_cert_path(CERT_PATH);
}
bool set_default_urls()
-39
View File
@@ -1110,31 +1110,6 @@ fail:
return ret;
}
/* Once system is on mix this file should exist */
bool system_on_mix(void)
{
bool ret = (access(MIXED_FILE, R_OK) == 0);
if (ret) {
warn_mixin_deprecation();
}
return ret;
}
/* If the MIX_BUNDLES_DIR has the valid-mix flag file we can run through
* adding the mix data to the OS */
bool check_mix_exists(void)
{
char *fullpath;
bool ret;
string_or_die(&fullpath, "%s%s/.valid-mix", globals.path_prefix, MIX_DIR);
ret = access(fullpath, F_OK) == 0;
free_and_clear_pointer(&fullpath);
if (ret) {
warn_mixin_deprecation();
}
return ret;
}
/* Iterate the file list and remove from the file system each file/directory */
int remove_files_from_fs(struct list *files)
{
@@ -1275,17 +1250,3 @@ void warn_nosigcheck(const char *file)
warn("\n");
warn("THE SIGNATURE OF %s WILL NOT BE VERIFIED\n\n", file);
}
void warn_mixin_deprecation(void)
{
static bool show = true;
if (show) {
info("\n");
warn("Mixin was deprecated in favor of swupd 3rd-party and it will be removed on next swupd release\n");
info("For more information check swupd 3rd-party manual or website documentation on:\n");
info("https://docs.01.org/clearlinux/latest/guides/clear/swupd-3rd-party.html\n");
info("\n");
show = false;
}
}
-25
View File
@@ -168,7 +168,6 @@ static int retrieve_manifest(int previous_version, int version, char *component,
}
free_and_clear_pointer(&filename);
/* Either we're not on mix or it failed, try curl-ing the file if link didn't work */
string_or_die(&filename, "%s/%i/Manifest.%s.tar", globals.state_dir, version, component);
string_or_die(&url, "%s/%i/Manifest.%s.tar", globals.content_url, version, component);
@@ -245,8 +244,6 @@ static void remove_manifest_files(char *filename, int version, char *hash)
/* Verifies signature for the local file DATA_FILENAME first, and on failure
* downloads the signature based on DATA_URL and tries to verify again.
* Automatically manages the signature for mix content, performing local
* verification only if the manifest is user created.
*
* returns: true if signature verification succeeded, false if verification
* failed, or the signature download failed
@@ -431,28 +428,6 @@ retry_load:
return manifest;
}
/* Special case manifest for mixer content enforcement */
struct manifest *load_manifest_full(int version)
{
struct manifest *manifest = NULL;
int ret = 0;
ret = retrieve_manifest(0, version, "full", false);
if (ret != 0) {
error("Failed to retrieve %d Manifest.full\n", version);
return NULL;
}
manifest = manifest_from_file(version, "full", false);
if (manifest == NULL) {
error("Failed to load %d Manifest.full\n", version);
return NULL;
}
return manifest;
}
/* m1: old (or current when verifying) manifest
* m2: new (or official if verifying) manifest */
void link_manifests(struct manifest *m1, struct manifest *m2)
-1
View File
@@ -148,7 +148,6 @@ static double packs_query_total_download_size(struct list *subs, struct manifest
for (list = list_head(subs); list; list = list->next) {
sub = list->data;
/* if it is a pack from a mix, we won't download it */
bundle = mom_search_bundle(mom, sub->component);
if (!bundle) {
debug("The manifest for bundle %s was not found in the MoM", sub->component);
-13
View File
@@ -49,11 +49,6 @@ extern "C" {
#define SWUPD_HASH_DIRNAME "DIRECTORY"
#define SWUPD_DEFAULTS "/usr/share/defaults/swupd/"
#define MIX_DIR "/usr/share/mix/"
#define MIX_STATE_DIR MIX_DIR "update/www/"
#define MIX_CERT MIX_DIR "Swupd_Root.pem"
#define MIX_BUNDLES_DIR MIX_STATE_DIR "mix-bundles/"
#define MIXED_FILE SWUPD_DEFAULTS "mixed"
#define SSL_CLIENT_CERT "/etc/swupd/client.pem"
#define DEFAULT_VERSION_URL_PATH "/usr/share/defaults/swupd/versionurl"
@@ -179,7 +174,6 @@ extern void apply_heuristics(struct file *file);
extern struct manifest *load_mom(int version, int *err);
extern struct manifest *load_manifest(int version, struct file *file, struct manifest *mom, bool header_only, int *err);
extern struct manifest *load_manifest_full(int version);
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);
@@ -400,11 +394,6 @@ extern struct file **manifest_files_to_array(struct manifest *manifest);
extern int enforce_compliant_manifest(struct file **a, struct file **b, int searchsize, int size);
extern void manifest_free_array(struct file **array);
extern bool system_on_mix(void);
extern bool check_mix_exists(void);
extern void check_mix_versions(int *current_version, int *server_version, char *path_prefix);
extern int read_mix_version_file(char *filename, char *path_prefix);
extern enum swupd_code print_update_conf_info(void);
extern int handle_mirror_if_stale(void);
@@ -421,8 +410,6 @@ extern struct global_const global;
*/
extern void free_and_clear_pointer(char **s);
extern void warn_mixin_deprecation(void);
enum swupd_code check_update();
/* some disk sizes constants for the various features:
+1 -116
View File
@@ -77,45 +77,6 @@ static void save_swupd_binary_path()
}
}
/* This loads the upstream Clear Manifest.Full and local
* Manifest.full, and then checks that there are no conflicts between
* the files they both include */
static int check_manifests_uniqueness(int clrver, int mixver)
{
int ret = 0;
struct manifest *clear = NULL;
struct manifest *mixer = NULL;
struct file **clearfull = NULL;
struct file **mixerfull = NULL;
mixer = load_manifest_full(mixver);
clear = load_manifest_full(clrver);
if (!clear || !mixer) {
error("Could not load full manifests\n");
ret = -1;
goto error;
}
clearfull = manifest_files_to_array(clear);
mixerfull = manifest_files_to_array(mixer);
if (clearfull == NULL || mixerfull == NULL) {
error("Could not convert full manifest to array\n");
ret = -1;
goto error;
}
ret = enforce_compliant_manifest(mixerfull, clearfull, mixer->filecount, clear->filecount);
error:
manifest_free_array(clearfull);
manifest_free_array(mixerfull);
manifest_free(clear);
manifest_free(mixer);
return ret;
}
static int update_loop(struct list *updates, struct manifest *server_manifest, extra_proc_fn_t file_validation_fn)
{
int ret;
@@ -167,17 +128,6 @@ int add_included_manifests(struct manifest *mom, struct list **subs)
return 0;
}
static bool need_new_upstream(int server)
{
if (!access(MIX_DIR "upstreamversion", R_OK)) {
int version = read_mix_version_file(MIX_DIR "upstreamversion", globals.path_prefix);
if (version < server) {
return true;
}
}
return false;
}
static enum swupd_code check_versions(int *current_version, int *server_version, int requested_version, char *path_prefix)
{
int ret;
@@ -299,7 +249,6 @@ static struct list *create_update_list(struct manifest *server)
enum swupd_code execute_update_extra(extra_proc_fn_t post_update_fn, extra_proc_fn_t file_validation_fn)
{
int current_version = -1, server_version = -1;
int mix_current_version = -1, mix_server_version = -1;
struct manifest *current_manifest = NULL, *server_manifest = NULL;
struct list *updates = NULL;
struct list *current_subs = NULL;
@@ -307,7 +256,6 @@ enum swupd_code execute_update_extra(extra_proc_fn_t post_update_fn, extra_proc_
int ret;
struct timespec ts_start, ts_stop; // For main swupd update time
double delta;
bool mix_exists;
bool re_update = false;
bool versions_match = false;
@@ -321,8 +269,6 @@ enum swupd_code execute_update_extra(extra_proc_fn_t post_update_fn, extra_proc_
progress_next_step("load_manifests", PROGRESS_UNDEFINED);
info("Update started\n");
mix_exists = check_mix_exists();
read_subscriptions(&current_subs);
if (handle_mirror_if_stale() < 0) {
@@ -333,57 +279,11 @@ enum swupd_code execute_update_extra(extra_proc_fn_t post_update_fn, extra_proc_
/* get versions */
timelist_timer_start(globals.global_times, "Get versions");
version_check:
ret = check_versions(&current_version, &server_version, requested_version, globals.path_prefix);
if (ret != SWUPD_OK) {
goto clean_curl;
}
if (mix_exists) {
check_mix_versions(&mix_current_version, &mix_server_version, globals.path_prefix);
if (mix_current_version == -1 || mix_server_version == -1) {
ret = SWUPD_CURRENT_VERSION_UNKNOWN;
goto clean_curl;
}
/* Check if a new upstream version is available so we can update to it still */
if (need_new_upstream(server_version)) {
info("NEW CLEAR AVAILABLE %d\n", server_version);
/* Update the upstreamversion that will be used to generate the new mix content */
FILE *verfile = fopen(MIX_DIR "upstreamversion", "w+");
if (!verfile) {
error("fopen() %s/upstreamversion returned %s\n", MIX_DIR, strerror(errno));
} else {
fprintf(verfile, "%d", server_version);
fclose(verfile);
}
if (run_command("/usr/bin/mixin", "build", NULL) != 0) {
error("Could not execute mixin\n");
ret = SWUPD_SUBPROCESS_ERROR;
goto clean_curl;
}
// new mix version
check_mix_versions(&mix_current_version, &mix_server_version, globals.path_prefix);
ret = check_manifests_uniqueness(server_version, mix_server_version);
if (ret > 0) {
info("\n");
warn("%i collisions were found between mix and upstream, please re-create mix !!\n", ret);
if (!allow_mix_collisions) {
ret = SWUPD_MIX_COLLISIONS;
goto clean_curl;
}
} else if (ret < 0) {
ret = SWUPD_COULDNT_LOAD_MANIFEST;
goto clean_curl;
}
goto version_check;
}
current_version = mix_current_version;
server_version = mix_server_version;
}
if (server_version <= current_version) {
if (requested_version == server_version) {
info("Requested version (%i)", requested_version);
@@ -412,12 +312,7 @@ version_check:
timelist_timer_start(globals.global_times, "Load MoM manifests");
int manifest_err;
/* get the from/to MoM manifests */
if (system_on_mix()) {
current_manifest = load_mom(current_version, &manifest_err);
} else {
current_manifest = load_mom(current_version, &manifest_err);
}
current_manifest = load_mom(current_version, &manifest_err);
if (!current_manifest) {
/* TODO: possibly remove this as not getting a "from" manifest is not fatal
* - we just don't apply deltas */
@@ -559,16 +454,6 @@ version_check:
timelist_timer_stop(globals.global_times); // closing: Updating search file index
}
/* Create the state file that will tell swupd it's on a mix on future runs */
if (mix_exists && !system_on_mix()) {
int fd = open(MIXED_FILE, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd == -1) {
error("Failed to create 'mixed' statefile\n");
ret = SWUPD_COULDNT_CREATE_FILE;
}
close(fd);
}
clean_exit:
list_free_list(updates);
manifest_free(current_manifest);
-46
View File
@@ -354,52 +354,6 @@ enum swupd_code read_versions(int *current_version, int *server_version, char *p
return SWUPD_OK;
}
int read_mix_version_file(char *filename, char *path_prefix)
{
char line[LINE_MAX];
FILE *file;
int v = -1;
int err;
char *buildstamp;
string_or_die(&buildstamp, "%s%s", path_prefix, filename);
file = fopen(buildstamp, "rm");
if (!file) {
free_and_clear_pointer(&buildstamp);
return v;
}
while (!feof(file)) {
line[0] = 0;
if (fgets(line, LINE_MAX, file) == NULL) {
break;
}
/* Drop newline in value */
char *c = strchr(line, '\n');
if (c) {
*c = '\0';
}
err = strtoi_err(line, &v);
if (err != 0) {
v = -1;
}
}
free_and_clear_pointer(&buildstamp);
fclose(file);
return v;
}
void check_mix_versions(int *current_version, int *server_version, char *path_prefix)
{
*current_version = read_mix_version_file("/usr/share/clear/version", path_prefix);
char *format_file;
string_or_die(&format_file, MIX_STATE_DIR "version/format%s/latest", globals.format_string);
*server_version = read_mix_version_file(format_file, path_prefix);
free_and_clear_pointer(&format_file);
}
int update_device_latest_version(int version)
{
FILE *file = NULL;