Apt-Pinning

From OptionC

This is a pre-draft version

A basic example: darcs

/etc/apt/sources.list

 # /etc/apt/sources.list
 # sarge/stable
 deb ftp://ftp.us.debian.org/debian/ sarge main contrib non-free
 deb-src ftp://ftp.us.debian.org/debian/ sarge main contrib non-free
 deb http://security.debian.org/ sarge/updates main contrib non-free

/etc/apt/apt.conf.d/70debconf

// /etc/apt/apt.conf.d/70debconf
// Pre-configure all packages with debconf before they are installed.
// If you don't like it, comment it out.
DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt || true";};

See what will happen (the "-s" switch shows you what would happen, but doesn't do anything - very helpful in this situation)...

debian-sarge:~# apt-get -s install darcs
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
  libcurl3 libgmp3 libidn11
Suggested packages:
  darcs-server libcurl3-gssapi ca-certificates libldap2-dev
The following NEW packages will be installed:
  darcs libcurl3 libgmp3 libidn11
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Inst libidn11 (0.5.13-1.0 Debian:3.1r0/stable)
Inst libcurl3 (7.13.2-2 Debian:3.1r0/stable)
Inst libgmp3 (4.1.4-6 Debian:3.1r0/stable)
Inst darcs (1.0.2-1 Debian:3.1r0/stable)
Conf libidn11 (0.5.13-1.0 Debian:3.1r0/stable)
Conf libcurl3 (7.13.2-2 Debian:3.1r0/stable)
Conf libgmp3 (4.1.4-6 Debian:3.1r0/stable)
Conf darcs (1.0.2-1 Debian:3.1r0/stable)

As you can see, this will install version 1.0.2-1 of darcs, as well as the dependencies, from stable, which is what we would expect. But what if you really, really, reall want version 1.0.3, have looked at the Debian package list (http://www.debian.org/distrib/packages) and know that there is a package available, but it is for etch/testing?

Change /etc/apt/sources.list to include a line for testing /etc/apt/sources.list

 # /etc/apt/sources.list
 # sarge/stable
 deb ftp://ftp.us.debian.org/debian/ sarge main contrib non-free
 deb-src ftp://ftp.us.debian.org/debian/ sarge main contrib non-free
 deb http://security.debian.org/ sarge/updates main contrib non-free
# etch/testing
deb ftp://ftp.us.debian.org/debian/ testing main contrib non-free

Reading Package Lists... Building Dependency Tree... The following extra packages will be installed:

 libc6 libcurl3 libgmp3c2 libidn11 libncurses5 libreadline4 libreadline5
 locales readline-common

Suggested packages:

 darcs-server glibc-doc ca-certificates libldap2-dev libcurl3-gssapi

The following NEW packages will be installed:

 darcs libcurl3 libgmp3c2 libidn11 libreadline5 readline-common

The following packages will be upgraded:

 libc6 libncurses5 libreadline4 locales

4 upgraded, 6 newly installed, 0 to remove and 229 not upgraded. Inst locales [2.3.2.ds1-22] (2.3.5-6 Debian:testing) [] Inst libc6 [2.3.2.ds1-22] (2.3.5-6 Debian:testing) Conf libc6 (2.3.5-6 Debian:testing) Inst libncurses5 [5.4-4] (5.4-9 Debian:testing) Conf libncurses5 (5.4-9 Debian:testing) Inst libreadline4 [4.3-11] (4.3-17 Debian:testing) [] Inst readline-common (5.0-11 Debian:testing) Inst libreadline5 (5.0-11 Debian:testing) Inst libidn11 (0.5.18-1 Debian:testing) Inst libcurl3 (7.14.0-5 Debian:testing) Inst libgmp3c2 (4.1.4-10 Debian:testing)Inst darcs (1.0.3-2 Debian:testing) Conf locales (2.3.5-6 Debian:testing) Conf readline-common (5.0-11 Debian:testing) Conf libreadline4 (4.3-17 Debian:testing) Conf libreadline5 (5.0-11 Debian:testing) Conf libidn11 (0.5.18-1 Debian:testing) Conf libcurl3 (7.14.0-5 Debian:testing) Conf libgmp3c2 (4.1.4-10 Debian:testing) Conf darcs (1.0.3-2 Debian:testing)

A more complicated example: openoffice.org2

Try to install openoffice.org2 (doesn't currently exist in stable)

debian-sarge:/# apt-get -s install openoffice.org2
Reading Package Lists... Done
Building Dependency Tree... Done
E: Couldn't find package openoffice.org2

It's in experimental, so we added it to /etc/apt/sources.lst

 # /etc/apt/sources.lst
 # sarge/stable
 deb ftp://ftp.us.debian.org/debian/ sarge main
 deb-src ftp://ftp.us.debian.org/debian/ sarge main
 deb http://security.debian.org/ sarge/updates main
 # experimental
 deb ftp://ftp.us.debian.org/debian/ experimental main

Update

debian-sarge:/#apt-get update

Try again

 debian-sarge:/# apt-get -s install openoffice.org2
 Building Dependency Tree...
 Some packages could not be installed. This may mean that you have
 requested an impossible situation or if you are using the unstable
 distribution that some required packages have not yet been created
 or been moved out of Incoming.

 Since you only requested a single operation it is extremely likely that
 the package is simply not installable and a bug report against
 that package should be filed.
 The following information may help to resolve the situation:

 The following packages have unmet dependencies:
  openoffice.org2: 
   Depends: openoffice.org2-core (> 1.9.125) but it is not goingto be installed
   Depends: openoffice.org2-writer but it is not going to be installed
   Depends: openoffice.org2-calc but it is not going to be installed
   Depends: openoffice.org2-impress but it is not going to be installed
   Depends: openoffice.org2-draw but it is not going to be installed
   Depends: openoffice.org2-math but it is not going to be installed
   Depends: openoffice.org2-base but it is not going to be installed


APT::Default-Release "stable";