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

automatic: Use original dnf4 config file location #1690

Merged
merged 1 commit into from
Sep 11, 2024
Merged
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
21 changes: 16 additions & 5 deletions dnf5-plugins/automatic_plugin/automatic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,22 +281,33 @@ void AutomaticCommand::pre_configure() {

// read the config files in following order (/etc overrides /usr):
// - [installroot]/usr/share/dnf5/dnf5-plugins/automatic.conf
// - [installroot]/etc/dnf/dnf5-plugins/automatic.conf
// - [installroot]/etc/dnf/dnf5-plugins/automatic.conf [deprecated]
// - [installroot]/etc/dnf/automatic.conf
auto & main_config = base.get_config();
bool use_host_config{main_config.get_use_host_config_option().get_value()};
std::filesystem::path installroot_path{main_config.get_installroot_option().get_value()};
std::vector<std::filesystem::path> possible_paths{"/usr/share/dnf5/dnf5-plugins", "/etc/dnf/dnf5-plugins"};
for (const auto & pth : possible_paths) {
std::vector<std::tuple<std::filesystem::path, bool>> possible_paths{
{"/usr/share/dnf5/dnf5-plugins", false}, {"/etc/dnf/dnf5-plugins", true}, {"/etc/dnf", false}};
auto & logger = *base.get_logger();
for (const auto & [pth, deprecated] : possible_paths) {
std::filesystem::path conf_file_path{pth / "automatic.conf"};
if (!use_host_config) {
conf_file_path = installroot_path / conf_file_path.relative_path();
}
if (std::filesystem::exists(conf_file_path)) {
if (deprecated) {
auto msg = libdnf5::utils::sformat(
_("Warning: Configuration file location \"{}\" for dnf automatic is deprecated. See "
"dnf5-automatic(8) for details."),
conf_file_path.string());
logger.warning(msg);
ppisar marked this conversation as resolved.
Show resolved Hide resolved
std::cerr << msg << std::endl;
}
libdnf5::ConfigParser parser;
parser.read(conf_file_path);
base.get_config().load_from_parser(
parser, "base", *base.get_vars(), *base.get_logger(), libdnf5::Option::Priority::AUTOMATICCONFIG);
config_automatic.load_from_parser(parser, *base.get_vars(), *base.get_logger());
parser, "base", *base.get_vars(), logger, libdnf5::Option::Priority::AUTOMATICCONFIG);
config_automatic.load_from_parser(parser, *base.get_vars(), logger);
}
}

Expand Down
2 changes: 2 additions & 0 deletions dnf5.spec
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,8 @@ automatically and regularly from systemd timers, cron jobs or similar.
%ghost %{_sysconfdir}/motd.d/dnf5-automatic
%{_libdir}/dnf5/plugins/automatic_cmd_plugin.so
%{_datadir}/dnf5/dnf5-plugins/automatic.conf
%ghost %config(noreplace) %{_sysconfdir}/dnf/automatic.conf
%ghost %config(noreplace) %{_sysconfdir}/dnf/dnf5-plugins/automatic.conf
%{_mandir}/man8/dnf*-automatic.8.*
%{_unitdir}/dnf5-automatic.service
%{_unitdir}/dnf5-automatic.timer
Expand Down
1 change: 0 additions & 1 deletion doc/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ Changes to individual commands

``automatic``
* Now a DNF5 plugin.
* Configuration file has been moved from ``/etc/dnf/automatic.conf`` to ``/etc/dnf/dnf5-plugins/automatic.conf``. However, its contents remain compatible.
* The specific systemd units, ``dnf-automatic-download``, ``dnf-automatic-install``, and ``dnf-automatic-notifyonly``, have been dropped. Only one ``dnf5-automatic`` timer is shipped.
* See the :ref:`Automatic command <automatic_plugin_ref-label>` for more information.

Expand Down
4 changes: 2 additions & 2 deletions doc/dnf5_plugins/automatic.8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Description

Alternative CLI to ``dnf upgrade`` with specific facilities to make it suitable to be executed automatically and regularly from systemd timers, cron jobs and similar.

The operation of the tool is controlled by configuration files. Default values are set from ``/usr/share/dnf5/dnf5-plugins/automatic.conf`` config file. Host-specific overrides from ``/etc/dnf/dnf5-plugins/automatic.conf`` are then applied.
The operation of the tool is controlled by configuration files. Default values are set from ``/usr/share/dnf5/dnf5-plugins/automatic.conf`` config file. Host-specific overrides from ``/etc/dnf/automatic.conf`` are then applied.

The tool synchronizes package metadata as needed and then checks for updates available for the given system and then either exits, downloads the packages or downloads and applies the updates. The outcome of the operation is then reported by a selected mechanism, for instance via the standard output, email or MOTD messages.

Expand Down Expand Up @@ -65,7 +65,7 @@ The following options can be used to override values from the configuration file
Run dnf5 automatic service
==========================

The service is typically executed using the systemd timer ``dnf5-automatic.timer``. To configure the service, customize the ``/etc/dnf/dnf5-plugins/automatic.conf`` file. You can either copy the distribution config file from ``/usr/share/dnf5/dnf5-plugins/automatic.conf`` and use it as a baseline, or create your own configuration file from scratch with only the required overrides.
The service is typically executed using the systemd timer ``dnf5-automatic.timer``. To configure the service, customize the ``/etc/dnf/automatic.conf`` file. You can either copy the distribution config file from ``/usr/share/dnf5/dnf5-plugins/automatic.conf`` and use it as a baseline, or create your own configuration file from scratch with only the required overrides.

Then enable the timer unit:

Expand Down
Loading