Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement drop-in configuration folder (RhBug:1352234) #1414

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,4 @@ DNF CONTRIBUTORS
Tomas Kasparek <[email protected]>
Vladan Kudlac <[email protected]>
Will Woods <[email protected]>
Ondřej Sojka <[email protected]>
1 change: 1 addition & 0 deletions dnf/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,7 @@ def configure(self, args, option_parser=None):
self.demands.cacheonly = True
self.base.conf._configure_from_options(opts)
self._read_conf_file(opts.releasever)
self.base.conf.read_dropin_dir()
if 'arch' in opts:
self.base.conf.arch = opts.arch
self.base.conf._adjust_conf_options()
Expand Down
4 changes: 2 additions & 2 deletions dnf/conf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
places, hard to change and debug. The new structure here will replace that. Its
goal is to:

* accept configuration options from all three sources (the main config file,
repo config files, command line switches)
* accept configuration options from all four sources (the main config file,
drop-in configuration folder, repo config files, command line switches)
* handle all the logic of storing those and producing related values.
* returning configuration values.
* optionally: asserting no value is overridden once it has been applied
Expand Down
5 changes: 5 additions & 0 deletions dnf/conf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
PRIO_REPOCONFIG = libdnf.conf.Option.Priority_REPOCONFIG
PRIO_PLUGINDEFAULT = libdnf.conf.Option.Priority_PLUGINDEFAULT
PRIO_PLUGINCONFIG = libdnf.conf.Option.Priority_PLUGINCONFIG
PRIO_DROPINCONFIG = libdnf.conf.Option.Priority_DROPINCONFIG
PRIO_COMMANDLINE = libdnf.conf.Option.Priority_COMMANDLINE
PRIO_RUNTIME = libdnf.conf.Option.Priority_RUNTIME

Expand Down Expand Up @@ -417,6 +418,10 @@ def read(self, filename=None, priority=PRIO_DEFAULT):
# update to where we read the file from
self._set_value('config_file_path', filename, priority)

def read_dropin_dir(self, dirname=dnf.const.CONF_DROPIN_DIR, priority=PRIO_DROPINCONFIG):
for filename in sorted(os.listdir(dirname)):
self.read(os.path.join(dirname, filename), priority)

@property
def verbose(self):
return self._get_value('debuglevel') >= dnf.const.VERBOSE_LEVEL
Expand Down
1 change: 1 addition & 0 deletions dnf/const.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import distutils.sysconfig

CONF_FILENAME='/etc/dnf/dnf.conf' # :api
CONF_AUTOMATIC_FILENAME='/etc/dnf/automatic.conf'
CONF_DROPIN_DIR='/etc/dnf/conf.d/'
DISTROVERPKG=('system-release(releasever)', 'system-release',
'distribution-release(releasever)', 'distribution-release',
'redhat-release', 'suse-release')
Expand Down
5 changes: 5 additions & 0 deletions doc/conf_ref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
all \*.repo files found under ``/etc/yum.repos.d``. The latter is typically used
for repository configuration and takes precedence over global configuration.

It is also possible to drop configuration snippets into ``/etc/dnf/conf.d/``.
These are read in alphabetical order and can override all configuration. Every
option must be part of a section to be read correctly; therefore start every
dropped-in configuration file with ``[main]`` or ``[repo]``.

The configuration file has INI format consisting of section declaration and
``name=value`` options below each on separate line. There are two types of sections
in the configuration files: main and repository. Main section defines all global
Expand Down