Use apt-get source on a debian repo without using /etc/apt/source.list
Solution 1:
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.
Solution 2:
From man apt-get:
...
-c, --config-file
Configuration File. Specify a configuration file to use. The program will
read the default configuration file and then this configuration file.
See apt.conf(5) for syntax information.
-o, --option
Set a Configuration Option. This will set an arbitrary configuration option.
The syntax is -o Foo::Bar=bar.
Files
/etc/apt/sources.list
Locations to fetch packages from.
Configuration Item: Dir::Etc::SourceList.
...
So, it seems, you can build your own config file and use that or set Dir::Etc::SourceList
on the command line -o Dir::Etc::SourceList=/path/to/my/sources.list