List missing dependencies of uninstalled package

Is there a way to get a list of missing capabilities and packages that provide them for a given uninstalled package? Similar to dnf repoquery --deplist <uninstalled package> but excluding satisfied dependencies.

1 Like

dnf check dependencies will show what dependencies are missing for all packages. There doesn’t seem to be a way to limit it to one package, but you can always grep.

1 Like

Another way might be to use dnf install <package> and look at the list of dependencies it wants to install for that package before continuing. That list would only be the ones not already installed.

3 Likes

If I understand correctly it checks the dependencies of installed packages, it can’t take an uninstalled package as argument, right?

You are correct. @computersavvy’s method is what you want.

1 Like

if you just want the list you can add --assumeno

4 Likes

It’s a little messy but here you go:

dnf repoquery --requires --resolve <PACKAGE> 2>/dev/null | xargs rpm -q | grep "not installed" | cut -d' ' -f2

Obviously, replace <PACKAGE> with what you want to query, like nagios, etc.

3 Likes

tl;dr

package="PACKAGE NAME" ; sudo -v && awk '!/^  dependency: |^   provider: / && NR > FNR; /^  dependency: /{dep=$0 ORS; next} NR == FNR{not_installed[$0]; next} $2 in not_installed{print dep $0; dep=""}' <(sudo dnf install "$package" --assumeno 2>/dev/null | awk '/^Installing dependencies:/{printswitch=1; next} /^$/{printswitch=0} printswitch{print $1 "-" $3 "." $2}') <(dnf repoquery --deplist --latest-limit 1 "$package")

replace <PACKAGE NAME> according to your needs. It’s not pretty but it does the job.


There’s a problem with my and Scott’s code: for instance on my system dnf install mplayer reports DNF is going to install just two dependency packages, enca and mplayer-common, and neither of them drags down additional packages if I try to install it individually (e.g. dnf install enca). Our commands count 9 dependency packages in my system. @vwbusguy, could it be that your command is listing uninstalled packages that provide capabilities that are satisfied by another installed package?

Update: I replaced Scott’s command with sudo dnf install $package --assumeno (from @grumpey and @computersavvy’s answers):

sudo -v && package="<PACKAGE NAME>" ; awk '/^  dependency: /{dep=$0 ORS; next} NR == FNR{not_installed[$0]; next} $2 in not_installed{print dep $0; dep=""}' <(sudo dnf install "$package" --assumeno 2>/dev/null | awk '/^Installing dependencies:/{printswitch=1; next} /^$/{printswitch=0} printswitch{print $1 "-" $3 "." $2}') <(dnf repoquery --deplist "$package")

now it’s even messier than my first attempt but the output is what I was aiming for.

Output with package="mplayer":

Last metadata expiration check: 4:25:07 ago on Sat 16 Jul 2022 08:45:43 CEST.
  dependency: libenca.so.0()(64bit)
   provider: enca-1.19-9.fc36.x86_64
  dependency: mplayer-common = 1.5-1.fc36
   provider: mplayer-common-1.5-1.fc36.x86_64

Update 2: There’s a further problem that may arise when $package matches multiple packages in dnf repoquery --deplist "$package". For example, currently mplayer only matches mplayer-1.5-1.fc36.x86_64 but asymptote matches asymptote-2.75-3.fc36.x86_64 and asymptote-2.81-1.fc36.x86_64. In the latter case there will be unwanted lines in the output, but I have an updated, messier command that solves the issue by introducing --latest-limit 1 in the dnf repoquery --deplist "$package" command; this version also lets Awk print the package’s name:

package="PACKAGE NAME" ; sudo -v && awk '!/^  dependency: |^   provider: / && NR > FNR; /^  dependency: /{dep=$0 ORS; next} NR == FNR{not_installed[$0]; next} $2 in not_installed{print dep $0; dep=""}' <(sudo dnf install "$package" --assumeno 2>/dev/null | awk '/^Installing dependencies:/{printswitch=1; next} /^$/{printswitch=0} printswitch{print $1 "-" $3 "." $2}') <(dnf repoquery --deplist --latest-limit 1 "$package")

Shall we have a mess contest? (-:

My candidate is

package="<PACKAGE NAME>" ; awk '/^  dependency: /{dep=$0 ORS; next} NR == FNR{not_installed[$0]; next} $2 in not_installed{print dep $0; dep=""}' <(dnf repoquery --requires --resolve $package --qf "%{name}-%{version}-%{release}.%{arch}" 2>/dev/null | xargs rpm -q | grep "not installed" | cut -d' ' -f2) <(dnf repoquery --deplist "$package")

What it does basically is to run Awk on both the output of dnf repoquery --deplist "$package" and the output of your command (with formatting tweaked to match that of dnf repoquery --deplist "$package"),

dnf repoquery --requires --resolve $package --qf "%{name}-%{version}-%{release}.%{arch}" 2>/dev/null | xargs rpm -q | grep "not installed" | cut -d' ' -f2

If a package is in the output of your command – i.e. it is not installed – then it prints the dependency: line from the output of dnf repoquery --deplist "$package" followed by the name of that package.

For example,

package="mplayer" ; awk '/^  dependency: /{dep=$0 ORS; next} NR == FNR{not_installed[$0]; next} $2 in not_installed{print dep $0; dep=""}' <(dnf repoquery --requires --resolve $package --qf "%{name}-%{version}-%{release}.%{arch}" 2>/dev/null | xargs rpm -q | grep "not installed" | cut -d' ' -f2) <(dnf repoquery --deplist "$package")

in my system prints

Waiting for process with pid 10467 to finish.
Last metadata expiration check: 1:36:23 ago on Sat 16 Jul 2022 08:45:43 CEST.
  dependency: libavcodec.so.59()(64bit)
   provider: libavcodec-free-5.0.1-11.fc36.x86_64
  dependency: libavcodec.so.59(LIBAVCODEC_59)(64bit)
   provider: libavcodec-free-5.0.1-11.fc36.x86_64
  dependency: libavformat.so.59()(64bit)
   provider: libavformat-free-5.0.1-11.fc36.x86_64
  dependency: libavformat.so.59(LIBAVFORMAT_59)(64bit)
   provider: libavformat-free-5.0.1-11.fc36.x86_64
  dependency: libavutil.so.57()(64bit)
   provider: libavutil-free-5.0.1-11.fc36.x86_64
  dependency: libavutil.so.57(LIBAVUTIL_57)(64bit)
   provider: libavutil-free-5.0.1-11.fc36.x86_64
  dependency: libenca.so.0()(64bit)
   provider: enca-1.19-9.fc36.x86_64
  dependency: libjack.so.0()(64bit)
   provider: jack-audio-connection-kit-1.9.20-2.fc36.x86_64
  dependency: libpostproc.so.56()(64bit)
   provider: libpostproc-free-5.0.1-11.fc36.x86_64
  dependency: libpostproc.so.56(LIBPOSTPROC_56)(64bit)
   provider: libpostproc-free-5.0.1-11.fc36.x86_64
  dependency: libswresample.so.4()(64bit)
   provider: libswresample-free-5.0.1-11.fc36.x86_64
  dependency: libswresample.so.4(LIBSWRESAMPLE_4)(64bit)
   provider: libswresample-free-5.0.1-11.fc36.x86_64
  dependency: libswscale.so.6()(64bit)
   provider: libswscale-free-5.0.1-11.fc36.x86_64
  dependency: libswscale.so.6(LIBSWSCALE_6)(64bit)
   provider: libswscale-free-5.0.1-11.fc36.x86_64
  dependency: mplayer-common = 1.5-1.fc36
   provider: mplayer-common-1.5-1.fc36.x86_64

For comparison, the output of dnf repoquery --deplist mplayer is 145 lines long. I also checked the number of distinct packages in the output of my command and it’s the same as with yours.

This is exactly what should be expected if all the dependencies of the proposed package to be installed are already in place.

Remember that the dnf install PACKAGE parses the dependencies of PACKAGE then offers to install only those that are not already installed. It seems using dnf is the cleanest method to get the info requested by the OP in the thread title.

2 Likes