Ubuntu – Apt doesn’t want to install an older version of package

aptdowngradepackage-management

I'm building a debian package from the source code. The package has, among the others, the following dependency (part of debian/control):

libswarm-dev (>= 0.6.1.0), libswarm-dev (<< 0.7),

This package and the project I'm trying to build are related to Yandex.Cocaine platform and Reverbrain company, which are not well-known, but I suspect that my problem is more general and not related to the specific package.
So, there are a lot of suitable versions of it in the connected repo:

vagrant@worker-2:~/cocaine/cocaine-plugins$ apt-cache policy libswarm-dev
libswarm-dev:
  Installed: (none)
  Candidate: 0.8.1.0
  Version table:
     0.8.1.0 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.8.0.0 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.7.3.0 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.7.2.0 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.7.1.0 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.7.0.11 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.7.0.10 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.7.0.9 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.7.0.8 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.7.0.7 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.7.0.6 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.7.0.5 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.7.0.4 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.7.0.3 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.7.0.2 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.7.0.1 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.6.5.1 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.6.5.0 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.6.3.9 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.6.3.8 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.6.3.7 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.6.3.6 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.6.3.5 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.6.3.4 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.6.3.3 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.6.3.2 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.6.3.1 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     0.6.3.0 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
vagrant@worker-2:~/cocaine/cocaine-plugins$ 

However, for some reason apt-get doesn't want to install them. Instead, apt insists on the latest version:

vagrant@worker-2:~/cocaine/cocaine-plugins$ sudo apt-get install libswarm-dev=0.6.5.1
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:
 libswarm-dev : Depends: libswarm2 (= 0.6.5.1) but 0.8.1.0 is to be installed
                Depends: libswarm2-urlfetcher (= 0.6.5.1) but 0.8.1.0 is to be installed
                Depends: libswarm2-xml (= 0.6.5.1) but 0.8.1.0 is to be installed
E: Unable to correct problems, you have held broken packages.

apt-get install -f doesn't help too:

vagrant@worker-2:~/cocaine/cocaine-plugins$ sudo apt-get install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 41 not upgraded.

All the dependencies of the libswarm-dev package have the required versions:

vagrant@worker-2:~$ apt-cache policy libswarm2
libswarm2:
  Installed: (none)
  Candidate: 0.8.1.0
  Version table:
     0.8.1.0 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     ...
     0.6.5.1 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     ...
vagrant@worker-2:~$ apt-cache policy libswarm2-urlfetcher
libswarm2-urlfetcher:
  Installed: (none)
  Candidate: 0.8.1.0
  Version table:
     0.8.1.0 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     ...
     0.6.5.1 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     ...
vagrant@worker-2:~$ apt-cache policy libswarm2-xml
libswarm2-xml:
  Installed: (none)
  Candidate: 0.8.1.0
  Version table:
     0.8.1.0 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     ...
     0.6.5.1 0
        500 http://repo.reverbrain.com/trusty/ current/amd64/ Packages
     ...

Of course I can install each of them by hand (and I eventually did), but obviously it is not a right way. I think it is work of apt, not mine. How can I resolve this?

This is Trusty release of Ubuntu.

Best Answer

Have you tried the steps here?

If not quick recap:

  • Make sure universe and restricted repositories enabled. Hit Alt+F2, type software-properties-gtk and hit Enter.
  • Run sudo apt-get update This updates your package index files.
  • Run sudo apt-get clean. This clears out the local repository of retrieved package files (the .deb files).
  • Run sudo apt-get -f install. This will correct broken dependencies.
  • Run sudo dpkg --configure -a
  • Run sudo apt-get -f install again.