Convert Non-Ubuntu Packages




Convert Non-Ubuntu Packages

Packages created for other Linux distributions can be installed on your Ubuntu system with a little TLC.

Various Linux distributions use their own packaging schemes, and although there are a huge number of packages available directly within Ubuntu, there may be times you come across software that's available only in a package for Red Hat or some other distro, only in source code form, or only as a Debian package that has been built against a different version of the toolchain.

If the software is available only as a tarball, you can create a package [Hack #62] and install it directly. If the software is available as a Debian package but hasn't been compiled specifically for Ubuntu (perhaps it's only in Debian Experimental, for example), you can fetch the source package and then use the standard package tools to compile a source package [Hack #63]. And if the software is provided in an alternative package format altogether, such as an RPM, you can use Alien to convert it into the correct format.

Convert Packages with Alien

Alien is a utility that understands a number of package formatsincluding RPM (Red Hat Package Manager), LSB (Linux Standards Base), SLP (Stampede), Slackware, PKG (Solaris), and DEB (Debian package, used by Ubuntu)and can convert from one to another.

Start by downloading the package you need to convert. Then install Alien:

$ sudo apt-get install alien
            

Now you can feed it your package to convert:

$ alien -c 
               
                  myprogram-1.0.1-1.i386.rpm
               
            

The -c flag tells Alien to also convert any installation or removal scripts that it finds in the original package.

Once Alien has finished, you will have an equivalent .deb package; use the instructions in "Install and Remove Standalone .deb Files" [Hack #57] to install it and check that it works. If things didn't go quite as planned, however, read on.

Solve Package-Conversion Problems

Software packages can be remarkably complex and contain scripts that perform specific setup routines when the package is installed, upgraded, or removed. These scripts may contain references to programs that are located in different places on different distributions, and this is almost impossible to convert totally automatically, so you have to understand that Alien performs conversions on a "best effort" basis. If the original package relies on another program already existing on your system, the installation may fail in strange and obscure ways that are hard to track down.

If the package appeared to install properly but doesn't seem to work, the first step to debugging the problem is to use dpkg to find where the various files were put on disk:

$ dpkg -L 
               
                  myprogram
               
            

Doing so may uncover obvious problems immediately, such as a program binary being installed in an unusual location such as /usr/local/bin instead of the more usual /usr/bin.

If that doesn't help, you can try running Alien again, but this time add the -g flag that tells it to just extract the original package instead of converting it:

$ alien -cg 
               
                  myprogram-1.0.1-1.i386.rpm
               
            

This will open up the package into its individual parts, allowing you to look inside and examine any scripts used to install the software, as well as examine the directory structure that will be used when the package is installed. Editing the installation script to suit your environment and then running it by hand may be enough to get the package working.

Convert Ubuntu Packages to Other Formats

The default behavior for Alien is to convert any package passed to it into a .deb package. That suits Ubuntu systems just fine, of course, but you can also use Alien to convert .deb packages to other formats, or to convert between formats. For example, to convert an Ubuntu package to RPM for installation on a Red Hat machine, run:

$ alien -c --to-rpm 
               
                  myprogram_1.0.1_i386.deb