[Yum-devel] [PATCH] Make mdpolicy to be a list, to give users/callers greater control
Tim Lauridsen
tim.lauridsen at googlemail.com
Wed Oct 7 13:11:04 UTC 2009
On 10/06/2009 11:16 PM, James Antill wrote:
> ---
> yum/config.py | 5 ++---
> yum/yumRepo.py | 37 ++++++++++++++++++-------------------
> 2 files changed, 20 insertions(+), 22 deletions(-)
>
> diff --git a/yum/config.py b/yum/config.py
> index 63b3d17..ae294d3 100644
> --- a/yum/config.py
> +++ b/yum/config.py
> @@ -667,9 +667,8 @@ class YumConf(StartupConf):
> skip_broken = BoolOption(False)
> # Note that "instant" is the old behaviour, but group:primary is very
> # similar but better :).
> - mdpolicy = SelectionOption('group:primary',
> - ('instant', 'group:all', 'group:main',
> - 'group:small', 'group:primary'))
> + mdpolicy = ListOption(['group:primary'])
> + # ('instant', 'group:all', 'group:main', 'group:small', 'group:primary'))
> multilib_policy = SelectionOption('all',('best', 'all'))
> # all == install any/all arches you can
> # best == use the 'best arch' for the system
> diff --git a/yum/yumRepo.py b/yum/yumRepo.py
> index 978cb45..0f810cd 100644
> --- a/yum/yumRepo.py
> +++ b/yum/yumRepo.py
> @@ -1355,13 +1355,6 @@ class YumRepository(Repository, config.RepoConf):
> self._doneOldRepoXML()
> return True
>
> - def _instantLoadRepoXML(self, text=None):
> - """ Retrieve the new repomd.xml from the repository, then check it
> - and parse it. If it fails revert.
> - Mostly traditional behaviour. """
> - if self._commonLoadRepoXML(text):
> - self._commonRetrieveDataMD([])
> -
> def _groupLoadRepoXML(self, text=None, mdtypes=None):
> """ Retrieve the new repomd.xml from the repository, then check it
> and parse it. If it fails we revert to the old version and pretend
> @@ -1375,19 +1368,25 @@ class YumRepository(Repository, config.RepoConf):
>
> def _loadRepoXML(self, text=None):
> """retrieve/check/read in repomd.xml from the repository"""
> + md_groups = {'instant' : [],
> + 'group:primary' : ['primary'],
> + 'group:small' : ["primary", "updateinfo"],
> + 'group:main' : ["primary", "group", "filelists",
> + "updateinfo", "prestodelta"]}
> + mdtypes = set()
> + if type(self.mdpolicy) in types.StringTypes:
> + mdtypes.update(md_groups.get(self.mdpolicy, [self.mdpolicy]))
> + else:
> + for mdpolicy in self.mdpolicy:
> + mdtypes.update(md_groups.get(mdpolicy, [mdpolicy]))
> +
> + if not mdtypes or 'group:all' in mdtypes:
> + mdtypes = None
> + else:
> + mdtypes = sorted(list(mdtypes))
> +
> try:
> - if self.mdpolicy in ["instant"]:
> - return self._instantLoadRepoXML(text)
> - if self.mdpolicy in ["group:all"]:
> - return self._groupLoadRepoXML(text)
> - if self.mdpolicy in ["group:main"]:
> - return self._groupLoadRepoXML(text, ["primary", "group",
> - "filelists", "updateinfo",
> - "prestodelta"])
> - if self.mdpolicy in ["group:small"]:
> - return self._groupLoadRepoXML(text, ["primary", "updateinfo"])
> - if self.mdpolicy in ["group:primary"]:
> - return self._groupLoadRepoXML(text, ["primary"])
> + return self._groupLoadRepoXML(text, mdtypes)
> except KeyboardInterrupt:
> self._revertOldRepoXML() # Undo metadata cookie?
> raise
Looks good to me
Tim
More information about the Yum-devel
mailing list