commit:     bf3fd3dea8ee35481caa4b8f95f0cd19141650b7
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 15 16:32:02 2026 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Feb 15 16:56:50 2026 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=bf3fd3de

Read binrepos.conf from /usr/share/portage/config too

Python's configparser will merge values. Read binrepos.conf from
/usr/share/portage/config first, like we do for repos.conf. This will
let us set some defaults.

Bug: https://bugs.gentoo.org/969086
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/_emerge/actions.py                  | 21 +++++++++++++++++----
 lib/portage/dbapi/bintree.py            | 22 ++++++++++++++++++----
 lib/portage/tests/dbapi/test_bintree.py |  2 +-
 man/portage.5                           |  7 +++++++
 4 files changed, 43 insertions(+), 9 deletions(-)

diff --git a/lib/_emerge/actions.py b/lib/_emerge/actions.py
index d9bd9080db..0723d44076 100644
--- a/lib/_emerge/actions.py
+++ b/lib/_emerge/actions.py
@@ -23,7 +23,11 @@ from portage import os
 from portage import shutil
 from portage import _encodings, _unicode_decode
 from portage.binrepo.config import BinRepoConfigLoader
-from portage.const import BINREPOS_CONF_FILE, _DEPCLEAN_LIB_CHECK_DEFAULT
+from portage.const import (
+    BINREPOS_CONF_FILE,
+    _DEPCLEAN_LIB_CHECK_DEFAULT,
+    PORTAGE_BASE_PATH,
+)
 from portage.dbapi.dep_expand import dep_expand
 from portage.dbapi._expand_new_virt import expand_new_virt
 from portage.dbapi.IndexedPortdb import IndexedPortdb
@@ -2131,10 +2135,19 @@ def action_info(settings, trees, myopts, myfiles):
     for repo in repos:
         append(repo.info_string())
 
-    binrepos_conf_path = os.path.join(
-        settings["PORTAGE_CONFIGROOT"], BINREPOS_CONF_FILE
+    binrepos_config_paths = []
+    if portage._not_installed:
+        binrepos_config_paths.append(
+            os.path.join(PORTAGE_BASE_PATH, "cnf", "binrepos.conf")
+        )
+    else:
+        binrepos_config_paths.append(
+            os.path.join(settings.global_config_path, "binrepos.conf")
+        )
+    binrepos_config_paths.append(
+        os.path.join(settings["PORTAGE_CONFIGROOT"], BINREPOS_CONF_FILE)
     )
-    binrepos_conf = BinRepoConfigLoader((binrepos_conf_path,), settings)
+    binrepos_conf = BinRepoConfigLoader(binrepos_config_paths, settings)
     if binrepos_conf and any(repo.name for repo in binrepos_conf.values()):
         append("Binary Repositories:\n")
         for repo in reversed(list(binrepos_conf.values())):

diff --git a/lib/portage/dbapi/bintree.py b/lib/portage/dbapi/bintree.py
index 60a7306697..87e407ad7e 100644
--- a/lib/portage/dbapi/bintree.py
+++ b/lib/portage/dbapi/bintree.py
@@ -10,6 +10,7 @@ from portage.cache.mappings import slot_dict_class
 from portage.const import (
     BINREPOS_CONF_FILE,
     CACHE_PATH,
+    PORTAGE_BASE_PATH,
     SUPPORTED_XPAK_EXTENSIONS,
     SUPPORTED_GPKG_EXTENSIONS,
     SUPPORTED_GENTOO_BINPKG_FORMATS,
@@ -969,14 +970,27 @@ class binarytree:
                 self._populate_additional(add_repos)
 
             if getbinpkgs:
-                config_path = os.path.join(
-                    self.settings["PORTAGE_CONFIGROOT"], BINREPOS_CONF_FILE
+                config_paths = []
+                if portage._not_installed:
+                    config_paths.append(
+                        os.path.join(PORTAGE_BASE_PATH, "cnf", "binrepos.conf")
+                    )
+                else:
+                    config_paths.append(
+                        os.path.join(self.settings.global_config_path, 
"binrepos.conf")
+                    )
+
+                config_paths.append(
+                    os.path.join(
+                        self.settings["PORTAGE_CONFIGROOT"], BINREPOS_CONF_FILE
+                    )
                 )
-                self._binrepos_conf = BinRepoConfigLoader((config_path,), 
self.settings)
+
+                self._binrepos_conf = BinRepoConfigLoader(config_paths, 
self.settings)
                 if not self._binrepos_conf:
                     writemsg(
                         _(
-                            f"!!! {config_path} is missing (or PORTAGE_BINHOST 
is unset), "
+                            f"!!! binrepos.conf is missing (or PORTAGE_BINHOST 
is unset), "
                             "but use is requested.\n"
                         ),
                         noiselevel=-1,

diff --git a/lib/portage/tests/dbapi/test_bintree.py 
b/lib/portage/tests/dbapi/test_bintree.py
index 976f6d5572..537556aff5 100644
--- a/lib/portage/tests/dbapi/test_bintree.py
+++ b/lib/portage/tests/dbapi/test_bintree.py
@@ -170,7 +170,7 @@ class BinarytreeTestCase(TestCase):
         ppopulate_remote.assert_not_called()
         self.assertEqual(
             out.getvalue(),
-            f"!!! {conf_file} is missing (or PORTAGE_BINHOST is unset), but 
use is requested.\n",
+            f"!!! binrepos.conf is missing (or PORTAGE_BINHOST is unset), but 
use is requested.\n",
         )
 
     @patch("portage.dbapi.bintree.BinRepoConfigLoader")

diff --git a/man/portage.5 b/man/portage.5
index 326c37fe48..8f3ba09751 100644
--- a/man/portage.5
+++ b/man/portage.5
@@ -121,6 +121,7 @@ use.stable.force
 .TP
 .BR /usr/share/portage/config/
 .nf
+binrepos.conf
 make.globals
 repos.conf
 sets
@@ -1856,6 +1857,12 @@ games\-emulation/xmess:net \- Adds network support
 .BR /usr/share/portage/config/
 .RS
 .TP
+.BR binrepos.conf
+The default configuration of binary repositories for Portage.  This comes from
+the portage package itself.  Settings in \fB/etc/portage/binrepos.conf\fR
+override values set here. The format is described extensively in section
+for \fB/etc/portage/binrepos.conf\fR.
+.TP
 .BR make.globals
 The global default settings for Portage.  This comes from the portage package
 itself.  Settings in \fBmake.conf\fR or \fBpackage.env\fR override values set

Reply via email to