How to Install deb Packages on CentOS / Convert RPM to deb (originally: How to Create an RPM or DEB Package from Source on Linux with CheckInstall)

As I’m sure you already know, there are many ways to install software on Linux: using the package management system provided by your distribution (aptitude, yum, or zypper, plus plenty of other examples), compiling from source (rarely used anymore, although it was the only available method in the early days of Linux), or using the respective low-level tools — dpkg for .deb, and rpm for .rpm — precompiled packages, and so on.

Convert RPM to DEB and DEB to RPM

Using Alien to convert RPM to DEB and DEB to RPM

In this article, we’ll introduce you to alien, a tool for converting between the various different Linux package formats, whose most common use is converting .rpm to .deb (or the other way around). If you need a package of a specific type and can only find it in another format, this tool will come in handy sooner or later — even if its author no longer maintains it and states on his website that alien will probably remain in an experimental state forever. For example, there was a time when I was looking for a .deb driver for an inkjet printer but couldn’t find one — the manufacturer only provided an .rpm package, and alien saved me. I installed alien, converted the package, and shortly afterwards I could use my printer without any problems. Even so, we have to make one thing clear: this tool should not be used to convert important system files and libraries, because they have different configurations in different distributions. Alien should only be used as a last resort, when the installation method recommended for the situation described above simply doesn’t fit. Last but not least, we have to note that although we use CentOS and Debian in this article, aside from those first two distributions and their respective families, as far as we know alien can also work on Slackware, and even Solaris.

Step 1: Install Alien and its dependencies

To install alien on CentOS/RHEL 7, you need to enable the EPEL and Nux Dextop repositories (yes, Dextop — not Desktop), in the following order:

  1. # yum install epel-release

The current latest version of the package that enables the Nux Dextop repository is 0.5 (released on August 10, 2015); before installing you can check whether a newer version is available at http://li.nux.ro/download/nux/dextop/el7/x86_64/.

  1. # rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
  2. # rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm

Then do,

  1. # yum update && yum install alien

On Fedora, you only need to run the commands above. On Debian and its derivatives, you only need:

  1. # aptitude install alien

Step 2: Convert a .deb into an .rpm package

For this test, we chose the date utility, which provides a set of date and time tools for processing large amounts of financial data. We’ll download the .deb package to our CentOS 7 machine, convert it to .rpm and install it:

Check CentOS Version

Check CentOS Version

Check the CentOS version

  1. # cat /etc/centos-release
  2. # wget http://ftp.us.debian.org/debian/pool/main/d/dateutils/dateutils_0.3.1-1.1_amd64.deb
  3. # alien --to-rpm --scripts dateutils_0.3.1-1.1_amd64.deb

Convert .deb to .rpm package in Linux

Converting .deb to .rpm on Linux

Important: (note how alien bumps the minor version number of the target package. If you want to ignore that behavior, add the -keep-version flag). If we try to install the package right away, we’ll run into a few problems:

  1. # rpm -Uvh dateutils-0.3.1-2.1.x86_64.rpm

Install RPM Package

Installing the RPM package

To fix that problem, we need to enable the epel-testing repository and then install the rpmbuild tool to edit the package’s configuration so we can rebuild the package:

  1. # yum --enablerepo=epel-testing install rpmrebuild

Then run,

  1. # rpmrebuild -pe dateutils-0.3.1-2.1.x86_64.rpm

It will open your default text editor. Go to the %files section and delete the lines that refer to the directories mentioned in the error message, then save the file and exit:

Convert .deb to Alien Version

Converting .deb to an Alien version

After you exit the file, you’ll be prompted to continue with the rebuild. If you choose “Y”, the file will be rebuilt into the specified directory (different from the current working directory):

  1. # rpmrebuild –pe dateutils-0.3.1-2.1.x86_64.rpm

Build RPM Package

Building the RPM package

Now you can go ahead and install the package as usual and verify it:

  1. # rpm -Uvh /root/rpmbuild/RPMS/x86_64/dateutils-0.3.1-2.1.x86_64.rpm
  2. # rpm -qa | grep dateutils

Install Build RPM Package

Installing the built RPM package

Finally, you can list the individual tools included in the date utility, and also view their respective man pages:

  1. # ls -l /usr/bin | grep dateutils

Verify Installed RPM Package

Verifying the installed RPM package

Step 3: Convert an .rpm into a .deb package

In this section, we’ll demonstrate how to convert .rpm to .deb. On a 32-bit Debian Wheezy machine, let’s download the .rpm package for the zsh shell from the CentOS 6 OS repository. Note that this shell is not available in the default installation of Debian and its derivatives.

  1. # cat /etc/shells
  2. # lsb_release -a | tail -n 4

Check Shell and Debian OS Version

Checking the shell and Debian OS version

  1. # wget http://mirror.centos.org/centos/6/os/i386/Packages/zsh-4.3.11-4.el6.centos.i686.rpm
  2. # alien --to-deb --scripts zsh-4.3.11-4.el6.centos.i686.rpm

You can safely ignore the message about the missing signature:

Convert .rpm to .deb Package

Converting the .rpm into a .deb package

After a moment, the .deb package should have been generated and be ready to install:

  1. # dpkg -i zsh_4.3.11-5_i386.deb

Install RPM Converted Deb Package

Installing the deb package converted from RPM

Once it’s installed, check whether zsh has been added to the list of valid shells:

  1. # cat /etc/shells

Confirm Installed Zsh Package

Confirming the installed Zsh package

Reprinted from: http://www.linuxidc.com/Linux/2015-09/122573.htm Article URL: http://erik.xyz/?p=1398