Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am configuring a Debian 6 (Squeeze) x86 server, and want to install some packages from testing or unstable when needed, so I'm using pinning.

I have configured my /etc/apt/sources.list as follow:

deb http://ftp.br.debian.org/debian stable main
deb http://ftp.br.debian.org/debian stable-updates main
deb http://security.debian.org/ stable/updates main

deb http://backports.debian.org/debian-backports squeeze-backports main

deb http://ftp.br.debian.org/debian testing main
deb http://ftp.br.debian.org/debian testing-updates main
deb http://security.debian.org/ testing/updates main

deb http://ftp.br.debian.org/debian unstable main

And my /etc/apt/preferences as follow:

Package: *
Pin: release a=stable
Pin-Priority: 700

Package: *
Pin: release a=stable-updates
Pin-Priority: 700

Package: *
Pin: release a=squeeze-backports
Pin-Priority: 675

Package: *
Pin: release a=testing
Pin-Priority: 650

Package: *
Pin: release a=testing-updates
Pin-Priority: 650

Package: *
Pin: release a=unstable
Pin-Priority: 600

Executing apt-cache policy, I get:

100 /var/lib/dpkg/status
   release a=now
600 http://ftp.br.debian.org/debian/ unstable/main i386 Packages
   release o=Debian,a=unstable,n=sid,l=Debian,c=main
   origin ftp.br.debian.org
650 http://security.debian.org/ testing/updates/main i386 Packages
   release o=Debian,a=testing,n=wheezy,l=Debian-Security,c=main
   origin security.debian.org
650 http://ftp.br.debian.org/debian/ testing-updates/main i386 Packages
   release o=Debian,a=testing-updates,n=wheezy-updates,l=Debian,c=main
   origin ftp.br.debian.org
650 http://ftp.br.debian.org/debian/ testing/main i386 Packages
   release o=Debian,a=testing,n=wheezy,l=Debian,c=main
   origin ftp.br.debian.org
675 http://backports.debian.org/debian-backports/ squeeze-backports/main i386 Packages
   release o=Debian Backports,a=squeeze-backports,n=squeeze-backports,l=Debian Backports,c=main
   origin backports.debian.org
700 http://security.debian.org/ stable/updates/main i386 Packages
   release v=6.0,o=Debian,a=stable,n=squeeze,l=Debian-Security,c=main
   origin security.debian.org
700 http://ftp.br.debian.org/debian/ stable-updates/main i386 Packages
   release o=Debian,a=stable-updates,n=squeeze-updates,l=Debian,c=main
   origin ftp.br.debian.org
700 http://ftp.br.debian.org/debian/ stable/main i386 Packages
   release v=6.0.6,o=Debian,a=stable,n=squeeze,l=Debian,c=main
   origin ftp.br.debian.org

The problem I'm facing is that when I try to install some packages from testing. Ex:

apt-get install ruby1.9.1-dev/testing

I get a broken package message:

The following packages have broken dependencies:
 ruby1.9.1-dev : Depends: libruby1.9.1 (= but is set to be installed
E: Broken Packages

This means I want to install from testing but Debian tries to install dependencies from stable. I know I can do:

apt-get install -t testing ruby1.9.1-dev

It works by installing all dependencies from testing, but I want to use the maximum possible the stable packages (install deps from stable if available).

Another problem I'm having is, if I install a package like this:

apt-get install -t testing ruby1.9.1-dev

And then try to install another package that depends on a library that was installed as a dependency of ruby1.9.1-dev from testing:

apt-get install gcc

I also get the Broken Packages error.

So the questions are:

How can I install a package from testing, but also install the maximum of dependencies possible from stable?

Is it possible to automatically install a package from testing when it is not available in stable by just running

apt-get install package_name


share|improve this question
Short answer: Don't mix releases and expect to keep a sane system, even with pinning. The Debian community sometimes refers to such a a system as "Frankendebian". It's not support by Debian's community. Debian backports is there to solve this. If it's a popular application and it's not in backports, there is might be a good reason. –  jordanm Jan 24 '13 at 0:47
Unfortunately the package I need to install is only available in testing and unstable. It's not available in backports. So the only solution is to install from stable/unstable or compile from source. I think that installing a package is better than compiling from source. –  Anthony Gaudino Jan 24 '13 at 1:17
No, it isn't always. Installing from testing will naturally depend on newer library versions that would not be required if the package or software was recompiled (due to the binary being linked to those libraries). –  jordanm Jan 24 '13 at 1:18
add comment

1 Answer

I found a possible solution

Change my /etc/apt/preferences to this:

Package: *
Pin: release a=stable
Pin-Priority: 999

Package: *
Pin: release a=stable-updates
Pin-Priority: 999

Package: *
Pin: release a=squeeze-backports
Pin-Priority: 995

Package: *
Pin: release a=testing
Pin-Priority: 993

Package: *
Pin: release a=testing-updates
Pin-Priority: 993

Package: *
Pin: release a=unstable
Pin-Priority: 991

Then I can install a package from testing that will install dependencies from stable or backports when possible. To do this I must execute:

apt-get -t stable install [PACKAGE NAME]/testing

For example if I run:

apt-get -s -t stable install imagemagick/testing

I get this list of packages that will be installed:

Inst locales [2.11.3-4] (2.13-37 Debian:testing [all]) []
Inst libc-bin [2.11.3-4] (2.13-37 Debian:testing [i386]) [libc6:i386 ]
Inst libc6 [2.11.3-4] (2.13-37 Debian:testing [i386]) [libc6-i686:i386 on libc6:i386] [libc6-i686:i386 ]
Inst libc6-i686 [2.11.3-4] (2.13-37 Debian:testing [i386])
Inst libuuid-perl [0.02-4] (0.02-5 Debian:testing [i386]) []
Inst perl-base [5.10.1-17squeeze4] (5.14.2-16 Debian:testing [i386]) [liblocale-gettext-perl:i386 on perlapi-5.10.0:i386] [liblocale-gettext-perl:i386 libtext-charwidth-perl:i386 libtext-iconv-perl:i386 ]
Inst libtext-charwidth-perl [0.04-6] (0.04-7+b1 Debian:testing [i386]) [liblocale-gettext-perl:i386 on perlapi-5.10.0:i386] [liblocale-gettext-perl:i386 libtext-iconv-perl:i386 ]
Inst liblocale-gettext-perl [1.05-6] (1.05-7+b1 Debian:testing [i386]) [libtext-iconv-perl:i386 ]
Inst libtext-iconv-perl [1.7-2] (1.7-5 Debian:testing [i386])
Inst gcc-4.7-base (4.7.2-5 Debian:testing [i386])
Inst multiarch-support (2.13-37 Debian:testing [i386])
Inst libstdc++6 [4.4.5-8] (4.7.2-5 Debian:testing [i386])
Inst libattr1 [1:2.4.44-2] (1:2.4.46-8 Debian:testing [i386])
Inst liblzma5 (5.1.1alpha+20120614-2 Debian:testing [i386])
Inst libcap2 (1:2.22-1.2 Debian:testing [i386])
Inst libdb5.1 (5.1.29-5 Debian:testing [i386])
Inst libgpg-error0 (1.10-3.1 Debian:testing [i386])
Inst libgcrypt11 (1.5.0-3 Debian:testing [i386])
Inst libp11-kit0 (0.12-3 Debian:testing [i386])
Inst libtasn1-3 (2.13-2 Debian:testing [i386])
Inst libgnutls26 (2.12.20-2 Debian:testing [i386])
Inst libgssapi-krb5-2 [1.8.3+dfsg-4squeeze6] (1.10.1+dfsg-3 Debian:testing [i386]) []
Inst libk5crypto3 [1.8.3+dfsg-4squeeze6] (1.10.1+dfsg-3 Debian:testing [i386]) []
Inst libkrb5-3 [1.8.3+dfsg-4squeeze6] (1.10.1+dfsg-3 Debian:testing [i386]) []
Inst libkrb5support0 [1.8.3+dfsg-4squeeze6] (1.10.1+dfsg-3 Debian:testing [i386])
Inst libidn11 (1.25-2 Debian:testing [i386])
Inst libpcre3 (1:8.30-5 Debian:testing [i386])
Inst libxml2 (2.8.0+dfsg1-7 Debian:testing [i386])
Inst imagemagick-common (8: Debian:testing [all])
Inst libavahi-common-data (0.6.31-1 Debian:testing [i386])
Inst libavahi-common3 (0.6.31-1 Debian:testing [i386])
Inst libdbus-1-3 (1.6.8-1 Debian:testing [i386])
Inst libavahi-client3 (0.6.31-1 Debian:testing [i386])
Inst libffi5 (3.0.10-3 Debian:testing [i386])
Inst libglib2.0-0 (2.33.12+really2.32.4-3 Debian:testing [i386])
Inst libcroco3 (0.6.6-2 Debian:testing [i386])
Inst libcups2 (1.5.3-2.13 Debian:testing [i386])
Inst libjpeg8 (8d-1 Debian:testing [i386])
Inst libpng12-0 (1.2.49-1 Debian:testing [i386])
Inst libjbig0 (2.0-2 Debian:testing [i386])
Inst libtiff4 (3.9.6-10 Debian:testing [i386])
Inst libcupsimage2 (1.5.3-2.13 Debian:testing [i386])
Inst libdatrie1 (0.2.5-3 Debian:testing [i386])
Inst libdjvulibre-text ( Debian:testing [all])
Inst libdjvulibre21 ( Debian:testing [i386])
Inst ttf-dejavu-core (2.33-3 Debian:testing [all])
Inst fontconfig-config (2.9.0-7.1 Debian:testing [all])
Inst libfontconfig1 (2.9.0-7.1 Debian:testing [i386])
Inst libjasper1 (1.900.1-13 Debian:testing [i386])
Inst libxau6 (1:1.0.7-1 Debian:testing [i386])
Inst libxdmcp6 (1:1.1.1-1 Debian:testing [i386])
Inst libxcb1 (1.8.1-2 Debian:testing [i386])
Inst libx11-data (2:1.5.0-1 Debian:testing [all])
Inst libx11-6 (2:1.5.0-1 Debian:testing [i386])
Inst libgdk-pixbuf2.0-common (2.26.1-1 Debian:testing [all])
Inst libgdk-pixbuf2.0-0 (2.26.1-1 Debian:testing [i386])
Inst libgomp1 (4.7.2-5 Debian:testing [i386])
Inst x11-common (1:7.6+8~bpo60+1 Debian Backports:squeeze-backports [all])
Inst libice6 (2:1.0.8-2 Debian:testing [i386])
Inst liblcms1 (1.19.dfsg-1.2 Debian:testing [i386])
Inst liblqr-1-0 (0.4.1-2 Debian:testing [i386])
Inst libltdl7 (2.4.2-1.1 Debian:testing [i386])
Inst liblcms2-2 (2.2+git20110628-2~bpo60+1 Debian Backports:squeeze-backports [i386])
Inst libsm6 (2:1.2.1-2 Debian:testing [i386])
Inst libxext6 (2:1.3.1-2 Debian:testing [i386])
Inst libxt6 (1:1.1.3-1 Debian:testing [i386])
Inst libmagickcore5 (8: Debian:testing [i386])
Inst libpixman-1-0 (0.24.0-1~bpo60+1 Debian Backports:squeeze-backports [i386])
Inst libxcb-render0 (1.8.1-2 Debian:testing [i386])
Inst libxcb-shm0 (1.8.1-2 Debian:testing [i386])
Inst libxrender1 (1:0.9.7-1 Debian:testing [i386])
Inst libcairo2 (1.10.2-7~bpo60+1 Debian Backports:squeeze-backports [i386])
Inst libilmbase6 (1.0.1-4 Debian:testing [i386])
Inst libmagickwand5 (8: Debian:testing [i386])
Inst libopenexr6 (1.6.1-6 Debian:testing [i386])
Inst libthai-data (0.1.18-2 Debian:testing [all])
Inst libthai0 (0.1.18-2 Debian:testing [i386])
Inst libxft2 (2.3.1-1 Debian:testing [i386])
Inst fontconfig (2.9.0-7.1 Debian:testing [i386])
Inst libpango1.0-0 (1.30.0-1 Debian:testing [i386])
Inst librsvg2-2 (2.36.1-1 Debian:testing [i386])
Inst libwmf0.2-7 ( Debian:testing [i386])
Inst libmagickcore5-extra (8: Debian:testing [i386])
Inst libpaper1 (1.1.24+nmu2 Debian:testing [i386])
Inst poppler-data (0.4.5-10 Debian:testing [all])
Inst libsystemd-login0 (44-7 Debian:testing [i386])
Inst krb5-locales (1.10.1+dfsg-3 Debian:testing [all])
Inst libclass-isa-perl (0.36-3 Debian:testing [all])
Inst perl-modules (5.14.2-16 Debian:testing [all]) []
Inst perl (5.14.2-16 Debian:testing [i386]) []
Inst libswitch-perl (2.16-2 Debian:testing [all])
Inst dbus (1.6.8-1 Debian:testing [i386])
Inst fonts-droid (20101110+git-3~bpo60+1 Debian Backports:squeeze-backports [all])
Inst libijs-0.35 (0.35-8 Debian:testing [i386])
Inst libjbig2dec0 (0.11+20120125-1 Debian:testing [i386])
Inst libgs9-common (9.05~dfsg-6.3 Debian:testing [all])
Inst libgs9 (9.05~dfsg-6.3 Debian:testing [i386])
Inst gsfonts (1:8.11+urwcyr1.0.7~pre44-4.2 Debian:6.0.6/stable, Debian:testing, Debian:unstable [all])
Inst ghostscript (9.05~dfsg-6.3 Debian:testing [i386])
Inst hicolor-icon-theme (0.12-1 Debian:6.0.6/stable, Debian:testing, Debian:unstable [all])
Inst imagemagick (8: Debian:testing [i386])
Inst libexiv2-12 (0.23-1 Debian:testing [i386])
Inst libglib2.0-data (2.33.12+really2.32.4-3 Debian:testing [all])
Inst libnetpbm10 (2:10.0-15+b1 Debian:testing [i386])
Inst libpaper-utils (1.1.24+nmu2 Debian:testing [i386])
Inst librsvg2-common (2.36.1-1 Debian:testing [i386])
Inst netpbm (2:10.0-15+b1 Debian:testing [i386])
Inst sgml-base (1.26+nmu3 Debian:testing [all])
Inst shared-mime-info (1.0-1+b1 Debian:testing [i386])
Inst liblensfun-data (0.2.5-2 Debian:testing [all])
Inst liblensfun0 (0.2.5-2 Debian:testing [i386])
Inst ufraw-batch (0.18-2 Debian:testing [i386])
Inst xml-core (0.13+nmu2 Debian:testing [all])

Notice that some stable and backports packages will be installed (and they really install as I tested).

Now If I want to install a package from stable I execute this:

apt-get -t stable install [PACKAGE NAME]/stable

I execute this because of problem 2 described in question (install another package that depends on a library that was installed as a dependency from testing).

If I install ruby1.9.1-dev from testing:

apt-get -t stable install --no-install-recommends ruby1.9.1-dev/testing

It will install some libraries including libc6 from testing but not gcc. Then If I want to install gcc from stable and I just run:

apt-get install gcc

I will get Broken package errors. If I try:

apt-get -t stable install gcc

It will install gcc from testing. To install gcc from stable I must run:

apt-get -t stable install gcc/stable

Note that It may downgrade packages, but in this case it will not downgrade any packages:

These extra packages will be installed:
  binutils cpp cpp-4.4 cpp-4.7 gcc gcc-4.4 gcc-4.4-base gcc-4.7-base libgcc1 libgmp10 libgomp1 libmpc2 libmpfr4 libstdc++6
Suggested packages:
  binutils-doc cpp-doc gcc-4.4-locales gcc-4.7-locales gcc-multilib make manpages-dev autoconf automake1.9 libtool flex bison gdb gcc-doc gcc-4.4-multilib
  libmudflap0-4.4-dev gcc-4.4-doc libgcc1-dbg libgomp1-dbg libmudflap0-dbg libcloog-ppl0 libppl-c2 libppl7
The following NEW packages will be installed:
  binutils cpp cpp-4.4 cpp-4.7 gcc gcc-4.4 gcc-4.7-base libgmp10 libgomp1 libmpc2 libmpfr4
The following packages will be updated:
  gcc-4.4-base libgcc1 libstdc++6
3 updated packages, 11 new installed packages, 0 to be removed and 159 not updated.
Inst gcc-4.7-base (4.7.2-5 Debian:testing [i386])
Inst libgcc1 [1:4.4.5-8] (1:4.7.2-5 Debian:testing [i386])
Inst libstdc++6 [4.4.5-8] (4.7.2-5 Debian:testing [i386])
Inst libgmp10 (2:5.0.5+dfsg-2 Debian:testing [i386])
Inst libgomp1 (4.7.2-5 Debian:testing [i386])
Inst libmpfr4 (3.1.0-5 Debian:testing [i386])
Inst libmpc2 (0.9-4 Debian:testing [i386])
Inst binutils (2.22-7.1 Debian:testing [i386])
Inst cpp-4.7 (4.7.2-5 Debian:testing [i386])
Inst cpp (4:4.7.2-1 Debian:testing [i386])
Inst gcc-4.4-base [4.4.5-8] (4.4.7-2 Debian:testing [i386])
Inst cpp-4.4 (4.4.7-2 Debian:testing [i386])
Inst gcc-4.4 (4.4.7-2 Debian:testing [i386])
Inst gcc (4:4.4.5-1 Debian:6.0.6/stable [i386])

Notice that gcc will be installed from stable.

Also note that if you put

APT::Default-Release "stable";

on /etc/apt/apt.conf.d/70debconf it looks like you will not need to use -t stable. Ex:

Instead of
    apt-get -t stable install gcc/stable

I could just run
    apt-get install gcc/stable

This is because I already specified that my target is stable on 70debconf.

I want to know if there are other/better solutions because this one is more of a hack.

share|improve this answer
add comment

Your Answer


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.