Hi!

I wrote a  simple plugin that allows filtering mirrors list. Possible uses;

1. exclude ftp:// mirrors
2. allow only mirrors matching certain pattern (like mirrors from Poland)

Would like to have it in yum distro ?

Best Regards,

Jacek Pliszka
#!/usr/bin/env python
#
# Version: 0.1
#
# A plugin for the Yellowdog Updater Modified which filters mirrorlist 
# for each repo with function given in the config file
#
# To install this plugin, just drop it into /usr/lib/yum-plugins, and
# make sure you have 'plugins=1' in your /etc/yum.conf.
#
# Configuration Options
# /etc/yum/pluginconf.d/filtermirrors.conf:
#   [main]
#   enabled=1
#   function='lambda s: s[:4] != "ftp:"'   # Beginning of the url has to be different than ftp:
## Another possible function:
#   function='lambda s: s.find(".pl/")>0' # Containing .pl/ string i.e. mirrors in Poland
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# (C) Copyright 2007 Jacek Pliszka <[EMAIL PROTECTED]>
#

from yum.plugins import PluginYumExit, TYPE_CORE, TYPE_INTERACTIVE
requires_api_version = '2.3'
plugin_type = (TYPE_CORE, TYPE_INTERACTIVE)

function=""

def init_hook(conduit):
    global function
    function = conduit.confString('main', 'function', default='lambda x : true')
  
def postreposetup_hook(conduit):
	global function
	repos=conduit.getRepos().listEnabled()
	myf=eval(function)
	for repo in repos:
		for i in repo.urls[:] :
			if not myf(i): 
				repo.urls.remove(i)

Attachment: filtermirrors.conf
Description: Binary data

_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel

Reply via email to