Skip to content

Conversation

@malmond77
Copy link
Contributor

libdnf has the canonical implementation of checksum handling. We aim to
replace all use of dnf.yum.misc.checksum() with this. In doing so, this
fixes installing previously downloaded and transcoded rpms to support

rpm-software-management/librepo#222

This also has some minor performance benefits: librepo's checksum
handling employs caching of previously downloaded files via extended
attributes. This works for ordinary rpms in the dnf cache, but does not
work (yet) for rpm paths specified on the command line due to
rpm-software-management/librepo#233. That
issue is pretty minor, and the fix ends up in libdnf later.

The previous implementation maps all runtime errors to MiscError. We do
this still by taking the libdnf.error.Error class (defined in SWIG) and
map it directly back to the Python exception as before.

@malmond77
Copy link
Contributor Author

@lgtm-com
Copy link

lgtm-com bot commented Mar 11, 2021

This pull request introduces 1 alert when merging 9c29239 into 5b2e24d - view on LGTM.com

new alerts:

  • 1 for Unused import

libdnf has the canonical implementation of checksum handling. We aim to
replace all use of dnf.yum.misc.checksum() with this. In doing so, this
fixes installing previously downloaded and transcoded rpms to support

rpm-software-management/librepo#222

This also has some minor performance benefits: librepo's checksum
handling employs caching of previously downloaded files via extended
attributes. This works for ordinary rpms in the dnf cache, but does not
work (yet) for rpm paths specified on the command line due to
rpm-software-management/librepo#233. That
issue is pretty minor, and the fix ends up in libdnf later.

The previous implementation maps all runtime errors to MiscError. We do
this still by taking the libdnf.error.Error class (defined in SWIG) and
map it directly back to the Python exception as before.
@lgtm-com
Copy link

lgtm-com bot commented Mar 12, 2021

This pull request fixes 1 alert when merging 054cd9d into 5b2e24d - view on LGTM.com

fixed alerts:

  • 1 for Module is imported with 'import' and 'import from'

malmond77 added a commit to malmond77/libdnf that referenced this pull request Mar 17, 2021
DNF has been carrying around yum's old checksum function. These
functions duplicate code in librepo. They are slower because librepo can
employ caching of digests. Lastly, these functions in Python do not know
about changes in checksum logic like
rpm-software-management/librepo#222

The choices here are:

1. Replicate `lr_checksum_cow_fd()` and caching logic in Python
2. Just use librepo from dnf.

This is 2. Note there was bug in librepo that forces no caching
for `checksum_value()`
(rpm-software-management/librepo#233). This is
now fixed, so we depend on librepo-1.13.1 to ensure this fix is present.

This change goes hand in hand with a change to `dnf` itself to make use
of the new functions and eliminate the old ones. This is
rpm-software-management/dnf#1743. We bump the
version of this library to ensure this dependency is expressed properly.

On errors, these functions raise libdnf.error.Error which can be easily
mapped into MiscError in dnf
malmond77 added a commit to malmond77/libdnf that referenced this pull request Mar 17, 2021
DNF has been carrying around yum's old checksum function. These
functions duplicate code in librepo. They are slower because librepo can
employ caching of digests. Lastly, these functions in Python do not know
about changes in checksum logic like
rpm-software-management/librepo#222

The choices here are:

1. Replicate `lr_checksum_cow_fd()` and caching logic in Python
2. Just use librepo from dnf.

This is 2. Note there was bug in librepo that forces no caching
for `checksum_value()`
(rpm-software-management/librepo#233). This is
now fixed, so we depend on librepo-1.13.1 to ensure this fix is present.

This change goes hand in hand with a change to `dnf` itself to make use
of the new functions and eliminate the old ones. This is
rpm-software-management/dnf#1743. We bump the
version of this library in the next commit to ensure this dependency is
expressed properly.

On errors, these functions raise libdnf.error.Error which can be easily
mapped into MiscError in dnf
malmond77 added a commit to malmond77/libdnf that referenced this pull request Mar 17, 2021
DNF has been carrying around yum's old checksum function. These
functions duplicate code in librepo. They are slower because librepo can
employ caching of digests. Lastly, these functions in Python do not know
about changes in checksum logic like
rpm-software-management/librepo#222

The choices here are:

1. Replicate `lr_checksum_cow_fd()` and caching logic in Python
2. Just use librepo from dnf.

This is 2. Note there was bug in librepo that forces no caching
for `checksum_value()`
(rpm-software-management/librepo#233). This is
now fixed, so we depend on librepo-1.13.1 to ensure this fix is present.

This change goes hand in hand with a change to `dnf` itself to make use
of the new functions and eliminate the old ones. This is
rpm-software-management/dnf#1743. We bump the
version of this library in the next commit to ensure this dependency is
expressed properly.

On errors, these functions raise libdnf.error.Error which can be easily
mapped into MiscError in dnf
@lgtm-com
Copy link

lgtm-com bot commented Mar 17, 2021

This pull request fixes 1 alert when merging 17a6621 into 4763920 - view on LGTM.com

fixed alerts:

  • 1 for Module is imported with 'import' and 'import from'

m-blaha pushed a commit to rpm-software-management/libdnf that referenced this pull request Mar 18, 2021
DNF has been carrying around yum's old checksum function. These
functions duplicate code in librepo. They are slower because librepo can
employ caching of digests. Lastly, these functions in Python do not know
about changes in checksum logic like
rpm-software-management/librepo#222

The choices here are:

1. Replicate `lr_checksum_cow_fd()` and caching logic in Python
2. Just use librepo from dnf.

This is 2. Note there was bug in librepo that forces no caching
for `checksum_value()`
(rpm-software-management/librepo#233). This is
now fixed, so we depend on librepo-1.13.1 to ensure this fix is present.

This change goes hand in hand with a change to `dnf` itself to make use
of the new functions and eliminate the old ones. This is
rpm-software-management/dnf#1743. We bump the
version of this library in the next commit to ensure this dependency is
expressed properly.

On errors, these functions raise libdnf.error.Error which can be easily
mapped into MiscError in dnf
@m-blaha m-blaha self-assigned this Mar 18, 2021
Copy link
Member

@m-blaha m-blaha left a comment

Choose a reason for hiding this comment

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

One small problem remains - config-manager plugin uses yum.misc.Checksums class (see https://github.com/rpm-software-management/dnf-plugins-core/blob/93c76f546ae9b0a766b15b3c0c302da06e206ee9/plugins/config_manager.py#L256). But its use case is simply shortening a long string so it could be easily replaced by direct usage of hashlib standard library.
So dnf-plugins-core must be first changed and conflicts_dnf_plugins_core_version in dnf.spec set accordingly not to allow installation of older dnf-plugins-core with this newer dnf.

The change itself looks good to me and ready to be merged.

malmond77 added a commit to malmond77/dnf-plugins-core that referenced this pull request Mar 18, 2021
This is a pre-requisite for
rpm-software-management/dnf#1743

That PR removes a class that is used here. The actual benefit of the
class is marginal. The only part that needs preserved is the automatic
coercion of str/unicode into bytes.
malmond77 added a commit to malmond77/dnf-plugins-core that referenced this pull request Mar 18, 2021
rpm-software-management/dnf#1743 removes code
this package uses, so we replaced it. We need to ensure that dnf does
not permit version of this package before 4.0.20 to be installed else
they will not be able to resolve the class.
See
rpm-software-management/dnf#1743 (review)
for context.
Also changes `conflicts` for `dnf-plugins-core` because this removes
code that the plugin used. The corresponding change in the plugins is
rpm-software-management/dnf-plugins-core#427
@malmond77
Copy link
Contributor Author

rpm-software-management/dnf-plugins-core#427 fixes the issue in dnf-plugins-core, and I've added the conflicts here.

malmond77 added a commit to malmond77/dnf-plugins-core that referenced this pull request Mar 18, 2021
This is a pre-requisite for
rpm-software-management/dnf#1743

That PR removes a class that is used here. The actual benefit of the
class is marginal. The only part that needs preserved is the automatic
coercion of str/unicode into bytes.
malmond77 added a commit to malmond77/dnf-plugins-core that referenced this pull request Mar 18, 2021
rpm-software-management/dnf#1743 removes code
this package uses, so we replaced it. We need to ensure that dnf does
not permit version of this package before 4.0.20 to be installed else
they will not be able to resolve the class.
See
rpm-software-management/dnf#1743 (review)
for context.
malmond77 added a commit to malmond77/dnf-plugins-core that referenced this pull request Mar 18, 2021
This is a pre-requisite for
rpm-software-management/dnf#1743

That PR removes a class that is used here. The actual benefit of the
class is marginal. The only part that needs preserved is the automatic
coercion of str/unicode into bytes.
malmond77 added a commit to malmond77/dnf-plugins-core that referenced this pull request Mar 18, 2021
rpm-software-management/dnf#1743 removes code
this package uses, so we replaced it. We need to ensure that dnf does
not permit version of this package before 4.0.20 to be installed else
they will not be able to resolve the class.
See
rpm-software-management/dnf#1743 (review)
for context.
@lgtm-com
Copy link

lgtm-com bot commented Mar 18, 2021

This pull request fixes 1 alert when merging 0368c45 into ed06bbf - view on LGTM.com

fixed alerts:

  • 1 for Module is imported with 'import' and 'import from'

m-blaha pushed a commit to rpm-software-management/dnf-plugins-core that referenced this pull request Mar 19, 2021
This is a pre-requisite for
rpm-software-management/dnf#1743

That PR removes a class that is used here. The actual benefit of the
class is marginal. The only part that needs preserved is the automatic
coercion of str/unicode into bytes.
m-blaha pushed a commit to rpm-software-management/dnf-plugins-core that referenced this pull request Mar 19, 2021
rpm-software-management/dnf#1743 removes code
this package uses, so we replaced it. We need to ensure that dnf does
not permit version of this package before 4.0.20 to be installed else
they will not be able to resolve the class.
See
rpm-software-management/dnf#1743 (review)
for context.
@m-blaha m-blaha merged commit fb12c60 into rpm-software-management:master Mar 19, 2021
inknos pushed a commit to inknos/dnf-plugins-core that referenced this pull request Feb 1, 2022
This is a pre-requisite for
rpm-software-management/dnf#1743

That PR removes a class that is used here. The actual benefit of the
class is marginal. The only part that needs preserved is the automatic
coercion of str/unicode into bytes.
inknos pushed a commit to inknos/dnf-plugins-core that referenced this pull request Feb 1, 2022
rpm-software-management/dnf#1743 removes code
this package uses, so we replaced it. We need to ensure that dnf does
not permit version of this package before 4.0.20 to be installed else
they will not be able to resolve the class.
See
rpm-software-management/dnf#1743 (review)
for context.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants