Introduction
While trying to install or update RPMs you noticed there are duplicate RPMs reported. An indicator is when trying to update an RPM or run yum update you see "conflicts with" errors like:
Error: lvemanager conflicts with lve-wrappers-0.6-11.el7.cloudlinux.x86_64
or and error like "Error: Package:" "Requires: <packagename>" like this
Error: Package: ea-php72-php-calendar-7.2.19-1.1.3.cpanel.x86_64 (EA4)
Requires: ea-php72-php-common(x86-64) = 7.2.19-1.1.3.cpanel
You can confirm this by running the following to show what RPMs are duplicates.
package-cleanup --dupes
Example output:
# package-cleanup --dupes|grep cpanel
ea-php70-php-litespeed-7.0.30-1.1.6.cpanel.x86_64
ea-php71-pear-1.10.1-12.12.7.cpanel.noarch
ea-php56-php-imap-5.6.36-1.1.6.cpanel.x86_64
ea-php55-php-iconv-5.5.38-37.37.5.cpanel.x86_64
ea-php55-php-fpm-5.5.38-37.37.5.cpanel.x86_64
ea-php55-php-devel-5.5.38-37.37.5.cpanel.x86_64
ea-apache24-tools-2.4.33-5.5.1.cpanel.x86_64
ea-php55-php-imap-5.5.38-37.37.5.cpanel.x86_64
#
You may read that it is okay to run "package-cleanup --cleandupes" but this at times has cleared/removed system RPMs that were needed and broke the operating system.
Procedure
Instead of using --cleandupes use the following that will take the list of RPMs and then clear the RPM from the RPM database and then reinstall that RPM to ensure it is fully installed.
package-cleanup --dupes | tail -n +3 | sort --version-sort | awk 'NR % 2 {print "rpm -e --justdb --nodeps " $1 } !(NR % 2) {match($0, "-[0-9]");print "yum -y reinstall " substr($0,0,RSTART-1)}' | sh