Tuesday, January 29, 2013

Install a specific package version

Yesterday, after a partial upgrade in my Ubuntu 12.10 installation, git was uninstalled.

After the upgrade I tried to re-install it and got the following error:
$ sudo apt-get install git
Reading package lists... Done
Building dependency tree    
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
 git : Depends: git-man (< 1:1.8.0.3-.) but 1:1.8.1.1-1~ppa0~quantal2 is to be installed
E: Unable to correct problems, you have held broken packages.
Basically git depended on git-man version 1.8.0.3, but the APT package handling utility was trying to install the newer version 1.8.1.1.

But how to install a specific version?

After some digging I found this tip.

I prefer the terminal option.
  • Query the APT cache about the packages versions avaiable:
$ sudo apt-cache showpkg git-man
Package: git-man
Versions:
1:1.8.1.1-1~ppa0~quantal2 (/var/lib/apt/lists/ppa.launchpad.net_git-core_ppa_ubuntu_dists_quantal_main_binary-amd64_Packages) (/var/lib/dpkg/status)
 Description Language:
                 File: /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_quantal_main_binary-amd64_Packages
                  MD5: 0c79f507738c0cb72351c8ae551ee47d
 Description Language: en
                 File: /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_quantal_main_i18n_Translation-en
                  MD5: 0c79f507738c0cb72351c8ae551ee47d
1:1.8.0.3-0ppa1~quantal1 (/var/lib/apt/lists/ppa.launchpad.net_git-core_ppa_ubuntu_dists_quantal_main_binary-amd64_Packages)
 Description Language:
                 File: /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_quantal_main_binary-amd64_Packages
                  MD5: 0c79f507738c0cb72351c8ae551ee47d
 Description Language: en
                 File: /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_quantal_main_i18n_Translation-en
                  MD5: 0c79f507738c0cb72351c8ae551ee47d
(...)
  • Install the desired version
$ sudo apt-get install git-man=1:1.8.0.3-0ppa1~quantal1
  • Install git normally
$ sudo apt-get install git