[UEFI] Adding snap support for Ubuntu < 22 and handling error code 2 for fwupgmgr refresh - #382
Conversation
…for fwupgmgr refresh
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #382 +/- ##
==========================================
+ Coverage 94.87% 94.93% +0.06%
==========================================
Files 111 111
Lines 20844 20883 +39
==========================================
+ Hits 19776 19826 +50
+ Misses 1068 1057 -11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR updates the Ubuntu (APT) certificate-update flow to (1) install fwupd via Snap on Ubuntu releases older than 22.04, and (2) treat fwupdmgr refresh exit code 2 (“no updates available”) as a non-error during certificate update.
Changes:
- Add Ubuntu-version gating in
AptitudePackageManagerto choosesnap install fwupdon Ubuntu < 22.04, otherwise useapt-get install. - Treat
fwupdmgr refreshexit code2as success in the cert update shell-step runner. - Extend unit tests and legacy env-layer command mocks to cover the new Snap install path and fwupd exit-code handling.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/core/tests/Test_AptitudePackageManager.py |
Adds tests for Snap-vs-APT selection by Ubuntu version and for handling fwupd refresh/update exit codes. |
src/core/tests/library/LegacyEnvLayerExtensions.py |
Updates legacy command mocking to recognize snap install fwupd and less strict fwupdmgr refresh/update matching. |
src/core/src/package_managers/AptitudePackageManager.py |
Implements Snap gating for fwupd install and treats fwupd refresh exit code 2 as success in cert update flow. |
Suppressed comments (1)
src/core/src/package_managers/AptitudePackageManager.py:108
- When
is_snap_fwupd_requiredis True, the code still relies on runningfwupdmgrby name (e.g.,fwupdmgr --version,sudo fwupdmgr refresh).EnvLayer.run_command_output()runs commands withshell=Trueand does not modify the environment, so PATH may not include/snap/binin non-interactive contexts. This can cause the cert update flow to fail withfwupdmgr: not foundeven aftersnap install fwupdsucceeds. Consider using an explicit path when snap is required (e.g.,/snap/bin/fwupdmgr) or ensuring/snap/binis added to PATH for these invocations.
self.is_snap_fwupd_required = self.__is_snap_fwupd_required()
self.get_installed_fwupd_version_cmd = "fwupdmgr --version"
self.install_fwupd_cmd = "sudo snap install fwupd" if self.is_snap_fwupd_required else "sudo apt-get install -y fwupd"
self.fwupd_refresh_cmd = "sudo fwupdmgr refresh" # NOTE: This could be made generic in package manager, depending on what solution type is adopted for other distros
self.fwupd_update_cmd = "sudo fwupdmgr update -y"
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Michelle McDaniel (michellemcdaniel)
left a comment
There was a problem hiding this comment.
Looks like there are still some code coverage issues
| self.is_snap_fwupd_required = self.__is_snap_fwupd_required() | ||
| self.get_installed_fwupd_version_cmd = "fwupdmgr --version" | ||
| self.install_fwupd_cmd = "sudo snap install fwupd" if self.is_snap_fwupd_required else "sudo apt-get install -y fwupd" | ||
| self.fwupd_refresh_cmd = "sudo fwupdmgr refresh" # NOTE: This could be made generic in package manager, depending on what solution type is adopted for other distros |
There was a problem hiding this comment.
One suggestion here:
Can we change it to "sudo fwupdmgr refresh --force" ?
That way, we'd never see the ignorable error.
This includes 2 updates:
fwupdmgr refreshwhen no metadata updates are found fwupd/fwupd#10208 and https://manpages.debian.org/trixie/fwupd/fwupdmgr.1.en.htmlTests Results: