Configuration¶
Configurable settings of the dnf.Base object are stored into a dnf.conf.Conf instance. The various options are described here.
-
class
dnf.conf.Conf¶ This object has attributes corresponding to all configuration options from both "[main] Options" and "Options for both [main] and Repo" sections. For example setting a proxy to access all repositories:
import dnf base = dnf.Base() conf = base.conf conf.proxy = "http://the.proxy.url:3128" conf.proxy_username = "username" conf.proxy_password = "secret" base.read_all_repos() base.fill_sack()
-
get_reposdir¶ Returns the value of the first valid reposdir or if unavailable the value of created reposdir (string)
-
substitutions¶ An instance of
dnf.conf.substitutions.Substitutionsclass. A mapping of substitutions used in repositories' remote URL configuration. The commonly used ones are:key
meaning
default
arch
architecture of the machine
autodetected
basearch
the architecture family of the current "arch"
autodetected
releasever
release name of the system distribution
Nonednf.rpm.detect_releasever()can be used to detect thereleasevervalue.Following example shows recommended method how to override autodetected architectures:
import dnf import hawkey arch = hawkey.detect_arch() base = dnf.Base() base.conf.substitutions['arch'] = arch base.conf.substitutions['basearch'] = dnf.rpm.basearch(arch) base.fill_sack() ...
-
exclude_pkgs(pkgs)¶ Exclude all packages in the pkgs list from all operations.
-
prepend_installroot(option)¶ Prefix config option named option with
installroot.
-
read(filename=None)¶ Read configuration options from the
mainsection in filename. Option values not present there are left at their current values. If filename isNone,config_file_pathis used. Conversely, the configuration path used to load the configuration file that was used is stored intoconfig_file_pathbefore the function returns.
-
dump()¶ Print configuration values, including inherited values.
-
write_raw_configfile(filename, section_id, substitutions, modify)¶ Update or create config file. Where filename represents name of config file (.conf or .repo); section_id represents id of modified section (e.g. main, fedora, updates); substitutions represents an instance of base.conf.substitutions; modify represents dict of modified options.
-
-
class
dnf.conf.substitutions.Substitutions¶ -
update_from_etc(installroot, varsdir=('/etc/yum/vars/', '/etc/dnf/vars/'))¶ Read user-defined variables values from variable directories. See variable files in Configuration reference.
-