alien

From LinuxReviews
Jump to navigationJump to search

alien is a command-line tool for converting Linux software packages between Debian .deb, Red Hat .rpm, Software .tgz and even Solaris .pkg file formats. The resulting converted packages it produces may or may not install and they may or may not work depending on the original package which has been converted. Converted packages who do install will, in most cases, only do so after going through some hoops.

Features And Usability

Using alien to convert a package from one format to another can be as simple as:

alien --to-rpm naver-whale-stable_amd64.deb

-r is a short-hand for --to-rpm.[1]

It can be that simple, but it rarely is.

Alien can be used as a regular user but it will warn that "Ownerships of files in the generated packages will probably be wrong.". This is correct, it has to be executed as root to get the right permissions in the resulting package.

Alien will not convert scripts that are included in a .deb or .rpm package unless the --scripts switch[1] is provided.

Practical Use-Case: NAVER whale

The NAVER whale web browser is only available as a Debian .deb package at whale.naver.com/en/. There is no other packages like an AppImage or an RPM available.

Converting naver-whale-stable_amd64.deb to an RPM package by simply running:

alien --to-rpm naver-whale-stable_amd64.deb

Will result in a RPM package that, when installed with

rpm -ivh naver-whale-stable-2.8.105.22-2.x86_64.rpm

produces the following fine error message:

error: Failed dependencies: libnelo2-multi.so()(64bit) is needed by naver-whale-stable-naver-whale-stable-2.8.105.22-2.x86_64

The libnelo2-multi.so library is included in the .deb package, and the resulting .rpm package, but the rpm tool does not recognize it as being in the package because it is not executable. It is possible to ignore that error by running RPM with the --nodeps parameter[2]. However, that will, in the case of the NAVER whale Debian package, reveal several in additional errors like:

file /usr/bin from install of naver-whale-stable-2.8.105.22-2.x86_64 conflicts with file from package filesystem-3.12-2.fc32.x86_64

That error means is that the rpm package is asking to create the folder /usr/bin, which will exists on every single Linux distribution out there. Rpm does not want it to do that since another package has already created that folder. Errors like that can be ignored by adding --replacefiles to the rpm command[2]. You should absolutely not blindly do that. However, this command can be used to make the package in this particular example install:

rpm -ivh --nodeps --replacefiles naver-whale-stable-2.6.90.16-2.x86_64.rpm

Snubbelrisk.jpg
Warning: You should absolutely not use --replacefiles as an rpm argument unless you are absolutely sure it won't actually replace any files. The above example is only included to show how it could be done, not how it should be done.

Creating a Build Tree Based On Foreign System Packages Using Alien

This is where using alien can get a bit tricky.

Alien has a -g option that lets you generate a package tree without building a package. This can be combined with the package type you want.

Converting the NAVER whale package to a RPM and not getting any errors when the resulting RPM is installed can be done by first extracting the .deb and preparing a RPM package, without building the RPM:

alien -r -g naver-whale-stable_amd64.deb

This creates a folder named something like naver-whale-stable-2.8.105.22 (depending on the package name and version) with a .spec file in it.

The folders that should not be managed by the RPM can now be removed from that .spec file:

grep -v  -e '%dir "/"' \
 -e '%dir "/opt/"' \
 -e '%dir "/usr/"' \
 -e '%dir "/usr/bin/"' \
 -e '%dir "/usr/share/"' \
 -e '%dir "/etc/"' \
 -e '"/etc/cron.daily/naver-whale"' \
 -e '%dir "/etc/cron.daily/"' \
 -e '%dir "/usr/share/appdata/"' \
 -e '%dir "/usr/share/applications/"' \
 -e '%dir "/usr/share/doc/"' \
 -e '%dir "/usr/share/man/"' \
 -e '%dir "/usr/share/man/man1/"' \
 -e '%dir "/usr/share/gnome-control-center/"' \
 naver-whale-stable-2.8.105.22/naver-whale-stable-2.8.105.22-2.spec > /tmp/spec.tmp
 mv /tmp/spec.tmp naver-whale-stable-2.8.105.22/naver-whale-stable-2.8.105.22-2.spec

And it is also possible to make the libnelo2-multi.so library executable so RPM understands that it really is there, in the package:

chmod a+x naver-whale-stable-2.8.105.22/opt/naver/whale/libnelo2-multi.so

Now, when the adjustments are done, a RPM package that will actually be installed without errors can be built using the tree alien made:

cd naver-whale-stable-2.8.105.22
rpmbuild --buildroot=${PWD}  -bb --target x86_64 'naver-whale-stable-2.8.105.22-2.spec'
cd ..

The above RPM command will create a fine naver-whale-stable-2.8.105.22-2.x86_64.rpm file and eradicate the naver-whale-stable-2.8.105.22 build tree alien created.

The resulting RPM can be installed without errors with:

sudo dnf -y install naver-whale-stable-2.8.105.22-2.x86_64.rpm

Verdict And Conclusion

alien can be a useful tool and it can produce working packages. Sometimes it does. Sometimes it doesn't. It varies from package to package.

As you can see in the practical example above, the packages alien produces will in many cases produce error messages when you try to install them. This is where the -g option, which only creates a build tree, is useful. However, it may not be useful for you. If you are a wizard capable of figuring out exactly why error messages are produced and you are able to adjust the package accordingly then you may find alien to be nice tool. You may also find that it is simply too difficult to use and to prone to errors you do not know how to fix or tackle.

Do not use alien unless you know what you are doing.. As pointed out above, broken packages can usually be installed with something like:

rpm -ivh --nodeps --replacefiles

But that is not something you should do. Ever. That leaves you with the option of not using packages produced by alien when there are errors or fixing them, which does require some knowledge. If you don't see that as problem then alien is for you. If you would prefer to just get working ready to be installed packages every time and you don't know what to do if you get an error then alien isn't a tool you should play around with.

Links

Footnotes

  1. 1.0 1.1 man.linuxreviews.org: alien.1 manual
  2. 2.0 2.1 man.linuxreviews.org: rpm.8 manual

Add your comment
LinuxReviews welcomes all comments. If you do not want to be anonymous, register or log in. It is free.