Redhat/Fedora/CentOS systems require .rpm packages for installation. Sometimes you may find that a RPM package is not available for a software or utility that you want but instead its DEB package is available. DEB packages are used for installation in Ubuntu/Debian systems and cannot be used directly in Redhat/Fedora/CentOS systems. So you will need to convert DEB to RPM package in order to be able to proceed with installation. In this article, we will look at how to convert DEB to RPM files in Linux.
How to Convert DEB to RPM files in Linux
We will use Alien software to convert .deb to .rpm package.
1. Install Alien & its dependencies
We have listed steps for both RPM as well as DEB system. You can use either of them depending on your Linux system.
Open terminal and run the following command to install alien software. First we need to enable EPEL and Nux desktop.
# yum install epel-release # rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
Install the latest Nux desktop. We have installed version 0.5. You may install another version as per your requirement.
# rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
Finally install alien package.
# yum update && yum install alien
In Fedora, you just need to run a single command shown below.
# yum update && yum install alien
Here is the command to install alien package in Ubuntu/Debian Linux.
# sudo aptitude install alien
2. Convert DEB to RPM Files
You can use -r option to convert DEB to RPM files. Here is an example. We use wget command to download a .deb file and then use alien command in two different ways to convert it to RPM file. They both give same result.
# wget http://ftp.us.debian.org/debian/pool/main/d/dateutils/dateutils_0.3.1-1.1_amd64.deb # alien -r dateutils_0.3.1-1.1_amd64.deb OR # alien --to-rpm --scripts dateutils_0.3.1-1.1_amd64.deb
3. Install Converted RPM file
If you try to directly install the RPM file generated above, sometimes it may give you an error message due to compatible package settings. In the message it will list 1 or more files that are causing the conflict as
Preparing ... file / from install of dateutils_0.3.1-1.1_amd64.deb conflicts with ... file /test.fgh from install of dateutils_0.3.1-1.1_amd64.deb conflicts with ... ...
So we need to run the following command to enable epel-testing repository and install rpmrebuild tool to modify the package’s installation settings.
# yum --enablerepo=epel-testing install rpmrebuild
Now run the following command to rebuild the package
# rpmrebuild -pe dateutils-0.3.1-2.1.x86_64.rpm
It will open the package settings in text editor. Go to %files% section and delete the lines that refer to the conflicting files listed above.
%files% %dir %attr... "/" %dir %attr... "/test.fgh"
Save and exit the file. When you exit, you will be asked if you want to continue with the rebuild. Enter Y to proceed.
Once the rebuild is complete, you can install it properly.
# rpm -Uvh /root/rpmbuild/RPMS/x86_64/dateutils-0.3.1-2.1.x86_64.rpm
Once installation is complete, you may verify it with the following command.
# ls -l /usr/bin | grep dateutils
That’s it. In this article, we have learnt how to convert DEB to RPM file and install it in Redhat/Fedora/CentOS Linux systems.
How to Convert RPM to DEB Files in Linux
How to Configure Access Control Lists (ACL) in Linux
How to Concatenate Multiple Lists in Python
How to Get MD5 Hash of String in Python
How to Split String by Delimiter in Python
How to Read File Line by Line in Linux Shell Script