I am writing a script that installs some packages and does some configuration work. I want the script to install a specific major version of a package, but I do not care which minor version of the package it is.

More to the point, I want it to install the latest 2.y.z release of the package, but not 1.y.z or 3.y.z (or any other major version number).

I have tried (without success)

  • zypper install 'mypackage=2'
  • zypper install 'mypackage>1<3'
  • zypper install 'mypackage>1' 'mypackage<3'
  • zypper install 'mypackage>=2.0.0' 'mypackage<3.0.0'

The last one seems promising, because then zypper complains:

'mypackage>=2.0.0' not found in package names. Trying capabilities. No provider of 'mypackage >= 2.0.0' found.

However, after that message, it still proceeds with installing mypackage-1.5.0, because that satisfies the second package-edition specified.


From the man page

install (in) [options] name|capability|rpm_file_uri...
           Install or update packages.

           The packages can be selected by their name or by a capability they provide.

               A capability is formed by "NAME[.ARCH][ OP EDITION]", where ARCH is an architecture code, OP is one of =, or > and EDITION is "VERSION[-RELEASE]". For example: zypper=0.8.8-2 The NAME component of a
               capability is not only a package name but any symbol provided by packages: /bin/vi, libcurl.so.3, perl(Time::ParseDate). Just remember to quote to protect the special characters from the shell, for example:
               zypper\>0.8.10 or 'zypper>0.8.10'.

               If EDITION is not specified, the newest installable version will be installed. This also means that if the package is already installed and newer versions are available, it will get upgraded to the newest installable

               If ARCH is not specified, or the last dot of the capability name string is not followed by known architecture, the solver will treat the whole string as a capability name. If the ARCH is known, the solver will select
               a package matching that architecture and complain if such package cannot be found.

Since it says one of the following and I don't see any conjunction operator, I'll say that it can't be done natively.

You could always script it with something like

zypper se -n -s package | grep " package " | grep " MIN_NUM" | cut -d '|' -f 4

Do note: that the above is very lazy and should be better written.

Also note: you should make a feature request. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.