GG3.NET

Theme: GrayTheme: RedTheme: GreenTheme: BlueUS/UK flagJP flagBG flag

Gentooの経験

What is Gentoo?[top]

Gentoo is a meta-distribution. In other words, it is not a real Linux distribution, but more of a helper that lets you install Linux on your machine. There are a lot of Linux distributions out there, but there are only a few "major" ones. There is Debian, and a lot of distributions are based on it. There is also RedHat with their RPM, and there are even more distributions that use that as their base. There are also SlackWare and Linux from Scratch, but there isn't much diversity between the others.

Gentoo, on the other hand, is a completely new distribution. It has nothing to do with any other distribution, it has its own package management system (it is called Portage, and has nothing to do with RPM or apt-get), and it also has a completely novel approach to init scripts handling.

Unique features[top]

So, what makes Gentoo unique? There are a number of features that I would like to discuss in this section.

Portage

Portage is the package management system of Gentoo. It is the heart and soul of Gentoo. In fact, if you take Portage and start making your own distribution, you will get a distribution that is almost as good as Gentoo.

The name of Portage is derived from the BSD ports system. However, unlike the BSD ports, portage has enhanced features like

  • automated dependency tracking
  • customization of packages
  • protection of configuration files

Portage reads its configuration from a number of places. It first checks the /etc/make.profile location, which is usually a symlink to an up-to date version of the current system profile. It then reads in /etc/make.conf which contains the user configuration.

When you install packages with portage, it finds all dependencies of the packages that you want to install, downloads their sources, compiles them on your machine and installs them on your live system.

Now let's go in some more details about portage, and what makes it so good.

The portage tree

All packages that can be installed on a Gentoo system are located in a directory on your system. Its location is specified in the configuration file with the variable PORTDIR.

The portage tree contains ebuild files, which are essentially bash scripts that tell portage how to install a given package. They also contain information about what packages a given package depends on, what functionality it provides, a short description, its homepage, etc.

The portage tree is kept up-to-date by using one of the many rsync servers. By using rsync, you are assured that your bandwidth is not excessively used. Furthermore, there are rsync servers in almost every country. You can safely try rsync.<country>.gentoo.org and use the ones closest to you. When I started using Gentoo, there were no rsync servers in Japan, so I simply provided one myself. That's why I got to be rsync1.jp.gentoo.org. However, if you are behind a firewall and unable to use rsync, you can always download the daily portage snapshots which will overwrite the current portage tree.

As of the time of this writing, the portage tree contains about 100,000 files, so if you're using ext3 or ext2, it may need more than 150MB of your hard drive space. However, with reiserfs it uses only about 30MB.

The good thing about this method is that the portage tree is kept up to date and you have access to the freshest applications almost as soon as they get out.

USE flags

The most important variable that is supported by portage is USE. This is the variable that tells portage how to install packages, what support should be installed in them, etc. For example, you want to install the samba package. On a typical RedHat system, you would need to install the kerberos and OpenLDAP packages as well, because the binary package for samba that they provide was compiled with LDAP and kerberos support and it cannot run without those libraries. With portage, the samba package supports a number of USE flags. You can see them with the following command:

$ emerge --pretend --verbose samba
These are the packages that I would merge, in order:
Calculating dependencies ...done!
[ebuild R ] net-fs/samba-3.0.7-r1 +acl +cups -debug -doc -kerberos -ldap -mysql -oav +pam -postgres +python +readline (-selinux) +xml +xml2

You are only interested in the output coming after samba-3.0.7-r1. The USE that are supported by this package are listed on the line. Those that are enabled are prefixed with a plus, and those that are disabled are prefixed with a minus. In the above example, if I am to install the samba package with the current configuration, I would end up with a samba that has no support for kerberos, LDAP or MySQL. This means that I have less dependencies to satisfy. If I were to enable the ldap use flag, I would automatically get samba with LDAP support, and openldap would automatically be installed prior to installing samba.

By using USE flags, one can install a system just the way they want it. One who does not need X11 on a server, simply has to make sure they have -X in their use flags, and they can be sure that if a package has optional support for the X windowing system, it will not blindly request X as a dependency.

Binary package support

This is not an unique feature, but is a feature that is worth mentioning. The portage system also supports binary packages. By support, I mean that you can:

  • create a binary package instead of/in addition to installing a new package
  • use a binary package instead of compiling from source
  • create a binary package from a package that is already installed on your system

The unique feature in this category is that you can create a binary package after you have installed a package on your system. For example, if you are afraid that the new version of mysql may give you a headache, you can quickpkg mysql first, which will create a binary package for mysql from the files already installed on your system. You can then install the new version of mysql, and if it doesn't appear to be to your taste you can quickly reinstall the old version by using the binary package that you previously created.

Furthermore, the binary packages that portage uses are very easy to use without portage itself. So, if you for example break your portage, you can still do

# bzcat portage-2.0.51-r3.tbz2 | tar xp

and you will be able to restore portage from a binary package, without needing portage itself. With rpm packages you can still do this, but the process is more complicated, because you need to find where the compressed data inside the RPM file starts, then extract that, uncommpress it and finally use cpio to unpack it. Debian's DEB approach is a little better, since you can directly use ar on their packages to get a directory with the tar.gz of the files to go the filesystem.

Why Gentoo?[top]

Portage is the reason why Gentoo is my choice of a distribution. It allows me to install the newest versions of packages just the way I want them. For a comparison with other major distributions, refer to the following table.

GentooRPM basedDebian basedSlackwareLFS
DependenciesYESYESYESNONO
Automatic depsYESNOYESNONO
Package customizationYESNONONONO
Safe uninstallYESYESYESAVERAGENO
Up-to-datenessYESAVERAGEYESYESYES
Get Firefox!Valid XHTML 1.0!Valid CSS!©2005 GG3.NET