From c77d2dfeb2d1856d9443b64ab8d9fe95d7796cf0 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 8 Oct 2011 15:51:45 -0700 Subject: [PATCH] RepoConfig: allow repos.conf 'masters' override This give the user the power to override 'masters' settings from layout.conf, is case they want use a different set of masters to satisfy dependencies. This is especially important now that recursive expansion of masters is supported since commit ab2a6cc357ba3c8272a4a1556e2c0bcd4bee102e, so that the user can avoid pulling in unwanted repositories as dependencies, if necessary. Also, empty 'masters' settings are now supported, in case a repo wants to avoid implicit inheritance of PORTDIR settings like package.mask. --- man/portage.5 | 7 +++++++ pym/portage/repository/config.py | 26 ++++++++++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/man/portage.5 b/man/portage.5 index 1d9545ab6..860803b4c 100644 --- a/man/portage.5 +++ b/man/portage.5 @@ -714,6 +714,13 @@ aliases = foo bar [kde-testing] # override the metadata/layout.conf masters setting from the kde-testing repo masters = gentoo kde + +[python] +# override the metadata/layout.conf masters setting from the python repo, +# so that settings won't be inherited from those masters, and so that +# those master repos won't be required as dependencies (the user must +# ensure that any required dependencies such as eclasses are satisfied) +masters = .fi .RE .TP diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py index 8f7e80969..1d042ac0e 100644 --- a/pym/portage/repository/config.py +++ b/pym/portage/repository/config.py @@ -66,8 +66,11 @@ class RepoConfig(object): #Locations are computed later. self.eclass_locations = None - #Masters are only read from layout.conf. - self.masters = None + # Masters from repos.conf override layout.conf. + masters = repo_opts.get('masters') + if masters is not None: + masters = tuple(masters.split()) + self.masters = masters #The main-repo key makes only sense for the 'DEFAULT' section. self.main_repo = repo_opts.get('main-repo') @@ -358,12 +361,19 @@ class RepoConfigLoader(object): layout_file = KeyValuePairFileLoader(layout_filename, None, None) layout_data, layout_errors = layout_file.load() - masters = layout_data.get('masters') - if masters and masters.strip(): - masters = masters.split() - else: - masters = None - repo.masters = masters + # Only set masters here if is None, so that repos.conf settings + # will override those from layout.conf. This gives the + # user control over inherited repositories and their settings + # (the user must ensure that any required dependencies such as + # eclasses are satisfied). + if repo.masters is None: + masters = layout_data.get('masters') + if masters is not None: + # We support empty masters settings here, in case a + # repo wants to avoid implicit inheritance of PORTDIR + # settings like package.mask. + masters = tuple(masters.split()) + repo.masters = masters aliases = layout_data.get('aliases') if aliases and aliases.strip(): -- 2.26.2