How to get name of the source package

There are many applications that share the same source package, so I will show three different ways to print the name of the source package.

The first method is to print package information and filter out required information.

$ apt-cache showsrc linux-image-amd64 | grep Package: | awk '{print $2}'
$ apt-cache search --full "^vim-tiny\$" | grep "Package\|Source" | cut -d " " -f2 | tac | tr  "\n" " " | awk "{print \$1}"

The second method is to simulate source package download.

$ apt-get source -s liblzma5 | sed '$!d;s/Fetch source //'

The third method is to query Debian package database, but it only works for installed packages.

$ dpkg-query -W -f='${Source} ${Package}\n' sshfs | awk '{print $1}'
Milosz Galazka's Picture

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.

Gdansk, Poland