Restricting a Package to a Fixed Version Number with yum

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux 9

Issue

  • Lock a package to a specific version only, and no later
  • Exclude a package from $ yum update
  • What is yum versionlock?

Resolution

  • yum-versionlock is a Yum plugin that takes a set of name/versions for packages and excludes all other versions of those packages (including optionally following obsoletes). This allows you to protect packages from being updated by newer versions. The plugin provides a command "versionlock" which allows you to view and edit the list of locked packages easily.
  1. Install package

    For RHEL 7
    # yum install yum-plugin-versionlock
    
    For RHEL 8 and 9
    # yum install python3-dnf-plugin-versionlock
    

    The /etc/yum/pluginconf.d/versionlock.list will be created on the system.

  2. To install or lock the version of the gcc group of packages, run

    # yum versionlock gcc-*
    

NOTE Older yum-plugin-versionlock of RHEL7 require the specification of package version and architecture.
Update to the latest version if you use "*".

Root Cause

By default "yum update" or "yum upgrade" command tends to update every package existing on the system so the system gets up to date. Flip side of it, some applications require a particular version of a package, and updating all the packages together may cause issue to run the app smoothly.

Diagnostic Steps

  • To display the list of locked packages, use:

    # yum versionlock list
    
  • To discard the list of locked packages, use:

    # yum versionlock clear
    
  • To discard the lock on a specific package, use:

    # yum versionlock delete package_name 
    
  • Component
  • yum

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments