So, I worked out a solution both using the most useful information from Dennis and Olaf answers. This involves using a custom config script for apt
, with some more options.
Dir::State "some-dir/tmp/var/lib/apt";
Dir::State::status "some-dir/tmp/var/lib/dpkg/status";
Dir::Etc::SourceList "some-dir/tmp/etc/apt.sources.list";
Dir::Cache "some-dir/tmp/var/cache/apt";
pkgCacheGen::Essential "none";
All the directories and files referenced here must exist on the file system, and there is some more commands to issue to get apt
to work as intended:
builduser@host$ mkdir some-dir/tmp/var/lib/apt/partial
builduser@host$ mkdir some-dir/tmp/var/cache/apt/archives/partial
builduser@host$ touch some-dir/tmp/var
My some-dir/etc/apt.sources.list
file looks like this:
deb-src http://ftp.debian.org/debian wheezy main contrib non-free
deb-src http://security.debian.org/ wheezy/updates main contrib non-free
I was then able to sucessfully download the cyrus-imapd-2.4
source package from the Wheezy repos as a regular user on Squeeze, by issuing the following commands:
builduser@host$ apt-get update -c some-dir/etc/apt.conf
builduser@host$ apt-get source cyrus-imapd-2.4 -c some-dir/etc/apt.conf
For those interested in the following step - building that cyrus package as non root - the answer lies here.