From Gentoo Wiki
Jump to:navigation Jump to:search

Rootless Gentoo Installations

Gentoo can be installed in root-less mode. The packages will be installed as a regular user, for instance in ~/root/. The user can add the binary/library paths from there and run programs that could not be installed on the system otherwise.

There are caveats for certain packages, though. Certain packages will fail to install, because they have not been thought to be installed this way. The most common reasons are:

  • usage of 'install' with root uid/gid
  • RESTRICT=userpriv is unavoidable for some packages


Usage of portage is documented on the Gentoo Prefix project.


Throughout this section we will consider that the prefix will be ~/root.

The steps are:

  • install stage3 archive
  • create paludis files
  • create paludis folders in the prefix:
mkdir ~/root/{var/{db/pkg,paludis/distfiles,cache/paludis/{names_cache,write_cache},tmp/paludis}
  • edit ~/.paludis-test/specpath.conf:
root = /home/user/root
  • copy your paludis configuration to ~/root/etc/paludis/
  • edit the paludis configuration; configure repositories (buildroot, location), and paths
  • edit use configuration file to have minimal use flags for system bootstrap
  • install paludis manually (don't use emerge, unless you proceed as in the above section)
cd ~/root
git clone git:/.../paludis.git
cd paludis
  • create ~/root/paludis/cave wrapper to run cave from its source directory
#!/usr/bin/env python
# Wrapper to run cave from its source dir 
import sys, os, subprocess

# Add folder containing libs to library path
for cwd, dirs, files in os.walk("."):
  for file in files:
    if file.endswith(".so") and cwd not in libdirs:
os.environ["LD_LIBRARY_PATH"] = ":".join(libdirs)

os.environ["PALUDIS_NO_GLOBAL_HOOKS"] = "1"
#os.environ["PALUDIS_DO_NOTHING_SANDBOXY"] = "1"
os.environ["PALUDIS_DISTRIBUTIONS_DIR"] = "paludis/distributions"
os.environ["PALUDIS_NO_CHOWN"] = "1"

if __name__ == '__main__':
  sys._exit(subprocess.Popen(["./src/clients/cave/.libs/cave", "--environment", "paludis:test"] + sys.argv[1:]).wait())
  • ./cave resolve paludis -/ n
  • create ~/root/root/bin/cave, a wrapper to the properly installed cave binary:
#!/usr/bin/env python
# Cave wrapper
import sys, os, subprocess

os.environ["PALUDIS_NO_GLOBAL_HOOKS"] = "1"
#os.environ["PALUDIS_DO_NOTHING_SANDBOXY"] = "1"
os.environ["PALUDIS_DISTRIBUTIONS_DIR"] = os.path.expanduser("~/root/etc/paludis/distributions")
os.environ["PALUDIS_NO_CHOWN"] = "1"
def main():

if __name__ == '__main__':
  sys._exit(subprocess.Popen([os.path.expanduser("~/root/usr/bin/cave"), "--environment", "paludis:test"] + sys.argv[1:]).wait())
  • add bin/library paths to the environment
  • add PATH=$ROOT/root/bin:$PATH to paludis bashrc
  • create an wrapper for install to avoid chgrp failures
  • cave resolve system -/ n ...