4

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.

Erwan Queffélec
  • 387
  • 3
  • 11
  • 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

4 Answers4

5

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.

Erwan Queffélec
  • 387
  • 3
  • 11
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

Olaf Dietsche
  • 265
  • 1
  • 7
1

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.

Dennis Kaarsemaker
  • 18,793
  • 2
  • 43
  • 69
0

If anybody stumble upon this on 2020, using dget (part of devscripts package) might be a better idea as it doesn't require any configurations; just give it a URL to .dsc file and it will do the job:

$ sudo apt install devscripts
$ dget -u http://archive.raspberrypi.org/debian/pool/main/f/ffmpeg/ffmpeg_4.1.6-1~deb10u1+rpt1.dsc

.dsc files are usually located in the repository archive along with .deb files.