Commit Graph

158 Commits

Author SHA1 Message Date
Richard Hughes
81c427ca6d Allow different plugins to add the same device
In this instance, we define the 'same device' to be a FuDevice that has at
least one matching GUID. We allow the plugins to define which one is 'better'
than other plugins, and use this to only have one FuDevice for the physical
device.

Alternative to https://github.com/hughsie/fwupd/pull/604
2018-08-06 21:58:28 -05:00
Richard Hughes
881f624eba trivial: Fix getting details about firmware for unknown devices
Fix a logic error when testing requirements; what was supposed to happen was
that a the firmware requirements were only processed when we had a FuDevice set
in the FuInstallTask, but instead we were falling through to the handler for
'unknown requirement type'.
2018-08-06 11:03:08 +01:00
Richard Hughes
38c7c334f4 trivial: Remove duplicate requirement checks
The fu_engine_check_requirements() tests are already called from
fu_engine_get_result_from_app() using a NULL device.
2018-08-06 10:59:13 +01:00
Mario Limonciello
4afe7fb742 fu-engine: Add a timer for device update wrapping blob installation
This makes it a lot easier to benchmark performance relative to
other implementations, systems and buses.
2018-08-06 00:34:42 -05:00
Richard Hughes
2d37c3f64b trivial: Add a virtual provide of com.redhat.fwupdate
Some firmware depends on this component, which we absorbed in the last release.

See also: https://github.com/hughsie/fwupd/issues/614
2018-08-04 19:06:03 +01:00
Richard Hughes
f307775675 Add release information for locked devices 2018-06-28 15:51:11 +01:00
Richard Hughes
87fb9ff447 Change the quirk file structure to be more efficient
This pivots the data storage so that the group is used as the preconditon
and the key name is used as the parameter to change. This allows a more natural
data flow, where a new device needs one new group and a few few keys, rather
than multiple groups, each with one key.

This also allows us to remove the key globbing when matching the version format
which is often a source of confusion.

Whilst changing all the quirk files, change the key prefixes to be more familiar
to Windows users (e.g. Hwid -> Smbios, and FuUsbDevice -> DeviceInstanceId)
who have to use the same IDs in Windows Update.

This also allows us to pre-match the desired plugin, rather than calling the
probe() function on each plugin.
2018-06-28 13:32:30 +01:00
Richard Hughes
a39d6a52b5 trivial: Skip plugins that require the 'Plugin' quirk is set 2018-06-28 12:17:15 +01:00
Richard Hughes
6dbe8fef34 Allow devices to assign a plugin from the quirk subsystem
Not calling dozens of ->probe() functions is dramatically more efficient when
there are a large number of USB devices attached.

This requires plugins to 'opt-in' to the new behaviour, and also to supply
quirks that match all devices.
2018-06-28 12:16:31 +01:00
Richard Hughes
83cd57f095 Fix downgrading older releases to devices
The requirement filter needs to be relaxed when getting the available releases
for a device when not used to install the firmware.
2018-06-27 14:07:23 +01:00
Richard Hughes
e48351e260 Set the alternate device ID, not the object itself
If the daemon either de-duplicates or replaces the object passed emitted from
device-added then the object set as the alternate may not be the same instance
as the daemon version. This causes weird things to happen.

To make this less fragile, specify the *ID* of the object that should be the
alternate device, which allows the daemon to do clever things, and then assign
the object from the ID as the last step.

Although fixing no bug, this makes implementing future functionality easier.
2018-06-22 13:28:27 +01:00
Richard Hughes
dbd8c76eb8 Run a plugin vfunc before and after all the composite devices are updated
Now we can update multiple devices (in multiple plugins) using one firmware
archive we need a way to cleanup after all the plugins have been run.

Fixes https://github.com/hughsie/fwupd/issues/561
2018-06-18 16:06:15 +01:00
Richard Hughes
61ac08d6d5 trivial: Allow firmware files to select a quad version format
This can be used to select the AA.BB.CC.DD format rather than the default
AA.BB.CCDD format for firmware versions. This allows us to support new vendor
requirements without adding more complicated rules to the quirk file.
2018-06-14 14:56:47 +01:00
Mario Limonciello
cf63aecdaf fu-engine: Don't hardcode /etc/pki/fwupd-metadata 2018-06-11 14:22:08 -05:00
Mario Limonciello
3f9a1c182a Clean up plugins as the last step of engine cleanup (Closes: #550)
Fixes a segfault that occurs during cleanup of USB plugins.

When g_module_close was called memory allocated by the plugin would
get freed leading to the finalize method for object class pointing
to garbage.
2018-06-06 14:39:03 -05:00
Richard Hughes
4be17d1364 Add support for relocating various runtime paths
This allows a snap package to be easily built.

With much help from Mario Limonciello <mario.limonciello@dell.com>, many thanks.
2018-05-31 16:25:22 +01:00
Richard Hughes
fe221dc13d trivial: Fix up some NULL/FALSE confusion 2018-05-29 09:33:44 +01:00
Mario Limonciello
51308e648a Adjust all licensing to LGPL 2.1+ (Closes: #526) 2018-05-29 09:03:13 +01:00
Richard Hughes
c02ee4da46 Allow whitelisting plugins in fwupdtool
When developing code it's really convenient to only run the new plugin. This
means you don't have to wait for the other hardware to initialize and there
are no side-effects from other plugins when installing firmware.

You can specify multiple plugins as globs, for instance:

    fwupdtool get-devices \
        --plugin-whitelist wacom \
        --plugin-whitelist "thunderbolt*"
2018-05-22 16:03:14 -05:00
Richard Hughes
8c71a3f2e9 Add a get-plugins command to fwupdtool
This returns the list of currently enabled plugins.
2018-05-22 16:03:14 -05:00
Richard Hughes
1d1f5cf098 trivial: Refactor the requirement tests to use a FuInstallTask 2018-05-21 21:23:45 +01:00
Richard Hughes
5b5f655e0b trivial: Allow the daemon to run without any idle sources
We need this if we want to run plugins without a daemon process.
2018-05-18 10:22:39 +01:00
Richard Hughes
c2de52a5b8 trivial: Only allow installing without history if the version is supplied 2018-05-18 10:14:36 +01:00
Richard Hughes
6e7419db0a trivial: Split up fu_engine_install()
This should allow the low-level tool to write unpackaged firmware.
2018-05-18 10:13:21 +01:00
Richard Hughes
76e0f94c86 Allow the client tools to avoid writing the history database 2018-05-14 18:54:15 +01:00
Richard Hughes
12040b51fe trivial: Fix fu_engine_get_device() to use the device list
This only worked when the device ID was already in the history database, and
was probably a copy-paste issue.
2018-05-14 13:38:58 +01:00
Richard Hughes
1e456bcd39 Do not call fu_plugin_init() on blacklisted plugins
Fixes https://github.com/hughsie/fwupd/issues/503
2018-05-11 07:26:17 -05: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
Richard Hughes
27bf9ecfbb trivial: Fix up all apps when building the store 2018-05-10 09:26:07 +01:00
Richard Hughes
7383ce263b trivial: Split out some common keyring functionality 2018-05-10 09:26:07 +01:00
Richard Hughes
5e447293fa Add the concept of logical mappings between different devices
This allows us to find out the logical parent device, for instance in composite
devices with more than one firmware image for a single device.

We also allow lazily specifying the device parent using a GUID and the engine
then automatically sets the parent object when the GUIDs match, which allows
children and parents to exist in different plugins.
2018-05-03 08:07:04 +01:00
Richard Hughes
3d71c16ed3 Allow specifying hwids with OR relationships
We don't want to use the version= attribute as the HWIDs are not versions, and
thinkgs like globbing just doesn't make sense given they are from hashes.

Fixes the client side part of https://github.com/hughsie/lvfs-website/issues/110
2018-05-01 14:33:23 +01:00
Richard Hughes
34e0dab1f1 Add fu_plugin_add_compile_version()
This allows plugins to set and explicit build-time version. It also uses the
same AppStream component-ID scheme rather than the home-grown 'FooVersion' key.

Also, use the new runtime and compile-time versions in the report metadata.
Due to the key change we'll also need to update some LVFS rules.
2018-04-20 20:45:08 +01:00
Richard Hughes
0eb123b986 Allow requiring specific versions of libraries for firmware updates
In some cases firmware can only be installed with an up to date GUsb (e.g. with
some STM-DFU hardware) or with a new version of fwupdate (e.g. any UEFI
UpdateCapsule without a capsule header).

We should be able to match against other software versions like we can the
fwupd version, e.g.

    <requires>
      <id compare="ge" version="0.9.2">org.freedesktop.fwupd</id>
      <id compare="ge" version="11">com.redhat.fwupdate</id>
    </requires>

Also, rather than checking each requirement we know about on the component,
check each requirement on the component about things we know. This ensures we
don't allow firmware to be installs that requires for instance fwupdate 22 when
the runtime version is only being added in fwupdate 12 and up.

This means the following is now an error that will fail to allow the firmware
to be installed:

    <requires>
      <firmware>doesnotexist</firmware>
      <some_future_tag>also_unknown</some_future_tag>
    </requires>

Also add a lot of self tests to test the various new failure modes.

Fixes https://github.com/hughsie/fwupd/issues/463
2018-04-20 16:19:05 +01:00
Mario Limonciello
ce2a8231ea Bump appstream-glib minimum version to 0.7.4
Ubuntu's LTS and Fedora's newest releases have it.  All CI targets
have it.
2018-04-20 09:05:17 -05:00
Richard Hughes
e598fc3447 trivial: Show the VID and PID when failing to add a USB device
Fixes https://github.com/hughsie/fwupd/issues/476
2018-04-19 20:15:09 +01:00
Mario Limonciello
ed1ac2a74b Enable CentOS 7 for CI
There are a lot of hacks here;
 * Pulling newer libappstream-glib from Fedora
 * Pulling a systemd backport
 * Manually installing pillow and pygobject
 * PKCS7 is turned off (gnutls is too old)
2018-04-18 10:25:22 -05:00
Richard Hughes
34e48634af trivial: Fix a critical warning when checking component requirements 2018-02-23 15:26:15 +00:00
Richard Hughes
849914e642 trivial: Don't keep asking the user if they want to report firmware
Don't optimize the device flag away. We need to be able to set the flag on all
devices that match the device ID, not just the one that happens to match now.
2018-02-14 19:57:27 +00:00
Mario Limonciello
44ebdb82d4 fu-engine: Clarify which devices don't have upgrades (Fixes #397) 2018-02-12 16:26:01 -06:00
Richard Hughes
4082d3367b Correctly mark updates as successful even if the device version number is wrong
If the device firmware was set incorrectly make then set it to the release
version so the database update works correctly. We can't do any kind of vercmp
in the database, so use a daemon warning so we can either fix the plugin or
the XML.

This fixes up the issue that the hardware reports '28.00' and the AppStream
release specifies '28.0'.

Fixes: https://github.com/hughsie/fwupd/issues/387
2018-02-09 16:55:09 +00:00
Richard Hughes
c0cd023d31 Be more careful deleting and modifying device history
If this happens:

1.2.3 -> 1.2.4 = failure
1.2.3 -> 1.2.5 = success

...we want to preserve both in the history database so they can both be shared
with the LVFS. Use the device ID and the new and old firmware versions when
modifying and deleting entries.

This fix is made slightly more tricky as we have to drop the PRIMARY KEY
attribute on the device_id, and due to a limitation in SQLite, it means copying
the old history into a new table.
2018-02-07 10:20:19 +00:00
Richard Hughes
65e44cac96 Always return useful information when calling GetResults()
Previous to having the history database we could only notify about firmware that
as installed using the uefi plugin, as that had a few system-wide API calls to
say 'this update failed' or 'this was the error'.

Now we have the local history database not only can we report more details about
the UEFI update (e.g. the old version number) but we can also offer the same
functionality for all other plugins.

Although this does rework how the data for GetResults() is populated, it does
make the FuEngine object quite a lot less confused.

It also fixes a warning in the fwupd plugin for gnome-software, which was
expecting the FwupdRelease to be populated for the FwupdDevice.
2018-02-07 10:20:19 +00:00
Richard Hughes
ee7e764603 trivial: Do not return failure if a device flag is already set
If we have multiple versions of upgrades/downgrades we'll be setting the
REPORTED flags for multiple history entries at once.
2018-02-01 14:01:58 +00:00
Richard Hughes
ad54f65f05 Add FWUPD_DEVICE_FLAG_NOTIFIED
This allows us to record whether we've shown the user a notification (either in
the terminal or in a GUI) that an update failed or was successful.

This can't be done in the session otherwise we'd get a notification for every
different user on the system. Notifying also isn't the same as reporting,
although one can certainly follow on from the latter.
2018-02-01 14:01:18 +00:00
Richard Hughes
534255cff3 Set the RemoteId when using GetDetails
This searches for the release container checksum in any enabled remote and
also sets the SUPPORTED flag if the local file matches.
2018-01-28 20:24:21 +00:00
Richard Hughes
2de8f13b2c Allow each plugin to opt-in to the recoldplug action
Recoldplug is really not required for the USB based plugins, and we should
restrict this action to plugins that have inter-dependencies on each other.
2018-01-17 20:19:58 +00:00
Richard Hughes
4012754569 trivial: Rename some FuDeviceList methods
The convention we're using is that find() returns the FuDeviceItem and get()
returns the FuDevice, so be consistent.

No code flow changes.
2018-01-16 13:48:51 +00:00
Richard Hughes
7e070c9bd7 Record an error if any NEEDS_REBOOT transaction fails to be applied
In the case of failing to even set up UpdateCapsule, the uefi plugin would
dutifully return SUCCESS as it was referring to the 2nd-to-last update that
actually worked.
2018-01-12 16:50:24 +00:00