I would like to install custom source from a git repository, but using my package manager (emerge for portage).


I have installed Gentoo using EFI using Sakaki's tutorial, so I have already emerged dev-vcs/git.

The packages that I want are for installing Canonical's Snapd (background reading from Ars Technica), and their instructions are:


Install snap-confine.ebuild and snapd.ebuild

'# enable the snapd systemd service:

sudo systemctl enable --now snapd.service

Steps Tried that Didn't Work

Try 1

First I tried to add the prerequisite git .ebuilds as repositories by putting them in my /etc/portage/repos.conf/ directory (two separate entries). I'll post one here as an example:


# Snapd build dependency #1
# Maintainer: obscured

location = /usr/local/portage/zyga-snap-confine
sync-type = git
sync-uri = https://github.com/zyga/snap-confine-gentoo.git
priority = 60
auto-sync = yes

I synced the repos, emaint sync --repo zyga-snap-confine. And then I tried finding the packages that I wanted via both emerge --search and eix. No luck.

It tossed errors about missing layout, a master = gentoo entry...I realize that there was missing metadata, but I had high hopes.

Try 2

I finally found a reference with what to do with an ebuild. In the official Gentoo Wiki, and from other posts here (Installing Git, Curl, and Expat from Source) and here (How to package software in Funtoo/Gentoo?), I decided to:

root@Gentoo ~ # cd /opt
root@Gentoo opt # git clone https://github.com/zyga/snap-confine-gentoo.git
root@Gentoo opt # cd snap-confine-gentoo
root@Gentoo snap-confine-gentoo # ebuild snap-confine-1.0.32.ebuild manifest clean merge

However, it returned errors:

Appending / to PORTDIR_OVERLAY...
!!! Repository 'x-' is missing masters attribute in '/metadata/layout.conf'
!!! Set 'masters = gentoo' in this file for future compatibility
ebuild: /opt/snap-confine-gentoo/snap-confine-1.0.32.ebuild: does not seem to have a valid PORTDIR structure

Preferred Solution

I'm relatively new to Gentoo and am self-taught on Linux, and I couldn't find a tutorial on repo maintenance in the Gentoo forums (there is a developer's guide, but it assumes a lot of knowledge). An ideal answer will provide both the cli method (I assume using git clone ...and ./configure?) as well as the package manager version.

Even if I have to create my own git repository to add missing metadata and layout files - I would prefer to manage the snapd installation that way.

  • 1
    You need to put the ebuilds in their own directory structure as so: /usr/local/portage/category/package i.e /usr/local/portage/snapcore/snap-confine and for the other one it would be /usr/local/portage/snap-core/snapd but you should really figure out which existing category the package fits in first.
    – likewhoa
    Commented Sep 2, 2016 at 4:35

1 Answer 1


Based off of @likewhoa comments above, the structure of the ebuild needed to be massaged. The creators did not have recent portage structure in mind when creating their git repositories.

For Command-line

(an ebuild without portage directory structure)
Within /usr/local/portage/ I decided that snap-confine belonged under category sys-apps

From bash root prompt:

cd /usr/local/portage
git clone https://github.com/zyga/snap-confine-gentoo.git
cd snap-confine-gentoo
mkdir -pv sys-apps/snap-confine
# the Manifest file will be recreated later
rm -v Manifest
mv -v snap-confine-1.0.32.ebuild sys-apps/snap-confine/
# to avoid errors, you need your masters = gentoo reference
mkdir -v metadata
echo 'masters = gentoo' > metadata/layout.conf 
cd sys-apps/snap-confine
ebuild snap-confine-1.0.32.ebuild manifest clean merge

As it turns out, the .ebuild wasn't properly formed with correct dependencies, but I think these steps provide a good tutorial - based off of:

  1. https://wiki.gentoo.org/wiki/Basic_guide_to_write_Gentoo_Ebuilds
  2. https://devmanual.gentoo.org/quickstart/

For Portage management

Based off of other Gentoo repositories, I recommended to the developer to create a single repo containing both the snap-confine and snapd ebuilds under the package categories sys-apps and app-emulation, respectively.

Then, we created a metadata/layout.conf file containing masters = gentoo to avoid portage compatibility complaints. Developer guidance also required that we have a profiles/repo_name file with the repo's name identified. Within each package's folder, we created a metadata.xml file and then ran repoman manifest to generate the Manifest file.

Lastly, a user needs to create an entry within /etc/portage/repos.conf/, the instructions for which are expertly detailed on the sakaki-tools github repo

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .