Prefix/libc

This is a project to support libc inside a Prefix, code named RAP (Rap Ain't Prefix). See also Project:Android. Practically, one can install Gentoo Linux in some location, for example in /scratch/gentoo on SGI Irix. This relocated installation path is stored in the ${EPREFIX} variable. All files are installed in ${EPREFIX}/{bin,etc,lib,tmp,usr,var}, etc.

Classical Prefix is based on rpath but it does not give you the freedom of having a separate sys-libs/glibc from the host. Many packages in Gentoo Linux will not compile against archaic glibc, e.g. =sys-libs/glibc-2.13 and many utilities need at least =>sys-libs/glibc-2.17. Also binary packages like Oracle java-1.8 JRE/SDK need a more recent glibc. Java IcedTea-3.2.0 needs 2.14.

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

Gentoo::RAP uses the main Gentoo x86 portage tree so you get more recent packages.

The bootstrap scripts will fetch quite a lot of tarball data, the portage tree, and package sources. There is no easy way to pre-fetch all the stuff needed beforehand, and be off-line during compilation. Watch for improvements.

Bug reports in Gentoo::Prefix have a separate category at https://bugs.gentoo.org while Gentoo::RAP issues can go along all other bug report tagged as "Current packages". Current issues with mostly ebuilds not respecting $EPREFIX variable can be seen here: https://bugs.gentoo.org/buglist.cgi?quicksearch=EPREFIX&list_id=3399810. Some might be already fixed in the Gentoo::Prefix tree.

bootstrap-rap.sh will nicely copy /etc/{passwd,hosts} from the host system setup. The files maybe get a bit outdated over the time as new users are added to the host's passwd/group files so the section 'Username_becomes_invalid_inside_RAP' below may be helpful for recreating the files using current info. bootstrap-prefix.sh does not need to copy user/group info into Gentoo::Prefix installation because it does not have its own glibc.

Other users on the same host can use the installed Gentoo::RAP or Gentoo::Prefix, but they cannot use eselect or gcc-config, etc. to switch between versions of the many tools. However they can call gcc-4.1.2 or python-3.4 directly. Only the user who has write permissions to the Gentoo::RAP or Gentoo::Prefix installation can adjust the 'system-wide' defaults.

The differences between the approaches are summarized in this table.

Installation
Download 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 tell you how to start your freshly bootstrapped Gentoo RAP system assuming it successfully completes. 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, PORTAGE_TMPDIR can be changed with:

On systemd/RedHat systems tmpfs (shm) is mounted by default on /tmp, /dev/shm doesn't exist any more there (at least when last checked with CO7/OL7).

Add an en_US.UTF-8 locale
Gentoo::RAP uses it's own libc so the locales should be generated in the Prefix. Add an entry to EPREFIX/etc/locale.gen

Then generate the locale by running:

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 :

Replace http://mirrors.tuna.tsinghua.edu.cn/gentoo with a favorite mirror.

For more details, refer to the GENTOO_MIRRORS article.

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 variety of environments. Documented here are some problems met during the bootstrap and the possible solutions. 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
Gentoo::RAP uses its own glibc, which performs independent name service from the host. The uid to username mapping is managed by nss within glibc. A new install of glibc requires a new set of mappings. That is not needed to be done by the Gentoo::Prefix approach (since it does not provide a separate glibc).

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 the system is configured such that a normal user cannot query the entire passwd or group by getent; in such a case portage breaks, portage will not be able to resolve the username and group. A 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.

FAQ
What is Gentoo::Prefix / Gentoo::RAP not good for?

Java binaries, even the Oracle jre/jdk packages contain some binary code which needs glib-2.17. If the host glibc is older, getting some key parts of java environment installed on Gentoo::Prefix will not work. Gentoo::Prefix has no multilib support so forget about running a 32bit Adobe acroread through it (although Gentoo::RAP also lacks 32bit support).

Can Gentoo::RAP execute 32bit and 64bit binaries (aka having multilib support)?

No, the profile used in it is amd64-oly.

The profile we are using is not multilib. Sometime before we thought bootstrapping another Prefix makes more sense if x86 is needed. Seems that we should revisit this, to test out multilib.

Any pressing issue with Gentoo::RAP?

Most apps using java-config and Apache ant still have issues. But it would be only worse if you tried Gentoo::Prefix instead (you would not get even that far).

Perl support. There is likely a general Prefix-related issue in some perl-related eclass or my own programming style issue. Many perl-based packages do not install because of 'Aborting due to QA concerns: double prefix files installed' (sci-biology/TransDecoder-2.1.0::science and many other). See.

Can I emerge myself glibc on Prefix?

If I remember no but Fabian claims it should be possible. However, it will be ignored anyways by the binaries and your binaries will anyway use host's glibc (supposedly an old one).

Are there any other special=difficult libs, like iconv, icu, readline, or is only glibc being the main problem?

Seems you can install all these on Gentoo::Prefix except the glibc.

Can I switch from Gentoo:Prefix to RAP?

No. Although it is possible, bootstrapping a new one costs far less time and effort. The bootstrap script will detect portage of Gentoo:Prefix in your PATH and take a shortcut.

Can I move binaries to another host?

It sounds one can understand that the binaries with -rpath compiled in may not work on another system unless LD_LIBRARY_PATH redirects the paths, but what about Gentoo:RAP binaries. Can they be moved? Could I check something in the binaries using "ldd or some elfutils program" to learn more? They use a modified loader with a hardcoded path, so only if you put them into very same place?

Install elfutils on the hosting operating system. See for example:

External resources

 * Gentoo On Unrooted Android