-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
replay
command to replay stored transactions
In comparison to dnf4 the command: - is no longer a `history` subcommand, it is a standalone command. - accepts as an argument a path to a directory where the transaction is stored. This is because now any transaction can be stored using the `--store` option which also stores the elements (packages, groups..) of the transaction.
- Loading branch information
Showing
13 changed files
with
158 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
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 <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "replay.hpp" | ||
|
||
#include <dnf5/shared_options.hpp> | ||
#include <libdnf5/utils/bgettext/bgettext-mark-domain.h> | ||
|
||
namespace dnf5 { | ||
|
||
void ReplayCommand::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 ReplayCommand::set_argument_parser() { | ||
auto & cmd = *get_argument_parser_command(); | ||
cmd.set_description("Replay a transaction that was previously stored to a directory"); | ||
auto & ctx = get_context(); | ||
auto & parser = ctx.get_argument_parser(); | ||
|
||
auto * transaction_path_arg = parser.add_new_positional_arg("transaction-path", 1, nullptr, nullptr); | ||
transaction_path_arg->set_description("Path to a directory with stored transaction."); | ||
transaction_path_arg->set_parse_hook_func([this]( | ||
[[maybe_unused]] libdnf5::cli::ArgumentParser::PositionalArg * arg, | ||
[[maybe_unused]] int argc, | ||
const char * const argv[]) { | ||
transaction_path = argv[0]; | ||
return true; | ||
}); | ||
cmd.register_positional_arg(transaction_path_arg); | ||
|
||
auto skip_unavailable = std::make_unique<SkipUnavailableOption>(*this); | ||
} | ||
|
||
void ReplayCommand::configure() { | ||
auto & context = get_context(); | ||
context.set_load_system_repo(true); | ||
context.set_load_available_repos(Context::LoadAvailableRepos::ENABLED); | ||
} | ||
|
||
void ReplayCommand::run() { | ||
auto & context = get_context(); | ||
auto settings = libdnf5::GoalJobSettings(); | ||
|
||
//TODO(amatej): add `--ignore-installed` and `--ignore-extras` options | ||
|
||
try { | ||
context.get_goal()->add_serialized_transaction(transaction_path + TRANSACTION_JSON, settings); | ||
} catch (const libdnf5::Error & ex) { | ||
throw libdnf5::cli::CommandExitError( | ||
1, M_("Error while handling: {}: {}"), transaction_path, std::string(ex.what())); | ||
} | ||
} | ||
|
||
} // namespace dnf5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ DNF5 Commands | |
provides.8 | ||
reinstall.8 | ||
remove.8 | ||
replay.8 | ||
repo.8 | ||
repoquery.8 | ||
search.8 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
.. | ||
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 <https://www.gnu.org/licenses/>. | ||
|
||
.. _replay_command_ref-label: | ||
|
||
############### | ||
Replay Command | ||
############### | ||
|
||
Synopsis | ||
======== | ||
|
||
``dnf5 replay [options] <transaction-path>`` | ||
|
||
|
||
Description | ||
=========== | ||
|
||
Replay a transaction stored in a directory at ``<transaction-path>``. The transaction directory can be created either by | ||
the ``--store`` option, available for all transaction commands, or by `History Store Command`. The replay will perform | ||
the exact same operations on the packages as in the original transaction and will return with an error in case of any | ||
differences in installed packages or their versions. | ||
|
||
To run the replay the transaction directory has to contain a file with the transaction in JSON format named ``transaction.json``. | ||
The directory can also contain packages, comps groups or comps environments that will be used used in the replayed transaction. | ||
|
||
|
||
Options | ||
======= | ||
|
||
``--skip-unavailable`` | ||
| In case some packages stored in the transaction are not available on the target system, | ||
| skip them instead of erroring out. | ||
|
||
Examples | ||
======== | ||
|
||
``dnf5 replay ./transaction`` | ||
| Replay a transaction stored at ./transaction. | ||
``dnf5 replay ./transaction --skip-unavailable`` | ||
| Replay a transaction stored at ./transaction skipping unavailable packages. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters