Today I was in need to install 1 single package from the unstable release of Debian in a server installed with the stable release, so what’s the best way to get this done ?
For this example I’ll use the package
drush because there are a lot of differences in the versions between the different release of Debian.
But as first thing you must be sure to have all the repository that you want to use in the file /etc/apt/sources.list in these days if you are using a server that uses the stable release (squeeze) you should have something similar to this one:
deb http://debian.fastweb.it/debian squeeze main contrib non-free deb http://debian.fastweb.it/debian wheezy main contrib non-free deb http://ftp.it.debian.org/debian unstable main contrib non-free deb http://security.debian.org/ squeeze/updates main contrib deb-src http://security.debian.org/ squeeze/updates main contrib deb http://www.backports.org/debian squeeze-backports main contrib non-free
This list defines all the standard repository: stable (squeeze), testing (wheezy) and Sid aka Unstable, we are also defining the backport repository and the security repository.
Now, to know which versions are available for a package that you want to install use the command:
apt-cache policy packagename, so using
drush as package I get this output:
apt-cache policy drush drush: Installed: (none) Candidate: 3.3-1 0 Version table: 5.7-1 0 100 http://ftp.it.debian.org/debian/ unstable/main amd64 Packages 100 /var/lib/dpkg/status 5.4-1 0 500 http://debian.fastweb.it/debian/ wheezy/main amd64 Packages 4.5-2~bpo60+1 0 650 http://www.backports.org/debian/ squeeze-backports/main amd64 Packages 3.3-1 0 700 http://debian.fastweb.it/debian/ squeeze/main amd64 Packages
If you wonder what are the numbers at the start of each repository, these are the priority of every source, the higher has more priority and they are read from the file /etc/apt/preferences that on my server contains these information:
Package: * Pin: release a=stable Pin-Priority: 700 Package: * Pin: release a=squeeze-backports Pin-Priority: 650 Package: * Pin: release a=testing Pin-Priority: 600 Package: * Pin: release a=unstable Pin-Priority: 100
So by default the system would install the package from the stable release, and in general this is what i want, but this time I want to install the 5.7 version of the package, let’s see how to do this:
You can use
apt-get -t distribution install package with this command you’ll use the named distribution to install the package name and the dependencies, so using
apt-get -t unstable install drush
drush 5.7-1 0 AND
php 5.4.4-9, one of the dependencies of this package.
This could be exactly what you are searching for, but perhaps you just want to have
drush from the unstable distribution and keep php at the stable distribution ?
To install just
drush from the unstable distribution you can use the command:
apt-get install drush/unstable the command is similar to the former, BUT there is an important difference this command tell to apt to install ONLY the package
drush from the unstable distribution and all its dependencies will be taken from the default distribution; in this case from the stable distirbution, and so at the end of this command you’ll have
drush 5.7-1 0 AND
These 2 ways should cover most of your needs, but it’s also possible to temporary change the priority file or tell
apt-get to install a specific version, and I’m sure that there are other ways to achieve this result, as usual there is more than one way to get the result on GNU/Linux and it’s a thing I love of this operating system.
- Linux Security: How to hide processes from other users
- Productivity boosting with open source applications
- 8 Simple To Follow Tips To Secure Your Apache Web Server
- The Humble “Open Source” Bundle
- Linux Games: FTL Advanced Edition expansion
Find me on Google+