How do I fix duplicated packages issue of CLN

Sometimes after incorrect updates duplicated packages appear in the system

For example:

<...>
alt-python27-2.7.13-3.el6.x86_64 is a duplicate with alt-python27-2.7.11-7.el6.x86_64
alt-python27-2.7.13-4.el6.x86_64 is a duplicate with alt-python27-2.7.13-3.el6.x86_64
alt-python27-libs-2.7.13-3.el6.x86_64 is a duplicate with alt-python27-libs-2.7.11-7.el6.x86_64
alt-python27-libs-2.7.13-4.el6.x86_64 is a duplicate with alt-python27-libs-2.7.13-3.el6.x86_64
<...>

 

First of all, we need the full list of dupes:

package-cleanup --dupes | tail -n +3

 

We'll also need to save this list into a file:

package-cleanup --dupes | tail -n +3 > duplist.txt

 

The main idea is to do the following (for each package):

  1. Remove the lowest version from the rpmdb: rpm -e --justdb --nodeps $PKGNAME
  2. Reinstall the highest version: yum -y reinstall $PKGNAME

 

It is a good idea to check what is going to be done before real operations:

(This will only display a list of all the commands without execution)

cat duplist.txt | 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)}'

 

Then we perform the necessary operations:

("pipe sh" has been added at the end in order to execute the sequence):

cat duplist.txt | 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

 

Alternatively, all this could be performed without an intermediary file:

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
  • 4 Users Found This Useful
Was this answer helpful?

Related Articles

How to fix lveinfo database error of CLN

Run the following command: service lvestats stoptar -zcvf /root/lveinfo_backup_$(date...

How to Install KernelCare on cPanel/WHM server

To install KernelCare, you need to log in with the root user on your cPanel server. Check for...

Switching all cPanel acc/s to "inherit" PHP version

You can change all cPanel users to inherit with this CLI command: for each in `cat...

How to fix issues like PHP selector not available

Some of our clients face the issues like "PHP selector not available" on cPanel accounts of their...

CloudLinux installed, but still showing CentOS

Some of our clients face the issue, that's why we're writing the tutorial to fix it. First of...