Prefix/libc

This is a project to support libc inside a Prefix, codenamed RAP (Rap Ain't Prefix). See also Project:Android. A general use case is for Prefix on RHEL 5 (CentOS 5 ans SL 5), where the host glibc-2.5 is too old to support modern features as fortify.

Classical Prefix is based on rpath but it does not give you the freedom having your own sys-libs/glibc, supposedly a recent-one (you must stay with glibc provided by the host operating system). Many packages in Gentoo Linux will not compile against archaic glibc, say 2.13. Many utilites need at least 2.17. Also binary packages like Oracle java JRE/SSDK need more recent glibc.

So then there is a Prefix/libc (sysroot method, called Gentoo::RAP).

Finally, at some point there will be another implementation of Prefix/libc approach (native paths method, experimental). It is developed by @redlizard. In the future it will be merged with Prefix/libc (sysroot method, aka Gentoo::RAP).

In terms of source repositories, Gentoo::Prefix uses its own portage tree (as an overlay), hosted by Fabian Groffen. This overlay contains packages that we need, or modifications that aren't yet finalised/merged with the main gentoo tree. However, Gentoo Prefix users need a way to update their trees. Since the Prefix tree is a union of the main gentoo tree, overlaid with the prefix overlay, this is non-trivial to obtain (like e.g. git clone). One simply needs rsync generation. The scripts for this can be found in the scripts dir of the prefix overlay. Gentoo infra doesn't want to run this for us. They said in the past they did want to, for us, but never got back, or only want to do it in a simply way (e.g. the git clone/pull).

Gentoo::RAP uses the main Gentoo x86 protage tree, so you get more recent packages. Gentoo::Prefix portage tree from Fabian has many patches to the quickly outdating packages. In contrary, Gentoo::RAP tries to override only some classes from the bare Gentoo code base and simply relies on the latest and greatest portage tree.

Bug reports in Gentoo::Prefix have a separate category at bugs.gentoo.org while Gentoo::RAP issues can go along all other bug report tagged as "Current packages".

bootstrap-rap.sh will nicely copy /etc/{passwd,hosts} from the host system setup, while bootstrap.sh is not that advanced.

The differences between the three approaches are summarized in this table.

Installation
Download the Gentoo RAP bootstrap-rap.sh. You can use various ways to obtain the script and get it to a place where you can execute it. Once in position, preform the following commands:

That's all! The script will guide you through the full process, and tells you how to start your freshly bootstrapped Gentoo RAP system if it successfully runs up till the end. In normal cases, you don't need any more than just this.

Manual Installation
RAP can also be installed manually as

Refer to Prefix/Manual_Bootstrap for more details.

Tested Distributions
At the moment, RAP supports Linux distributions only. The following tables tracks the tested distributions with the script. Feel free to add your own.

Compile Inside Memory
On a cluster node with large memory and shared network filesystem, compiling in a memory tmpfs can be significantly faster. /dev/shm is mounted as tmpfs by many distributions. For example:

Before calling bootstrap-rap.sh, it can be done with

Add an en_US.UTF-8 locale
We are having our own libc, the locales should be generated in Prefix. Add an entry to EPREFIX/etc/locale.gen

Then generate the locale by

For more details, refer to the handbook.

Use a nearby mirror
The bootstrap script needs to download quite a bit. It can be accelerated by using a Gentoo mirror nearby. To use a mirror, GENTOO_MIRRORS should be set both in the environment

and make.conf:

Replace http://mirrors.tuna.tsinghua.edu.cn/gentoo with your favorite mirror. For more details, refer to GENTOO_MIRRORS.

The rsync mirror is set in repos.conf

Replace rsync://mirrors.tuna.tsinghua.edu.cn/gentoo-portage with your favorite mirror. Refer to repos.conf for details.

Troubleshooting
RAP is expected to run on a wild variety of environments. Let's document here the problems met during the bootstrap and the solutions made. It is very funny to see how many host systems are badly screwed.

/bin/tar exists but does not work. The working one is in /usr/local/bin
Solution: edit the script to prepend /usr/local/bin to PATH.

Username becomes invalid inside RAP
RAP has its own glibc, which performs independent name service from the host. The bootstrap script first tries to generate passwd and group from getent and links host /etc/{passwd,group} as fallback,

If usernames are provided by LDAP, sometimes it is configured so that a normal user cannot query the entire passwd or group by getent. In that case portage breaks, will not be able to resolve the username and group. An quick fix is to show yourself to Prefix by specifying who you are,

But other uses on the host cannot be resolved. To get a fair sample of all users on the system, enumerate the /home directory,

Another solution is to use host nss_ldap library. (nss is part of glibc, which resolves uid/gid.)

Then set nsswitch to query ldap.