summaryrefslogtreecommitdiff
path: root/libappstream-glib/as-inf.c
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2015-07-03 16:27:31 +0100
committerRichard Hughes <richard@hughsie.com>2015-07-03 17:09:48 +0100
commit680d47fe40a959f447e10b8b52175d3c2b04e3dd (patch)
treec03af3881b118024db91d41b3ca83a63c3e5b073 /libappstream-glib/as-inf.c
parent3ba6c79e8e22cc02f93fabf0809294bdf5e59785 (diff)
downloadappstream-glib-680d47fe40a959f447e10b8b52175d3c2b04e3dd.tar.gz
Do not expect the INF ClassGuid to be the ESRT GUID
I misunderstood the role of the ClassGuid for UEFI firmware. It is not supposed to be the ESRT GUID, but instead a generic 'firmware' GUID set by Microsoft. The actual ESRT is set as a FirmwareID registry key only, so learn how to parse the HK section and fix up all the unit tests. As there are .cab files in the wild (cough, ColorHug, cough) that set the device ID as the ClassGuid, fall back to this to maintain compatibility with either method. Many thanks to Mario Limonciello for helping to debug this. See https://msdn.microsoft.com/en-us/library/windows/hardware/ff547502%28v=vs.85%29.aspx for more information.
Diffstat (limited to 'libappstream-glib/as-inf.c')
-rw-r--r--libappstream-glib/as-inf.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/libappstream-glib/as-inf.c b/libappstream-glib/as-inf.c
index 52bda79..95e3335 100644
--- a/libappstream-glib/as-inf.c
+++ b/libappstream-glib/as-inf.c
@@ -687,6 +687,49 @@ as_inf_parse_line (AsInfHelper *helper, gchar *line, GError **error)
goto out;
}
+ /* convert registry entries. e.g.
+ * "HKR,,FirmwareFilename,,firmware.bin"
+ * -> "HKR_FirmwareFilename"="firmware.bin"
+ * "HKR,,FirmwareVersion,%REG_DWORD%,0x0000000"
+ * -> "HKR_FirmwareVersion_0x00010001"="0x0000000" */
+ if (g_strcmp0 (helper->group, "Firmware_AddReg") == 0 &&
+ g_str_has_prefix (line, "HK")) {
+ guint i;
+ _cleanup_strv_free_ gchar **reg_split = NULL;
+ _cleanup_string_free_ GString *str = NULL;
+ str = g_string_new ("");
+ reg_split = g_strsplit (line, ",", -1);
+ for (i = 0; reg_split[i+1] != NULL; i++) {
+ g_strstrip (reg_split[i]);
+ if (reg_split[i][0] == '\0')
+ continue;
+ g_string_append_printf (str, "%s_", reg_split[i]);
+ }
+ if (str->len > 0) {
+ _cleanup_free_ gchar *key_tmp = NULL;
+
+ /* remove trailing '_' */
+ g_string_truncate (str, str->len - 1);
+
+ /* remove leading and trailing quote */
+ g_strchug (reg_split[i]);
+ if (!as_inf_strip_value (helper, reg_split[i], error)) {
+ ret = FALSE;
+ goto out;
+ }
+ if (helper->dict == NULL) {
+ helper->require_2nd_pass = TRUE;
+ helper->last_line_continuation_ignore = TRUE;
+ goto out;
+ }
+ key_tmp = as_inf_replace_variable (helper, str->str, error);
+ if (key_tmp == NULL)
+ return FALSE;
+ as_inf_set_key (helper, key_tmp, reg_split[i]);
+ goto out;
+ }
+ }
+
/* add fake key */
key = g_strdup_printf ("value%03i", helper->nokey_idx++);
as_inf_set_key (helper, key, line);