12

Is there a way to tell yum to install a package, selecting a version of that package that would be satisfied by currently installed dependencies?

For example, if I'm installing a pecl package and I currently have installed php-5.4.11 but a newer php-5.4.14 is available. Rather than install the new package (and update all php packages to 5.4.14) I just want it to select an older version of the package I requested to be installed without updating all the others (or fail if this cannot be done).

This is a specific case in which I know I could exclude or fix the php package but I'm looking for a generic option that would apply to any install.

Something like:

yum install php-pecl-xxxx --no-updates
TPS
  • 2,481
  • Have not come across any such option as of now. However if u want to install the package without upgrading I would recommend downloading a rpm of same version and then install it. – Aazim Parkar May 02 '13 at 15:38

3 Answers3

11

Temporary Solution:

Use the -C (--cacheonly) flag:

sudo yum install foobar -C

Reference: Working with Yum Cache [in] Red Hat Enterprise Linux 6.

Permanent solution:

Use the metadata_expire option in your yum.conf to control this.

Edit /etc/yum.conf and set

metadata_expire=15d

You can use d, h or m to configure the time in days, hours or minutes.

Here is the documentation:

metadata_expire is Time (in seconds) after which the metadata will expire.  So that if the current metadata downloaded is less than this many seconds old then yum will not update the metadata against the repository. If you find that yum is not downloading information on updates as often as you would like lower the value of this option.  You can also change from the default of using seconds to using days, hours or minutes by appending a d, h or m respectively.  The default is 6 hours, to compliment yum-updatesd running once an hour.  It's also possible to use the word "never", meaning that the metadata will never expire.  Note that when using a metalink file the metalink must always be newer than the metadata for the repository, due to the validation, so this timeout also applies to the metalink file.  Also note that "never" does not override "yum clean expire-cache"

  — Source: yum.conf(5)

0

In the yum-utils package there is a tool called yumdownloader. You can use it to download from repos without installing. All the standard switches like --disablerepo apply. See the man page for more into on it.

I think you can download the RPM and then do what you want using RPM directly.

slm
  • 369,824
  • 1
    This is a part of an automatic package installation system, the problem is that we don't want yum to 'install the latest' and 'update everything that's needed'. We really just want it to install a version of the package that is compatible with what's already installed. Basically an installonly or install xxx -no-updates option. – Clint Priest May 02 '13 at 16:32
0

If the older version of the package is still in your yum repositories, then you can just run yum install packagename-version-release.arch and it'll install the older version without trying to upgrade to the latest release. You'll need to use the full name, version, release and arch if there are multiple versions and architectures in your yum repo. You can get all that information by running yum list available 'packagename*' to search for all packages starting with 'packagename'. If you've managed to upgrade your packages and want to downgrade to the older release, you can run yum downgrade packagename1 packagename2. You'll need to include the list of all the packages you want to downgrade, since it probably will involve a lot of dependencies.

If the older release isn't in your yum repository, then just download it from wherever you found the old package and install it with yum install /path/to/package.rpm, although I would caution against installing packages from untrusted sources.

jsbillings
  • 24,406
  • But it would be much much more useful if yum could just pick the latest compatible version available. – forcefsck Nov 30 '15 at 11:45
  • It can, but it's up to the packager to define requirements that are appropriate. – jsbillings Nov 30 '15 at 16:06
  • Sometimes the requirements are covered with an older package, but yum insists on picking only the latest. Eg. in the case described above, it should be possible for yum to automatically select php-pecl-5.4.11 if the system is version locked to php-5.4.11. It can be a problem for automation. – forcefsck Nov 30 '15 at 20:49
  • Yum only will update to the latest version if there are no dependencies on the old version. In the case above, the version requirement was never required by the pecl package. Yum can't read your mind and choose an arbitrary version unless you indicate what version in a requires or by versionlock-ing the pecl and php packages. – jsbillings Dec 01 '15 at 15:18
  • For this example specifically, provided that php is not upgradeable (either version-locked or no newer packages available on repos), yum could select the latest version of pecl that won't require a php upgrade. It's not exactly mind reading, I believe apt-get does this already.

    Again, this is a problem for automation when you need to install an extra package without upgrading half your system and you need yum to be smart enough to handle the request, ie, if multiple versions exist, pick the latest compatible with the already installed packages that for whatever reason can't be upgraded.

    – forcefsck Dec 01 '15 at 15:45