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 rpm2cpio piped to cpio to extract the embedded file system and payload.
  • Slackware (TGZ/TXZ): Utilizes standard tar utilities along with compression tools like gzip or xz.
  • 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: alien queries the foreign package for metadata such as package name, version, architecture, and description. For an RPM, it queries tags via rpm or extracts the internal spec structure. It then maps these values to the fields required by Debian's DEBIAN/control file (e.g., Package, Version, Architecture, Maintainer, and Description).
  • Dependency Handling: Foreign package dependency names rarely match Debian package names. By default, alien does 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, alien extracts 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:

  1. Permission Normalization: Permissions on files and directories are checked and normalized to conform to Debian policy, ensuring standard users cannot alter critical system binaries.
  2. Archive Compilation: The utility executes Debian’s native packaging tool, dpkg-deb, using the command dpkg-deb --build <temporary_directory> <output_name>.deb.
  3. Cleanup: Once dpkg-deb compiles the control information and payload into the final compressed .deb archive, 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.