Using and creating Gentoo Linux repositories using Layman

Gentoo Linux uses ebuild scripts to compile and install software packages. Ebuilds for many packages are available in the default portage repository. However, you may want to add your own ebuilds, for example to add additional packages to your system or to apply a patch to the source of a package. Using overlays with Layman is an efficient way to handle this on either one machine or a number of machines.

Use existing overlays with Layman

Emerge Layman

Typically, you should use Layman to handle overlays in Gentoo:

$ emerge -va app-portage/layman

Directory for Layman on the client:
/var/lib/layman/ # layman >= 1.3.0

Use Layman

Add to /etc/make.conf:

source /var/lib/layman/make.conf

Create an initial configuration file:

$ echo PORTDIR_OVERLAY=\"\" > /var/lib/layman/make.conf

To handle overlays with Layman:
layman -L # list all available overlays
layman -a <overlay> # add overlay <overlay>
layman -d <overlay> # delete overlay <overlay>
layman -S # sync all installed overlays
layman -l # list all installed overlays

Create your own overlays

Create a local overlay (server = client)

If you want to use the repository on the same machine only, use a local overlay:

$ mkdir /usr/local/portage

Edit /etc/make.conf and add your own LOCAL overlay:


On the server


Create the directory for the repository on the server:

$ mkdir /usr/local/portage/<reponame>/
  • create your overlay there by adding ebuild files in the proper subdirectories

Create a local rsync mirror:


  • in /etc/rsyncd.conf, add:
            path = /usr/local/portage/<reponame>
            comment = <reponame> Gentoo tree
            exclude = distfiles/ packages/

    access is also set in this file. Note: * works, 192.168.1.* doesn’t – use!

On the client

In /var/lib/layman/<reponame>-overlays.xml add:

<!-- <?xml version="1.0" encoding="UTF-8"?> Remove comments! -->  
<overlay contact="" name="<reponame>" src="rsync://<reponame>" status="unofficial" type="rsync">
  <description><reponame>-Overlay for Gentoo Linux</description>

overlays :

layman -S # creates a new overlays.xml in /var/lib/layman/
layman -L # now lists the new overlay
layman -a <reponame> # adds the overlay and downloads its contents, creating /var/lib/layman/<reponame>/ and adding the entry to /var/lib/layman/make.conf
eix-update # to update eix’s index if you use it

Make sure that


in client:/var/lib/layman/<reponame>-overlays.xml and


in server:/etc/rsyncd.conf use the same name for the module (here, gentoo-<reponame>)

Obtain discarded Gentoo ebuilds

  • Go to the Gentoo CVS Attic
  • Click your way through the tree to the package you’re looking for
  • At the top of the page, after Files shown: <nn>, click on (Show <nn> dead files)
  • You might also need patches et cetera from the files subdirectory
This entry was posted in All, Software and tagged , , , . Bookmark the permalink.

2 Responses to Using and creating Gentoo Linux repositories using Layman

  1. kfir says:

    Hi and much thanks for this post.
    I’m currently creating a local repository on my server, and the xml on the client should change.
    Please use man layman and go to section ‘OVERLAY LIST FORMAT’ and you should see the new format of the xml file. Once you do it like this, you will be able to see it when running ‘layman -L’


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s