Skip to content

ENH,REQ: dnf install --json #1799

@westurner

Description

@westurner

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

# TC1: In order to install vim-enhanced in a ~devcontainer,
#      install all of these packages *without installing X (libX*)* and tracker-miners, etc:

# setUp() {
#   # echo "FROM fedora-toolbox:41" >> Dockerfile
#
#   dnf install -y toolbox
#   toolbox create -i fedora-toolbox:41 -n dnftest && toolbox enter dnftest
# 
#   dnf install -y distrobox
#   distrobox create -i fedora-toolbox:41 -n dnftest && distrobox enter dnftest 
# }

pkgs="vim-enhanced powerline-fonts fzf python3-virtualenv ruff black python3-pyflakes python3-flake8 python3-lsp-server python3-jupyter-lsp"
sudo dnf install $pkgs
# ...
# Transaction Summary:
# Installing:      343 packages
# Upgrading:         2 packages
# Replacing:         2 packages


## To determine which pkgspec passed to dnf install is resulting in X being installed:
for pkg in $pkgs; do (set -x; dnf install --assumeno "${pkg}"); done
#  Downsides:
#  - $pkgs is not correctly quoted; it probably should be `IFS=" " read args; for arg in "${args[@]}"`
#  - This simulates installing each package independently, not all at once
#  - This has to open and close the database for each command invocation


dnf repoquery --help | grep queryformat


## To *approximate* dnf install with repoquery --qf="depends, requires, suggests, supplements"
for pkg in $pkgs; do (set -x; dnf repoquery --queryformat='## Depends\n%{depends}## Requires\n%{requires}## Suggests\n%{suggests}## Supplements\n%{supplements}\n' "${pkg}"); done
#  Downsides:
#  - this isn't JSON, you must parse the pkgspecs, are they?
#  - this doesn't optionally list the 'suggests' and 'supplements' only if those flags were passed


# Ideally, there would be simple cli opt like --tree or --deplist
# that shows the (space-indented or json) recursive list of packages that will be installed;
# something like:

dnf install --show-recursive-dependency-list-first [ --json [-o <dnf.log.json>]] 

dfn install --deplist --json [-o <dnf.log.json>]] 

dnf install --deplist
dnf install --json     # could imply --deplist  # or whatever the opt should be called

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority: LOWRFERequest For Enhancement (as opposed to a bug)TriagedSomeone on the DNF 5 team has read the issue and determined the next steps to take

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions