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 history command #140

Closed
Tracked by #429
mcurlej opened this issue Nov 11, 2022 · 14 comments
Closed
Tracked by #429

Implement history command #140

mcurlej opened this issue Nov 11, 2022 · 14 comments
Assignees
Labels
epic Priority: HIGH RFE Request For Enhancement (as opposed to a bug) Triaged Someone on the DNF 5 team has read the issue and determined the next steps to take
Milestone

Comments

@mcurlej
Copy link
Member

mcurlej commented Nov 11, 2022

Command: history
Aliases: hist

The history command allows the user to view what has happened in past transactions and act according to this information (assuming the history_record configuration option is set).

dnf history [list] [--reverse] [<spec>...]

The default history action is listing information about given transactions in a table. Each <spec> can be either a <transaction-spec>, which specifies a transaction directly, or a <transaction-spec>..<transaction-spec>, which specifies a range of transactions, or a <package-name-spec>, which specifies a transaction by a package which it manipulated. When no transaction is specified, list all known transactions.

--reverse

The order of history list output is printed in reverse order.

dnf history info [<spec>...]

Describe the given transactions. The meaning of <spec> is the same as in the History List Command. When no transaction is specified, describe what happened during the latest transaction.

dnf history redo <transaction-spec>|<package-file-spec>

Repeat the specified transaction. Uses the last transaction (with the highest ID) if more than one transaction for given is found. If it is not possible to redo some operations due to the current state of RPMDB, it will not redo the transaction.

dnf history replay [--ignore-installed] [--ignore-extras] [--skip-unavailable] <filename>

Replay a transaction stored in file <filename> 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 if case of any differences in installed packages or their versions. See also the Transaction JSON Format specification of the file format.

--ignore-installed

Don’t check for the installed packages being in the same state as those recorded in the transaction. E.g. in case there is an upgrade foo-1.0 -> foo-2.0 stored in the transaction, but there is foo-1.1 installed on the target system.

--ignore-extras

Don’t check for extra packages pulled into the transaction on the target system. E.g. the target system may not have some dependency, which was installed on the source system. The replay errors out on this by default, as the transaction would not be the same.

--skip-unavailable

In case some packages stored in the transaction are not available on the target system, skip them instead of erroring out.

dnf history rollback <transaction-spec>|<package-file-spec>

Undo all transactions performed after the specified transaction. Uses the last transaction (with the highest ID) if more than one transaction for given is found. If it is not possible to undo some transactions due to the current state of RPMDB, it will not undo any transaction.

dnf history store [--output <output-file>] <transaction-spec>

Store a transaction specified by <transaction-spec>. The transaction can later be replayed by the History Replay Command.

Warning: The stored transaction format is considered unstable and may change at any time. It will work if the same version of dnf is used to store and replay (or between versions as long as it stays the same).

-o <output-file>, --output=<output-file> Store the serialized transaction into <output-file>. Default is transaction.json.

```dnf history undo |````

Perform the opposite operation to all operations performed in the specified transaction. Uses the last transaction (with the highest ID) if more than one transaction for given <package-file-spec> is found. If it is not possible to undo some operations due to the current state of RPMDB, it will not undo the transaction.

dnf history userinstalled

Show all installonly packages, packages installed outside of DNF and packages not installed as dependency. I.e. it lists packages that will stay on the system when Autoremove Command or Remove Command along with clean_requirements_on_remove configuration option set to True is executed. Note the same results can be accomplished with dnf repoquery --userinstalled, and the repoquery command is more powerful in formatting of the output.

This command by default does not force a sync of expired metadata, except for the redo, rollback, and undo subcommands. See also Metadata Synchronization and Configuration Files Replacement Policy.

@mcurlej mcurlej added the RFE Request For Enhancement (as opposed to a bug) label Nov 11, 2022
@mcurlej mcurlej added this to DNF team Nov 24, 2022
@mcurlej mcurlej moved this to Backlog in DNF team Nov 24, 2022
@AdamWill
Copy link
Contributor

it seems like as of right now this is partially implemented, but not fully. notably:

[adamw@xps13a blivet (prefer-gpt-x86_64)]$ dnf history list ostree
Invalid transaction ID range "ostree", "ID" or "ID..ID" expected, where ID is "NUMBER", "last" or "last-NUMBER".
[adamw@xps13a blivet (prefer-gpt-x86_64)]$ 

i.e. you can't do history list (or, in fact, history info) by package name. It seems to only expect history transaction IDs. querying by package name is very useful and missing it is somewhat significant.

@kontura
Copy link
Contributor

kontura commented Jan 15, 2024

Make sure rpm-software-management/dnf#2031 is fixed in the new rollback implementation.

@voxik
Copy link

voxik commented Feb 28, 2024

Is there a chance to prioritize the undo / rollback functionality? I'd say this is in my experience the last missing bit to make the DNF5 fully usable for me.

@jan-kolarik
Copy link
Member

Is there a chance to prioritize the undo / rollback functionality? I'd say this is in my experience the last missing bit to make the DNF5 fully usable for me.

After the completion of the system upgrade and related offline transactions (PoC already in review here), I'd say this currently stands as our second-highest priority issue. Given the significant overlap between the transactions store and replay functionality in the history command and the mentioned system-upgrade functionality, there shouldn't be an extensive amount of remaining work.

@jan-kolarik jan-kolarik modified the milestones: Fedora 40, Fedora 41 May 13, 2024
@jan-kolarik jan-kolarik moved this from Backlog to In Progress in DNF team May 13, 2024
@retrixe
Copy link

retrixe commented Aug 26, 2024

Minor nit with the existing implementations of history info/undo/rollback in v5.2.5.0, numbers less than 1 e.g. 0 to specify the last transaction, -1 to specify the one before, etc, don't work (apologies if this is already known)

@kontura
Copy link
Contributor

kontura commented Nov 4, 2024

As far as I remember, dnf history worked just fine

I don't think we will be bringing back the optional subcommands. We have it documented here: https://dnf5.readthedocs.io/en/latest/changes_from_dnf4.7.html#optional-arguments

@kontura
Copy link
Contributor

kontura commented Nov 4, 2024

Ah, you are right, the docs are wrong, optional arguments are allowed.

Both dnf upgrade and dnf upgrade htop are fine.

The problem was only with optional subcommads. I will fix the docs.

Is it really too much work to have dnf history as an alias to dnf history list?

Probably not, but it would reintroduce the ambiguity.
While it may not be such a big problem for history (because it accepts only transaction ids) it is a problem for for example group list command and we would like if all the subcommands behaved the same way.

@github-project-automation github-project-automation bot moved this from In Progress to Done in DNF team Nov 26, 2024
@damaestro
Copy link

The default dnf history behavior is confusing. If we are not going to default to list as DNF4 did, please just show the help.

Rather than showing the easily misinterpreted output:

Missing command. Add "--help" for more information about the arguments.

Please just show the --help information:

Usage:
  dnf5 [GLOBAL OPTIONS] history <COMMAND> ...
                                
Query Commands:                 
  list                          List transactions
  info                          Print details about transactions
                                
Software Management Commands:   
  undo                          Revert all actions from the specified transactio
                                n
  redo                          Repeat all actions from the specified transactio
                                n
  rollback                      Undo all transactions performed after the specif
                                ied transaction
  store                         [experimental] Store transaction to a file

If that is too much to ask, please update the error message to make it not seem like dnf doesn't have a history command and give the user better clarity. The current output is easily interpreted as the history command is what is missing.

@ppisar
Copy link
Contributor

ppisar commented Nov 29, 2024

Printing a usage text on a bad invocation is a terrible idea. If the text is long enough, it scrolls the error message away. In my option, the current behavior is guiding enough, it literally says to use "--help" option. Please bear mind that your suggestion would affect all commands. Not only "dnf5 history".

@damaestro
Copy link

Maybe:

Missing argument. Try "history list". Add "--help" for more information about available arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic Priority: HIGH RFE Request For Enhancement (as opposed to a bug) Triaged Someone on the DNF 5 team has read the issue and determined the next steps to take
Projects
Archived in project
Development

No branches or pull requests

10 participants