Linux list package dependencies

How can I check dependency list for a deb package

How can I check dependency list for a deb package. I am running Ubuntu 11.10 and I have backed up all deb packages from var/cache/apt/archives . I want to format my pc and re-install selected applications only. Also how can I get the list of installed packages and dependencies.

For the complete list of installed packages use dpkg —get-selections | sed -n ‘s/[[:space:]]install$//p’

8 Answers 8

This will show you all the information about the package:

Don’t forget to put /var/cache/apt/archives/ before the package name and use tab completion to find the full package name with version, e.g. dpkg -I /var/cache/apt/archives/elasticsearch_2.4.4_all.deb .

You could add that the package can be obtained without (re)installing it (which is probably a popular use case) with sudo apt-get install —reinstall —download-only [package name] .

Note that this (or dpkg-deb as reported elsewhere) will only list the package’s self-reported dependencies. It does not guarantee that if you install everything listed as a dependency, that you will have everything needed to make the package functional. Packages (especially 3rd party ones) typically assume some level of base system components not listed in their dependencies.

In addition to the dpkg method, you can check the dependencies of packages in the repository:

apt-cache depends package-name 

EDIT Updated with @Tino’s recommendation. @Tigran’s comment no longer applies.

depends VS rdepends

  • apt-cache depends package-name
    //show package-name depends on who
  • apt-cache rdepends package-name
    //show who depends on package-name

depends

$ apt-cache depends vim-runtime vim-runtime Breaks: vim-tiny |Recommends: vim vim-athena vim-gtk vim-gtk3 vim-nox |Recommends: vim-gtk |Recommends: vim-gtk3 |Recommends: vim-athena |Recommends: vim-nox Recommends: vim-tiny Enhances: vim-tiny 

rdepends

$ apt-cache rdepends vim-runtime vim-runtime Reverse Depends: vim vim vim-nox vim-gtk vim-athena vim-gtk3 vim vim-nox vim-gtk vim-athena vim-gtk3 

@TigranSaluev Note that dpkg -I package only works for installed packages. apt-cache works for all packages which are known after you have done apt-get update .

Читайте также:  Примонтировать ntfs диск линукс

apt-cache depends package is a better way, in that case, as showpkg does not tell if a dependency is a recommend, conflict etc., so it is a bit puzzling. For a script which does depends combined with showpkg see unix.stackexchange.com/a/362866/23450

apt-cache depends operates on only the candidate package from your sources, not the specific package version you have installed. Can be confusing if your apt repo supports multiple versions. In which case apt-cache depends package-name=VERSION seems to be the only option.

dpkg -I package worked for deb file just copied from another computer (actually after apt failed to install it).

For 14.04 and later:

dpkg doesn’t have the -I any more and you have to use dpkg-deb to show package information including dependencies:

I know this question is very old, but it is possible. I also had to dig through StackOverflow/AskUbuntu for ALL of this.

This ONLY SHOWS what depends are in the first package. Not all.

There might be some duplicates in the script methods but you can probably filter them out by doing this:

COMMAND | tr " " "\n" | sort | uniq -d | xargs 

In a script

dpkg-deb -I | grep -E "Depends|Recommends|Suggests|Pre\-Depends" | tr -d "|," | sed "s/([^)]*)/()/g" | tr -d "()" | tr " " "\n" | grep -Ev "Depends|Recommends|Suggests|Pre\-Depends" | xargs 

In a script, but not downloaded (remote)

apt-cache show | grep -E "Depends|Recommends|Suggests|Pre\-Depends" | tr -d "|," | sed "s/([^)]*)/()/g" | tr -d "()" | tr " " "\n" | grep -Ev "Depends|Recommends|Suggests|Pre\-Depends" | xargs 

Human readable

dpkg-deb -I | grep -E --color=none "Depends|Recommends|Suggests|Pre\-Depends" 

Human readable (remote)

apt-cache show | grep -E --color=none "Depends|Recommends|Suggests|Pre\-Depends" 

Get amount of dependencies

dpkg-deb -I | grep -E "Depends|Recommends|Suggests|Pre\-Depends" | tr -d "|," | sed "s/([^)]*)/()/g" | tr -d "()" | tr " " "\n" | grep -Ev "Depends|Recommends|Suggests|Pre\-Depends" | xargs | tr " " "\n" | wc -l 

Get amount of dependencies (remote)

apt-cache show | grep -E "Depends|Recommends|Suggests|Pre\-Depends" | tr -d "|," | sed "s/([^)]*)/()/g" | tr -d "()" | tr " " "\n" | grep -Ev "Depends|Recommends|Suggests|Pre\-Depends" | xargs | tr " " "\n" | wc -l 

Nice set of commands you might want to split \ those long ones for readability, but leave it up to you.

using dpkg-deb —showformat will shorten the command considerably, e.g., dpkg-deb —show —showformat=’$ $ $ $\n’ bash_5.1-2_amd64.deb | sed -r ‘s/ \([^()]*\),?//g’

this doesn’t seem like it works or else I don’t understand what i’m looking at. If I apt depends curl I get libc6 , libcurl , zlib1g . If I apt depends libc6 I get libgcc-s1 and libcyrpt1 . But if I use your scripts those 2nd levels are not appearing. (Ubuntu 20.04)

Читайте также:  Форматы пакетов для linux

apt-cache depends [Package-Name] will work as well. Although if you source the .deb package from outside your sources list, things like apt-cache showpkg [Package-Name] && apt-cache depends [Package-Name] might show outdated info or might not sync with the actual installed package hence dpkg -I [Package-Name] would work best in that case.

For a specific package version:

In case you have the uninstalled package (usually downloaded manually from outside a repository), you need to use dpkg. The following command will show a summary of the package informations, including it’s dependencies:

In case the package is already installed on your machine (originated from the repository or from a manual download), or is not installed but is available in the repository, you can use apt. The following command will show only the list of it’s dependencies.

Источник

How to get list of dependencies of non-installed RPM package?

yum doesn’t have that capability. Use the repoquery tool from the yum-utils package instead.

OR to also see which additional RPM packages are needed to satisfy the dependencies, use —resolve

repoquery --requires --resolve

If you have it downloaded then you use rpm -qp —requires .

If you use RHN, you need to add —plugins to the call to repoquery. See stackoverflow.com/questions/15433843/…

What does —resolve actually do? Running repoquery —requires —resolve on a package that is already installed should return an empty list right, since all dependencies are already satisfied? When I tried it on a package that is already installed, I got a few listed, including itself (all of these are already installed).

Produces a list of all dependencies and what packages provide those dependencies for the given packages.

Update for dnf

To do the same thing with dnf, we can do

Alternative to Yum deplist command to find out dependencies of the package is dnf repoquery —requires using repoquery plugin.

Unfortunately, this will return a list of all possible providers of each dependency, which can end up returning many hundreds or thousands of lines, instead of a simple list of the names of dependent packages.

Читайте также:  Icloud bypass on linux

If you have a local RPM, you can get a list of dependencies via:

rpm -qpR mediawiki-1.4rc1-4.i586.rpm 

if you ommit -q then you can query your configured repos: rpm -qR graphviz lists all the dependencies for me

If you need the list of packages needed, use:

dnf repoquery —requires —resolve`

In the case of firefox, by running:

sudo dnf repoquery —requires —resolve firefox

I’ve got the ouput: Last metadata expiration check: 0:00:00 ago on Wed 13 Dec 2017 21:41:47 GMT. atk-0:2.26.1-1.fc27.x86_64 bash-0:4.4.12-12.fc27.x86_64 cairo-0:1.15.8-1.fc27.x86_64 cairo-gobject-0:1.15.8-1.fc27.x86_64 dbus-glib-0:0.108-4.fc27.x86_64 dbus-libs-1:1.12.0-1.fc27.x86_64 fontconfig-0:2.12.6-4.fc27.x86_64 freetype-0:2.8-6.fc27.x86_64 freetype-freeworld-0:2.8-4.fc27.x86_64 gdk-pixbuf2-0:2.36.11-1.fc27.x86_64 glib2-0:2.54.2-1.fc27.x86_64 glibc-0:2.26-16.fc27.i686 glibc-0:2.26-16.fc27.x86_64 gtk2-0:2.24.31-6.fc27.x86_64 gtk3-0:3.22.26-1.fc27.x86_64 hunspell-0:1.5.4-4.fc27.x86_64 libX11-0:1.6.5-4.fc27.x86_64 libX11-xcb-0:1.6.5-4.fc27.x86_64 libXcomposite-0:0.4.4-11.fc27.x86_64 libXdamage-0:1.1.4-11.fc27.x86_64 libXext-0:1.3.3-7.fc27.x86_64 libXfixes-0:5.0.3-4.fc27.x86_64 libXrender-0:0.9.10-4.fc27.x86_64 libXt-0:1.1.5-6.fc27.x86_64 libffi-0:3.1-14.fc27.x86_64 libgcc-0:7.2.1-2.fc27.x86_64 libjpeg-turbo-0:1.5.1-4.fc27.x86_64 libstdc++-0:7.2.1-2.fc27.x86_64 libvpx-0:1.6.1-4.fc27.x86_64 libxcb-0:1.12-5.fc27.x86_64 mozilla-filesystem-0:1.9-17.fc27.x86_64 nspr-0:4.17.0-1.fc27.i686 nspr-0:4.17.0-1.fc27.x86_64 nss-0:3.34.0-1.0.fc27.i686 nss-0:3.34.0-1.0.fc27.x86_64 nss-util-0:3.34.0-1.0.fc27.x86_64 p11-kit-trust-0:0.23.8-1.fc27.i686 p11-kit-trust-0:0.23.9-2.fc27.x86_64 pango-0:1.40.14-1.fc27.x86_64 startup-notification-0:0.12-14.fc27.x86_64 u2f-hidraw-policy-0:1.0.2-5.fc27.x86_64 zlib-0:1.2.11-4.fc27.x86_64

Источник

Check RPM dependencies

When you are installing a program using .deb packages on Ubuntu, you can check dependencies of package using Ubuntu Packages Search. For example I can see dependencies of Wireshark from here. As you can see, dependencies marked by red bullet. If you know all packages your program depends them, you can download and install them using dpkg . Is there any alternative website for RPM packages? Specially for RHEL? I know that I can get these packages’ names by other methods such as when installing RPM package using rpm -i , but it is not user friendly and needs access to running Linux.

3 Answers 3

In fact that’s not a one but four different questions :).

*) First you can quickly list a downloaded package’s dependencies/requirements by using the following commands:

$ rpm -qp mypackage.rpm --provides $ rpm -qp mypackage.rpm --requires 

*) Second, you can use yum utility in order to satisfy these (somewhat cryptic) dependencies automatically (assuming that all your repositories are set up correctly, and all the dependencies are available):

$ sudo yum install mypackage.rpm 

*) Third, there are several RPM search resources, some of them already suggested above. I’d like to list another one, just for the reference — pkgs.org.

*) Fourth, there is an additional popular repository for RHEL5 and RHEL6 distros — EPEL. Note that it’s not supported by Red Hat.

Hope my answer(s) will help.

Источник

Оцените статью
Adblock
detector