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.
8 Answers
This will show you all the information about the package:
dpkg -I package.deb 6 In addition to the dpkg method, you can check the dependencies of packages in the repository:
apt-cache depends package-nameEDIT Updated with @Tino's recommendation. @Tigran's comment no longer applies.
depends VS rdepends
apt-cache
dependspackage-name
//show package-name depends on whoapt-cache
rdependspackage-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-tinyrdepends
$ 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 5 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:
dpkg-deb -I package.deb 1 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.
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 Here are the methods:
In a script
dpkg-deb -I <The .deb> | grep -E "Depends|Recommends|Suggests|Pre\-Depends" | tr -d "|," | sed "s/([^)]*)/()/g" | tr -d "()" | tr " " "\n" | grep -Ev "Depends|Recommends|Suggests|Pre\-Depends" | xargsIn a script, but not downloaded (remote)
apt-cache show <The package name> | grep -E "Depends|Recommends|Suggests|Pre\-Depends" | tr -d "|," | sed "s/([^)]*)/()/g" | tr -d "()" | tr " " "\n" | grep -Ev "Depends|Recommends|Suggests|Pre\-Depends" | xargsHuman readable
dpkg-deb -I <The .deb> | grep -E --color=none "Depends|Recommends|Suggests|Pre\-Depends"Human readable (remote)
apt-cache show <The package name> | grep -E --color=none "Depends|Recommends|Suggests|Pre\-Depends"Get amount of dependencies
dpkg-deb -I <The .deb> | 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 -lGet amount of dependencies (remote)
apt-cache show <The package name> | 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 4 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:
dpkg --info [package name]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.
apt depends [package name] Here is some sloppy, and probably not very encompassing post-processing you can do to dpkg -I output to get dependency items as a list:
Condensed for computers
# dpkg -I package.deb | python -c "import sys, re; t=re.split(r'\n(?= ?[\w]+:)|:', sys.stdin.read()); print '\n'.join([i.strip() for i in {key.strip(): value.strip() for key, value in zip(t[::2], t[1::2])}['Depends'].split(',')])"
#Expanded for humans:
dpkg -I package.deb | python -c " import sys, re; # Split keys and values into pairs (zipped together later) t=re.split( r'\n(?= ?[\w]+:)|:', sys.stdin.read() ); # Newline separate each dependency print '\n'.join([ # Trim each dependency value i.strip() for i in { # Build assoc array from package metadata key.strip(): value.strip() for key, value in zip(t[::2], t[1::2]) }['Depends'].split(',') ])
" 3 For a specific package version:
apt-cache show <package_name>=<version>To find available versions: How can I check the available version of a package in the repositories?