The developers and package maintainers may not always create packages for all Linux distributions. Some packages might be available only for a specific Linux platform. In such cases, you can use package conversion tools like Alien to easily convert Linux packages to different formats. In this guide, we will see what is Alien, how to install Alien in various Linux operating systems and then how to convert a Linux package from one format to another using Alien package converter.
Table of Contents
What is Alien?
Alien is a command line package converter that converts between different Linux package formats such as Red Hat rpm, Debian deb, Stampede slp, Slackware tgz, and Solaris pkg etc.
Alien currently supports the following package formats:
- Linux Standard Base (LSB),
- LSB-compliant
.rpm
packages, .deb
,- Stampede (
.slp
), - Solaris (
.pkg
) - Slackware (
.tgz
,.txz
,.tbz
, .tlz
).
The alien programs comes in rescue when a specific package or a specific version of a package is not available for your Linux distribution. You can easily convert such package to your preferred package format using Alien and install it on your system.
Alien is not only a package converter, it can also install the generated packages automatically after package conversion. It can even has option to convert the scripts that are meant to be run when the package is installed. You must be careful when using this option. You should examine the scripts carefully and check what these scripts do before using this option.
Heads Up: Alien should not be used to convert important system packages, such as init, libc, which are necessary for the functioning of your Linux system. The system packages that are specifically designed for a particular Linux distribution can't be used interchangeably and may break your system if you forcibly try to install them.
Install Alien in Linux
Alien package converter is available in the default repositories of popular Linux distributions.
To install Alien in Alpine Linux, run:
$ sudo apk add alien
Install Alien in Debian, Ubuntu LTS, Linux Mint, Pop!_OS:
$ sudo apt install alien
Install Alien in Fedora:
$ sudo dnf install alien
Install Alien in CentOS 8, RHEL 8, AlmaLinux 8, Rocky Linux 8:
$ sudo dnf install epel-release
$ sudo dnf install alien
Convert Linux packages using Alien
The general syntax to convert Linux packages using Alien from one format to another is:
alien [--to-deb] [--to-rpm] [--to-tgz] [--to-slp] [options] file [...]
Converting packages using Alien is very easy!
To convert a .rpm
package into a .deb
package, simply run alien as root
or sudo
user:
$ sudo alien --to-deb /path/to/file.rpm
Similarly, to convert .deb
file to .rpm
, run:
$ sudo alien --to-rpm /path/to/file.deb
Here is the list of supported flags to convert Linux packages to different formats.
-d
,--to-deb
- Make debian packages. This is the default.-r
,--to-rpm
- Make rpm packages.-l
,--to-lsb
- Make a LSB package.-t
,--to-tgz
- Make tgz packages.--to-slp
- Make slp packages.-p
,--to-pkg
- Make Solaris pkg packages.
Let us see some examples. For the purpose of this guide, I will be using hello world .rpm
package. Please note that hello
package is packaged for almost all Linux distributions. So you don't need to convert it. I am using it just for the sake of demonstration.
Convert RPM packages to DEB packages using Alien
Now let us convert the hello rpm package to .deb
format using Alien like below:
$ sudo alien --to-deb hello-2.10-5.fc34.x86_64.rpm
Or shortly,
$ sudo alien -d hello-2.10-5.fc34.x86_64.rpm
This will convert the given .rpm
package into .deb
package and save the generated package in the current directory.
Heads Up: If no flag is specified, Alien will convert the packages to .deb
format by default.
You can install the generated package using the default package manager.
We can also convert multiple packages at a time. The following command will convert the given packages (hello & vim) to .deb
format.
$ sudo alien hello-2.10-7.x86_64.rpm vim-enhanced-8.2.2637-1.fc34.x86_64.rpm
Convert DEB packages to RPM packages using Alien
Similarly, we can convert the .deb
package into .rpm
package file like below:
$ sudo alien --to-rpm hello-2.10-5.fc34.x86_64.rpm
Or shortly,
$ sudo alien -r hello-2.10-5.fc34.x86_64.rpm
Install packages automatically
Sometimes, you might want to install the generated packages automatically.
To convert a package and install it automatically with Alien, use -i
flag.
$ sudo alien -d -i hello-2.10-7.x86_64.rpm
This command will convert the given .rpm package to .deb package format and then install it, and finally remove the generated package.
Sample output:
dpkg --no-force-overwrite -i hello_2.10-8_amd64.deb Selecting previously unselected package hello. (Reading database ... 52712 files and directories currently installed.) Preparing to unpack hello_2.10-8_amd64.deb ... Unpacking hello (2.10-8) ... Setting up hello (2.10-8) ... Processing triggers for man-db (2.9.4-2) ...
Convert to multiple package formats
Alien can able to create multiple package file formats from a single package file. The following example shows how to create .deb
, and .tgz
packages from a .rpm
file.
$ sudo alien --to-deb --to-tgz hello-2.10-7.x86_64.rpm
Keep version numbers
By default, Alien adds one to the minor version number of each package it converts. For instance, if the version number is 1.2-3, Alien will add one to minor version and change it to 1.2-4.
Take a look at the following command output.
$ sudo alien --to-deb hello-2.10-7.x86_64.rpm hello_2.10-8_amd64.deb generated
The version of source package in the above command is 2.10.7. After the package conversion, Alien changed the minor version from 7 to 8 in the target file.
If you don't want Alien to change the version number, use -k
, --keep-version
flag to keep the original version number in the generated package.
$ sudo alien -k --to-deb hello-2.10-7.x86_64.rpm hello_2.10-7_amd64.deb generated
As you see above, the source file and target have the same version number.
Getting help
To display the brief description of Alien and all supported general options, refer the Alien help section by running the following command:
$ alien --help
Also, refer the manual page.
$ man alien
Conclusion
I won't give any assurance about the accuracy of Alien converter. I tested only a few packages such as Vim, Hello world, and Nano. As far as I tested, Alien works just fine for me in Debian 11 bullseye.
It probably won't work for some packages that depends on large number of dependencies. The result may vary from package to package.
In such cases, you may need to build them from source manually or using other reliable applications such as CheckInstall or Fpm. I suggest you to look into the following resources to learn how to build packages from source.
- How To Build Debian Packages From Source
- How To Build Packages From Source Using CheckInstall
- How To Easily Build Linux Packages For Multiple Platforms
- Recreate Debian Binary Packages That Are Already Installed On A System
- How To Convert DEB Packages Into Arch Linux Packages
Hope this helps.
Resource:
1 comment
Hi,
Thanks a lot
Very nice and useful article