Debian: How to find which repository a package is located in?

2

I want to install a file libgmp-dev on my Debian Wheezy. Which repository should I add to my sources.list?

In general, how to find in which repository a given package/program is available? Or is it not at all available for the Debian? In the later case, I must install it from source. But I would like to install if one is available from a repo.

In other words, I guess I want to know: how do I know which repositories to add to my sources.list to fulfill my package installation requirements?

I have already seen the following question and its answers but it seems they work only on local cache. How to tell from what Ubuntu or Debian repository a package comes?

Because if I run any of the following commands as suggested in the answers

$ apt-cache policy libgmp-dev $ apt-cache show-pkg libgmp-dev

I always get the error: N: Unable to locate package libgmp-dev

Tem Pora

Posted 2014-09-13T09:22:00.533

Reputation: 258

Answers

1

This simply means APT does not think the package with the name matching exactly what you entered is available in any repository your local APT knows of.

What does this mean? One of these two things:

  • The package you'd like to find has some other name;
  • The repository the package with that exact name is not known to APT.

What can you do about this?

First, try to search the package cache (the list of all the packages from the repositories known to APT on your system) for a less precise name, something like

apt-cache search libgmp

or even

apt-cache search gmp

might do the trick (you might want to pipe the output to less to be able to search further through it). For instance, the package might include a version in it, like libgmp4-dev (meaning there might be libgmp3-dev available or something like this).

Next, be sure APT knows about the repository containing that package.

On my Wheezy system, I have:

$ apt-cache search libgmp-dev
libgmp-dev - Multiprecision arithmetic library developers tools
libgmp3-dev - Multiprecision arithmetic library developers tools

and

$ apt-cache policy libgmp-dev
libgmp-dev:
  Installed: (none)
  Candidate: 2:5.0.5+dfsg-2
  Version table:
     2:5.0.5+dfsg-2 0
        500 http://http.debian.net/debian/ wheezy/main amd64 Packages

which means the package is available in the standard (main) Debian repository.

So… make sure you have that repository available:

  1. Locate the file /etc/apt/sources.list.
  2. Try to find there an uncommented (not prefixed with the # character) line reading like

    deb http://ftp.de.debian.org/debian wheezy main
    

    and if you don't have one, try adding

    deb http://http.debian.net/debian wheezy main
    

    there, saving the file.

  3. Run

    # apt-get update
    

    to fetch the package list from that repository and adding the list of available packages from it to the local APT's cache.

  4. Verify the package became available using

    $ apt-cache policy libgmp-dev
    

kostix

Posted 2014-09-13T09:22:00.533

Reputation: 2 435

This isn't really the solution if you don't know which repository a package is in. apt-cache can only search things you already have in your sources.list -- if you are trying to figure out what to add there to be able to find a package, this doesn't tell you anything about how to do that. – tripleee – 2018-04-17T06:58:23.097

@tripleee, on a broader scale, you appear to paint, this problem is unsoluble unless you have access to any possible existing repository containing debian packages in the part of the universe accessible via TCP/IP. While this might be of some interest to philosophers, I fail to see any practical aspect to it—except for may be educating the OP on the backports or vendor-provided repos (and their attached perils). Feel free to post a bunch of comments then. – kostix – 2018-04-17T09:44:57.313

That, and Ubuntu's various universe / multiverse / third-party add-ons in their various guises; I was imagining there'd be an existing question and answer but couldn't quickly find one. I'll add a pointer if I do. – tripleee – 2018-04-17T09:47:34.540

@tripleee, note that the question is explicitly tagged as debian (and was not asked on https://askubuntu.com FWIW), so should you go on explaining PPAs please be sure to state clearly the degree to which that information applies to Debian. I'd say this is a good start as long as we're concerned with Debian (and not specifically Ubuntu).

– kostix – 2018-04-17T10:17:53.687

0

To find which repository a package is located in, go here:
https://www.debian.org/distrib/packages

On that page, you can either look for package names, or you can enter filenames and get a resultset with the names of all packages containing the file you searched for.

Regarding your example

libgmp-dev is a package from the usual Debian repos, look here

If you have a working Debian system, you should be able to install it using apt-get install libgmp-dev. If you have issues with that, please open a new question.

Jan

Posted 2014-09-13T09:22:00.533

Reputation: 1 777

Thanks. But I'd like to know why I get the error Unable to locate package libgmp-dev when I run apt-cache policy libgmp-dev. – Tem Pora – 2014-09-14T10:16:34.457

1That's another question, your title reads "Debian: How to find which repository a package is located in?". – Jan – 2014-09-14T20:57:48.140

But you have not answered that question. I am not interested in libgmp-dev per se. An answer must be for any general package. Thanks. – Tem Pora – 2014-09-14T21:18:21.950

You didn't read carefully enough and missed the link. I edited my answer to make it more clear. – Jan – 2014-09-14T21:23:31.710