Gentoo for All the Unusual Reasons

You might think of Gentoo as a bleeding-edge distribution for development workstations, but the simple packaging system can make it a good choice for any production system that needs to stay up to date.

First Portage downloads, builds and installs libpcre, and then it does the same for bluefish. Four minutes later, I have my upgrade. Pretty easy.

You might have noticed that it didn't say it was going to install version 0.13. That's because, at present, version 0.13 is masked, which is why it showed up in red. In this scenario, 0.13 just came out, and there's now an ebuild for it. The ebuild, though, still is being tested to see that the software actually installs and that there's nothing blatantly wrong with it. If I had really needed it, I could have overridden Portage and told it to bring in 0.13. Likewise, I could have picked version 0.11 if I'd had a reason to do so. This flexibility is one of Gentoo's greatest strengths.

Do-It-Yourself Packages

A trickier situation occurs when I need to install a piece of software the system doesn't provide. One of the significant reasons various distributions established package management tools was to have a single, unified view of what is installed on the system. For each piece of software, be it a basic system tool, a core library, a server program or a user application, a package is made. As each package is installed on your system, the OS records what files are put where and that the package is installed. That way, other software that depends on these packages can be installed, knowing that their prerequisite pieces are in place.

But what happens if you install a newer version of software and don't have a package appropriate to your OS? You typically go though the same build steps that the person who built the package did, except you probably do one of the following two things:

  1. Install it in some private place, perhaps /usr/local/bin, and then go to the effort of making sure your program is being run, not the older one.

  2. Blindly install your software in the root filesystem, hoping you don't clobber anything on the way and praying that nothing in the future overwrites the programs and files you have installed.

Think about that for a minute. Doesn't having to worry about these things strike you as a bit silly? After all, isn't that what the package management system is supposed to prevent?

The question I'm posing isn't “does the ability to make packages exist”, because the answer to that is “yes across the board”, nor am I asking “can you create your own packages”. Rather, I want to know how easy is it to do so.

Let's say you've got the OS-provided copy of bogofilter and an .rpm for version 0.16.1. Suddenly, the authors of bogofilter discovered a silly but serious error has crept in and release 0.16.2 shortly thereafter.

The problem is you're stuck with waiting for your distribution to release a new version of the .rpm, .deb, .pkg and so on, which could take a long while, leaving you in the position of wanting to roll your own. That's where the trouble creeps in. Conceptually, creating your own new .rpm or .deb package is easy. “Just use the existing 0.16.1 package as a prototype.” But for most people, that is, anyone not at wizard level and sometimes not even then, it's actually rather tough to do. You have to:

  • Download the package description or somehow extract it from the existing package file.

  • Manually download the new version of the upstream .tar.gz (or whatever) source and unpack it.

  • Transplant the build descriptions (in the case of Debian into the new upstream sources) and maybe even patch against those sources.

  • You might have to modify the build script to instruct it about the new version.

  • Actually try to create the package. This involves compiling it, which probably also requires you to install a large number of -dev packages you hadn't previously known about.

  • Then you install and test.

All of this is doable, but there's a fairly steep learning curve (especially for newbies) in getting the skills needed here. More to the point, it's a lot of work that you'd rather not do.

Package Descriptions in Gentoo

Conceptually no different from the process outlined above, building packages on a Gentoo system is easier. The magical part is package description files in Gentoo, ebuilds, follow a simple format. They're basically shell scripts (ebuilds are covered later in this article). Along the way, you specify from where to get the source tarball. When you build, Portage downloads the source and then proceeds to unpack and compile it. Because they're shell scripts, they can use shell variables to great effect. In particular, they take the version number by parsing the ebuild filename and putting it in a variable the script can use.

In our bogofilter example above, the package file (called bogofilter-0.16.1.ebuild) contains a line like this:


When you go to build and install bogofilter, Portage sets $PV to be 0.16.1 based on the filename and fetches the appropriate .tar.gz. It then unpacks it and proceeds to ./configure; make; make install and then build the package as instructed. To create an ebuild script for the new version you want, 0.16.2, do this:

# cd /usr/portage/net-mail/
# cp bogofilter-0.16.1.ebuild bogofilter-0.16.2.ebuild
# ebuild bogofilter-0.16.2.ebuild digest

Assuming that nothing in the package description, unpacking instructions and so forth, needs to be updated, that's all you have to do.

There's a touch more to keep abreast of. For example, you probably would do the above action in a private copy of the /usr/portage tree so you don't lose your changes when the primary tree updates. Portage explicitly supports this; look in the description of the PORTAGE_OVERLAY variable in the on-line documentation or right in /etc/make.conf to learn how to tell Portage where your custom ebuilds are. Now you can tell Portage to # emerge bogofilter


-- Andrew Frederick Cowie Operational Dynamics Consulting Pty Ltd


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

interesting article

Anonymous's picture

An interesting article. I've been thinking of playing with Gentoo for a while. The idea of easily being able to build customized packages appeals to me, as it's seems to be like rocket science on Debian...

no so hard

damaki's picture

Just 2 commands for any standard source (./configure based) :
dpkg-build -rfakeroot

Nothing else...

I have seen debian boxes tota

Anonymous's picture

I have seen debian boxes totally corrupted by this kind of installation

Debian is particullary picky about extern packages, gentoo will build any package acording to your new choice if needed.

What if you do that for kdelibs ? gtk ? glibc ? the system will suffer, not on gentoo !

Another overlooked benefit is

Anonymous's picture

Another overlooked benefit is Security. Gentoo Hardened includes tons of excellent security features including SELinux, and you are not limited like other security-focused distributions. You can install basically any software on Linux, and the binary is automatically hardened; just check the configuration.

I use gentoo on every compute

Anonymous's picture

I use gentoo on every computer i got on my home, If you want an easy to install gentoo based distribution with graphical instalation you should check Vidalinux Desktop. Is based on gentoo but is using Redhats anaconda to install everything. http::// :-D


Anonymous's picture

good golly, did you see the minimum system requirements?
Minimum Supported Configuration:
AMD Athlon XP or Pentium 4 compatible processor, 1.0 Ghz; 10-GB hard disk; 256-MB RAM; 800x600 screen resolution

Recommended Configuration:
AMD Athlon XP or Pentium 4 compatible processor, 2.0 Ghz or faster; at least 20-GB hard disk; at least 512-MB RAM; 1024x768 screen resolution or better

where gentoo's minimum system requirements are:
Hardware Requirements
CPU i486 or later
Memory 64 MB
Diskspace 1.5 GB (excluding swap space)
Swap space At least 256 MB

does anaconda really take this much power?

I've been using Linux for ove

Anonymous's picture

I've been using Linux for over 10 years and Gentoo was the distro to pull me away from Win32 for daily use. It's takes a little work for the initial install and the larger compiles like kde. Once installed its great. Easy to use, maintain and update. Seems you have what you need in the version your looking for, including its dependances.

Great Distro. Next Debian & Slackware (Slack being my 1st Linux distro) then Mandrake and Suse. All Great.

The main thing is to Enjoy Linux no matter the distro!

hallo this sucks your link go

Anonymous's picture

hallo this sucks your link goes straight to M$

Nah he accidently added two c

Anonymous's picture

Nah he accidently added two colon's, which for some reason is redirecting to you know where.

Stephane's picture