Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Versionlock functionality for dnf5 #1121

Merged
merged 18 commits into from
Feb 14, 2024
Merged

Versionlock functionality for dnf5 #1121

merged 18 commits into from
Feb 14, 2024

Conversation

m-blaha
Copy link
Member

@m-blaha m-blaha commented Jan 2, 2024

Replacement of dnf4 versionlock plugin.
The config file format changed from ambiguous plain text with globs to TOML format.

PR contains also commands for config file manipulation (dnf5 versionlock add/exclude/delete/clear). More sophisticated manipulations (e.g. "lock to major version 5", "lock to epoch 1") are currently not supported from commandline - the user needs to edit the config file manually to achieve this.

  • Setup since fields to 5.1.13 for new API methods before the merging

Adjustments of current CI tests: rpm-software-management/ci-dnf-stack#1434
Closes: #332.

@m-blaha m-blaha force-pushed the mblaha/versionlock-2 branch 6 times, most recently from 252bbe3 to c14e9fd Compare January 9, 2024 08:52
@m-blaha m-blaha force-pushed the mblaha/versionlock-2 branch 3 times, most recently from 0cf31c9 to b436ca5 Compare January 19, 2024 13:48
@m-blaha m-blaha marked this pull request as ready for review January 19, 2024 13:51
Copy link
Member

@jan-kolarik jan-kolarik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did an initial review and plan to revisit it, likely tomorrow, to perform testing on the commands.

include/libdnf5/rpm/package_sack.hpp Show resolved Hide resolved
include/libdnf5/rpm/package_query.hpp Show resolved Hide resolved
dnf5/commands/repoquery/repoquery.cpp Outdated Show resolved Hide resolved
dnf5/commands/list/list.cpp Show resolved Hide resolved
include/libdnf5/rpm/versionlock_config.hpp Outdated Show resolved Hide resolved
include/libdnf5/rpm/versionlock_config.hpp Outdated Show resolved Hide resolved
include/libdnf5/rpm/versionlock_config.hpp Show resolved Hide resolved
dnf5/commands/versionlock/versionlock_add.cpp Outdated Show resolved Hide resolved
@jan-kolarik jan-kolarik self-assigned this Jan 24, 2024
@@ -28,6 +28,7 @@ along with libdnf. If not, see <https://www.gnu.org/licenses/>.
#include "libdnf5/base/base_weak.hpp"
#include "libdnf5/common/exception.hpp"
#include "libdnf5/common/weak_ptr.hpp"
#include "libdnf5/rpm/versionlock_config.hpp"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just #include "versionlock_config.hpp" on L27 as others from the same folder.

@jan-kolarik
Copy link
Member

I'd consider adding the docs for manual editing of the toml config file or track it as the follow-up issue. This commit message is a good start.

@jan-kolarik
Copy link
Member

I've needed to patch the rpm.i bindings file to compile with bindings:
0001-swig-Add-new-versionlock-bindings.patch

@m-blaha
Copy link
Member Author

m-blaha commented Feb 7, 2024

@jan-kolarik I've resolved most of you comments. To simplify the review process I added the changes as new commits. But I can squash them after the review if you want me to.

Config file for versionlock excludes is a TOML file with following
structure:

-----------------------
version = "1.0"

[[packages]]
name = "bash"               # name of the package
[[packages.conditions]]
key = "evr"                 # epoch, version, evr, and arch keys are supported
comparator = "="            # <, <=, =, >=, >, and != operators are supported
value = "0:5.2.15-5.fc39"   # pattern to match
--------------------------------

Each package can contain multiple `conditions` tables. In such case all
the conditions must be true for a package to match. This allows for
example instructing versionlock to keep a package on given major
version.
This example will keep acpi package on major version 2:

[[packages]]
name = "acpi"
[[packages.conditions]]
key = "version"
comparator = ">="
value = "2"
[[packages.conditions]]
key = "version"
comparator = "<"
value = "3"

To exclude any particular package version from getting installed just
use != comparator (meaning you want to lock to any version different
from the given one).
This example will exclude acpi-1.2-3.fc39 package:

[[packages]]
name = "acpi"
[[packages.conditions]]
key = "evr"
comparator = "!="
value = "1.2-3.fc39"
Needed to support "exclude" functionality of the versionlock.
@m-blaha m-blaha force-pushed the mblaha/versionlock-2 branch from 92aa0a4 to 44f92e6 Compare February 7, 2024 14:27
The default path is now [installroot]/etc/dnf/versionlock.toml. If
needed, we can add a config option for the path later.
This command is designed for maintaining versionlock configuration file.
It supports following subcommands:
- list: list the current configuration
- add <pkg_spec>: add new entry for the given pkg_spec
- exclude <pkg_spec>: add new exclude entry for the given pkg_spec
- delete <pkg_spec>: remove any versionlock entries for pkg_spec
- clear: remove all entries from the configuration
m-blaha and others added 6 commits February 7, 2024 18:29
- Since the add and delete subcommands do not modify any rules but
  merely add or delete a rule, we can detect changes in the ruleset
  simply by comparing the size of the vector before and after the
  operation.
- Simplify exclude implementation leveraging std::any_of
@m-blaha m-blaha force-pushed the mblaha/versionlock-2 branch from 44f92e6 to f33d4fc Compare February 7, 2024 17:30
@jan-kolarik
Copy link
Member

LGTM, I believe if there is no other complaint or request, we can prepare the since tags to 5.1.13 and merge ...

@m-blaha
Copy link
Member Author

m-blaha commented Feb 13, 2024

Cool, thanks. I'm gonna add a new commit with Since 5.1.13 later today.

@jan-kolarik jan-kolarik added this pull request to the merge queue Feb 14, 2024
Merged via the queue into main with commit e3e8175 Feb 14, 2024
5 of 9 checks passed
@jan-kolarik jan-kolarik deleted the mblaha/versionlock-2 branch February 14, 2024 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

how to add "version lock" with dnf5 ...
2 participants