How Alien Converts Foreign Packages to DEB
The alien command-line utility serves as a package
converter for Linux systems, enabling the installation of non-native
packages on Debian-based distributions. This article explains the
internal mechanics of alien, detailing how it unpacks
source package archives—such as Red Hat RPM, Slackware TGZ, Stampede
SLP, and Solaris PKG—translates their structural metadata and control
scripts into Debian-compliant formats, and rebuilds the resulting file
tree into a functional .deb archive.
1. Source Package Extraction
When alien is executed against a foreign package format
(such as an .rpm file), its first step is to unpack the
archive into a temporary working directory. Rather than handling
decompression natively, alien leverages standard system
utilities corresponding to the target package type:
- RPM: Invokes tools such as
rpm2cpiopiped tocpioto extract the embedded file system and payload. - Slackware (TGZ/TXZ): Utilizes standard
tarutilities along with compression tools likegziporxz. - Stampede SLP and Solaris PKG: Executes their respective system unpackers.
Once unpacked, the entire directory tree of binaries, configuration
files, and documentation is placed into a temporary root directory
mimicking the target Linux filesystem (e.g., /usr/bin,
/etc).
2. Metadata Extraction and Translation
Debian packages rely on a specific DEBIAN control
directory containing structured metadata that governs package
management. alien translates foreign metadata into
Debian-compatible files:
- Control File Generation:
alienqueries the foreign package for metadata such as package name, version, architecture, and description. For an RPM, it queries tags viarpmor extracts the internal spec structure. It then maps these values to the fields required by Debian'sDEBIAN/controlfile (e.g.,Package,Version,Architecture,Maintainer, andDescription). - Dependency Handling: Foreign package dependency
names rarely match Debian package names. By default,
aliendoes not automatically translate or enforce complex dependencies, which avoids breaking local package trees, though it can attempt basic dependency mapping if explicitly instructed. - Maintainer Scripts: If foreign pre-installation,
post-installation, or removal scripts are present,
alienextracts them. By default, it excludes them to prevent incompatible shell scripts from damaging the host system, but users can force their inclusion as standard Debian maintainer scripts (preinst,postinst,prerm,postrm).
3. Assembling the Debian Package
After the filesystem hierarchy is prepared and the
DEBIAN control directory is fully populated,
alien builds the package:
- Permission Normalization: Permissions on files and directories are checked and normalized to conform to Debian policy, ensuring standard users cannot alter critical system binaries.
- Archive Compilation: The utility executes Debian’s
native packaging tool,
dpkg-deb, using the commanddpkg-deb --build <temporary_directory> <output_name>.deb. - Cleanup: Once
dpkg-debcompiles the control information and payload into the final compressed.debarchive, the temporary directory is deleted.
The resulting .deb file can then be installed directly
on Debian, Ubuntu, and derivative operating systems using native package
managers such as dpkg -i or apt install.