Gentoo, the most popular source based distribution, has turned ten years old. What benefits does a such a system provide over its binary distros? As Linux becomes more and more popular, is there still a place for source based distros?
When Linus first released the kernel onto the Internet, it wasn’t a pre-compiled binary that he provided, but rather the source code. Software has its origins in the source and it’s what free software is all about!
In fact, many free software projects still provide their primary releases in source code form, leaving it up to distribution package managers to compile and ship the binaries with their operating systems.
Building applications from source code is actually not as foreign as it might seem, indeed it is integral to a free desktop. So why then do so many users balk at the idea of a source based distribution?
The Way Things Are
Certainly the majority of the top Linux distributions are binary based – that is to say that the package manager delivers applications to the machine pre-compiled from source code, in binary form. All of these distributions have the ability for users to build applications from source and, to varying degrees of ease, permit the re-building of installed applications to the user’s requirements.
Debian based distros can pull down the source code of any package available in the repository with a single command. Along side its binary package manager, Arch Linux has a complete ports style system that allows a user to easily re-build any package and install it onto the computer.
The major benefit of a binary based distro is speed of installation. All of the packages available are able to be installed as quickly as they can be downloaded and extracted to the hard drive.
The Secret is in the Source
When using a binary distribution however, the package managers have made several core decisions for you. They’ve decided the architecture that the package is compiled for, which is usually i386 or generic x86_64. They have also decided what optimizations are applied to the code when compiled via the GNU Compiler Collection (GCC).
They have decided which features will be built into the program, such as Bluetooth support, OpenGL or zero configuration networking. When you install one of these binaries, it will pull in whatever libraries the developer has decided will be included. Generally speaking, these tend to be very broad as the binary must work on as many computers and provide as many features as possible.
Imagine if you were able to make these choices for yourself! Well, you can. DistroWatch lists over half a dozen source based distributions, including Linux From Scratch and of course Gentoo itself, which is perhaps the most popular.
Recently Gentoo celebrated its tenth anniversary, with a special live DVD release. So what has made this distribution stand the test of time? Obviously it must offer some benefit to a large number of people or it would have died out.
You’ve Gotta Have a System
Gentoo’s package management system is ports based and consists of build scripts for each available program, called Ebuilds. The Ebuilds, patches and other scripts sit inside what is called the Portage tree.
The installation of a package under Gentoo is completely automated and generally as simple as any other distro. Installing an application like Vim is as easy as:
These Portage tools, such as emerge, are very powerful and automate the entire build and installation process. An added benefit is the ability to install a particular version of a package you require. The Portage tree often contains several versions of a package and although a specific one would be recommended, a user can install whichever they please. Creating your own Portage tree is also as simple as creating or modifying an existing Ebuild to suit your needs.
Portage isn’t just about the source however, it also supports the installation of binary packages. A user could connect to an online repository and install applications from there. Or they could create binary packages from the applications they have already installed and use them on other machines, all via Portage.
What this means is that a user can easily build their own custom system and distribute that onto as many other computers as they like, from where it would do so at the speed of a regular binary distro.
That’s the main benefit of a source based distribution, flexibility. The user can turn the system into whatever they want it to be, making the decisions themselves rather than the package managers, as with other distros.
Don’t want support for Bluetooth, zero configuration networking, OpenGL, Pulseaudio, or even GTK? It can all be done, and Gentoo makes it easy.
When building a system from scratch for a specific machine, one needn’t be concerned with the lowest common denominator. The system can be tuned precisely for that system. PowerPC systems aside, most 32-bit Linux distributions build their code for an Intel 386 processor. They do this because computers since then are a subset of that original and are therefore backwards compatible. Even if you have a more modern processor such as an Intel Pentium 4 or even an AMD Athlon, they are all x86 CPUs.
Newer x86 CPUs include more advanced instruction sets such as mmx, sse and 3dnow. A system built for an i386 processor will not be able to take advantage of these, but if it were optimized for a specific later processor then it could.
Code is often optimized for a specific processor when compiled, so when building from source the possibility opens up to optimize for something more modern. The GNU C compiler can, of course, optimize code for any such processor, including Intel Core 2 and AMD64 processors in 64-bit. If you are building Linux for a low-end CPU such as Atom, C3, or Geode, then compiling each and every binary on your system to take advantage of that specific CPU can be highly beneficial.
Pick and Choose Features
The settings for building packages on the Gentoo system revolves around a central make configuration file called, make.conf. Here the user can specify what processor they want to build the system for, what level of optimization they want GCC to use and what features they want included in the system. For example, one sets the GCC optimization level such as -O2 or -Os, along with the CPU such as -march=core2.
When compiling an application, these settings will automatically be used and therefore optimize the entire operating system for that processor. The resulting binaries may not be compatible with older machines however, as they enable all instruction sets for the specified CPU.
The features each package will support is handled via the “USE” variable, the values for which are called “use flags.” If the system requires support for Bluetooth, then adding “bluetooth” to the USE flag variable will ensure that for any applications where bluetooth support is available, they will get it built in.
Likewise, the “-bluetooth” value will remove support for Bluetooth from any package which could have made use of it, such as GNOME.
The result is a more lean system, which only includes support for the features wanted on the machine.