Wednesday, January 25, 2012

How to list or remove rpms of a specific architecture

Advertisements


Sometimes we gets package conflict errors because packages of different architectures are installed in same  system. We have to check the architecture of the system using "uname -a" command and remove the packages of other architecture. how can we remove a i386 rpm? how can we remove a x86_64 rpm?

For finding all i386 and i686 rpms
rpm -qa --queryformat='%{n}-%{v}-%{r}.%{arch}\n' | grep '\.i[3456]86$'

To find a particular i386 package
rpm -qa --queryformat='%{n}-%{v}-%{r}.%{arch}\n' | grep '\.i[3456]86$'  | grep "package-name"

For finding all x86_64 rpms
rpm -qa --queryformat='%{n}-%{v}-%{r}.%{arch}\n' | grep '\.x86_64$'

To find a particular x86_64 package
rpm -qa --queryformat='%{n}-%{v}-%{r}.%{arch}\n' | grep '\.x86_64$'  | grep "package-name"

To remove all i386 and i686 rpms (This is not recommended. You better grep out the one you want to remove using the above commands and remove it manually)
rpm -qa --queryformat='%{n}-%{v}-%{r}.%{arch}\n' | grep '\.i[3456]86$' | xargs rpm -ev

Sometimes you will get dependecy error. You can then use --nodeps option
eg:
rpm -qa --queryformat='%{n}-%{v}-%{r}.%{arch}\n' | grep '\.i[3456]86$' | grep openssl
rpm -ev openssl-0.9.8e-20.el5.i686 --nodeps

To remove all x86_64 rpms (This is not recommended. You better grep out the one you want to remove using the above commands and remove it manually)
rpm -qa --queryformat='%{n}-%{v}-%{r}.%{arch}\n' | grep '\.x86_64$'  | xargs rpm -ev

No comments:

Post a Comment

Be nice. That's all.