From 6e8eb45af55b1d4b919752693af72f94d7233b8b Mon Sep 17 00:00:00 2001 From: Jaroslav Mracek Date: Tue, 23 May 2023 15:15:38 +0200 Subject: [PATCH 1/3] Apply downloadonly configuration for dnf5 The downloadonly is important for several components. --- dnf5/context.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dnf5/context.cpp b/dnf5/context.cpp index af442c1e6..775db43f6 100644 --- a/dnf5/context.cpp +++ b/dnf5/context.cpp @@ -428,6 +428,10 @@ bool Context::check_gpg_signatures(libdnf::base::Transaction & transaction) { void Context::download_and_run(libdnf::base::Transaction & transaction) { transaction.download(); + if (base.get_config().get_downloadonly_option().get_value()) { + return; + } + std::cout << std::endl << "Verifying PGP signatures" << std::endl; if (!check_gpg_signatures(transaction)) { throw libdnf::cli::CommandExitError(1, M_("Signature verification failed")); From 66c273ba555f72a2a923160a0007cdaf852ec067 Mon Sep 17 00:00:00 2001 From: Jaroslav Mracek Date: Wed, 24 May 2023 12:48:07 +0200 Subject: [PATCH 2/3] Add --downloadonly option to multiple commands --- dnf5/commands/downgrade/downgrade.cpp | 1 + dnf5/commands/group/group_install.cpp | 1 + dnf5/commands/install/install.cpp | 1 + dnf5/commands/reinstall/reinstall.cpp | 1 + dnf5/commands/upgrade/upgrade.cpp | 1 + dnf5/include/dnf5/shared_options.hpp | 4 ++++ dnf5/shared_options.cpp | 10 ++++++++++ 7 files changed, 19 insertions(+) diff --git a/dnf5/commands/downgrade/downgrade.cpp b/dnf5/commands/downgrade/downgrade.cpp index 8251b3e62..a87a4effc 100644 --- a/dnf5/commands/downgrade/downgrade.cpp +++ b/dnf5/commands/downgrade/downgrade.cpp @@ -52,6 +52,7 @@ void DowngradeCommand::set_argument_parser() { cmd.register_positional_arg(keys); allow_erasing = std::make_unique(*this); + create_downloadonly_option(*this); auto skip_unavailable = std::make_unique(*this); auto skip_broken = std::make_unique(*this); create_allow_downgrade_options(*this); diff --git a/dnf5/commands/group/group_install.cpp b/dnf5/commands/group/group_install.cpp index 7b5a104ac..b095175c5 100644 --- a/dnf5/commands/group/group_install.cpp +++ b/dnf5/commands/group/group_install.cpp @@ -42,6 +42,7 @@ void GroupInstallCommand::set_argument_parser() { auto skip_unavailable = std::make_unique(*this); auto skip_broken = std::make_unique(*this); create_allow_downgrade_options(*this); + create_downloadonly_option(*this); } void GroupInstallCommand::configure() { diff --git a/dnf5/commands/install/install.cpp b/dnf5/commands/install/install.cpp index 121bec089..99738dabb 100644 --- a/dnf5/commands/install/install.cpp +++ b/dnf5/commands/install/install.cpp @@ -53,6 +53,7 @@ void InstallCommand::set_argument_parser() { cmd.register_positional_arg(keys); allow_erasing = std::make_unique(*this); + create_downloadonly_option(*this); advisory_name = std::make_unique(*this); advisory_security = std::make_unique(*this); diff --git a/dnf5/commands/reinstall/reinstall.cpp b/dnf5/commands/reinstall/reinstall.cpp index f4bb7f73a..be408679d 100644 --- a/dnf5/commands/reinstall/reinstall.cpp +++ b/dnf5/commands/reinstall/reinstall.cpp @@ -51,6 +51,7 @@ void ReinstallCommand::set_argument_parser() { keys->set_complete_hook_func([&ctx](const char * arg) { return match_specs(ctx, arg, true, false, true, true); }); cmd.register_positional_arg(keys); + create_downloadonly_option(*this); auto skip_unavailable = std::make_unique(*this); auto skip_broken = std::make_unique(*this); create_allow_downgrade_options(*this); diff --git a/dnf5/commands/upgrade/upgrade.cpp b/dnf5/commands/upgrade/upgrade.cpp index eee41a153..6bf17dd25 100644 --- a/dnf5/commands/upgrade/upgrade.cpp +++ b/dnf5/commands/upgrade/upgrade.cpp @@ -66,6 +66,7 @@ void UpgradeCommand::set_argument_parser() { allow_erasing = std::make_unique(*this); auto skip_unavailable = std::make_unique(*this); create_allow_downgrade_options(*this); + create_downloadonly_option(*this); advisory_name = std::make_unique(*this); advisory_security = std::make_unique(*this); diff --git a/dnf5/include/dnf5/shared_options.hpp b/dnf5/include/dnf5/shared_options.hpp index 5eed26840..de07a9486 100644 --- a/dnf5/include/dnf5/shared_options.hpp +++ b/dnf5/include/dnf5/shared_options.hpp @@ -66,6 +66,10 @@ void create_allow_downgrade_options(dnf5::Command & command); /// The values are stored in the `destdir` configuration option void create_destdir_option(dnf5::Command & command); +/// Create the `--downloadonly` option for a command provided as an argument. +/// The values are stored in the `downloadonly` configuration option +void create_downloadonly_option(dnf5::Command & command); + } // namespace dnf5 diff --git a/dnf5/shared_options.cpp b/dnf5/shared_options.cpp index 667829256..fe18ff14d 100644 --- a/dnf5/shared_options.cpp +++ b/dnf5/shared_options.cpp @@ -60,5 +60,15 @@ void create_destdir_option(dnf5::Command & command) { command.get_argument_parser_command()->register_named_arg(destdir); } +void create_downloadonly_option(dnf5::Command & command) { + auto & parser = command.get_context().get_argument_parser(); + auto downloadonly = parser.add_new_named_arg("downloadonly"); + downloadonly->set_long_name("downloadonly"); + downloadonly->set_description("Only download packages for a transaction"); + downloadonly->set_const_value("true"); + downloadonly->link_value(&command.get_context().base.get_config().get_downloadonly_option()); + command.get_argument_parser_command()->register_named_arg(downloadonly); +} + } // namespace dnf5 From a3b2b193c6be87621e00b341d3444bdbbeee1d49 Mon Sep 17 00:00:00 2001 From: Jaroslav Mracek Date: Wed, 24 May 2023 14:56:56 +0200 Subject: [PATCH 3/3] Add a message when --downloadonly is used The message clarify what approval of transaction will do. --- dnf5/main.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/dnf5/main.cpp b/dnf5/main.cpp index 3c695f737..7d72dbd2a 100644 --- a/dnf5/main.cpp +++ b/dnf5/main.cpp @@ -769,12 +769,16 @@ int main(int argc, char * argv[]) try { dnf5::print_transaction_size_stats(context); - for (const auto & tsflag : base.get_config().get_tsflags_option().get_value()) { - if (tsflag == "test") { - std::cout - << "Test mode enabled: Only package downloads, pgp key installations and transaction checks " - "will be performed." - << std::endl; + if (base.get_config().get_downloadonly_option().get_value()) { + std::cout << "The operation will only download packages for the transaction." << std::endl; + } else { + for (const auto & tsflag : base.get_config().get_tsflags_option().get_value()) { + if (tsflag == "test") { + std::cout << "Test mode enabled: Only package downloads, pgp key installations and transaction " + "checks " + "will be performed." + << std::endl; + } } }