dnf - honor installroot and substitutes in paths (#83011)

In #80094 support for var substitution for cachedir was added but there
are more options that should be supported. Using an API for
prepend_installroot which should be done anyway provide that feature
so use that. In addition, perform the operation once all substitutes
are in place (releasever as well).
pull/83030/head
Martin Krizek 4 weeks ago committed by GitHub
parent 4e57249d59
commit 3a6f825a8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,3 @@
bugfixes:
- dnf - honor installroot for ``cachedir``, ``logdir`` and ``persistdir``
- dnf - perform variable substitutions in ``logdir`` and ``persistdir``

@ -403,7 +403,6 @@ from ansible.module_utils.yumdnf import YumDnf, yumdnf_argument_spec
# to set proper locale before importing dnf to be able to scrape
# the output in some cases (FIXME?).
dnf = None
libdnf = None
class DnfModule(YumDnf):
@ -484,7 +483,6 @@ class DnfModule(YumDnf):
os.environ['LANGUAGE'] = os.environ['LANG'] = locale
global dnf
global libdnf
try:
import dnf
import dnf.const
@ -492,7 +490,6 @@ class DnfModule(YumDnf):
import dnf.package
import dnf.subject
import dnf.util
import libdnf
HAS_DNF = True
except ImportError:
HAS_DNF = False
@ -560,9 +557,6 @@ class DnfModule(YumDnf):
# Load substitutions from the filesystem
conf.substitutions.update_from_etc(installroot)
# Substitute variables in cachedir path
conf.cachedir = libdnf.conf.ConfigParser.substitute(conf.cachedir, conf.substitutions)
# Handle different DNF versions immutable mutable datatypes and
# dnf v1/v2/v3
#
@ -596,6 +590,11 @@ class DnfModule(YumDnf):
# setting this to an empty string instead of None appears to mimic the DNF CLI behavior
conf.substitutions['releasever'] = ''
# Honor installroot for dnf directories
# This will also perform variable substitutions in the paths
for opt in ('cachedir', 'logdir', 'persistdir'):
conf.prepend_installroot(opt)
# Set skip_broken (in dnf this is strict=0)
if self.skip_broken:
conf.strict = 0

@ -58,9 +58,6 @@ ignore_missing_imports = True
[mypy-dnf.*]
ignore_missing_imports = True
[mypy-libdnf.*]
ignore_missing_imports = True
[mypy-apt.*]
ignore_missing_imports = True

@ -25,9 +25,6 @@ ignore_missing_imports = True
[mypy-dnf.*]
ignore_missing_imports = True
[mypy-libdnf.*]
ignore_missing_imports = True
[mypy-apt.*]
ignore_missing_imports = True

Loading…
Cancel
Save