-
Notifications
You must be signed in to change notification settings - Fork 87
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
ENH,REQ: dnf install --json #1799
Comments
Here's how to read the trasaction json files with the |
Do I understand correctly that the new switch is intended to print the transaction table in a machine-readable format? One challenge with the Also, keep in mind that a transaction initiated by package installation might include not only dependency installations but also upgrades or downgrades of dependent packages, and potentially even removal of conflicting packages (if the You can also create your own simple script tailored for your use-case using
|
The --json flag would write machine-readable JSON
I wrote that patch to write (the shell command field of) all transactions
without truncation, and then as JSON; and then I was trying to determine
which package dependency was causing Xorg and hundreds of additional
packages to installed.
If dnf install could display the complete dependency graph, as
machine-readable JSON, users could parse the JSON to understand why each
package is being installed, upgraded, or removed
Thanks for the dnf5 API usage example; is that already in the docs?
Presumably installing packages with the Python API does not (yet?) add a
transaction with an equivalent shell command for dnf history?
…---------- Forwarded message ---------
From: Marek Blaha ***@***.***>
Date: Thu, Oct 31, 2024, 3:10 AM
Subject: Re: [rpm-software-management/dnf5] ENH,REQ: dnf install --json
(Issue #1799)
To: rpm-software-management/dnf5 ***@***.***>
Cc: Wes Turner ***@***.***>, Author ***@***.***>
Do I understand correctly that the new switch is intended to print the
transaction table in a machine-readable format? One challenge with the
install command is that it’s somewhat interactive, requiring user
confirmation for the transaction that will be executed. This proposal could
work if paired with the --assumeno option, but it may feel awkward if the
user has to confirm a transaction presented in JSON format.
Also, keep in mind that a transaction initiated by package installation
might include not only dependency installations but also upgrades or
downgrades of dependent packages, and potentially even removal of
conflicting packages (if the --allowerasing option is used).
You can also create your own simple script tailored for your use-case using
dnf5 API. For example:
#!/usr/bin/python3
import libdnf5
# Initialize
base = libdnf5.base.Base()
base.load_config()
base.setup()
repo_sack = base.get_repo_sack()
repo_sack.create_repos_from_system_configuration()
repo_sack.load_repos()
# Create a goal, which is a class that allows to add items for resolving into
# a transaction.
goal = libdnf5.base.Goal(base)
# Add package specs for installation into the goal.
for pkgspec in ["vim-enhanced", "powerline-fonts", "fzf",
"python3-virtualenv", "ruff"]:
goal.add_rpm_install(pkgspec)
# Resolve the goal, create a transaction object.
transaction = goal.resolve()
# Now you can iterate the resolved transaction and print it in desired format
print("Resolved transaction:")
for tspkg in transaction.get_transaction_packages():
print(tspkg.get_package().get_nevra(), ": ",
libdnf5.base.transaction.transaction_item_action_to_string(tspkg.get_action()))
—
Reply to this email directly, view it on GitHub
<#1799 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAMNS6ABU2WTMEU7JIQFQ3Z6HJX3AVCNFSM6AAAAABQTZTNDOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBZGE3TIOJQGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Related: #867. |
ENH,REQ,STORY: Users can show the (space-indented (by default) or JSON) recursive list of packages that will be installed with a CLI option to
dnf install
like--pkgtrees
or--deplist
and also--json
The text was updated successfully, but these errors were encountered: