About APT pinning in various distributions and versions

One thing about APT pinning I've now learned for life is that you should always check the output of apt-cache policy. In various distributions and APT versions the pinning might behave a bit differently. Checking the output of apt-cache policy (note that there's no package name at the end of the command, thus it'll list your APT sources and their pinning values) reveals most probably the reason why your preferences file does not do whatever you wish it to do.

Eg. in case of Debian Lenny (5.*) the output for the lenny sources might look like this:
500 http://security.debian.org lenny/updates/non-free Packages
     release v=5.0,o=Debian,a=oldstable,l=Debian-Security,c=non-free
     origin security.debian.org
500 http://security.debian.org lenny/updates/contrib Packages
     release v=5.0,o=Debian,a=oldstable,l=Debian-Security,c=contrib
     origin security.debian.org
500 http://security.debian.org lenny/updates/main Packages
     release v=5.0,o=Debian,a=oldstable,l=Debian-Security,c=main
     origin security.debian.org
500 http://ftp.us.debian.org lenny/non-free Packages
     release v=5.0.9,o=Debian,a=oldstable,l=Debian,c=non-free
     origin ftp.us.debian.org
500 http://ftp.us.debian.org lenny/contrib Packages
     release v=5.0.9,o=Debian,a=oldstable,l=Debian,c=contrib
     origin ftp.us.debian.org
500 http://ftp.us.debian.org lenny/main Packages
     release v=5.0.9,o=Debian,a=oldstable,l=Debian,c=main
     origin ftp.us.debian.org

In case of a Debian Squeeze (6.*) system that has Lenny sources too it might look like this:
  -1 http://security.debian.org/ lenny/updates/non-free i386 Packages
     release v=5.0,o=Debian,a=oldstable,n=lenny,l=Debian-Security,c=non-free
     origin security.debian.org
  -1 http://security.debian.org/ lenny/updates/contrib i386 Packages
     release v=5.0,o=Debian,a=oldstable,n=lenny,l=Debian-Security,c=contrib
     origin security.debian.org
  -1 http://security.debian.org/ lenny/updates/main i386 Packages
     release v=5.0,o=Debian,a=oldstable,n=lenny,l=Debian-Security,c=main
     origin security.debian.org
  -1 http://ftp.us.debian.org/debian/ lenny/non-free i386 Packages
     release v=5.0.8,o=Debian,a=oldstable,n=lenny,l=Debian,c=non-free
     origin ftp.us.debian.org
  -1 http://ftp.us.debian.org/debian/ lenny/contrib i386 Packages
     release v=5.0.8,o=Debian,a=oldstable,n=lenny,l=Debian,c=contrib
     origin ftp.us.debian.org
  -1 http://ftp.us.debian.org/debian/ lenny/main i386 Packages
     release v=5.0.8,o=Debian,a=oldstable,n=lenny,l=Debian,c=main
     origin ftp.us.debian.org

A quite significant difference between the two is that the APT in Lenny distinguishes Lenny from Squeeze only based on the v (aka. version) and the a (aka. archive) attributes of the sources. While the APT in Squeeze also adds the n attribute (aka. codename).

You can find various APT pinning tutorials on the net, but if you don't apply them to the very same distribution+version that the tutorial was written for (or even: you apply them years later and the used APT sources return different archive names -oldstable, stable, testing- than they did at the time of writing), then you might experience quite different results as the writer of the article or blog post.

Therefore it's always useful to check the output of apt-cache policy to see what attributes of an APT source you can use in your pinning rules.