How to display dependencies for deb package

Pretty print package dependencies from package file itself.

Extract and simply print dependencies from a package without using dpkg utilities.

$ ar -p postgresql-common_181_all.deb control.tar.gz | \
    tar --to-stdout --gzip --extract --file - ./control | grep Depends:
Depends: adduser, debconf (>= 0.5.00) | debconf-2.0, lsb-base (>= 3.0-3), postgresql-client-common (= 181), procps, ssl-cert (>= 1.0.11), ucf, init-system-helpers (>= 1.18~)

Extract and simply print dependencies from a package using dpkg utility.

$ dpkg --info postgresql-common_181_all.deb | grep Depends
Depends: adduser, debconf (>= 0.5.00) | debconf-2.0, lsb-base (>= 3.0-3), postgresql-client-common (= 181), procps, ssl-cert (>= 1.0.11), ucf, init-system-helpers (>= 1.18~)

Extract and pretty print dependencies from a package using dpkg utility.

$ dpkg --info postgresql-common_181_all.deb | \
    awk 'BEGIN{print "Depends:"} \
         /Depends: / { gsub("Depends: ", ""); \
                       n=split($0,deps,","); \
                       for(i=1;i<=n;i++) print deps[i] }'
Depends:
 adduser
 debconf (>= 0.5.00) | debconf-2.0
 lsb-base (>= 3.0-3)
 postgresql-client-common (= 181)
 procps
 ssl-cert (>= 1.0.11)
 ucf
 init-system-helpers (>= 1.18~)

About Milosz Galazka

Milosz is a Linux Foundation Certified Engineer working for a successful Polish company as a system administrator and a long time supporter of Free Software Foundation and Debian operating system. He is also open for new opportunities and challenges.