Linux find 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 .

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.

Читайте также:  Linux посмотреть загрузку ядер процессора

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)

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.

Читайте также:  Linux disk usage analyzer console

Источник

How to Check Dependencies of a Package in Ubuntu/Debian-based Linux Distributions

Installing applications via command line is quite easy in Ubuntu/Debian. All you need to do is to use apt install package_name.

But what if you want to know the dependencies of a package before or after installing it?

In this tutorial, I’ll show you various ways to see the dependencies of a package in Ubuntu and other Debian-based Linux distributions that use APT package management system.

What is package dependency in Ubuntu?

If you didn’t know already, when you install a software package in Linux, sometimes, it needs other packages to function properly. These additional packages are called dependencies. If these dependency packages are not installed on the system, it is usually installed automatically with the package.

For example, the GUI tool HandBrake for converting video formats needs FFmpeg, GStreamer. So for HandBrake, FFmpeg and GStreamer are the dependencies.

If you don’t have these packages installed on your system, they will be automatically installed when you install HandBrake on Ubuntu.

Check dependencies of a package in Ubuntu and Debian based distributions

As it often happens in Linux, there are more than one way to achieve the same result. Let’s see various ways to see the dependencies of a package.

Checking dependencies with apt show

You can use the apt show command to display details of a package. Part of this information is dependencies and you can see it in the line starting with Depends.

For example, here’s what it shows for ubuntu-restricted-extras package.

[email protected]:~$ apt show ubuntu-restricted-extras Package: ubuntu-restricted-extras Version: 67 Priority: optional Section: multiverse/metapackages Origin: Ubuntu Maintainer: Ubuntu Developers [email protected]> Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 14.3 kB Depends: ubuntu-restricted-addons Recommends: libavcodec-extra, ttf-mscorefonts-installer, unrar Download-Size: 3,200 B APT-Manual-Installed: yes APT-Sources: http://us.archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages Description: Commonly used media codecs and fonts for Ubuntu This collection of packages includes: - MP3 and other audio codec software to play various audio formats (GStreamer plugins) - software to install the Microsoft Web fonts - the Adobe Flash plugin - LAME, software to create compressed audio files. . This software does not include libdvdcss2, and will not let you play encrypted DVDs. For more information, see https://help.ubuntu.com/community/RestrictedFormats/PlayingDVDs . These software packages are from the Multiverse channel, restricted by copyright or legal issues in some countries. For more information, see http://www.ubuntu.com/ubuntu/licensing

As you can see, ubuntu-restricted-extras package depends on ubuntu-restricted-addons package.

Here’s a catch! The dependency package may also depend on some other package and the chain could go on. Thankfully, the APT package manager handles this for you by automatically installing all the dependencies (most of the time).

Читайте также:  Linux foundation certified system administrator lfcs

What is recommended package?

Did you notice the line starting with Recommends in the above output?

Recommended packages are not direct dependencies for the package but they enable additional features.

As you can see, ubuntu-restricted-extras has ttf-mscorefonts-installer as recommended package for installing Microsoft Fonts on Ubuntu.

The recommended packages are also installed by default and if you explicitly want to forbid the installation of recommended package, use the –no-install-recommends flag like this:

sudo apt install –no-install-recommends package_name

Use apt-cache for getting just the dependencies information

The apt show has way too many information. If you want to get the dependencies in a script, the apt-cache command gives you a better and clean output.

apt-cache depends package_name

The output looks much clean, does it not?

Apt Check Dependencies Ubuntu

Check the dependencies of a DEB file using dpkg

Both apt and apt-cache command work on the packages that are available from the repositories. But if you download a DEB file, these command won’t work.

In this case, you can use the dpkg command with -I or –info option.

The dependencies can be seen in the line starting with Depends.

Check Dpendencies Of Deb Package

Checking dependencies and reverse dependencies with apt-rdepends

If you want more details on the dependencies, you can use the apt-rdepends tool. This tool creates the complete dependency tree. So, you get the dependency of a package and the dependencies of the dependencies as well.

It is not a regular apt command and you’ll have to install it from the universe repository:

sudo apt install apt-rdepends

The output is usually quite large depending on the dependency tree.

Reading package lists. Done Building dependency tree Reading state information. Done shutter Depends: procps Depends: xdg-utils imagemagick Depends: imagemagick-6.q16 (>= 8:6.9.2.10+dfsg-2~) imagemagick-6.q16 Depends: hicolor-icon-theme Depends: libc6 (>= 2.4) Depends: libmagickcore-6.q16-6 (>= 8:6.9.10.2) Depends: libmagickwand-6.q16-6 (>= 8:6.9.10.2) hicolor-icon-theme libc6 Depends: libcrypt1 (>= 1:4.4.10-10ubuntu4) Depends: libgcc-s1 libcrypt1 Depends: libc6 (>= 2.25)

The apt-rdepends tool is quite versatile. It can also calculate the reverse dependencies. Which means, you can see what other packages depend on a certain package.

apt-rdepends -r package_name

The output could be pretty big because it will print the reverse dependency tree.

[email protected]:~$ apt-rdepends -r ffmpeg Reading package lists. Done Building dependency tree Reading state information. Done ffmpeg Reverse Depends: ardour-video-timeline (>= 1:5.12.0-3ubuntu4) Reverse Depends: deepin-screen-recorder (5.0.0-1build2) Reverse Depends: devede (4.15.0-2) Reverse Depends: dvd-slideshow (0.8.6.1-1) Reverse Depends: green-recorder (>= 3.2.3)

I hope this quick tutorial was helpful in improving your command line knowledge a bit. Stay tuned for more such tips.

Источник

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