trivial: Add yet another version encoding

This variant is a quad-style, but with the Microsoft style 4 digit BuildVer.
This commit is contained in:
Richard Hughes 2018-10-18 11:34:22 +01:00
parent ce4a1a8ba6
commit 89ab873f72
4 changed files with 75 additions and 1 deletions

58
docs/version-format.md Normal file
View File

@ -0,0 +1,58 @@
Version Formats
===============
In some circumstances fwupd has to convert from a unsigned integer version
number into something that has either been used in documentation or has been
defined in some specification.
A good example here is the UEFI ESRT table, which specifies a `uint32_t` for
the version but does not specify how this should be formatted for the user.
As is typical in underspecified specifications, vendors have converted the
integer in different ways. For instance, Dell uses version strings like 1.2.3
and Microsoft use versions like 1.2.3.4.
The fwudp daemon can match specific devices and apply the correct version style
using quirk files. The version format can also be specified in the firmware
`metainfo.xml` file so that the new version is correctly shown, and so that it
matches on the LVFS website.
The current version formats supported by fwupd and the LVFS are:
* `plain`: Use plain integer version numbers with no dots, e.g. `AABBCCDD`
* `quad`: Use Dell-style `AA.BB.CC.DD` version numbers
* `triplet`: Use Microsoft-style `AA.BB.CCDD` version numbers
* `pair`: Use two `AABB.CCDD` version numbers
* `bcd`: Use binary coded decimal notation
* `intel-me`: Use Intel ME-style notation (`aaa+11.bbbbb.CC.DDDD`)
* `intel-me2`: Use alternate Intel ME-style-style `A.B.CC.DDDD` notation
These can be specified in quirk files like this:
# Vendor Modelname
[Guid=5b92717b-2cad-4a96-a13b-9d65781df8bf]
VersionFormat = intel-me2
...or in metainfo.xml files like this:
<custom>
<value key="LVFS::VersionFormat">intel-me2</value>
</custom>
Runtime requirements
--------------------
Versions of fwupd `< 1.2.0` can only support firmware updates with key values
`LVFS::VersionFormat` of `quad` and `triplet`. Additionally, on older versions
no quirk `VersionFormat` device fixups are supported.
If want to use one of the additional version formats you should depend on a
specific version of fwupd in the firmware file:
<requires>
<id compare="ge" version="1.2.0">org.freedesktop.fwupd</id>
</requires>
This is not *strictly* required, as the integer value can be used for update
calculations if the version is specified in hex (e.g. `0x12345678`) in the
`<release>` tag, although the user might get a bit confused if the update
version does not match the update description.

View File

@ -33,6 +33,8 @@ fu_common_version_format_from_string (const gchar *str)
return FU_VERSION_FORMAT_TRIPLET;
if (g_strcmp0 (str, "quad") == 0)
return FU_VERSION_FORMAT_QUAD;
if (g_strcmp0 (str, "intel-me2") == 0)
return FU_VERSION_FORMAT_INTEL_ME2;
if (g_strcmp0 (str, "bcd") == 0)
return FU_VERSION_FORMAT_BCD;
if (g_strcmp0 (str, "plain") == 0)
@ -59,6 +61,8 @@ fu_common_version_format_to_string (FuVersionFormat kind)
return "triplet";
if (kind == FU_VERSION_FORMAT_QUAD)
return "quad";
if (kind == FU_VERSION_FORMAT_INTEL_ME2)
return "intel-me2";
if (kind == FU_VERSION_FORMAT_BCD)
return "bcd";
if (kind == FU_VERSION_FORMAT_PLAIN)
@ -123,6 +127,14 @@ fu_common_version_from_uint32 (guint32 val, FuVersionFormat kind)
(val >> 16) & 0xff,
val & 0xffff);
}
if (kind == FU_VERSION_FORMAT_INTEL_ME2) {
/* A.B.CC.DDDD */
return g_strdup_printf ("%u.%u.%u.%u",
(val >> 28) & 0x0f,
(val >> 24) & 0x0f,
(val >> 16) & 0xff,
val & 0xffff);
}
return NULL;
}

View File

@ -17,7 +17,8 @@
* @FU_VERSION_FORMAT_TRIPLET: Use Microsoft-style AA.BB.CCDD version numbers
* @FU_VERSION_FORMAT_PAIR: Use two AABB.CCDD version numbers
* @FU_VERSION_FORMAT_BCD: Use binary coded decimal notation
* @FU_VERSION_FORMAT_INTEL_ME: Use Intel ME-style notation
* @FU_VERSION_FORMAT_INTEL_ME: Use Intel ME-style bitshifted notation
* @FU_VERSION_FORMAT_INTEL_ME2: Use Intel ME-style A.B.CC.DDDD notation notation
*
* The flags used when parsing version numbers.
**/
@ -29,6 +30,7 @@ typedef enum {
FU_VERSION_FORMAT_PAIR, /* Since: 1.2.0 */
FU_VERSION_FORMAT_BCD, /* Since: 1.2.0 */
FU_VERSION_FORMAT_INTEL_ME, /* Since: 1.2.0 */
FU_VERSION_FORMAT_INTEL_ME2, /* Since: 1.2.0 */
/*< private >*/
FU_VERSION_FORMAT_LAST
} FuVersionFormat;

View File

@ -2961,6 +2961,8 @@ fu_common_version_func (void)
{ 0xff000100, "4278190336", FU_VERSION_FORMAT_PLAIN },
{ 0x0, "11.0.0.0", FU_VERSION_FORMAT_INTEL_ME },
{ 0xffffffff, "18.31.255.65535", FU_VERSION_FORMAT_INTEL_ME },
{ 0x0b32057a, "11.11.50.1402", FU_VERSION_FORMAT_INTEL_ME },
{ 0xb8320d84, "11.8.50.3460", FU_VERSION_FORMAT_INTEL_ME2 },
{ 0, NULL }
};
struct {