Use apt-get source on a debian repo without using /etc/apt/source.list
I'm trying to use apt-get source
as a regular user on a debian squeeze
system.
I want to retrieve the sources for cyrus-imapd-2.4
from the testing/wheezy
repository.
apt-get source
works without root privileges; however, it seems there is no way to get apt-get to fetch anything from a repository that is not in /etc/apt/sources.list
.
Is there any command line option, alternate sources.list
file, environment variable that will get apt
to work with a custom repository ?
I do have root access so I could change the /etc/apt/sources.list
, however I really do not want to do that for a number of reason.
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.
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
You can probably muck about with setting Dir::Etc and Dir::State (apt-get -o Dir::State=/tmp/var ....). See /usr/share/doc/apt/examples/configure-index.gz for all available variables.