[Linux] Converting Between RPM and deb Packages with the alien Command

目次

Overview

Linux systems are primarily divided into two package management systems: Red Hat-based (RPM) and Debian-based (deb). These formats are not natively compatible. The alien command allows you to convert package files between these formats, enabling you to install software that might not be natively available for your distribution. This tool is invaluable when, for example, you are using Ubuntu but need a specific piece of software that is only distributed in RPM format.

Specifications (Arguments and Options)

Syntax

alien [options] [source_file_name]

Conversion Format Options

These options specify the target format for the conversion.

OptionDescription
-d / –to-debConverts to deb format (Debian, Ubuntu, etc.). This is the default.
-r / –to-rpmConverts to RPM format (RHEL, CentOS, Fedora, etc.).
-t / –to-tgzConverts to tgz format (Slackware or a simple compressed archive).
-p / –to-pkgConverts to pkg format (Solaris).

Other Main Options

OptionDescription
-i / –installAutomatically installs the converted package into the system.
–bump=numberIncrements the package version (release number) during conversion.
–description=stringChanges the package description to the specified string.
-T / –testTests the conversion scripts without actually converting the file.
–target=architectureForces a specific target architecture (e.g., amd64, i386).

Main Formats Supported by alien

FormatDescription
RPMUsed by Red Hat Enterprise Linux, CentOS, AlmaLinux, Fedora, etc.
debUsed by Debian, Ubuntu, Kali Linux, Linux Mint, etc.
tgzUsed by Slackware or as a general tar+gzip archive.
pkgPackage format used by Solaris OS.

Basic Usage

To convert an RPM package (e.g., sl-5.02-1.el8.x86_64.rpm) into a deb package for use on Ubuntu, use the following command. The -d option is assumed by default.

# Convert an RPM file to a deb file
sudo alien --to-deb sl-5.02-1.el8.x86_64.rpm

Example Output:

sl_5.02-2_amd64.deb generated

The converted file is generated in the same directory as the source file.

Practical Commands

Converting from a deb Package to an RPM Package

Conversely, you can convert an Ubuntu package for use on a system like CentOS.

# Convert a deb file to an RPM file
sudo alien --to-rpm sl_5.02-1_amd64.deb

Example Output:

sl-5.02-2.x86_64.rpm generated

Converting and Installing an RPM Package Immediately

This command performs the conversion and the installation (via dpkg -i) in one step. This is useful for quickly testing RPM software in an Ubuntu environment.

# Execute conversion and installation at the same time
sudo alien -i sl-5.02-1.el8.x86_64.rpm

Example Output:

sl_5.02-2_amd64.deb generated
Selecting previously unselected package sl.
(Reading database ... 20543 files and directories currently installed.)
Preparing to unpack sl_5.02-2_amd64.deb ...
Unpacking sl (5.02-2) ...
Setting up sl (5.02-2) ...

Converting to Multiple Formats Simultaneously

You can generate both an RPM file and a tgz file from a single deb file at once.

# Convert to RPM and tgz formats simultaneously
sudo alien --to-rpm --to-tgz sl_5.02-1_amd64.deb

Customization Points

Incrementing Version Numbers (–bump)

When converting the same package multiple times, use this to automatically increase the release number. This prevents installation errors caused by duplicate versions.

alien --to-deb --bump=1 package.rpm

Specifying Architecture (–target)

Use this option in cross-platform development when you need to output a package for a different CPU architecture.

alien --to-deb --target=arm64 package.rpm

Important Notes

Dependencies are Not Resolved

The alien command only repackages binary files and directory structures. It does not convert or resolve the “libraries (dependencies)” required by the source package. It is common to encounter “library not found” errors when running the converted software.

Missing Installation Scripts

Configuration scripts such as pre-install or post-install included in RPMs or debs are often ignored or fail to run correctly after conversion. Therefore, alien is not suitable for complex packages that deeply modify system settings, such as databases or web servers.

Need for Root Privileges

To correctly preserve file ownership and permissions, it is highly recommended to run the alien command with sudo (root privileges).

Advanced Usage

Converting to tgz Format and Extracting Contents

If you do not want to install a package but need to extract a specific binary file from it, converting it to the general tgz format and then decompressing it is the fastest method.

# Convert to tgz
sudo alien --to-tgz proprietary-driver.rpm

# Decompress and check the contents
tar zxvf proprietary-driver.tgz

Summary

The alien command is a powerful bridge for using software across different Linux distributions. However, it is not a perfect universal converter and should be understood as a simple porting tool. It is best used as a last resort for standalone tools with few dependencies or for older software that lacks an official package for your specific distribution.

よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!

この記事を書いた人

私が勉強したこと、実践したこと、してることを書いているブログです。
主に資産運用について書いていたのですが、
最近はプログラミングに興味があるので、今はそればっかりです。

目次