[Redhat] Lock package versions

In Redhat/CentOS 6 it’s possible to selectively pin a particular package version to keep it from updating. For that we will use the versionlock plugin:

yum install yum-plugin-versionlock

To add a package to the lock list:

yum versionlock add <package_name>
Loaded plugins: security, versionlock
Adding versionlock on: 0:<package_name>-<package_version>
versionlock added: 1

To remove an entry from lock list:

yum versionlock delete 0:<package_name>-<package_version>
Loaded plugins: security, versionlock
Deleting versionlock for: 0:<package_name>-<package_version>
versionlock added: 1

To check the lock list content:

yum versionlock list
Loaded plugins: security, versionlock
0:<package_name>-<package_version>
...
versionlock list done

[Debian] Error: subprocess post-removal script returned error exit status xx

This error message may appear if you are unlucky enough to install a damaged or badly designed package and then want to remove it. Now that your package manager is “stuck” you must fix the situation by hand.

Go to the directory /var/lib/dpkg/info and list every scripts related to the faulty package ls .* <package_name>.

Depending the precise error modify the appropriate script (prerm or postrm). Sometime changing /bin/sh -e by /bin/sh could be enough. Other time you must comment the ‘faulty’ line. Worst case scenario place an exit 0 at the second line.