AppStreams promise type enhancements#136
Open
nickanderson wants to merge 1 commit intocfengine:masterfrom
Open
AppStreams promise type enhancements#136nickanderson wants to merge 1 commit intocfengine:masterfrom
nickanderson wants to merge 1 commit intocfengine:masterfrom
Conversation
f73f03d to
8d34c03
Compare
8d34c03 to
03bec2e
Compare
This commit adds three major enhancements to the appstreams promise type:
Generic DNF options support via 'options' attribute
- Accepts list of "key=value" strings (e.g., ["install_weak_deps=false"])
- Uses DNF's set_or_append_opt_value() for generic option handling
- Enables any DNF configuration option without hardcoding
Automatic stream switching detection and handling
- Detects when installed stream differs from requested stream
- Uses ModuleBase.switch_to() API for proper stream transitions
- Supports both upgrades and downgrades (e.g., 8.2→8.1, 8.1→8.3)
ModuleBase API integration for proper module context
- Replaces mpc.enable/install/save with ModuleBase.install()
- Ensures module-specific package versions are installed
- Maintains upstream's sack reset and explicit package download logic
Example usage:
appstreams:
"php"
state => "installed",
stream => "8.2",
profile => "minimal",
options => { "install_weak_deps=false" };
03bec2e to
a6c0ca7
Compare
larsewi
approved these changes
Apr 22, 2026
| self.log_error(f" Package {pkg} failed: {error}") | ||
|
|
||
| def _install_module(self, mpc, base, module_name, stream, profile): | ||
| def _apply_dnf_options(self, base, options): |
Contributor
There was a problem hiding this comment.
This function seems to apply DNF configuration options at best effort. I.e., if it fails, it just logs a warning and continues. Is this the intention? If so, maybe you should rename the function to _try_apply_dnf_options?
| self.log_error( | ||
| f"Failed to verify module switch for {module_name}:{stream}/{profile}" | ||
| ) | ||
| return Result.NOT_KEPT |
Contributor
There was a problem hiding this comment.
Maybe you can flatten this code to avoid too many nested if's. If you turn the conditions on their head you could get something like:
enabled_stream = mpc.getEnabledStream(module_name)
if enabled_stream != stream:
# Log error saying enabled stream was not equal to stream
return Result.NOT_KEPT
installed_profiles = mpc.getInstalledProfiles(module_name)
if profile not in installed_profiles:
# Log error saying profile not in installed_profiles
return Result.NOT_KEPT
# etc... and then eventually return REPAIREDIt's a little bit more readable in my opinion. But it's only an opinion. There is nothing wrong with the way you did it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generic DNF Options Support
Previously the appstreams promise type had no way to pass DNF configuration options. Users could not control behavior like weak dependency installation.
After adding support for
optionsthe module now accepts any DNF configuration option.Changes now log to dnf history. sys.argv is faked so that
dnf historywill output useful information in the prominent "Command Line" field.It's now possibly to easily switch streams. Previously, if a module was already enabled at one stream and you requested a different stream, the promise would report KEPT without making changes or would fail.
Promise would report KEPT because it detected the module was "installed", but didn't check if the stream matched. Now there is automatic detection and handling of stream changes (both upgrades and downgrades).
Same policy, same starting state:
DNF History shows:
And downgrades:
Result:
Fixed Package Versions installed by stream.
Previously packages might be installed from the wrong stream or default stream instead of the requested module stream.
Policy:
Result (with old mpc.enable/install API):
dnf history showed what we desired and what actually happened:
Now it uses the ModuleBase api and resolves versions from the module stream correctly:
Same policy:
Result:
DNF history:
optionsattribute