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

rpm-ostree dnf info -> dnf info #5170

Open
westurner opened this issue Nov 24, 2024 · 3 comments
Open

rpm-ostree dnf info -> dnf info #5170

westurner opened this issue Nov 24, 2024 · 3 comments

Comments

@westurner
Copy link

westurner commented Nov 24, 2024

rpm-ostree dnf info would be super convenient.

Also or instead, dnf info could work on rpm-ostree systems;
though as far as general dnf <command> support,
dnf commands that don't change anything (that do not mutate state) could work on rpm-ostree systems

Workarounds:

  • rpm -q --whatprovides "${filepath}"
  • rpm -qi "${pkgname}"
    • this only works for packages that are already installed,
      whereas dnf info pulls the package catalogs and
      lists both: "Installed packages" and "Available packages"
  • Create a toolbox and run dnf in the toolbox container;
    toolbox create; toolbox run dnf info <path>
    • but a container may have a different distro+release or image
    • and probably has different different packages installed than the host
  • rpm-ostree install dnf5
    • There is a reason that /usr/bin/dnf isn't already installed on rpm-ostree systems;
      but rpm-ostree calls into libdnf,
      so dnf info could work on rpm-ostree systems.
/usr/bin/python -m dnf.cli.main info

alias dnf='/usr/bin/python -m dnf.cli.main'
dnf info --help

Tasks:

Decide on a CLI commands passthrough syntax:

  • $ rpm-ostree info -> dnf info
  • $ rpm-ostree dnf info -> dnf info
  • $ rpm-ostree dnf {info,} -> dnf {}
    • Which commands in addition to info, should pass through?
      • justify dnf info:
        • dnf info doesn't change anything
@westurner westurner changed the title rpm-ostree dnf info -> dnf info (instead of having to look up rpm -q --whatprovides <path>) rpm-ostree dnf info -> dnf info Nov 24, 2024
@westurner
Copy link
Author

#alias dnf='python -m dnf.cli.main'
alias dnf='/usr/bin/python -m dnf.cli.main'
python -m dnf.cli.main -h
python -m dnf.cli.main search --help
python -m dnf.cli.main repoquery --help

python -m dnf.cli.main search kernel-core

python -m dnf.cli.main repoquery --whatdepends kernel-core
python -m dnf.cli.main repoquery --whatprovides kernel-core
python -m dnf.cli.main repoquery --provides kernel-core 

python -m dnf.cli.main repoquery --installed
python -m dnf.cli.main repoquery --userinstalled   #
python -m dnf.cli.main history list 0..1
for n in $(python -m dnf.cli.main history list | awk '{ print $1 }' | tail -n+3 | sort -n); do (set -x; python -m dnf.cli.main history store -o dnf_transaction.${n}.json "$n"); done  #

(set -e; for installroot  in /sysroot/ostree/deploy/fedora/deploy/*; do python -m dnf.cli.main --installroot="${installroot}" repoquery --installed; done)  # err: /var/tmp isn't writeable


python -m dnf.cli.main repoquery --whatprovides /bin/bash
python -m dnf.cli.main repoquery --whatprovides /etc/systemd


ls -al /usr/lib/python3.13/site-packages/dnf/cli/commands/search.py
python -m dnf.cli.main repoquery --whatprovides "$_"
rpm-ostree status --json | grep dnf
rpm-ostree status --json | jq '.' | grep dnf

rpm -qa | grep dnf | grep python3
rpm -ql python3-dnf

To list (security) updates with /usr/bin/python -m dnf.cli.main :

alias dnf='/usr/bin/python -m dnf.cli.main'
dnf updateinfo 
dnf updateinfo --help 
dnf updateinfo --updates 
dnf updateinfo --updates --list 
dnf updateinfo --updates --info 

dnf updateinfo --security --list
dnf updateinfo --security --info

From "How to search from repositories for rpms to be installed without dnf in Silverblue" https://discussion.fedoraproject.org/t/how-to-search-from-repositories-for-rpms-to-be-installed-without-dnf-in-silverblue/72738/5 , when I finally figured this out last week:

python -m dnf.cli.main history list 0..1 | cat | 
python -m dnf.cli.main history list 0..1
for n in $(python -m dnf.cli.main history list | awk '{ print $1 }' | tail -n+3 | sort -n); do (set -x; python -m dnf.cli.main history store -o dnf_transaction.${n}.json "$n"); done  #

It's necessary to change the column width to get the history list command to print full width output like ps -w?:

cols_before=$(tput cols)
stty columns 999999
dnf history list | wc -L
stty columns "${cols_before}"

And then also "Can I query the version of a specific (layered) dnf package in rpm-ostree?"

This might be possible by trying each ... "--installroot" :

for installroot in $(ls /sysroot/ostree/deploy/fedora/deploy/*/); do
   echo "# layer: ${installroot}"
    /usr/bin/python -m dnf.cli.main --installroot="${installroot}" repoquery --installed
done

Not quite, because it can't write to /var/tmp for what should be a read-only query:

Config error: [Errno 30] Read-only file system: '/sysroot/ostree/deploy/fedora/deploy/[...].0/var/tmp': '/sysroot/ostree/deploy/fedora/deploy/[...].0/var/tmp'

@westurner
Copy link
Author

westurner commented Feb 7, 2025

So, the currently working solution to this is:

alias dnf='/usr/bin/python -m dnf.cli.main
dnf info --help

This could just be in the default /etc/[skel/]profile; though dnf won't fail with something like "This dnf command doesn't work on an rpm-ostree system"

And, will the dnf4 python CLI continue to be installed by default in [distros X, Y, and Z] images, given that dnf5 is a rewrite to cpp?

https://github.com/rpm-software-management/dnf5/blob/main/dnf5/main.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant