diff --git a/dnf5/commands/debuginfo-install/debuginfo-install.cpp b/dnf5/commands/debuginfo-install/debuginfo-install.cpp
new file mode 100644
index 000000000..6dee2887b
--- /dev/null
+++ b/dnf5/commands/debuginfo-install/debuginfo-install.cpp
@@ -0,0 +1,79 @@
+/*
+Copyright Contributors to the libdnf project.
+
+This file is part of libdnf: https://github.com/rpm-software-management/libdnf/
+
+Libdnf is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+Libdnf is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with libdnf. If not, see .
+*/
+
+#include "debuginfo-install.hpp"
+
+#include
+
+#include
+
+
+namespace dnf5 {
+
+
+using namespace libdnf5::cli;
+
+
+void DebuginfoInstallCommand::set_parent_command() {
+ auto * arg_parser_parent_cmd = get_session().get_argument_parser().get_root_command();
+ auto * arg_parser_this_cmd = get_argument_parser_command();
+ arg_parser_parent_cmd->register_command(arg_parser_this_cmd);
+ arg_parser_parent_cmd->get_group("software_management_commands").register_argument(arg_parser_this_cmd);
+}
+
+void DebuginfoInstallCommand::set_argument_parser() {
+ auto & ctx = get_context();
+ auto & parser = ctx.get_argument_parser();
+ auto & cmd = *get_argument_parser_command();
+
+ get_argument_parser_command()->set_description("Install debuginfo packages.");
+
+ allow_erasing = std::make_unique(*this);
+ auto skip_broken = std::make_unique(*this);
+ auto skip_unavailable = std::make_unique(*this);
+
+ patterns_to_debuginfo_install_options = parser.add_new_values();
+ auto patterns_arg = parser.add_new_positional_arg(
+ "patterns",
+ ArgumentParser::PositionalArg::AT_LEAST_ONE,
+ parser.add_init_value(std::unique_ptr(new libdnf5::OptionString(nullptr))),
+ patterns_to_debuginfo_install_options);
+ patterns_arg->set_description("Patterns");
+ cmd.register_positional_arg(patterns_arg);
+}
+
+void DebuginfoInstallCommand::configure() {
+ auto & context = get_context();
+ context.set_load_system_repo(true);
+ context.set_load_available_repos(Context::LoadAvailableRepos::ENABLED);
+ context.get_base().get_repo_sack()->enable_debug_repos();
+}
+
+void DebuginfoInstallCommand::run() {
+ auto goal = get_context().get_goal();
+ auto settings = libdnf5::GoalJobSettings();
+ goal->set_allow_erasing(allow_erasing->get_value());
+
+ for (const auto & pattern : *patterns_to_debuginfo_install_options) {
+ auto option = dynamic_cast(pattern.get());
+ goal->add_debug_install(option->get_value(), settings);
+ }
+}
+
+} // namespace dnf5
diff --git a/dnf5/commands/debuginfo-install/debuginfo-install.hpp b/dnf5/commands/debuginfo-install/debuginfo-install.hpp
new file mode 100644
index 000000000..1294c78a8
--- /dev/null
+++ b/dnf5/commands/debuginfo-install/debuginfo-install.hpp
@@ -0,0 +1,47 @@
+/*
+Copyright Contributors to the libdnf project.
+
+This file is part of libdnf: https://github.com/rpm-software-management/libdnf/
+
+Libdnf is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+Libdnf is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with libdnf. If not, see .
+*/
+
+
+#ifndef DNF5_COMMANDS_DEBUGINFO_INSTALL_DEBUGINFO_INSTALL_HPP
+#define DNF5_COMMANDS_DEBUGINFO_INSTALL_DEBUGINFO_INSTALL_HPP
+
+#include
+#include
+
+namespace dnf5 {
+
+
+class DebuginfoInstallCommand : public Command {
+public:
+ explicit DebuginfoInstallCommand(Context & context) : Command(context, "debuginfo-install") {}
+ void set_parent_command() override;
+ void set_argument_parser() override;
+ void configure() override;
+ void run() override;
+
+ std::vector> * patterns_to_debuginfo_install_options{nullptr};
+
+ std::unique_ptr allow_erasing;
+};
+
+
+} // namespace dnf5
+
+
+#endif // DNF5_COMMANDS_DEBUGINFO_INSTALL_DEBUGINFO_INSTALL_HPP
diff --git a/dnf5/main.cpp b/dnf5/main.cpp
index c8bdcf7dc..314ac2c53 100644
--- a/dnf5/main.cpp
+++ b/dnf5/main.cpp
@@ -23,6 +23,7 @@ along with libdnf. If not, see .
#include "commands/check-upgrade/check-upgrade.hpp"
#include "commands/check/check.hpp"
#include "commands/clean/clean.hpp"
+#include "commands/debuginfo-install/debuginfo-install.hpp"
#include "commands/distro-sync/distro-sync.hpp"
#include "commands/downgrade/downgrade.hpp"
#include "commands/download/download.hpp"
@@ -671,6 +672,7 @@ static void add_commands(Context & context) {
context.add_and_initialize_command(std::make_unique(context));
context.add_and_initialize_command(std::make_unique(context));
context.add_and_initialize_command(std::make_unique(context));
+ context.add_and_initialize_command(std::make_unique(context));
context.add_and_initialize_command(std::make_unique(context));
context.add_and_initialize_command(std::make_unique(context));
context.add_and_initialize_command(std::make_unique(context));
diff --git a/doc/changes.rst b/doc/changes.rst
index 0de9dcd62..8e9130724 100644
--- a/doc/changes.rst
+++ b/doc/changes.rst
@@ -172,6 +172,9 @@ Changes to individual commands
* Existing repository files are not modified; drop-in override files are created instead.
* See the :ref:`config-manager documentation ` for more information.
+``debuginfo-install``
+ * Now does not support `autoupdate` functionality. The permanent enablement of debug repositories can be achieved
+ using `config-manager` command.
``distro-sync``
* Now when any argument doesn't match an installed package, DNF5 fails. The behavior can be modified by the ``--skip-unavailable`` option.
* Dropped ``distrosync`` and ``distribution-synchronization`` aliases.
diff --git a/doc/commands/debuginfo-install.rst b/doc/commands/debuginfo-install.rst
new file mode 100644
index 000000000..8af7cb58d
--- /dev/null
+++ b/doc/commands/debuginfo-install.rst
@@ -0,0 +1,72 @@
+..
+ Copyright Contributors to the libdnf project.
+
+ This file is part of libdnf: https://github.com/rpm-software-management/libdnf/
+
+ Libdnf is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ Libdnf is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with libdnf. If not, see .
+
+.. _debuginfo_install_command_ref-label:
+
+##########################
+ Debuginfo-install Command
+##########################
+
+Synopsis
+========
+
+``dnf5 debuginfo-install [options] ...``
+
+
+Description
+===========
+
+Install the associated debuginfo packages for a given package specification.
+The command temporary enables corresponding debug repository for each enabled
+repository using following algorithm. When enabled repository ID has suffix `-rpm`
+then it enables -debug-rpms. When enabled repository does not have suffix `-rpm`
+it enables repository using pattern -debuginfo.
+
+When regular upgrade of debuginfo packages is expected, then it requires enabling
+of debug repository permanently using `config-manager` command.
+
+Arguments
+=========
+
+````
+ The pattern to install the associated debuginfo package for.
+
+Options
+=======
+
+``--allowerasing``
+ | Allow erasing of installed packages to resolve any potential dependency problems.
+
+``--skip-broken``
+ | Resolve any dependency problems by removing packages that are causing problems from the transaction.
+
+``--skip-unavailable``
+ | Allow skipping packages that are not available in repositories. All available packages will be installed.
+
+
+Examples
+========
+
+``dnf debuginfo-install foobar``
+ Install the debuginfo packages for the foobar package.
+
+``dnf upgrade --enablerepo=*-debuginfo -debuginfo``
+ Upgrade debuginfo package of a .
+
+``dnf upgrade --enablerepo=*-debuginfo "*-debuginfo"``
+ Upgrade all debuginfo packages.
diff --git a/include/libdnf5/base/goal.hpp b/include/libdnf5/base/goal.hpp
index a4a711c0d..fbf2702e1 100644
--- a/include/libdnf5/base/goal.hpp
+++ b/include/libdnf5/base/goal.hpp
@@ -65,6 +65,12 @@ class LIBDNF_API Goal {
/// @param settings A structure to override default goal settings.
void add_install(const std::string & spec, const libdnf5::GoalJobSettings & settings = libdnf5::GoalJobSettings());
+ /// Process spec to install related debug info and debug source packages
+ /// @param spec A string with installation spec
+ /// @param settings A structure to override default goal settings.
+ void add_debug_install(
+ const std::string & spec, const libdnf5::GoalJobSettings & settings = libdnf5::GoalJobSettings());
+
/// High level API for an artifact upgrade. See `add_install()` for details.
/// @param spec A string with upgrade spec
/// @param settings A structure to override default goal settings.
diff --git a/include/libdnf5/base/goal_elements.hpp b/include/libdnf5/base/goal_elements.hpp
index a38a5802c..608ba3bf5 100644
--- a/include/libdnf5/base/goal_elements.hpp
+++ b/include/libdnf5/base/goal_elements.hpp
@@ -152,7 +152,8 @@ enum class GoalAction {
REPLAY_REINSTALL,
REPLAY_REASON_CHANGE,
REPLAY_REASON_OVERRIDE,
- REVERT_COMPS_UPGRADE
+ REVERT_COMPS_UPGRADE,
+ INSTALL_DEBUG
};
/// Convert GoalAction enum to user-readable string
diff --git a/include/libdnf5/repo/repo_sack.hpp b/include/libdnf5/repo/repo_sack.hpp
index d81e536f1..549576d89 100644
--- a/include/libdnf5/repo/repo_sack.hpp
+++ b/include/libdnf5/repo/repo_sack.hpp
@@ -142,6 +142,12 @@ class LIBDNF_API RepoSack : public sack::Sack {
/// @since 5.0
void enable_source_repos();
+ /// For each enabled repository enable corresponding debug repository.
+ /// When repo ID has suffix -rpm then it enables -debug-rpms
+ /// otherwise it enables -debuginfo
+ /// @since 5.2.4
+ void enable_debug_repos();
+
~RepoSack();
private:
diff --git a/libdnf5/base/goal.cpp b/libdnf5/base/goal.cpp
index 6415d0bdd..ccd3561b1 100644
--- a/libdnf5/base/goal.cpp
+++ b/libdnf5/base/goal.cpp
@@ -48,6 +48,7 @@ along with libdnf. If not, see .
#include
#include
#include