voxpupuli / puppet-yum

Puppet module for Yum
https://forge.puppet.com/puppet/yum
MIT License
16 stars 101 forks source link

[needs validation] allow RpmNameGlob for versionlock entries #228

Open foxxx0 opened 2 years ago

foxxx0 commented 2 years ago

As stated in the manpage [1] yum versionlock supports package-wildcard and does not require exact matches for package-names. The following is valid versionlock.list content:

libvirt*-0:7.6.0-*.*
qemu*-0:6.1.0-*.*

This commit swaps Yum::RpmName with Yum::RpmNameGlob for the versionlock assert_type() and thus allowing the above mentioned examples.

[1] https://man7.org/linux/man-pages/man1/yum-versionlock.1.html

vchepkov commented 2 years ago

versionlock config file is very purely documented, and years of use was just accidental. https://bugzilla.redhat.com/show_bug.cgi?id=1757895#c9

command line supports wildcards, config file never did. only exact match was allowed, so anything else was rejected as a side effect

kBite commented 1 year ago

@vchepkov Verified it's working for RHEL-8

# dnf versionlock clear
Last metadata expiration check: 0:00:12 ago on Fri 16 Sep 2022 06:20:53 PM UTC.

# dnf update --assumeno kernel
Last metadata expiration check: 0:00:16 ago on Fri 16 Sep 2022 06:20:53 PM UTC.
Dependencies resolved.
============================================================================================================================================================================================================================================================================================
 Package                                                             Architecture                                                Version                                                                       Repository                                                              Size
============================================================================================================================================================================================================================================================================================
Installing:
 kernel                                                              x86_64                                                      4.18.0-372.26.1.el8_6                                                         almalinux_baseos                                                       8.1 M
 kernel-core                                                         x86_64                                                      4.18.0-372.26.1.el8_6                                                         almalinux_baseos                                                        39 M
 kernel-modules                                                      x86_64                                                      4.18.0-372.26.1.el8_6                                                         almalinux_baseos                                                        32 M
Removing:
 kernel                                                              x86_64                                                      4.18.0-372.16.1.el8_6                                                         @almalinux_baseos                                                        0
 kernel-core                                                         x86_64                                                      4.18.0-372.16.1.el8_6                                                         @almalinux_baseos                                                       69 M
 kernel-modules                                                      x86_64                                                      4.18.0-372.16.1.el8_6                                                         @almalinux_baseos                                                       23 M

Transaction Summary
============================================================================================================================================================================================================================================================================================
Install  3 Packages
Remove   3 Packages

Total download size: 79 M
Operation aborted.

# echo 'kernel*-0:4.18.0-372.16.*' > /etc/dnf/plugins/versionlock.list

# dnf update --assumeno kernel
Last metadata expiration check: 0:00:29 ago on Fri 16 Sep 2022 06:20:53 PM UTC.
Dependencies resolved.
Nothing to do.
Complete!

# cat /etc/dnf/plugins/versionlock.list
kernel*-0:4.18.0-372.16.*

Using dnf versionlock CLI it will expand the regex:

# dnf versionlock clear
...

# dnf versionlock add kernel*-0:4.18.0-372.16.*
...
Adding versionlock on: kernel-core-0:4.18.0-372.16.1.el8_6.*
Adding versionlock on: kernel-0:4.18.0-372.16.1.el8_6.*
Adding versionlock on: kernel-modules-0:4.18.0-372.16.1.el8_6.*

But when trying the same after writing the regex directly to versionlock.list it recognizes it as equivalent:

# echo 'kernel*-0:4.18.0-372.16.*' > /etc/dnf/plugins/versionlock.list

# dnf versionlock add kernel*-0:4.18.0-372.16.*
...
Package already locked in equivalent form: kernel*-0:4.18.0-372.16.*