Installing a specific package version with APT

In order to install a specific version of a package in Debian, you can edit /etc/apt/preferences or you can simply specify the version directly on the command line.

Let’s see all the choices we have to install clamav-freshclam:

debian-box:/# apt-cache policy clamav-freshclam
  Installed: 0.90.1dfsg-3etch10
  Candidate: 0.90.1dfsg-3etch10
  Version table:
     0.92.1~dfsg-1volatile1 0
        500 http://apt-cacher etch/volatile/main Packages
 * 0.90.1dfsg-3etch10 0
        800 http://apt-cacher etch/updates/main Packages
        100 /var/lib/dpkg/status
     0.90.1dfsg-3etch9 0
        800 http://apt-cacher etch/main Packages

The default version to be installed is 0.90.1dfsg-3etch10 0, which is the standart Etch version. If we want to install the volatile version:

debian-box:/# apt-get install clamav-freshclam=0.92.1~dfsg-1volatile1
Reading package lists… Done
Building dependency tree… Done
Suggested packages:
The following packages will be upgraded:
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 12.7MB of archives.
After unpacking 3379kB of additional disk space will be used.
Get:1 http://apt-cacher etch/volatile/main clamav-freshclam 0.92.1~dfsg-1volatile1 [12.7MB]
Fetched 12.7MB in 1s (7263kB/s)           
Preconfiguring packages …

More info here.