Converting packages with Alien
The Alien package conversion tool can be very effective but can also generate unpredictable results. We show how to get the most out of this tool.
I can't lie to you about your chances, but you have my sympathies. – Ash to Ripley in Alien
Debian packages have a reputation for reliability, but Alien  is a notable exception. The problem has nothing to do with its code. Rather, the problem is that its purpose – to convert packages to other formats – is so dependent on the purpose and quality of the packages it works with that the success rate is mostly unpredictable. Despite its limitations, Alien remains a popular package. The dream of compatibility across package formats is simply too tantalizing to abandon.
Alien was first written before the turn of the millennium, when the balance of power between package managers was more equal. Back then, developer Joey Hess thought it made sense to give Debian a means of converting
.rpm packages to
These days, with popularity tilted toward Debian derivatives like Ubuntu and Linux Mint, users of
.rpm-based distributions like Fedora are more likely to find Alien useful, even though its Debian origins remain obvious. In recent years, most Debian-derived distributions include Alien in their repositories, although you will still have to hunt it down specifically in Fedora and other
Alien is most reliably used on packages with either few or self-contained dependencies. For example, fonts, clipart, and audio collections work well because they generally require no dependencies.
When a converted package requires dependencies that other applications require, however, problems may arise, because different distributions do not always place files in the same directory. These days, even Debian derivatives might not use the same file locations, although the odds are usually in your favor.
When the original package does assume different locations, it either won't install or won't work. If the converted package is one that the system requires to work, such as
libc, you might even find your system unbootable.
True, recent versions of Alien include options to allow you to edit the converted package. However, making use of these options requires knowledge of where core files are located on your system and involves either altering the script or creating symbolic links for the package to use. You might get a certain satisfaction from hacking the package so it works, but you might find the manual conversion more effort than your interest in a package merits.
If you are not equipped to fine-tune a package, the comprehensive man page suggests a sensible rule to follow: "If you can't remove a package without breaking your system, don't try to replace it with an alien version."
Supported Format Conversions
You can tell which distribution technology Alien was first written for because, even now, the command defaults to creating a Debian package. To begin, login as root, so you can be sure of access to all dependencies, and enter:
The output will be a Debian package in the same directory as the original package and one version number higher. You can add additional files to convert in a space-separated list, and you do not need to specify an output file.
Alien's options include
--to-deb, but they seem to exist for the sake of completeness more than anything else. If you do have problems converting a package to Debian, the cause is most likely the lack of one of the basic commands listed in the man page, such as
make. On a non-Debian system, you might need to download the
alien-extra package .
Alien also converts to and from the Solaris
.pkg format with
--to-pkg and Stampede packages with
--to-slp (and no other option), and from tar files (
--to-tgz. However, tar files only work if they contain binary files in a standard Linux directory tree; otherwise, Alien will produce the requested output file, but it won't work. Even worse, if the tar file contains source code, the converted package will simply install the source code in the root directory, leaving you to delete it.
.rpm is the most common format for conversion. It is chosen by the addition of either the
--to-rpm option. In my experience, it tends to be the most reliable non-Debian format to use, perhaps because it is the most in demand and more work has been done on it.
As an offshoot of its
.rpm support, Alien also includes support for packages created by the Linux Standard Base (LSB) . The LSB project attempts to standardize the filesystem hierarchy on distributions. Its packages are a subset of the
.rpm format, usually prefixed by
In theory, conversion to or from LSB format should be more reliable than any other format, because the prefix minimizes the potential conflicts in dependencies. At times, the practice matches the theory. Too often, though, the practice falls short of the theory. Not all distributions fully support the LSB (even those involved in the project), and the packages that are LSB compatible are in a definite minority. Still, if you are lucky enough to find LSB packages you want to convert, they seem the likeliest format to be trouble free.
Face to Face with Alien
If you are very sure about the package you are converting, you can add the
--install option to the basic command to install the result as soon as it is created and then delete the package.
By default, the output package will have a version number one higher than the original package, but if the version number is important to you, you can add
--keep-version to leave it unchanged. You can also use
--version=VERSION to specify a version or
--bump=NUMBER to increase the version by more than one. My personal preference is to leave the version number unchanged, which makes the original package easier to find again.
However, even if you are confident about the package, Alien is probably best run verbosely so you can troubleshoot. It includes two verbose modes:
--verbose and the even more chatty
--veryverbose, either of which can help you figure how to create a workable package (Figure 1).
Alternatively, if you hope to create a Debian package, you can use
--test as a dry run (Figure 2). Taking this extra step can help avoid many of the problems that a misapplication of Alien can cause.
If the converted project requires tweaking, you have several options. If you have built Alien from source and patched it, you can see a record of the patches in
/var/lib/alien. When creating a Debian package, you can specify the particular patch to use with
--patch=PATCH. You also have the options of
--anypatch, either of which can be used in the hope that a different version of Alien will give you different results.
Another way to tweak is to use
--fixperms to correct the permissions in the package being converted. If you study Alien's verbose output, you will notice that much of the conversion process involves altering permissions, so this can be a useful option. You need to be careful, though, because the options can either clean up confused or mixed permissions or remove required ones – which is exactly why you should avoid running this command without examining the package contents first.
The same is also true for
--scripts. Both of these options try to convert the scripts so they run on your system. However, given the potential problems, in some cases you may be better off manually editing paths in the package.
With any format, you might also want to copy the original package to another directory and then use
--generate (Figure 3). Instead of creating a package, these options create staging directories from which you view and/or manually edit the files in the package in a text editor, just as you would when building a package from scratch. The command displays the name of the directory as output. Just remember to back up the package if you are using the option only for informational purposes.
When you have finished manipulating the original package's files, you can then rebuild it as a package for your system. Given enough expertise, that is probably the most reliable way to use Alien, although it may be beyond your knowledge without a bit of study beforehand.
Knowing When to Quit
Many users quickly become impatient with Alien's imperfections, and, to some extent, they are justified. Alien deals with so many moving targets that it is unlikely ever to become completely reliable – nor can anything as simple as adding a graphical interface take the place of expert knowledge of filesystem hierarchies or package building .
Users with less expertise – that is, the majority of us – often have to decide how far to pursue the use of Alien on a particular package. On one hand, Alien can be a quick solution for installing a package and can keep all the packages on a system under the control of the package manager, making them easier to find and remember.
On the other hand, when trouble arises, sooner or later you need to make a choice. Alien users can either continue to invest time in fine-tuning, hoping eventually to produce an installable package (and learning valuable system information as a by-product), or else cut their losses of time and effort and install the package some other way – perhaps in a virtual machine running a distribution that can handle the package you hope to use or by compiling from source. Alien can seem almost magical when it works, but, in some cases, you may eventually be better off with another installation solution.
- Alien: http://joeyh.name/code/alien/
- Download alien-extra package: ftp://ykbsb2.yk.psu.edu/pub/alien/
- Linux Standard Base: https://en.wikipedia.org/wiki/Linux_Standard_Base
- Package Converter: http://code.google.com/p/foxoman/wiki/PackageConverter
Buy this article as PDF
Upcoming switch to HTML5-only ads is further evidence the Flash is entering its final days.
US government invests $19 billion on enhancing security and replacing ancient computer systems.
But you can still be a non-voting “individual supporter” if you pay the money
Several current systems could fall victim to the attack
Latest Linux engine comes with better graphics and support for Intel's new power-saving chips.
Hackers send a message of beauty and liberation to server logs
Citrix gets excited about new Pi-Powered XenDesktop client system
Linux on Azure cert heralds a new era for Redmond.
Proposals for presentations at the CeBIT Open Source Forum will be accepted through 24 January 2016.
Adobe looks for a new start; renames its embattled Flash tool.