dnf - replace usage of private attribute with supported API (#73529)
base._update_security_filters is a private attribute of DNF used as performance optimization. Modification or even call from outside of DNF is against all recommendation including PEP8. * Improve compatibility with all DNF versions * Add changelog fragment for dnf security change
This commit is contained in:
parent
ba2b1a6bf6
commit
d9183b8df5
2 changed files with 21 additions and 9 deletions
2
changelogs/fragments/dnf-security.yaml
Normal file
2
changelogs/fragments/dnf-security.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- Replace usage of private dnf.Base() attribute by future dnf API
|
|
@ -687,15 +687,25 @@ class DnfModule(YumDnf):
|
||||||
rc=1
|
rc=1
|
||||||
)
|
)
|
||||||
|
|
||||||
filters = []
|
add_security_filters = getattr(base, "add_security_filters", None)
|
||||||
if self.bugfix:
|
if callable(add_security_filters):
|
||||||
key = {'advisory_type__eq': 'bugfix'}
|
filters = {}
|
||||||
filters.append(base.sack.query().upgrades().filter(**key))
|
if self.bugfix:
|
||||||
if self.security:
|
filters.setdefault('types', []).append('bugfix')
|
||||||
key = {'advisory_type__eq': 'security'}
|
if self.security:
|
||||||
filters.append(base.sack.query().upgrades().filter(**key))
|
filters.setdefault('types', []).append('security')
|
||||||
if filters:
|
if filters:
|
||||||
base._update_security_filters = filters
|
add_security_filters('eq', **filters)
|
||||||
|
else:
|
||||||
|
filters = []
|
||||||
|
if self.bugfix:
|
||||||
|
key = {'advisory_type__eq': 'bugfix'}
|
||||||
|
filters.append(base.sack.query().upgrades().filter(**key))
|
||||||
|
if self.security:
|
||||||
|
key = {'advisory_type__eq': 'security'}
|
||||||
|
filters.append(base.sack.query().upgrades().filter(**key))
|
||||||
|
if filters:
|
||||||
|
base._update_security_filters = filters
|
||||||
|
|
||||||
return base
|
return base
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue