Debian – download packages for different distribution with apt

aptdebiandependencieslinux

I want to download a .deb package with it's dependencies for a different distribution.

I have many Linux systems in my company: Ubuntu 11.04, 11.10, 12.10, and Debian 5 and 6.

The command to download a full dependency tree would be apt-get -d install package.

I'm currently using a Debian 6 (squeeze), and downloading packages for the same distribution works fine. I tried downloading (without installing) packages tree by changing my sources.list into Debian 5 (lenny) sources.

However I get the following error:

# apt-get -d install python-lxml
...
The following packages have unmet dependencies:
 python-lxml : Depends: python (< 2.6) but 2.6.6-3+squeeze7 is to be installed
E: Broken packages

Running a different OS for each distro will result in 12+ machines. I'm looking for a clearer solution.

Any suggestions?

Best Answer

APT's core job is to resolve dependencies. So you can't really blame it for complaining about dependencies.

You'll need to invoke it with a different configuration so that it doesn't mix the package databases. Keep separate apt.conf and sources.list files and for each distribution, e.g..

apt-get -o Dir::Etc::Main=/path/to/precise/apt.conf -d …

with apt.conf containing at least

Dig::State::status "/path/to/precise/status";
APT::Get::Download-Only "true";

You may need to symlink or replicate some files in /etc/apt in the /path/to/precise directory (depending on what you have in them).

Do not run apt-get as root when you pass an alternate database. If apt-get has permission to modify your system and you accidentally misconfigure something or turn off -d, you could seriously mess up your system. Run apt-get with only the privileges it needs, which as long as you're only downloading stuff doesn't include root. You will need to have enough permissions to write to the cache directory /var/cache/apt and its contents; I recommend creating a group for that (addgroup aptcache; chgrp -R aptcache /var/cache/apt; chmod -R g+w /var/cache/apt and adding yourself to it).

Related Question