masking a package in gentoo overlay

June 24, 2017

It’s a post on how to selectively mask a ebuild in the overlay. The running example will be a package app-misc/foo using systemd (systemd is masked in selinux profiles).

Here is how our ebuild looks like:

# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

DESCRIPTION="An example package with a depend masked in selinux profiles."

KEYWORDS="~amd64 ~x86 ~ppc ~ppc64"

# systemd is masked on selinux profiles

The problem with it is that it’s not usable on selinux profiles due to systemd mask:

overlay-selective-mask-in-gentoo/app-misc $ repoman full

RepoMan scours the neighborhood...
  dependency.bad [fatal]        3
   app-misc/foo/foo-0.ebuild: DEPEND: ~amd64(hardened/linux/amd64/no-multilib/selinux)
   app-misc/foo/foo-0.ebuild: DEPEND: ~amd64(hardened/linux/amd64/selinux)
   app-misc/foo/foo-0.ebuild: DEPEND: ~x86(hardened/linux/x86/selinux)

Thus our goal is to mask this package on selinux profiles. Unfortunately it requires quite a few steps to do it:

  1. Add profiles/profiles.desc file and populate it with all profiles we want to override.

    Repoman already shows us 3 profiles we need to override.

    We need to create profiles/profiles.desc file with the following contents:

    amd64           hardened/linux/amd64/selinux                            stable
    amd64           hardened/linux/amd64/no-multilib/selinux                stable
    x86             hardened/linux/x86/selinux                              stable
  2. Create package.mask which we will use for our overrides.

    I’ve added our mask to new profiles/features/selinux/package.mask file:

    # Sergei Trofimovich <> (24 Jun 2016)
    # requires systemd (masked on selinux)
  3. Create profile overrides for each profile.

    Let’s look in detail on hardened/linux/x86/selinux profile. It’s override requires a single file.

    Let’s create profiles/hardened/linux/x86/selinux/parent with the following contents:


    Here gentoo:hardened/linux/x86/selinux refers to parent profile and :features/selinux refers to our tiny mixin with single package.mask.

  4. Enable portage-2 extension to metadata/layout.conf.

    Unfortunately [repo]:<absolute-path> is not described in PMS and is not portable across all Gentoo package managers.

    To enable it for portage we need to add the following in metadata/layout.conf:

    profile-formats = portage-2


Now repoman is happy:

overlay-selective-mask-in-gentoo/app-misc $ repoman full

RepoMan scours the neighborhood...

Note: use --without-mask to check KEYWORDS on dependencies of masked packages
Note: use --include-dev (-d) to check dependencies for 'dev' profiles

RepoMan sez: "If everyone were like you, I'd be out of business!"

Full example repository is available at: