summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--futility/updater.c14
-rw-r--r--futility/updater.h5
-rw-r--r--futility/updater_quirks.c47
3 files changed, 64 insertions, 2 deletions
diff --git a/futility/updater.c b/futility/updater.c
index df706485..63ed6869 100644
--- a/futility/updater.c
+++ b/futility/updater.c
@@ -1605,14 +1605,13 @@ int updater_setup_config(struct updater_config *cfg,
{
int errorcnt = 0;
int check_single_image = 0, check_wp_disabled = 0;
+ const char *default_quirks = NULL;
if (try_update)
cfg->try_update = 1;
if (force_update)
cfg->force_update = 1;
- if (quirks)
- errorcnt += !!setup_config_quirks(quirks, cfg);
if (sys_props)
override_properties_from_list(sys_props, cfg);
@@ -1623,6 +1622,17 @@ int updater_setup_config(struct updater_config *cfg,
if (pd_image)
errorcnt += !!load_image(pd_image, &cfg->pd_image);
+ /*
+ * Quirks must be loaded after images are loaded because we use image
+ * contents to decide default quirks to load. Also, we have to load
+ * default quirks first so user can override them using command line.
+ */
+ default_quirks = updater_get_default_quirks(cfg);
+ if (default_quirks)
+ errorcnt += !!setup_config_quirks(default_quirks, cfg);
+ if (quirks)
+ errorcnt += !!setup_config_quirks(quirks, cfg);
+
if (mode) {
if (strcmp(mode, "autoupdate") == 0) {
cfg->try_update = 1;
diff --git a/futility/updater.h b/futility/updater.h
index 02c1d8e5..660b9649 100644
--- a/futility/updater.h
+++ b/futility/updater.h
@@ -187,5 +187,10 @@ int get_config_quirk(enum quirk_types quirk, const struct updater_config *cfg);
/* Gets the system property by given type. Returns the property value. */
int get_system_property(enum system_property_type property_type,
struct updater_config *cfg);
+/*
+ * Gets the default quirk config string for target image.
+ * Returns a string (in same format as --quirks) to load or NULL if no quirks.
+ */
+const char * const updater_get_default_quirks(struct updater_config *cfg);
#endif /* VBOOT_REFERENCE_FUTILITY_UPDATER_H_ */
diff --git a/futility/updater_quirks.c b/futility/updater_quirks.c
index df3c9983..f65c6db9 100644
--- a/futility/updater_quirks.c
+++ b/futility/updater_quirks.c
@@ -8,10 +8,33 @@
#include <assert.h>
#include <stdio.h>
+#include <string.h>
#include "updater.h"
#include "host_misc.h"
+struct quirks_record {
+ const char * const match;
+ const char * const quirks;
+};
+
+static const struct quirks_record quirks_records[] = {
+ { .match = "Google_Whirlwind.", .quirks = "enlarge_image" },
+ { .match = "Google_Arkham.", .quirks = "enlarge_image" },
+ { .match = "Google_Storm.", .quirks = "enlarge_image" },
+ { .match = "Google_Gale.", .quirks = "enlarge_image" },
+
+ { .match = "Google_Chell.", .quirks = "unlock_me_for_update" },
+ { .match = "Google_Lars.", .quirks = "unlock_me_for_update" },
+ { .match = "Google_Sentry.", .quirks = "unlock_me_for_update" },
+ { .match = "Google_Asuka.", .quirks = "unlock_me_for_update" },
+ { .match = "Google_Caroline.", .quirks = "unlock_me_for_update" },
+ { .match = "Google_Cave.", .quirks = "unlock_me_for_update" },
+
+ { .match = "Google_Poppy.", .quirks = "min_platform_version=6" },
+ { .match = "Google_Scarlet.", .quirks = "min_platform_version=1" },
+};
+
/*
* Helper function to write a firmware image into file on disk.
* Returns the result from vb2_write_file.
@@ -145,3 +168,27 @@ void updater_register_quirks(struct updater_config *cfg)
quirks->apply = quirk_unlock_me_for_update;
}
+
+/*
+ * Gets the default quirk config string for target image.
+ * Returns a string (in same format as --quirks) to load or NULL if no quirks.
+ */
+const char * const updater_get_default_quirks(struct updater_config *cfg)
+{
+ const char *pattern = cfg->image.ro_version;
+ int i;
+
+ if (!pattern) {
+ DEBUG("Cannot identify system for default quirks.");
+ return NULL;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(quirks_records); i++) {
+ const struct quirks_record *r = &quirks_records[i];
+ if (strncmp(r->match, pattern, strlen(r->match)) != 0)
+ continue;
+ DEBUG("Found system default quirks: %s", r->quirks);
+ return r->quirks;
+ }
+ return NULL;
+}