3

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?

7
  • Don't mix distros/releases. It's asking for an unmaintainable broken mess.
    – jordanm
    Jan 15, 2013 at 20:41
  • However if I'm using the mechanism only for downloading and not installing, there should be no problem.
    – iTayb
    Jan 15, 2013 at 20:49
  • The fact that you say that with a straight face illustrates just how little you understand the purpose of a package manager.
    – Shadur
    Jan 16, 2013 at 8:12
  • It sounds very much like you're looking for the wrong solution to the problem.
    – Shadur
    Jan 16, 2013 at 8:19
  • @Shadur Yep, I know that APT is a package manager. Nevertheless I want to use it as a download manager in this specific situation. Unless there's a tool which downloads dependency trees. I know none, and it seems that APT can do it fairly well with the right configuration. So be it.
    – iTayb
    Jan 17, 2013 at 17:56

4 Answers 4

4

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).

4
  • 1
    That would probably work, but the first time he makes a single mistake -- and he will -- it's going to leave his system an unrecoverable mess.
    – Shadur
    Jan 16, 2013 at 8:23
  • 1
    @Shadur How so? The databases are kept separate. Oh, yes, I forgot to mention something important: don't run that as root, so you can't mess up. Jan 16, 2013 at 10:21
  • 1
    They're only separate as long as he never ever forgets any of the steps whenever he swaps between trees.
    – Shadur
    Jan 16, 2013 at 10:29
  • 1
    @Shadur What steps? What swap? Each call to apt-get is independent. Either it's running as root with no alternate apt.conf, or it's not running as root and so can't install anything. Jan 16, 2013 at 10:33
1

It's difficult to discern what you intend to do with these packages after downloading them, which would really help.

If you are downloading these packages for future installation in another machine, and you want to keep them around locally, I would recommend creating a partial apt repository for each distro using reprepro. If you have a lot of debian/ubuntu systems in your company, you will probably want to do this anyway.

In my environment I have a python xmlrpc server on the repository and the clients send the output of dpkg --get-selections to be merged with the partial package list on the repository, helping to keep the local repository in sync. They are very simple scripts, and when I get the time I'll post them to github.

If you are needing to use these packages on a local machine after the download, and the packages aren't built for the system you are using, you may want to investigate using schroot. The schroot package will allow you to run a chroot of each distribution so that you can test your code, or whatever else you need to do.

0

I really, REALLY can't recommend enough that you decide on a single distribution and enforce its use on the network unless you particularly like spending five times as much time and effort making sure all systems are up to date and security issues patched.

At the very least, debian Lenny was declared end-of-life almost a year ago -- there won't be any more security updates. I should not have to tell you how bad an idea it is to keep running it.

I'm a little less familiar with ubuntu's life cycle, but I'm willing to bet the 04/11 variant isn't being kept up to date anymore either.

Furthermore, even if you manage to get apt to do what you're asking, you're intentionally disabling so many internal safeguards that a single mistake will leave your system a horrifying mess

If you really absolutely HAVE to have all those distributions running, perhaps you'd be better off telling each apt to use a caching http proxy like squid that you set up on a central server in order to minimize bandwidth use and exposure to the outside.

1
  • The linux machines are testing models for my company's apps. We wish for maximum compatibility in different configurations and distributions, and that's why we need to setup somehow old end-of-life releases.
    – iTayb
    Jan 17, 2013 at 17:53
0

You could use a docker image for the distro that you want to download packages for and grab them from there. SO answer for getting dependencies from here.

# Get the distro image of choice
docker pull debian:stretch-slim

# Run the image binding the current (host) directory to container
docker run -it --mount type=bind,source="$(pwd)",target=/packages debian:stretch-slim bash

At your docker prompt

# Change to the packages directory
cd packages

# Update your packages list
apt update

# Define what packages (and their dependencies) you want to download
PACKAGES="wget unzip"

# Downloads to `/packages` i.e. your PWS on host
apt-get download $(apt-cache depends --recurse --no-recommends --no-suggests \
  --no-conflicts --no-breaks --no-replaces --no-enhances \
  --no-pre-depends ${PACKAGES} | grep "^\w")
exit

You must log in to answer this question.

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