1

I've recently built a package which provides multiple virtual ones, more specifically snmp which provides libsnmp-base, libsnmp30 and so on:

 - Version: 5.8~git20160427.8d07349f-14
 - Depends: ...
 - Provides:
   snmp,libsnmp-base,libsnmp-dev,libsnmp30,python-snmp,snmpd,snmptrapd,tkmib
 - Conflicts:
   libsnmp-base,libsnmp-dev,libsnmp30,python-snmp,snmpd,snmptrapd,tkmib
 - Replaces:
   libsnmp-base,libsnmp-dev,libsnmp30,python-snmp,snmpd,snmptrapd,tkmib

It is installed on my system & provided on my online PPA. When I try to install another package (php7.0-snmp) which depends on libsnmp30 & libsnmp-base, APT offers me the option of uninstalling snmp in order to install the required dependencies.

It seems that APT always prefers real packages over virtual ones, despite the facts that:

  • the virtual ones have a more recent version
  • they are already installed

Aptitude offers more solutions, but none involves the preferred & most logical one: keep snmp because it already offers the most recent needed dependencies:

sudo aptitude install php7.0-snmpThe following NEW packages will be installed:
  libsnmp30{a} php7.0-snmp 
0 packages upgraded, 2 newly installed, 0 to remove and 1 not upgraded.
Need to get 832 kB of archives. After unpacking 3,382 kB will be used.
The following packages have unmet dependencies:
 snmp : Conflicts: libsnmp30 but 5.7.3+dfsg-1ubuntu4 is to be installed.
The following actions will resolve these dependencies:

     Remove the following packages:               
1)     snmp                                       

     Install the following packages:              
2)     libsnmp-base [5.7.3+dfsg-1ubuntu4 (xenial)]

Accept this solution? [Y/n/q/?] n
The following actions will resolve these dependencies:

     Keep the following packages at their current version:
1)     libsnmp30 [Not Installed]                          
2)     php7.0-snmp [Not Installed]                        

Accept this solution? [Y/n/q/?] n
The following actions will resolve these dependencies:

     Install the following packages:                                           
1)     libsnmp-base [5.7.3+dfsg-1ubuntu4 (xenial)]                             

     Downgrade the following packages:                                         
2)     snmp [5.8~git20160427.8d07349f-14 (now) -> 5.7.3+dfsg-1ubuntu4 (xenial)]

Accept this solution? [Y/n/q/?] n

*** No more solutions available ***

How can I install php7.0-snmp without having to uninstall snmp?

1 Answer 1

1

Virtual packages can't help you here. From the Debian Policy Manual:

If a relationship field has a version number attached, only real packages will be considered to see whether the relationship is satisfied (or the prohibition violated, for a conflict or breakage). In other words, if a version number is specified, this is a request to ignore all Provides for that package name and consider only real packages. The package manager will assume that a package providing that virtual package is not of the "right" version. A Provides field may not contain version numbers, and the version number of the concrete package which provides a particular virtual package will not be considered when considering a dependency on or conflict with the virtual package name.

One way out is to create minimal packages for each of the provided packages, which just depend on your actual snmp package (transitional packages). They'll be of a higher version and preferred automatically.

2
  • OK, but there is no version number attached to any of the relationship field, and the policy stating "the version number of the concrete package which provides a particular virtual package will not be considered when considering a dependency on or conflict with the virtual package name" does not make any sense and should be changed.
    – user281819
    May 6, 2016 at 8:34
  • @jean-christophe Check the depends for php7.0-snmp
    – muru
    May 6, 2016 at 8:45

You must log in to answer this question.