Search code examples
ubuntudebiandpkg

dpkg-query uninstalled debian package


Using below dpkg-query command to retrieve package info

dpkg-query -W -f='${PACKAGE}\n' dpkg

But how do i query a debian package (from a package file not installed package) for its Meta info like VERSION, PACKAGE using dpkg-query or any other means?

dpkg-query -W -f='${PACKAGE}\n' /path/to/debian/package.deb

Above command would fail as it expects package name instead of .deb file.

FYI: I'm currently using as below and looking for a straight solution.

dpkg -I /path/to/debian/package.deb | grep -Po "^\s+Version:\s+\K.*"

Solution

  • dpkg-deb is the native tool that works on uninstalled package files:

        dpkg-deb -f pkg.deb [ Version Package ... ]
        dpkg-deb -I pkg.deb [ conffiles md5sums preinst postinst ... ]
    

    For options that are unique to dpkg-deb, dpkg is synonym to dpkg-deb, e.g.:

        dpkg -f pkg.deb Version