Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
So, Olaf and Dennis answers were both good leads but there was still a lot to find out before getting the things to work. For reference I've put the actual solution in my own answer, and had to untick the answer flag and replace it by an upvote. –  Erwan Queffélec Nov 11 '12 at 11:57

3 Answers 3

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

share|improve this answer

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.

share|improve this answer
up vote 1 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.