]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
gentoo: Set FEATURES by appending to /etc/portage/make.conf
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sat, 22 Jul 2023 14:53:43 +0000 (16:53 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Sat, 22 Jul 2023 17:58:13 +0000 (19:58 +0200)
Setting via the environment variable doesn't work in all cases, so
let's append to /etc/portage/make.conf instead. This allows us to
get rid of the custom devtpms for portage as it doesn't try to chown
tty's anymore now that userpriv is actually disabled.

mkosi/distributions/gentoo.py

index 0d4aa70c0ac1a626e44da10a376734bde3a938e7..e99e031a2753dcb6d5328f6d470f1a4da458cc3f 100644 (file)
@@ -19,7 +19,6 @@ from mkosi.types import PathString
 def invoke_emerge(state: MkosiState, packages: Sequence[str] = (), apivfs: bool = True) -> None:
     bwrap(
         cmd=[
-            "sh", "-c", "chmod 1777 /dev/shm && exec $0 \"$@\" || exit $?",
             "emerge",
             *packages,
             "--update",
@@ -48,26 +47,11 @@ def invoke_emerge(state: MkosiState, packages: Sequence[str] = (), apivfs: bool
             "--bind", state.cache_dir / "stage3/var", "/var",
             "--ro-bind", "/etc/resolv.conf", "/etc/resolv.conf",
             "--bind", state.cache_dir / "repos", "/var/db/repos",
-            # https://bugs.gentoo.org/910587
-            "--dev", "/dev",
         ],
         env=dict(
             PKGDIR=str(state.cache_dir / "binpkgs"),
             DISTDIR=str(state.cache_dir / "distfiles"),
-            FEATURES=" ".join([
-                "getbinpkg",
-                "-candy",
-                # Disable sandboxing in emerge because we already do it in mkosi.
-                "-sandbox",
-                "-userfetch",
-                "-userpriv",
-                "-usersandbox",
-                "-usersync",
-                "-ebuild-locks",
-                "parallel-install",
-                *(["noman", "nodoc", "noinfo"] if state.config.with_docs else []),
-            ]),
-        ) | {"USE": "build"} if not apivfs else {} | state.config.environment,
+        ) | ({"USE": "build"} if not apivfs else {}) | state.config.environment,
     )
 
 
@@ -142,6 +126,25 @@ class GentooInstaller(DistributionInstaller):
 
         copy_path(state.pkgmngr, stage3, preserve_owner=False)
 
+        features = " ".join([
+            "getbinpkg",
+            "-candy",
+            # Disable sandboxing in emerge because we already do it in mkosi.
+            "-sandbox",
+            "-userfetch",
+            "-userpriv",
+            "-usersandbox",
+            "-usersync",
+            "-ebuild-locks",
+            "parallel-install",
+            *(["noman", "nodoc", "noinfo"] if state.config.with_docs else []),
+        ])
+
+        # Setting FEATURES via the environment variable does not seem to apply to ebuilds in portage, so we
+        # append to /etc/portage/make.conf instead.
+        with (stage3 / "etc/portage/make.conf").open("a") as f:
+            f.write(f"\nFEATURES=\"${{FEATURES}} {features}\"\n")
+
         bwrap(
             cmd=["chroot", "emerge-webrsync"],
             apivfs=stage3,