Each Linux distribution has its own preferred package format. CentOS/RHEL are derived from Fedora, and use “rpm” packages, whereas Debian derived distros like Ubuntu use “deb” files. Most of the time, you can find what you want using the respective package managers and libraries for each distribution. And failing that, you can always compile directly from source! Though there are problems associated with the latter approach – you should always make sure that you can uninstall your software cleanly on Linux.

Sometimes however, you just can’t find a way to get the source for a program, or an RPM package that you can install via your own package manager. All you have is a “deb” file from another distro. Or maybe you want a deb file and only have an rpm file to work with. Here’s what happens when you try and use the wrong distro to install a package meant for another distro:

As you can see, it doesn’t work. CentOS expects rpm packages, not deb ones. So when pushed to it, we can try and convert the deb files into rpm (and vice-versa) using the “alien” package. Let’s see how to do it.

Converting deb Files Into rpm

For this example, I’m going to use a program called “Diceware” that’s available in the deb repositories here. We have similar programs for rpm (of course), but let’s say you specifically want to use this particular package. The first step is to install “alien” on your system. If you’re on CentOS/RHEL, you type in:

yum install alien

This package installs a large number of related files on your system – all necessary tools for converting one package format into another:

Now that’s alien is installed, I go to my temp directory and place my deb file into it. To convert it to an rpm file, I use the following command:

alien --to-rpm diceware_0.9.1-2_all.deb

Where you will replace the section in bold, with the name of your own deb file. If you want to perform the conversion the other way around and transition from an rpm file to a deb file, use the following option instead of –to-rpm:

--to-deb

Alien will perform the conversion to the best of its ability. You can now try and install the resulting rpm or deb package using your package manager like this for me:

yum localinstall diceware-0.9.1-3.noarch.rpm

Dealing with Filesystem Conflicts

A lot of hockey-pockey goes into converting package files from one distro into another – and the process almost never works perfectly. Chances are that during your installation of the rpm or deb file, you’re going to run into errors like this “Transaction check error”:

These are problems in the “spec” file of the rpm package that need to be resolved. To do this, we’re going to have to modify and rebuild it using the “rpmrebuild” utility. First, make sure that you already have the EPEL repos installed using this command:

yum install epel-release

Then install it on your system like this:

yum --enablerepo=epel-testing install rpmrebuild

This is a repo that’s normally disabled, so we temporarily enable it for this installation with the –enablerepo=epel-testing flag. Once rpmbuild is installed, open up the rpm package for editing using this command:

rpmrebuild -pe diceware_0.9.1-2_all.rpm

This will allow you to edit the RPM package in the standard vi editor. Scroll down or find the “%files%” section, and make a note of the lines containing the directories mentioned in the error messages. In my case, these are:

  1. “/”
  2. “/usr/bin”
  3. “/usr/lib”

As shown here:

Delete these lines using the vi editor. If you don’t know how to do this, check out this quick tutorial on how to use vi. After deleting them, save your changes. The program will exit and then ask you whether you want to rebuild the rpm package. Select “y” for yes:

As you can see, the rpmrebuild places the new rpm package in a different location – not the current directory. In my case, the location is: /root/rpmbuild/RPMS/noarch/diceware-0.9.1-3.noarch.rpm

Copy this location and try and install it again using the regular package manager. This time, everything should work out fine as shown below:

Install DEB files in CentOS

And there you have it! You’ve successfully installed a “deb” file onto a CentOS installation. Keep in mind that there’s no guarantee that this will work properly even after it’s installed. Linux package files aren’t meant to be cross run like this, so it’s entirely possible that you will still get errors. But if you know what you’re doing and want to give it a try, using “alien” is the path to take.

tracking pixel

Is your website slow?

Enter its URL below to find out now:

About the Author

Bhagwad Park

Leave a Reply

Your email address will not be published. Required fields are marked *