2

I am installing KDE on a Gentoo Linux Hardened system. The official Gentoo wiki says the recommended way is to apply the KDE desktop profile, issue emerge -NDu --with-bdeps=y @world, and then install the kdebase-meta package. However, I am on the Hardened profile and apparently I can only have one selected profile at once.

So far I've been successful with manually applying the KDE profile's global and per-package USE flags on my Portage configuration files (/etc/portage/make.conf, /etc/portage/package.use and stuff), but I fear this hack might be rather difficult to maintain in the long run as the Gentoo dev team modifies the profile. Every time I get a Portage update, I'd have to reapply the desktop and desktop/kde profiles' USE flags and configuration just in case they were changed.

Is there any other way to have multiple active Portage profiles at once on Gentoo Linux?

1

Problem

As you have discovered, Gentoo only allows one Profile Setup at a time. As you can see from my eselect profile list:

 [1]   default/linux/amd64/13.0
 [2]   default/linux/amd64/13.0/selinux
 [3]   default/linux/amd64/13.0/desktop
 [4]   default/linux/amd64/13.0/desktop/gnome
 [5]   default/linux/amd64/13.0/desktop/gnome/systemd
 [6]   default/linux/amd64/13.0/desktop/kde *
 [7]   default/linux/amd64/13.0/desktop/kde/systemd
 [8]   default/linux/amd64/13.0/desktop/plasma
 [9]   default/linux/amd64/13.0/desktop/plasma/systemd
 [10]  default/linux/amd64/13.0/developer
 [11]  default/linux/amd64/13.0/no-multilib
 [12]  default/linux/amd64/13.0/systemd
 [13]  default/linux/amd64/13.0/x32
 [14]  hardened/linux/amd64
 [15]  hardened/linux/amd64/selinux
 [16]  hardened/linux/amd64/no-multilib
 [17]  hardened/linux/amd64/no-multilib/selinux
 [18]  hardened/linux/amd64/x32
 [19]  hardened/linux/musl/amd64
 [20]  hardened/linux/musl/amd64/x32
 [21]  default/linux/uclibc/amd64
 [22]  hardened/linux/uclibc/amd64

Solution

Having set your profile to hardened (14 on my list), we now need to examine the files for the KDE Profile: (note that this takes a bit of writing without a text editor):

  1. cd /usr/portage/profiles/targets/desktop/kde
  2. nano -w make.defaults
  3. nano -w parent
  4. You should now see files in /usr/portage/profiles/targets/desktop/.
  5. nano -w make.defaults

Using Scratch Paper, copy down the USE Flags from Step 2, and opening parent in Step 3 reveals .. , which now means we travel one directory up. Copy the USE Flags from Step 5. As the final step, issue emerge -v app-portage/ufed && ufed. You can now set the USE Flags you copied down in /etc/portage/make.conf. You may want to repeat the process for:

  • /usr/portage/profiles/desktop/kde/package.use
  • /usr/portage/profiles/desktop/package.use

by placing the packages listed in those two files into /etc/portage/package.use.


During Syncs, files in /etc/portage will not be overwritten and the USE Flags in /etc/portage/make.conf will mimic the behavior you are trying to achieve. See the Portage Files Section in the Handbook for more information. In essence, your Portage overrides in /etc/portage will add to your hardened profile, as Portage uses your configuration before it reads your selected profile. I know it's a pain as the USE Flags in the profiles package.use files can be updated with each sync, so you will need to see if any are added after each sync. Generally, the profile files aren't updated very often.

  • It is possible to use multiple profiles and this procedure is not the correct one. Please see my answer below. I have to give you the credit, that the wiki I refer to didn't contain this info at the time of posting this answer. One would have to study existing profiles to figure this possibility. – Tim Jun 5 '18 at 15:26
0

Use cascading

Profiles allow for cascading, no need to manually set useflags:

All profiles are cascading/stackable profiles composed by several subprofiles...

The same page also contains a chapter specifically for answering for the demand in this questions:

Combining profiles

If there isn't a profile in the Gentoo repository that meets your exact requirements, you can try combining multiple profiles into a single custom profile. An example of this would be combining a hardened profile with a desktop systemd profile, such as default/linux/amd64/17.0/desktop/plasma/systemd and default/linux/amd64/17.0/hardened. It is expected that you already have a custom repository set up.

The wikipage leads you to more links how to set up a repository and finally create the profile.

HowTo

Here is a summary on how I've done it for a no-multilib/plasma/systemdcombination (adjust to your needs):

1. Create directory structure for repository

mkdir -p /usr/portage/local/{metadata,profiles/default/linux/amd64/17.0/no-multilib/plasma/systemd}

2. Define the parents

Edit /usr/portage/local/profiles/default/linux/amd64/17.0/no-multilib/plasma/systemd/parent to contain something like:

/usr/portage/profiles/default/linux/amd64/17.0/desktop/plasma/systemd
/usr/portage/profiles/default/linux/amd64/17.0/no-multilib

Note that the documentation uses relative paths, but I found the level of negative recursions (../../..) a wee bit confusing. Absolute paths work just as fine, unless you plan on moving /usr/portage around on the system.

I found that a lower line takes preference. So if a flag or setting is set / unset in the first profile, and the opposite happens in a lower line, the lower line's profile setting applies. For instance, plasma profile allows for some multi-lib settings. If I where to set the multi-lib line above the plasma one, some packages will still be attempted to be build as multi-lib (giving all sorts of funny build failures). You may need to play around with the order of this lines.

3. Set repository metadata

Edit /usr/portage/local/metadata/layout.conf. Auto-sync tells emerge --sync not to sync this repository.

masters = gentoo
auto-sync = false

Define the friendly name. This will be prefixed to all the eselect profile list entries for this repo. /usr/portage/local/profiles/repo_name:

local

And /usr/portage/local/profiles/profiles.desc will tell eselect where to look for profiles. First field is arch, second profile name, and third field stable or experimental:

amd64 default/linux/amd64/17.0/no-multilib/plasma/systemd stable

4. Make portage aware of this new repository

Create and edit /etc/portage/repos.conf/local.conf to contain:

[local]
location = /usr/portage/local

5. Set the profile and fingers crossed

~# eselect profile list
[...]
[55]  local:default/linux/amd64/17.0/no-multilib/plasma/systemd (stable)
~# eselect profile set 55
~# emerge --update --newuse --deep --ask --verbose @world

Maintenance friendly

Although, this is a bit of work to set up, it is very easy to maintain. Profile useflags and setting always keep in sync with the main tree. Even if once in a while it is necessary to update the profile version, it goes without too may difficulty. For instance, if there is a new profile version from the Gentoo tree:

~# cd /usr/portage/local/profiles/default/linux/amd64
~# cp -av 17.0 18.0
~# vi 18.0/no-multilib/plasma/systemd/parent
/usr/portage/profiles/default/linux/amd64/18.0/desktop/plasma/systemd
/usr/portage/profiles/default/linux/amd64/18.0/no-multilib
~# vi /usr/portage/local/profiles/profiles.desc
amd64 default/linux/amd64/18.0/no-multilib/plasma/systemd stable
~# eselect [...]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.