9

Is there any way (dpkg, apt?) to get a package's sources and URL to repository, if available, in Debian ?

3

What about sudo apt-get source packageName? It installs the newest available source tree, when available, in the current working directory.

Check man apt-get for more details.

  • I need just the name. Is there a way to get it ? Also, how could I get the git repo URL from where it downloads the package ? – Marius Cotofana Jan 16 '13 at 19:47
  • 3
    No real need for sudo here, right? – sr_ Jan 16 '13 at 21:15
5

To get the source:
Check that you have a deb-src line in /etc/apt/sources.list.
As root, run apt-get build-dep package.
As normal user, run apt-get source package.

To get the URL, go to http://packages.debian.org/source/sourcepackage. Then you get a list of the different versions in the supported archives.
If the source package name differs from the binary, it's in the package description, 2nd line it seems.
grep -A1 binpackagename /var/lib/apt/*Packages |grep Source should do the trick.

5

Try:

apt-get install --yes --no-download --reinstall --print-uris package-name

You can extract just URL by adding: | tail -n1 | grep -o "http[^']\+"

  • does not work for me – lalebarde Feb 27 '16 at 9:02
  • Worked for me, thanks. The important part is --print-uris – Gabriel Devillers Oct 5 '17 at 9:55
  • Doesn't work if the package has unmet deps – Evan Carroll May 17 '18 at 2:26
4

apt-cache policy package displays which versions can be installed from which repositories.

bash$ apt-cache policy dpkg
dpkg:
  Installed: 1.16.1.2ubuntu7.1
  Candidate: 1.16.1.2ubuntu7.1
  Version table:
 *** 1.16.1.2ubuntu7.1 0
        500 http://fi.archive.ubuntu.com/ubuntu/ precise-updates/main amd64 Packages
        500 http://mirrors.nic.funet.fi/ubuntu/ precise-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     1.16.1.2ubuntu7 0
        500 http://fi.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
3

for latest version:

apt-get download --print-uris package | cut -d' ' -f1

for specific version

apt-get download --print-uris package=version | cut -d' ' -f1
0

You can use website pkgs.org where you can search for packages. It will give you package and repository path as well.

0

You can use a very simple script called apt-url, that uses apt-move behind the scene to show the package URL.

This script could be found at:

https://github.com/leitao/apt-url

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.