4

I am trying to download some debian packages and their dependencies in a directory.

I tried using the command aptitude download <package_name> it downloaded the package without its dependencies.

How do I tell it to download the dependencies too?

GAD3R
  • 63,407
  • 31
  • 131
  • 192
Bilal Fazlani
  • 143
  • 1
  • 1
  • 5
  • This seems to be a duplicate of [this](http://stackoverflow.com/questions/13756800/how-to-download-all-dependencies-and-packages-to-directory). Will the accepted answer work in your case? – maulinglawns Sep 29 '16 at 06:35

3 Answers3

12

You can use apt-rdepends to build the complete set of dependencies (recursively), including the main package, then download that:

apt-get download $(apt-rdepends "${package}" | grep -v ^\ )

(replacing "${package}" of course).

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
  • that's great, and it places a bunch of .debs into the current directory. But it can give errors like `E: Can't select candidate version from package c-compiler as it has no candidate` when there are virtual packages in the list. – Andrey Regentov Jul 05 '20 at 15:57
  • That’s a good point, thanks for raising it; `apt-repends` also suffers from listing alternatives equally (for example, `cargo` is listed as depending on `gcc`, `clang` and `c-compiler`). – Stephen Kitt Jul 05 '20 at 16:57
2

A rather hackish way to do that is to have another utility (apt-cache in this example) list the package's dependencies:

# PACKAGE=nautilus; aptitude download $PACKAGE $(apt-cache depends "$PACKAGE" | grep Depends | awk -F ': ' '{print $NF}' | xargs)
Joseph R.
  • 38,849
  • 7
  • 107
  • 143
1

Easier Way

aptitude -d -o Dir::Cache:archives=/home/alex/aptitude-test/ install alsaplayer for exampel.