Commit Graph

288 Commits

Author SHA1 Message Date
Richard Hughes
af14073522 Allow applying all releases to get to a target version
Some hardware does not handle upgrading from version 1.2.2 to 1.2.4 and instead
needs to be upgraded from 1.2.2->1.2.3->1.2.4 so that on-device metadata can be
migrated correctly.

Add a new per-device flag `install-all-releases` which causes the daemon to not
skip directly to the newest release. This is designed to be set from a quirk
file.

This can obviously only be used for devices that can apply firmware "live" and
thus do not need a reboot or system shutdown to actually apply the firmware.
This also needs the cabinet archive to ship multiple versions of the firmware,
and for the metainfo.xml file to refer to multiple release objects.
2020-01-07 15:33:12 +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
Richard Hughes
7f765005e2 Add a runtime warning when adding a device without an vendor-id or protocol set
Also, allow setting the protocol in the quirk file if required.
2020-01-06 14:48:32 +00:00
Mario Limonciello
62b8336383 trivial: fu-remotes-list: drop usage of FU_SELF_TEST_REMOTES_DIR
Instead use `CONFIGURATION_DIRECTORY`, which already supported by
`fu-common`.
2019-12-12 13:23:13 -06:00
Richard Hughes
45a00738d8 Allow building on Windows with MinGW
Add various fixes to enable us to build a selection of useful USB plugins.
Also, skip tests that don't make sense on WIN32 or that will not work.

With much help from Mario Limonciello <mario.limonciello@dell.com> -- Thanks!
2019-12-03 16:33:43 +00:00
Richard Hughes
297d1598ef trivial: Only dlopen the test plugin once
This causes problems in the self tests when not lazy-loading symbols.

Also use g_build_filename() for the paths to be more portable and readable.
2019-12-01 20:59:19 +00:00
Mario Limonciello
5beceda89b trivial: Move progressbar out of libfwupdplugin
The intention with f0f504c740 was to
not offer this in the plugin, but when rebasing 6b0e66354b
this was forgotten to be removed.
2019-11-27 08:18:02 -06:00
Richard Hughes
3ed2ac8315 trivial: Unexport fu_test_get_filename()
We don't actually need either of the things it provides (looking up in source
and built, and converting to an absolute path) so just replace it with
g_build_filename() instead.

This also has the advantage that it does the right thing on Windows.
2019-11-27 12:45:35 +00:00
Richard Hughes
606fa91dae trivial: Unexport fu_test_compare_lines()
It's only used two places in the self tests.
2019-11-27 12:45:35 +00:00
Richard Hughes
f3d5207351 trivial: Unexport fu_test_loop_run_with_timeout() 2019-11-27 12:45:35 +00:00
Mario Limonciello
6b0e66354b Convert libfwupdprivate to a shared library libfwupdplugin 2019-11-27 11:32:43 +00:00
Richard Hughes
019a1bc2b0 trivial: Untangle FuHistory from FuPlugin
This will allow us to export FuPlugin in the future without dragging in the
private fu-history.h too.
2019-11-26 14:14:27 +00:00
Richard Hughes
afdba37644 trivial: Set the offline trigger using an environment variable
This allows us to build a object that does not have a custom FU_OFFLINE_DESTDIR.
2019-11-25 09:29:46 +00:00
Richard Hughes
00d6f4734f trivial: Don't assume that plugins end in .so 2019-11-24 08:14:48 +00:00
Richard Hughes
4debb3dcd2 trivial: Fix unused header includes 2019-11-22 14:23:11 +00:00
Richard Hughes
f7006d2baa Add support for matching <firmware> requirements on device parents
For composite devices you might want to restrict the child device in respect
to the parent, for instance requiring the parent to have greater than a specific
firmware version number.

The other useful thing to use this for is checking if the parent has a specific
GUID (of any version) which allows us to match against the common VID&PID
instance IDs. This would allow us to restrict a generic child device update to
a specific OEM vendor parent.

This is specified as <firmware depth="1" ...> to match the parent device and
<firmware depth="2" ...> to match the grandparent device.
2019-11-14 16:25:58 +00:00
Richard Hughes
2414f24b8a trivial: Provide some defines for common image names 2019-11-08 09:30:09 -06:00
Richard Hughes
5272cfc63d Add versions formats for the Microsoft Surface devices
Apparently there are yet more ways to encode a 32 bit number...
2019-11-07 21:34:09 +00:00
Richard Hughes
0bbef29d3e Always report the update-error correctly for multiple updates
The root of this problem is that we were trying to use pending.db as both a
pending report store and also a record of history, so you could see updates for
device foo 1.2.3->1.2.4 and then 1.2.4->1.2.5.
This sort-of half worked, but it meant in some cases we matched on the old
device version, sometimes on the new release version and sometimes matching on
either.

The problem was that in various places we were using the device ID as *the*
primary key, and so we had various functions like fu_history_get_device_by_id()
that expected to return just one device, not several.

The device ID also changes if the device is moved from USB plug to another, and
so it got even more complicated again trying to de-dupe the devices.

The sanest thing to do is to decide that pending.db only contains the latest
attempt to go from one version to another using device-id as the primary key.
This makes reporting work reliably now, although has the effect you can't
report a 1.2.3->1.2.4 and 1.2.4->1.2.5 at the same time. Note, if you tried to
do the latter before, the update-error (if set) would be wrong on the second
report...

For the 1.3.3 release make it all simpler and so the reporting works reliably.
Longer term we can design a better database schema that uses unique ID to
represent the *transaction* itself, that isn't tied to the device ID in any way.
This might mean extending the DBus API to cope with multiple devices being
returned with the same device-id set.
2019-11-01 08:16:18 -05:00
Richard Hughes
51a869a01d Use XMLb to query quirks
During startup we do 1898 persistent allocations to load the quirk files, which
equates to ~90kb of RSS. Use libxmlb to create a mmap'able store we can query
with XPath queries at runtime.
2019-10-30 08:29:58 -05:00
Mario Limonciello
dd0b437d86 trivial: fu-self-test: set polling self tests to slow
Currently the test runs for 100ms and looks to see that at least 8 times
the poll function callback hit.

This normally works well enough, but during self tests it depends upon
too much timing and leads to failures sometimes:

```
** (/<<PKGBUILDDIR>>/obj-s390x-linux-gnu/src/fu-self-test:50432): DEBUG: 15:37:55.189: poll cnt=0
*# DEBUG: poll cnt=1
** (/<<PKGBUILDDIR>>/obj-s390x-linux-gnu/src/fu-self-test:50432): DEBUG: 15:37:55.199: poll cnt=1
*** (/<<PKGBUILDDIR>>/obj-s390x-linux-gnu/src/fu-self-test:50432): DEBUG: 15:37:55.209: poll cnt=2
** (/<<PKGBUILDDIR>>/obj-s390x-linux-gnu/src/fu-self-test:50432): DEBUG: 15:37:55.227: poll cnt=3
*# DEBUG: poll cnt=4
** (/<<PKGBUILDDIR>>/obj-s390x-linux-gnu/src/fu-self-test:50432): DEBUG: 15:37:55.255: poll cnt=4
*# DEBUG: poll cnt=5
** (/<<PKGBUILDDIR>>/obj-s390x-linux-gnu/src/fu-self-test:50432): DEBUG: 15:37:55.267: poll cnt=5
Bail out! ERROR:../src/fu-self-test.c:3489:fu_device_poll_func: assertion failed (cnt >= 8): (6 >= 8)
--- stderr ---
**
ERROR:../src/fu-self-test.c:3489:fu_device_poll_func: assertion failed (cnt >= 8): (6 >= 8)
-------
```

Mark this as a slow test so that it doesn't cause CI failures.
2019-10-22 09:58:05 -05:00
Richard Hughes
1db25c9f2c Allow a custom FuFirmwareImage->write() in superclassed objects 2019-10-15 08:10:11 -05:00
Richard Hughes
c0695320c8 Add a generic DFU firmware object for plugins to use 2019-10-11 13:19:46 +01:00
Richard Hughes
224e991ab8 trivial: Add klass->to_string for superclassed FuFirmwareImage objects
This matches the behaviour of FuFirmware.
2019-10-10 16:16:42 +01:00
Richard Hughes
e37575192d Do not enumerate physical devices when running the internal self tests
We don't need to enumerate USB and UDev devices in the self tests. In the case
where the probe fails (due to a permissions error, as not running as root) we
don't want the tests to fail.
2019-09-25 04:49:52 -05:00
Mario Limonciello
3be596b907 fu-util/fu-tool: Better display historical information
* When firmware has been modified use the device key "Previous version"
  instead of "Current version".
* Show release as a child node when looking at history
* Don't output empty flags for release
* Use the key "New version" for releases

Sample output from `get-history`
```
├Integrated Webcam™:
│ │   Device ID:           08d460be0f1f9f128413f816022a6439e0078018
│ │   Previous version:    1.2.2
│ │   Update State:        success
│ │   Flags:               updatable
│ │   Last modified:       2019-09-20 14:53
│ │   GUID:                b585990a-003e-5270-89d5-3705a17f9a43
│ │
│ └  New version:       1.2.3
│
└Integrated Webcam™:
  │   Device ID:           08d460be0f1f9f128413f816022a6439e0078018
  │   Modified version:    1.2.2
  │   Update State:        success
  │   Flags:               updatable
  │   Last modified:       2019-09-20 14:53
  │   GUID:                b585990a-003e-5270-89d5-3705a17f9a43
  │
  └  New version:       1.2.4
```

Sample output from `get-updates`
```
Integrated Webcam™:
  │   Device ID:           08d460be0f1f9f128413f816022a6439e0078018
  │   Summary:             A fake webcam
  │   Current version:     1.2.2
  │   Previous Version:     1.2.0
  │   Bootloader Version:  0.1.2
  │   Vendor:              ACME Corp. (USB:0x046D)
  │   Flags:               updatable|supported|registered
  │   GUID:                b585990a-003e-5270-89d5-3705a17f9a43
  │
  ├FakeDevice Firmware:
  │     New version:       1.2.4
  │     Remote ID:         fwupd-tests
  │     Summary:           Firmware for the ACME Corp Integrated Webcam
  │     License:           GPL-2.0+
  │     Size:              17 bytes
  │     Vendor:            ACME Corp
  │     Flags:             is-upgrade
  │     Description:       Fixes another bug with the flux capacitor to prevent time going backwards.
  │
  └FakeDevice Firmware:
        New version:       1.2.3
        Remote ID:         fwupd-tests
        Summary:           Firmware for the ACME Corp Integrated Webcam
        License:           GPL-2.0+
        Size:              17 bytes
        Vendor:            ACME Corp
        Flags:             is-upgrade
        Description:       Fixes a bug with the flux capacitor to avoid year 2038 overflow.
```
2019-09-20 16:02:55 -05:00
Richard Hughes
6819f9e461 Allow parsing a raw SREC file
At least two vendors are not using SREC according to the spec. They are using
it like a recipe to write specific values at specific addresses.

All the logic like line lengths and checksumming (and therefore all the various
checks for malicious firmware) are still valid, so provide a new function to
just tokenize the file and to not assign a padded image.
2019-09-20 09:59:32 +01:00
Richard Hughes
f679e5efa8 Include the kernel release as a runtime version
Although not always useful (due to patches being backported) being able to
depend on a specific kernel version might save our bacon in the future.
2019-08-28 15:52:50 +01:00
Mario Limonciello
da55c48b7d Remove replug flag after the device comes back from reboot
This prevents errors like this from happening:

```
failed to get device after update: failed to wait for detach replug: device did not come back
```
2019-08-28 09:24:31 +01:00
Mario Limonciello
6ff8a16390 trivial: Adjust daemon device sorting
This should output devices by priority followed by name instead now.
2019-08-27 15:39:29 +01:00
Richard Hughes
847cae824a trivial: Fix fu_common_string_append_kv() to align properly with idx > 0 2019-08-27 15:39:29 +01:00
Mario Limonciello
71d2f62dc2 trivial: update references of hughsie/fwupd to fwupd/fwupd 2019-08-22 09:47:52 -05:00
Richard Hughes
6e3e62bee8 Use fu_common_string_append_kv() in subclassed device
Also define the indent level in the the ->to_string vfunc so we can correctly
print client devices in all cases.
2019-08-14 16:48:37 +01:00
Richard Hughes
5308ea4fae Never use memcpy() in a possibly unsafe way
There are several subtle bugs in various places in fwupd caused by not treating
user-provided offsets into buffers as unsafe. As fwupd runs as root we have to
assume that all user firmware is evil, and also that devices cannot be trusted.

Make a helper to put all the logic into one place and convert all users.
2019-08-12 09:22:09 -05:00
Richard Hughes
cea28dea96 Add a ->to_string() vfunc to FuFirmware
This allows firmware to add to the existing image output and will be used for
future firmware types.
2019-08-09 15:54:25 +01:00
Richard Hughes
7afd7cba0d Use FuFirmware as a container for firmware images
In many plugins we've wanted to use ->prepare_firmware() to parse the firmware
ahead of ->detach() and ->write_firmware() but this has the limitation that it
can only return a single blob of data.

For many devices, multiple binary blobs are required from one parsed image,
for instance providing signatures, config and data blobs that have to be pushed
to the device in different way.

This also means we parse the firmware *before* we ask the user to detach.

Break the internal FuDevice API to support these firmware types as they become
more popular.

This also allows us to move the Intel HEX and SREC parsing out of the dfu plugin
as they are used by a few plugins now, and resolving symbols between plugins
isn't exactly awesome.
2019-08-08 13:10:57 +01:00
Richard Hughes
b4627629cd Relax the certificate time checks in the self tests for the legacy certificate
One test verifies a firmware with a signature from the old LVFS which was
hosted on secure-lvfs.rhcloud.com and used the original PKCS-7 key. This key
had a two year validity (expiring today, ohh the naivety...) rather than the
newer fwupd.org key which expires in the year 2058.

For this specific test only, disable the certificate time checks to fix CI.

Fixes https://github.com/hughsie/fwupd/issues/1264
2019-08-01 10:09:58 +01:00
Richard Hughes
5cbb5cf908 Allow using --force to trigger a duplicate offline update 2019-05-07 14:30:07 +01: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
94422f651e Only force a semver when the device opts-in
This is only used by one, so-far out-of-tree plugin. Reduce complexity by not
using the version format to decide if we're forcing a semver.
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
3c8777f0f6 Do not fall back integers to a plain version format
We can't possibly know what version format to use.
2019-04-17 12:11:45 -04:00
Richard Hughes
2c40b3734f Use the device version format when converting the release version
This is arguably the more correct fix, regardless of the UEFI quirk use as each
release was reading and converting the exact same property from the component.

Fixes https://github.com/hughsie/fwupd/issues/1156
2019-04-17 12:11:45 -04:00
Richard Hughes
456328072b Detect version number like RQR24.06_B0030 as 'plain'
Failing the semver checks we want to fall back to PLAIN, rather than UNKNOWN.

Fixes https://github.com/hughsie/fwupd/issues/1151
2019-04-16 11:32:03 -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
b62c3a4fae Add support for the not-child extension from Logitech
This ensures that child devices are updated before the receiver as the update
protocol may be changed during the update.

Fixes https://github.com/hughsie/fwupd/issues/1139
2019-04-09 15:23:10 +08:00
Aleksander Morgado
f9843b427e trivial: fix running tests with gnutls < 3.6 2019-04-01 14:36:25 -05:00
Richard Hughes
bd6966b241 trivial: Move another self test -> slow() 2019-03-25 14:18:30 -05:00
Richard Hughes
994b4d9532 Save the new version in the history database for offline updates
This allows us to write the downgrade/upgrade text correctly in fwupdoffline.
2019-03-25 16:59:48 +00:00
Richard Hughes
809abea834 Ask to reboot after scheduling an offline firmware update 2019-03-23 11:14:44 +00:00
Richard Hughes
f28abe7fda Allow signing and verifying data using a PKCS-7 self-signed client certificate
This is a per-client certificate and private key that can be used to sign
metadata sent to remote servers, for instance success/failure reports.
2019-03-11 13:57:39 +00:00
Richard Hughes
c8cc77c1c2 trivial: Add FuEngineLoadFlags argument to fu_engine_load()
No functionality changes, but allows us to do something new in the future.
2019-03-07 08:28:36 -06:00
Richard Hughes
8dd4c1c4dd Allow restricting firmware updates for enterprise use 2019-03-05 19:05:07 +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
Mario Limonciello
96a0dd5606 Add a support for delayed activation
This is intended for devices that it is not safe to immediately activate
the firmware.  It may be called at a more convenient time instead.

Both fwupdmgr and fwupdtool support the feature.

- if called at runtime with fwupdmgr it uses the daemon
- during shutdown fwupdtool uses the pending.db to perform this feature.
2019-02-27 09:04:54 +00:00
Richard Hughes
b768e4d924 Do not fail to start the daemon if tpm2_pcrlist hangs
In some situations SELinux prevents fwupd from executing tpm2_pcrlist, but the
failure mode is that the process just hangs and never completes. This causes
systemd to time out the fwupd daemon startup and then errors to be shown in
GNOME Software.

To prevent this happening, add an optional timeout argument to
fu_common_spawn_sync() and cancel the subprocess if it takes longer than this
to complete.

See https://bugzilla.redhat.com/show_bug.cgi?id=1665701 for details.
2019-02-26 14:27:13 +00:00
Richard Hughes
1bc432316a Defer the InstanceID->GUID hashing until after setup
This allows hardware from OEMs to *not* match generic firmware supplied by the
device manufacturer. The idea being, that the OEM will supply firmware that
will actually work on the device.

Based on a patch from Mario Limonciello, many thanks.
2019-02-06 08:02:16 +00:00
Richard Hughes
65c81921b6 Add fu_device_add_instance_id() and prefer explicit conversion 2019-02-04 15:19:57 +00:00
Richard Hughes
592baedfff Export some of the GUID functionality 2019-02-04 15:19:57 +00:00
Richard Hughes
5297678d3c Allow a plugin to set _ANOTHER_WRITE_REQUIRED to run more than one plugin
For this to work with different plugins the device IDs must match.
2019-02-04 14:54:54 +00:00
Richard Hughes
c6c312f267 trivial: Move fu_plugin_runner_schedule_update() into the engine 2019-02-04 14:54:54 +00:00
Mario Limonciello
4f24d0bae3 When using directory remote type automatically generate metadata
The CAB files will be parsed upon `fwupd`/`fwupdtool` startup and
loaded into the daemon.
2019-01-29 09:21:54 -06:00
Mario Limonciello
51ddf18faa When generating a CAB Silo use the prefix "components"
This makes fu_engine_get_details use a more standard prefix.
2019-01-28 09:52:37 +00:00
Richard Hughes
f425d29a28 Show a console warning if loading an out-of-tree plugin
Fixes https://github.com/hughsie/fwupd/issues/950
2019-01-19 07:26:20 +00:00
Richard Hughes
4e886a4dfa Include the device checksum and update protocol in the historydb 2018-12-14 19:23:04 +00:00
Richard Hughes
4badf7e963 Do not allow a GUID of zero
The tempation for OEMs or ODMs to ship firmware updates matching a NULL GUID is
too fragile to allow -- even with CHID restrictions.
2018-12-07 09:05:30 -06:00
Richard Hughes
55b8a249e0 Sanitize the version if the version format has been specified
This converts versions like 'v1.2.3' into a valid semver of '1.2.3' if the
version format has been set.

Fixes https://github.com/hughsie/fwupd/issues/884
2018-12-05 07:07:35 -06:00
Richard Hughes
b97f07e7be Provide a way for plugins to decompress a custom archive to ram
This allows plugins to load an archive supplied as the 'deliverable' of the
cabinet archive. This means plugins can bundle up a set of images in a cross
platform way, for instance adding boot.img+os.img+manifest.xml into a zip file,
rather than having to (ab)use the DfuSe file format or deal with libarchive
directly.
2018-11-28 14:18:03 +00:00
Richard Hughes
ac458d3436 Guess the version format when it is not provided
The most important change here is that versions without dots (not a 'semver')
are treated as 'PLAIN' rather than 'UNKNOWN'.
2018-11-14 11:52:46 +00:00
Richard Hughes
6e0c8f8742 Add per-release install duration values
These are set from the AppStream metadata and are specific to the firmware
release.

If not provided, the install duration falls back to the per-device duration
values which can be set in the quirk files.
2018-11-12 14:18:28 +00:00
Richard Hughes
26db91ba13 trivial: Create an empty tree before tests start
This ensures we only load the files we actually write in the test.
2018-11-12 14:18:28 +00:00
Richard Hughes
42111a3880 trivial: Relax the timing requirements on the FuDevice poll test
If the poll source is scheduled just at the right time, we might only get 8x
'10ms ticks' in a 100ms window. This fixes an occasional build failure on
slower hardware and in CI.
2018-11-08 20:45:35 +00:00
Richard Hughes
89ab873f72 trivial: Add yet another version encoding
This variant is a quad-style, but with the Microsoft style 4 digit BuildVer.
2018-10-18 19:31:04 +01:00
Richard Hughes
7fb61fdd1c Support the Intel ME version format
This slightly weird encoding is going to be used by Lenovo for firmware updates.
It will also be used to quirk the ME UEFI device added from the ESRT.
2018-10-17 15:25:52 +01: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
d3d2c2c39f Don't use AppStream-glib for the GUID helpers
Long term we want to wean ourselves away from libappstream-glib.
2018-10-11 07:54:01 +01:00
Mario Limonciello
f20f9f65bc fu-device: Ensure that parent ID is created before creating quirked children 2018-10-10 16:24:18 -05:00
Mario Limonciello
2dd731b2f0 Update all sub-devices for a composite update
This allows a frontend to call update on an individual device ID which will
cause a CAB file to be downloaded, but then also re-use the same CAB file to
try to process devices with a relationship as part of a transaction.
2018-10-10 11:24:27 -05:00
Richard Hughes
12c849966d Allow firmware files to depend on versions from other devices
At the moment firmware can declare that it has certain requirements, for
instance the existing firmware version, the bootloader version, or the
vendor ID of the device.

In some situations we actually want to check the firmware version of a
*different* device. Good examples here would be only allowing an EC upgrade if
a specific BIOS update has already been done, or only allowing a wireless
reciever to be updated if the attached wireless devices have been updated first.

To use this, you can do something like:

    <requires>
      <id compare="ge" version="1.1.3">org.freedesktop.fwupd</id>
      <firmware compare="ge" version="0.9.0">guid-of-other-device</firmware>
    </requires>
2018-10-02 06:53:52 -05:00
Richard Hughes
5a9a6bd479 trivial: Return reference counted devices from FuDeviceList 2018-09-12 16:10:38 +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
Richard Hughes
ebae396d0a udev: Do not add devices after a small delay
Now devices can have multiple GUIDs and do not share platform IDs there is
really no point waiting to add the device.

This allows us to remove a whole lot of code for this now-unused functionality.
2018-09-09 16:24:30 +01:00
Richard Hughes
1513585d21 trivial: Move the poll setup into common code
This is used by two device types in the unifying plugin, and soon to be one
other new plugin.
2018-09-09 13:43:18 +01:00
Richard Hughes
841c1807e1 trivial: Copy the parent if set for the repluged device
Based on a patch from Mario Limonciello, many thanks.
2018-09-07 15:32:32 +01:00
Richard Hughes
c125ec02ed Clarify what the platform ID actually is by renaming it
It wasn't hugely clear what the platform ID was actually meant to represent. In
some cases it was being used like a physical ID, in others it was a logical ID,
and in others it was both. In some cases it was even used as a sysfs path.

Clear up all the confusion by splitting the platform ID into two parts, an
optional *physical* ID to represent the electrical connection, and an optional
*logical* ID to disambiguate composite devices with the same physical ID.

Also create an explicit sysfs_path getter for FuUdevDevice to make this clear.

This allows WAIT_FOR_REPLUG to always work, rather than depending on the order
that the GUIDs were added, and that the kernel would always return the same
sysfs path (which it doesn't have to do, especially for hidraw devices).
2018-09-06 16:22:46 +01:00
Mario Limonciello
64c905b1f3 Remove children of devices when the parent is removed 2018-09-04 10:00:52 +01:00
Richard Hughes
3a8d532855 Allow the device list to take care of waiting for the device replug
This means that individual plugins do not have to manage thier own GUsbDevice
lifecycle and no longer have to call g_usb_context_wait_for_replug().
2018-08-31 16:41:40 +01:00
Richard Hughes
a574a75b61 trivial: Add fu_common_strstrip() for future use 2018-08-31 16:39:09 +01:00
Richard Hughes
50d6bd10bd trivial: Add refcounting to fu_device_open() 2018-08-29 19:12:29 +01:00
Richard Hughes
4937ff5499 trivial: Add a self test to test the quirk database performance 2018-08-28 20:47:09 +01:00
Richard Hughes
570f839483 trivial: Fix a tiny memory leak in the self tests 2018-08-28 20:40:50 +01:00
Richard Hughes
bda4d81d3d trivial: Allow plugins to add virtual children from quirk files
The example here would be adding virtual i2c devices attached to an existing
USB hub device.
2018-08-28 18:30:00 +01:00
Richard Hughes
6dec401a67 Store the DeviceInstanceId as a GUID in the quirk database
This allows us to match non-DeviceID GUIDs, and also GUIDs we don't know how to
generate.

To make this fully useful, search for device quirks when GUIDs are added.
2018-08-28 18:30:00 +01:00
Richard Hughes
f22bd6e424 trivial: Move out the byte-array chunking to libfwupdprivate
Five plugins (soon to be 7) are linking to the DFU plugin just for this simple
segment-aware chunking functionality. Move this into common code to make
building simpler.
2018-08-22 15:14:12 +01:00
Mario Limonciello
37b5958d4a firmware-builder: Make running more resilient
Test whether CONFIG_USER_NS and related knobs are set.
* Fail daemon execution if not
* Skip self tests if not.

Detect ENOTTY errno set by process spawn.
Skip self tests if set.

Fixes FTBFS on Debian pbuilder and unprivileged docker.
2018-08-14 08:18:49 -05: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
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
f307775675 Add release information for locked devices 2018-06-28 15:51:11 +01:00
Richard Hughes
3c304c4826 trivial: Allow running fu-self-test without ninja 2018-06-28 15:51:11 +01:00