My *nix world

Emerging Perl without Perl in Gentoo

One programming language that plays an important role especially in some Linux distro is Perl. In case of Gentoo, which is a source code base distro, dev-lang/perl is even more important than just another programming language. It is the language in which are written the system core packages that manage the Gentoo, for instance the package manager component called Portage.

So what happens when you, for some reason or another, decide to remove the dev-lang/perl together with some of its libraries AND furthermore something like sys-libs/db ?How is possible emerging Perl without Perl in Gentoo?

Well, removing all the above is deadly combination, I can tell you that. You see, the dev-lang/perl depends on sys-libs/db and sys-libs/db depends heavily on dev-lang/perl, because without dev-lang/perl you cannot fetch + unpack + configure + compile + install anything in a distro like Gentoo.

Did I said a "deadly combination" ? Let me put it in this way:

  • emerge --unmerge perl <= BAD IDEA
  • emerge --unmerge perl sys-libs/db <= VERY, VERY BAD IDEA

If you still haven't had enough then just:

  • emerge --unmerge some-perl-libraries <= Mayday! Mayday! Huston, we've got a problem!

By removing solely the sys-libs/db it is not necessarly a tragedy (except if you immediately reboot your Linux box) because you can recompile + reinstall it again since you still have dev-lang/perl.

By removing only the dev-lang/perl is also not a tragedy because you might still be able to use Portage and recompile & reinstall it again (except if you removed some other Perl libraries like I did).

However, by removing both the dev-lang/perl and sys-libs/db, let alone some other Perl libraries, your Gentoo is checkmate. This is a cross-dependency nightmare that cannot be solved easily. Don't get me wrong, the system would still work, the only problem is that it will become pretty unmanageable, ie. no more update or maintenance scripts whatsoever.

So how do you fix it? The answer is ... the Gentoo binary package!

In a nutshell: you take another Gentoo system (a working Gentoo system with a similar architecture - eg. i686 or x86_64) which has more or less the same configuration and USE-flags. Then compile these packages without (re)installing them over there, I mean you can do it but it's not necessary. Instead you create/build their binary distribution version, a tar.bz2-like package (called .tbz2) that encloses all the necessary binary files together with some other configuration files which usually go to the /usr/share directory. Basically these files that normally are deployed by "ebuild your-pkg-name.ebuild install" command.

You can build such binary packages by using the --buildpkgonly (-B) emerge option (or -b option, man emerge is your friend). By default they will be copied (distributed) into the PKGDIR directory as defined by Portage. If you are unsure where th PKGDIR is on your system then just run the portageq pkgdir command to find the PKGDIR value or check your Portage's make.conf file for this value.

Next you copy these binary .tbz2 files (from PKGDIR/category-folder/the-binary-distro-file.tbz2) to your perl-less Gentoo into the PKGDIR directory.

Normally you would install them by running emerge with the --usepkg (-k) or --usepkgonly (-K) option switch like this:

emerge -K path-to/perl-5.xyz.tbz2

or

emerge -K dev-lang/perl

Please note that the above commands are just examples, they won't work as the parameters are made-up.

However, if the presented method won't work for some reason then think like Linux, not like Gentoo: a file is a file! What I mean by that is that you should not be focused on following blindly some steps but to follow ferociously your goal: put the file there. So just extract them into the /tmp/whatever-temp-folder and check them first if that makes you feel better. Next copy them into the system's root (just inspect their content, you will figure it out where to copy them).

Of course, this is not the most orthodox method, however by doing so you just put back the system's core packages that might allow you to reuse the Portage which will allow you later to (re)build the necessary packages from their source code.

That's all! Your Portage is back and so is your Gentoo!

@edit: Recently I removed the dev-lang/python-exec, which includes the Portage emerge utility. By removing this package I lost the ability to install/update the Gentoo. Ultimately this situation is exactly like the one described by this post: how to emerge a package without emerge tool? One solution I found, which applies also to this post, is to download the Gentoo's Stage3 archive then to copy the missing file(s) from there into your system. In my case I only had to copy the /usr/lib/python-exec/python-exec2 and /usr/bin/python-exec2c.

Now, if you think that this article was interesting don't forget to rate it. It shows me that you care and thus I will continue write about these things.

The following two tabs change content below.
Emerging Perl without Perl in Gentoo

Eugen Mihailescu

Founder/programmer/one-man-show at Cubique Software
Always looking to learn more about *nix world, about the fundamental concepts of math, physics, electronics. I am also passionate about programming, database and systems administration. 16+ yrs experience in software development, designing enterprise systems, IT support and troubleshooting.
Emerging Perl without Perl in Gentoo

Latest posts by Eugen Mihailescu (see all)

Tagged on: , , , , ,

2 thoughts on “Emerging Perl without Perl in Gentoo

  1. Johnson

    Thank you so much. I was so dumb as to unmerge perl and zlib, which led to a similiar dilemma. Could not recompile a single package. Building zlib and perl again on my laptop and scp'ing it over saved my day.

Leave a Reply

Your email address will not be published. Required fields are marked *