Categories
SysOps

How to lock specified packages from being updated

Use versionlock plugin to protect packages from being updated on the CentOS operating system.

Install Yum versionlock plugin.

$ sudo yum install yum-plugin-versionlock

List locked packages.

$ sudo yum versionlock list
Loaded plugins: fastestmirror, versionlock
versionlock list done

List available updates.

$ yum check-update
Loaded plugins: fastestmirror, versionlock
Loading mirror speeds from cached hostfile
 * base: ftp.icm.edu.pl
 * extras: ftp.man.poznan.pl
 * updates: ftp.icm.edu.pl

libwbclient.x86_64                                                     4.10.16-7.el7_9                                               updates
samba-client-libs.x86_64                                               4.10.16-7.el7_9                                               updates
samba-common.noarch                                                    4.10.16-7.el7_9                                               updates
samba-common-libs.x86_64                                               4.10.16-7.el7_9                                               updates
samba-libs.x86_64                                                      4.10.16-7.el7_9                                               updates

Lock these samba-* packages.

$ sudo yum versionlock samba-*
Loaded plugins: fastestmirror, versionlock
Adding versionlock on: 0:samba-common-libs-4.10.4-10.el7
Adding versionlock on: 0:samba-client-libs-4.10.4-10.el7
Adding versionlock on: 0:samba-libs-4.10.4-10.el7
Adding versionlock on: 0:samba-common-4.10.4-10.el7
versionlock added: 4

List locked packages.

$ sudo yum versionlock list   
Loaded plugins: fastestmirror, versionlock
0:samba-common-libs-4.10.4-10.el7.*
0:samba-client-libs-4.10.4-10.el7.*
0:samba-libs-4.10.4-10.el7.*
0:samba-common-4.10.4-10.el7.*
versionlock list done

Perform an upgrade process.

$ sudo yum upgrade
Loaded plugins: fastestmirror, versionlock                                                                                                  
Loading mirror speeds from cached hostfile                                                                                                  
 * base: ftp.icm.edu.pl                                                                                                                     
 * extras: ftp.icm.edu.pl                                                                                                                   
 * updates: ftp.icm.edu.pl                                                                                                                  
Excluding 4 updates due to versionlock (use "yum versionlock status" to show them)                                                          
Resolving Dependencies                                                                                                                      
--> Running transaction check                                                                                                               
---> Package libwbclient.x86_64 0:4.10.4-10.el7 will be updated                                                                             
--> Processing Dependency: libwbclient = 4.10.4-10.el7 for package: samba-common-libs-4.10.4-10.el7.x86_64                                  
--> Processing Dependency: libwbclient = 4.10.4-10.el7 for package: samba-client-libs-4.10.4-10.el7.x86_64                                  
--> Processing Dependency: libwbclient = 4.10.4-10.el7 for package: samba-libs-4.10.4-10.el7.x86_64
---> Package libwbclient.x86_64 0:4.10.16-7.el7_9 will be an update
--> Processing Dependency: samba-client-libs = 4.10.16-7.el7_9 for package: libwbclient-4.10.16-7.el7_9.x86_64
--> Processing Dependency: libreplace-samba4.so(SAMBA_4.10.16)(64bit) for package: libwbclient-4.10.16-7.el7_9.x86_64
--> Finished Dependency Resolution                                                                                                          
Error: Package: samba-libs-4.10.4-10.el7.x86_64 (@anaconda)
           Requires: libwbclient = 4.10.4-10.el7
           Removing: libwbclient-4.10.4-10.el7.x86_64 (@anaconda)
               libwbclient = 4.10.4-10.el7
           Updated By: libwbclient-4.10.16-7.el7_9.x86_64 (updates)
               libwbclient = 4.10.16-7.el7_9
           Available: libwbclient-4.10.16-5.el7.i686 (base)
               libwbclient = 4.10.16-5.el7                                                                                                  
Error: Package: samba-client-libs-4.10.4-10.el7.x86_64 (@anaconda)
           Requires: libwbclient = 4.10.4-10.el7
           Removing: libwbclient-4.10.4-10.el7.x86_64 (@anaconda)
               libwbclient = 4.10.4-10.el7
           Updated By: libwbclient-4.10.16-7.el7_9.x86_64 (updates)
               libwbclient = 4.10.16-7.el7_9                                                                                                
           Available: libwbclient-4.10.16-5.el7.i686 (base)
               libwbclient = 4.10.16-5.el7
Error: Package: libwbclient-4.10.16-7.el7_9.x86_64 (updates)
           Requires: samba-client-libs = 4.10.16-7.el7_9
           Installed: samba-client-libs-4.10.4-10.el7.x86_64 (@anaconda)
               samba-client-libs = 4.10.4-10.el7
Error: Package: samba-common-libs-4.10.4-10.el7.x86_64 (@anaconda)
           Requires: libwbclient = 4.10.4-10.el7
           Removing: libwbclient-4.10.4-10.el7.x86_64 (@anaconda)
               libwbclient = 4.10.4-10.el7
           Updated By: libwbclient-4.10.16-7.el7_9.x86_64 (updates)
               libwbclient = 4.10.16-7.el7_9
           Available: libwbclient-4.10.16-5.el7.i686 (base)
               libwbclient = 4.10.16-5.el7
Error: Package: libwbclient-4.10.16-7.el7_9.x86_64 (updates)
           Requires: libwbclient = 4.10.4-10.el7
           Removing: libwbclient-4.10.4-10.el7.x86_64 (@anaconda)
               libwbclient = 4.10.4-10.el7
           Updated By: libwbclient-4.10.16-7.el7_9.x86_64 (updates)
               libwbclient = 4.10.16-7.el7_9
           Available: libwbclient-4.10.16-5.el7.i686 (base)
               libwbclient = 4.10.16-5.el7
Error: Package: libwbclient-4.10.16-7.el7_9.x86_64 (updates)
           Requires: libreplace-samba4.so(SAMBA_4.10.16)(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
[vagrant@debian ~]$ yum check-update                                   
Loaded plugins: fastestmirror, versionlock
Loading mirror speeds from cached hostfile
 * base: ftp.icm.edu.pl
 * extras: ftp.man.poznan.pl
 * updates: ftp.icm.edu.pl
Excluding 4 updates due to versionlock (use "yum versionlock status" to show them)

libwbclient.x86_64                                                  4.10.16-7.el7_9                                                  updates

It looks like the libwbclient needs to be locked too.

$ sudo yum versionlock libwbclient 
Loaded plugins: fastestmirror, versionlock
Adding versionlock on: 0:libwbclient-4.10.4-10.el7
versionlock added: 1

List locked packages.

$ sudo yum versionlock list
Loaded plugins: fastestmirror, versionlock
0:samba-common-libs-4.10.4-10.el7.*
0:samba-client-libs-4.10.4-10.el7.*
0:samba-libs-4.10.4-10.el7.*
0:samba-common-4.10.4-10.el7.*
0:libwbclient-4.10.4-10.el7.*
versionlock list done

List available updates.

$ yum check-update
Loaded plugins: fastestmirror, versionlock
Loading mirror speeds from cached hostfile
 * base: ftp.icm.edu.pl
 * extras: ftp.man.poznan.pl
 * updates: ftp.icm.edu.pl
Excluding 5 updates due to versionlock (use "yum versionlock status" to show them)

Perform an upgrade process.

$ sudo yum upgrade
Loaded plugins: fastestmirror, versionlock
Loading mirror speeds from cached hostfile
 * base: ftp.icm.edu.pl
 * extras: ftp.icm.edu.pl
 * updates: ftp.icm.edu.pl
Excluding 5 updates due to versionlock (use "yum versionlock status" to show them)
No packages marked for update

Clear versionlock database.

$ sudo yum versionlock clear               
Loaded plugins: fastestmirror, versionlock
versionlock cleared

List available updates.

$ yum check-update
Loaded plugins: fastestmirror, versionlock
Loading mirror speeds from cached hostfile
 * base: ftp.icm.edu.pl
 * extras: ftp.man.poznan.pl
 * updates: ftp.icm.edu.pl

libwbclient.x86_64                                                     4.10.16-7.el7_9                                               updates
samba-client-libs.x86_64                                               4.10.16-7.el7_9                                               updates
samba-common.noarch                                                    4.10.16-7.el7_9                                               updates
samba-common-libs.x86_64                                               4.10.16-7.el7_9                                               updates
samba-libs.x86_64                                                      4.10.16-7.el7_9                                               updates

You can delete a single entry in case of an error.

$ sudo yum versionlock delete libwbclient
Loaded plugins: fastestmirror, versionlock
Deleting versionlock for: 0:libwbclient-4.10.4-10.el7.*
versionlock deleted: 1