I'd like to prefer the installation in nginx from squeeze-backports over that in mainline stable. I've got the backports repository enabled. I have this preference file:
# /etc/apt/preferences.d/nginx
Package: nginx nginx-common
Pin: release a=squeeze-backports
Pin-Priority: 999
Setting the target specifically works as expected:
# aptitude install -t squeeze-backports nginx
The following NEW packages will be installed:
libgd2-noxpm{a} libgeoip1{a} libjpeg62{a} libpcre3{a} libxml2{a} libxslt1.1{a} nginx nginx-common{a} nginx-full{a}
The following packages are RECOMMENDED but will NOT be installed:
geoip-database xml-core
0 packages upgraded, 9 newly installed, 0 to remove and 39 not upgraded.
Need to get 828 kB/2,235 kB of archives. After unpacking 4,985 kB will be used.
Do you want to continue? [Y/n/?]
but sans target does not:
# aptitude install nginx
The following NEW packages will be installed:
libgeoip1{a} libpcre3{a} nginx
The following packages are RECOMMENDED but will NOT be installed:
geoip-database
0 packages upgraded, 3 newly installed, 0 to remove and 25 not upgraded.
Need to get 339 kB/694 kB of archives. After unpacking 1,667 kB will be used.
Do you want to continue? [Y/n/?]
apt_preferences (5)
details the algorithm for deciding which package version to install:
If the target release has been specified then APT uses the following algorithm to set the priorities of the versions of a package. Assign:
priority 1 :: to the versions coming from archives which in their Release files are marked as "NotAutomatic: yes" but not as "ButAutomaticUpgrades: yes" like the debian experimental archive.
priority 100 :: to the version that is already installed (if any) and to the versions coming from archives which in their Release files are marked as "NotAutomatic: yes" and "ButAutomaticUpgrades: yes" like the debian backports archive since squeeze-backports.
priority 500 :: to the versions that are not installed and do not belong to the target release.
priority 990 :: to the versions that are not installed and belong to the target release.
If the target release has not been specified then APT simply assigns priority 100 to all installed package versions and priority 500 to all uninstalled package versions, except versions coming from archives which in their Release files are marked as "NotAutomatic: yes" - these versions get the priority 1 or priority 100 if it is additionally marked as "ButAutomaticUpgrades: yes".
APT then applies the following rules, listed in order of precedence, to determine which version of a package to install.
Never downgrade unless the priority of an available version exceeds 1000. ("Downgrading" is installing a less recent version of a package in place of a more recent version. Note that none of APT's default priorities exceeds 1000; such high priorities can only be set in the preferences file. Note also that downgrading a package can be risky.)
Install the highest priority version.
etc. You can read the full thing here. As I understand it, priority 999 is this current highest priority and the nginx from squeeze-backports should be favored. It clearly is not. Perhaps the devil is in the details--I'm not sure if the nginx package is marked NotAutomatic or ButAutomaticUpgrades or how to determine that--but the examples later in the manpage would suggest I've done the correct thing. Yet
# apt-cache policy nginx
nginx:
Installed: (none)
Candidate: 1.1.8-2~bpo60+1
Package pin: 1.1.8-2~bpo60+1
Version table:
1.1.8-2~bpo60+1 999
100 http://backports.debian.org/debian-backports/ squeeze-backports/main i386 Packages
0.7.67-3+squeeze1 999
500 http://debian.osuosl.org/debian/ squeeze/main i386 Packages
Priority 100 for the package I desire. What gives?
Is it possible that you're being bitten by this bug?
According to the most recent update, this is
fixed in aptitude 0.6.3-3.2