apt: list required dependencies for deb package without installing it
For a build tool I'm writing (for which I'd like to implement a sort of dependency-caching system) I'd like to know what the missing dependencies for a .deb package are, without resorting to installing it (possibly) and reading apt-get output, i.e.: I must be able to do it non-interactively in a software, it's not something that a human should do
The manual procedure would be something like:
dpkg -i something.deb || true
apt-get -f install
At this point, apt prints something like:
The following extra packages will be installed:
ca-certificates git git-man krb5-locales libasn1-8-heimdal libcurl3-gnutls
libedit2 liberror-perl libgssapi-krb5-2 libgssapi3-heimdal
libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal
libhx509-5-heimdal libidn11 libk5crypto3 libkeyutils1 libkrb5-26-heimdal
libkrb5-3 libkrb5support0 libldap-2.4-2 libroken18-heimdal librtmp0
libruby1.9.1 libsasl2-2 libsasl2-modules libsasl2-modules-db
libwind0-heimdal libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6
libxmuu1 libyaml-0-2 openssh-client openssl patch rsync ruby ruby1.9.1 xauth
I would like to reliably obtain such list without installing the .deb (possibly, because I can remove the package after having installed and have a system just like before, after-all) but especially without needing to manually and interactively parse apt-get output for package listing.
I can use apt-get, apt-cache, aptitude or whatever package is available in Debian and/or Ubuntu for performing such tasks.
dpkg -I package.deb
It's command show package info. You can find depends in.