Commit Graph

27 Commits

Author SHA1 Message Date
Richard Hughes
10fffc7fe3 trivial: Add some tests to verify the install task ordering 2020-04-16 18:01:20 +01:00
Mario Limonciello
537da0e98b fu-engine: Make two passes of requirements checking
Resolves installation for local CAB files that have `VersionFormat`
    set but not yet also set from metadata.

    In the first pass ignore the version format. This will rule out all
    other checks such as GUID and protocol.

    Then apply version format to the device if specified in the CAB.
    Lastly do a second pass with all requirements set.
2020-03-09 15:54:30 -05:00
Richard Hughes
9a68084dbc Always check for PLAIN when doing vercmp() operations
In 1de7cc we checked the version format when checking for update, but there are
many other places that are doing verfmt-insensitive comparisons. For instance,
the predicates in <requires> all fail if the device version format is plain.
his breaks updating some NVMe drives where the `ne` requirements are not
semantic versions.

To avoid trying to catch all the bugs in different places, and in case we have
a future verfmt that should be treated another way, refactor this out in to a
common function and deprecate the old function.
2020-02-20 15:49:27 +00:00
Richard Hughes
1de7cc920f Do not use fu_common_vercmp() when the device verfmt is PLAIN
This fixes the upgrade from 5101AALB to 51H0AALB, which fwupd was comparing as '5101' > '51'.
2020-02-13 13:33:43 +00:00
Richard Hughes
21eaeeff8d trivial: Fix up some typos found using codespell 2020-01-14 12:25:41 +00:00
Richard Hughes
1eb7c7443e Allow quirking devices that always require a version check
These are devices that we have to be careful with the version numbers, for
instance only updating from versions that have already had data migration
completed.

The new flag can be set in quirk files or on the objects directly.
2020-01-07 12:29:28 +00:00
Mario Limonciello
baa9e75ca8 fu-install-task: Enforce that device protocol matches metadata
Currently devices with a matching GUID will match any metadata that
has the same GUID.

For Dell in the future there will be a situation that the same GUID
is supported by two different FwupdDevice objects but the payload
required for the different objects will vary.

So start matching the protocol and the GUID both to make sure that
the right Fwupd device gets matched from the metadata.
2019-12-06 09:56:08 -06:00
Richard Hughes
df049edf0f Add support for multiple LVFS::VersionFormat tags
We painted ourselves into a corner when we added the `LVFS::VersionFormat`
metadata key, as using newer keys like `bcd` would not be recognised by older
versions of the daemon as there was no explicit fallback path.

This allows plugins or devices to 'upgrade' from simpler formats like:

 * `pair` -> `bcd`
 * `quad` -> `intel-me`
 * `triplet` -> `surface`
 * `plain` -> `misc-defined-vendor-format`

This means the LVFS can write multiple `LVFS::VersionFormat` keys, although the
'older' version format has to be listed first to preserve compatibility with
older daemon versions that just validate the first matching node.
2019-12-04 16:22:46 +00:00
Richard Hughes
1fbcb1a180 Do not do semver conversion in fu_common_vercmp()
We don't know the version format, and so it's impossible to do it reliably --
just do it in the caller where we *do* know the FuDevice version format.
2019-12-04 15:45:30 +00:00
Richard Hughes
5079f26f0e Never guess the version format from the version string
This leads to madness, as some formats are supersets of the detected types,
e.g. 'intel-me' is detected as 'quad' and 'bcd' is detected as 'pair'.

Where the version format is defined in a specification or hardcoded in the
source use a hardcoded enum value, otherwise use a quirk override.

Additionally, warn if the version does not match the defined version format
2019-04-30 09:25:41 +01:00
Richard Hughes
c84b36c541 Export the version-format to clients
This allows a vendor to verify the VersionFormat of a device without running
the daemon in verbose mode.
2019-04-30 09:25:41 +01:00
Richard Hughes
982e23c438 Do not compare version formats when the release format is unknown 2019-04-17 12:11:45 -04:00
Richard Hughes
ce3cea8cb4 Require --force to install a release with a different version format
If the user is trying to install version '20190104' on something with the
existing version '1.2.3' then something has gone wrong. Ensure the device
release version format matches the release version format and fail to apply the
update if this is not true.

In the common case setting the version with fu_device_set_version('1.2.3')
would set the version format to TRIPLET, and setting <release version='1.2.3'>
so no action is required. In cases where the version format could be ambiguous
then the format should be set both in a quirk and also in the metainfo file.
2019-04-09 04:16:32 -04:00
Richard Hughes
e6280655c4 Allow forcing an offline-only update on a live system using --force 2019-03-24 08:08:32 +00:00
Richard Hughes
245885ca1f Rename FwupdRelease:trust-flags to FwupdRelease:flags
In the future we'll want to use this flag to signify if the release is an
upgrade, downgrade, below the version-lowest, or if it is locked in some way.
2019-03-04 13:55:31 +00:00
Richard Hughes
481aa2a923 Port from libappstream-glib to libxmlb
The libxmlb library is much faster to query, and does not require the daemon
to parse the XML metadata at startup. It's a zero-copy mmap design that is more
modern and less clunky.

RSS has reduced from 3Mb (peak 3.61Mb) to 1Mb (peak 1.07Mb) and the startup
time has gone from 280ms to 250ms.
2018-10-17 14:41:13 +01:00
Richard Hughes
05cbb7245c Don't use AppStream-glib for version helpers
Refactor the imported version format code now we now longer need to stick to
the API mistakes of libappstream-glib.
2018-10-11 07:54:01 +01:00
Richard Hughes
b08e7bc7aa trivial: Set a log domain for each file
This allows us to do something like:

G_MESSAGES_DEBUG=FuEngine ./src/fwupd
2018-09-11 18:59:05 +01:00
Mario Limonciello
da0e90f263 fu-install-task: Allow using --force to ignore version_lowest (Closes #701) 2018-09-05 08:03:28 -05:00
Mario Limonciello
14c823e967 trivial: fu-install-task: Correct error message ordering (#701) 2018-09-05 10:26:28 +01:00
Mario Limonciello
7d35278cb6 fu-install-task: Don't fail update installation if compiled without GPG/PKCS7
Currently if you download a CAB file from LVFS and try to install it
on a daemon compiled without GPG it will fail to install since LVFS has signed
it.  You had to make an intentional decision to disable GPG.

Allow this scenario to work just as if the CAB file were unsigned, but save
a warning in the logs that it happened.
2018-08-24 19:11:00 +01:00
Richard Hughes
02c90d8a03 Remove the unused Emacs indenting headers from all source files
Fixes https://github.com/hughsie/fwupd/issues/636
2018-08-09 12:48:04 +01:00
Mario Limonciello
51308e648a Adjust all licensing to LGPL 2.1+ (Closes: #526) 2018-05-29 09:03:13 +01:00
Richard Hughes
c02cb83d20 trivial: Split out fu_install_task_compare() for future use 2018-05-21 21:23:45 +01:00
Richard Hughes
1d1f5cf098 trivial: Refactor the requirement tests to use a FuInstallTask 2018-05-21 21:23:45 +01:00
Richard Hughes
7e77bf3116 trivial: Be consistent with 'name [id]' in debug output
Based on a patch by Mario Limonciello <mario.limonciello@dell.com>, many thanks.
2018-05-10 09:26:07 +01:00
Richard Hughes
4ad41f027c Allow installing more than one firmware using 'fwupdmgr install'
When using failed to open firmware.cab we pass in a device ID of '*' which
tells the daemon to update anything that matches. The current implementation
will fail in two ways:

* If duplicate hardware is installed (for instance two Unifying receivers) then
  only the first matching device will be updated.

* If the firmware archive contains two different images then we only try and
  upgrade the first device that matches. This means we're unable to update
  composite devices using one firmware file.

To fix both issues, carefully build a list of tasks that can be processed using
the given firmware and installed devices, request authentication using all the
different action IDs, then upgrade all the devices one-at-a-time.

Based on a patch by Mario Limonciello <mario.limonciello@dell.com>, many thanks.
2018-05-10 09:26:07 +01:00