7

Say for example I wish to install the latest Debian package "libgcc1" for Jessie on AMD64.

How can I determine the correct URL to download from https://packages.debian.org

For example, in this case, clicking manually through the https://packages.debian.org website gets me ultimately to the correct download, which is:

http://ftp.us.debian.org/debian/pool/main/g/gcc-4.9/libgcc1_4.9.2-10_amd64.deb

IMPORTANT NOTE: I do NOT have apt available. I am writing some code that manually extracts the dependency names from .deb packages, but I am now stuck trying to work out the next steps, which is to get the correct actual .deb package for the package name.

So for example I need to go from these bits of information:

  • package name: libgcc1
  • version: latest
  • architecture: amd64
  • debian release: jessie

to:

http://ftp.us.debian.org/debian/pool/main/g/gcc-4.9/libgcc1_4.9.2-10_amd64.deb

How can I determine this relationship?

EDIT: for all the people asking "Why not use apt?", the answer is that the core problem I am trying to solve is to install apt. I can't use apt because I am trying to install apt.

thanks

14
  • 1
    Don't forget you really should be considering the security updates, too, which are in a separate repository package list Dec 26, 2016 at 11:44
  • 2
    Re: your edit: A Debian system without such an essential package as apt is very broken. Either (1) fix it by downloading apt using apt from elsewhere (maybe even using debootstrap?), or (2) reinstall, or (3) find and install apt by hand with a web browser, then install other packages using apt.
    – Celada
    Dec 26, 2016 at 21:32
  • 2
    debootstrap --variant=minbase is your best bet then — it only installs essential packages and apt. That's the absolute barest minimum you can have with a working apt and guaranteed working packages when you do install them later (I'm assuming that you want apt so you can then install other packages). Dec 26, 2016 at 21:50
  • 1
    Seriously, minbase installs the minimum viable Debian system for the given release, 101 packages for Jessie. If you try to get away with anything less, you're asking for trouble down the road because any package can rely on all essential packages being installed, without depending on them. Dec 26, 2016 at 21:59
  • 1
    You're doing it wrong. If you want to install Debian packages, use debootstrap and install Debian's package manager. Redoing the work that went into debootstrap will take you ages and will fail repeatedly as Debian evolves. Dec 26, 2016 at 22:03

3 Answers 3

11

Well, if you had apt available...

apt-get -y install --print-uris $PACKAGE | cut -f 2 -d \' | grep \.deb

It will actually give you all of the packages needed for whatever it is goign to install.

user@darkstar:~/ $ apt-get -y install --print-uris audacity | cut -f 2 -d \' | grep \.deb
http://archive.ubuntu.com/ubuntu/pool/universe/libs/libsbsms/libsbsms10_2.0.2-1_amd64.deb
http://archive.ubuntu.com/ubuntu/pool/universe/s/serd/libserd-0-0_0.22.0~dfsg0-2_amd64.deb
http://archive.ubuntu.com/ubuntu/pool/universe/s/sord/libsord-0-0_0.14.0~dfsg0-1_amd64.deb
http://archive.ubuntu.com/ubuntu/pool/universe/s/sratom/libsratom-0-0_0.4.6~dfsg0-1_amd64.deb
http://archive.ubuntu.com/ubuntu/pool/universe/s/suil/libsuil-0-0_0.8.2~dfsg0-1_amd64.deb
http://archive.ubuntu.com/ubuntu/pool/universe/a/audacity/audacity-data_2.1.2-1_all.deb
http://archive.ubuntu.com/ubuntu/pool/main/f/flac/libflac++6v5_1.3.1-4_amd64.deb
http://archive.ubuntu.com/ubuntu/pool/universe/libi/libid3tag/libid3tag0_0.15.1b-11_amd64.deb
http://archive.ubuntu.com/ubuntu/pool/universe/l/lilv/liblilv-0-0_0.22.0~dfsg0-1_amd64.deb
http://archive.ubuntu.com/ubuntu/pool/universe/p/portsmf/libportsmf0v5_0.1~svn20101010-4ubuntu1_amd64.deb
http://archive.ubuntu.com/ubuntu/pool/universe/v/vamp-plugin-sdk/libvamp-hostsdk3v5_2.6~repack0-2_amd64.deb
http://archive.ubuntu.com/ubuntu/pool/universe/a/audacity/audacity_2.1.2-1_amd64.deb

Since you don't, look at http://ftp.us.debian.org/debian/dists/stable/main/binary-amd64 and grab a copy of the Packages.gz file there. Look through it, and you'll see The package name listed as

Package: audacity

A few lines after that, you'll see:

Filename: pool/main/a/audacity/audacity_2.0.6-2_amd64.deb

And there you go. Unfortunately, the line number isn't consistent.

3
  • 1
    See edit to explain why I cannot use apt. Dec 26, 2016 at 21:15
  • Did you read the rest of my answer/reply? The part that comes after "Since you dont..."
    – ivanivan
    Dec 26, 2016 at 21:21
  • 1
    I couldn't get the first part of this answer to work. apt-get -y install assumes the package isn't already installed, and for packages that are already installed, apt-get -y --reinstall install --print-uris $PACKAGE always just prints "Reinstallation of $PACKAGE is not possible, it cannot be downloaded."
    – John
    May 2, 2023 at 16:57
6

If you don't have apt available, you'll be stuck basically reimplementing apt. It probably makes more sense to just get apt. But if you must...

Start the same way apt itself does: from a URL as specified in /etc/apt/sources.list, such as http://ftp.us.debian.org/debian/. Don't forget the to take into account the additional entries you might have in that list for updates, security.debian.org, and possibly backports.

You need to evaluate the rules in /etc/apt/preferences{,.d} to know which source any particular package should come from and you need to do version number comparisons and to evaluate pinning rules.

Build a full URL from that:

http://ftp.us.debian.org/debian/dists/<name>/<section>/binary-<architecture>/Packages.gz

That file contains the relative URLs to all of the individual packages.

You also need the following files in order to verify the hash of that file to check its integrity:

http://ftp.us.debian.org/debian/dists/jessie/Release
http://ftp.us.debian.org/debian/dists/jessie/Release.gpg

...and the public key from /etc/apt/trusted* that lets you verify that. The Release file contains hashes for all the other files, which you should verify.

I'll have forgotten to take into account a bunch of other subtle rules about the format and layout of a Debian package repository.

As you can see, much better to just use apt.

1
  • See edit to explain why I cannot use apt. Dec 26, 2016 at 21:14
4

It is better to install and use apt .

To download the package run:

apt-get download libgcc1

To get the path to your .deb package , run:

apt-cache show libgcc1 | grep Filename

sample output:

Filename: pool/main/g/gcc-4.9/libgcc1_4.9.2-10_amd64.deb

Edit: To answer @John.

If the package is already installed, you can use grep-available from dctrl-tools package:

sudo apt install dctrl-tools

Here is an example (search through the package tar):

grep-available -P tar -s Filename
3
  • 1
    See edit to explain why I cannot use apt. Dec 26, 2016 at 21:15
  • Doesn't work for me. apt-cache show does not ever seem to output a "Filename" property.
    – John
    May 2, 2023 at 16:58
  • @John Welcome. See my edit.
    – GAD3R
    May 2, 2023 at 19:15

Not the answer you're looking for? Browse other questions tagged .