Hello,

Attached a new version:
*) Supports sparc and ppc too:
*) Make it possible to blacklist packages
*) do nothing on unsupported archs (like i386)

TODO:
*) cleanups
*) adding other archs?

Default config file and python file attached.
Please CC me when replying.

Adel
#!/usr/bin/python

# 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 Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Copyright 2007 by Adel Gadllah

import re, os
from yum.plugins import TYPE_CORE

requires_api_version = '2.3'
plugin_type = TYPE_CORE


def exclude_hook(conduit):

	if os.uname()[-1] == 'x86_64':
		basearch_x86(conduit)
	if os.uname()[-1] == 'ppc64':
		basearch_ppc(conduit)
	if os.uname()[-1] == 'sparc64':
		basearch_ppc(conduit)	

""" Only install i386 packages when told to do so """
def basearch_x86(conduit):
	""" get blacklist from config file """
	blacklist = []
	conflist = conduit.confString('x86', 'blacklist')
	if conflist:
		tmp = conflist.split(",")
		for confitem in tmp:
			print confitem
			blacklist.append(confitem.strip())


	exclude = []
	conf , cmd = conduit.getCmdLine()
	packageList = conduit.getPackages()
	skip = 0
	if cmd[0] == "install":
		for userpkg in cmd:
			for skippkg in blacklist:
				if userpkg == skippkg:
					skip = 1
			if not re.search("i?86$", userpkg) and not skip:
				exclude.append(userpkg)
			skip = 0
	else:
		return
	
	for pkg in packageList:
		if not re.search("i?86$", pkg.arch):
			continue
		for expkg in exclude:
			if expkg == pkg.name:
				conduit.delPackage(pkg)
				conduit.info(3, "--> excluded " + pkg.name + "." + pkg.arch)

""" Only install ppc64 packages when told to do so 
    or when required """ 
def basearch_ppc(conduit):
	""" get blacklist from config file """
	blacklist = []
	conflist = conduit.confString('ppc', 'blacklist')
	if conflist:
		tmp = conflist.split(",")
		for confitem in tmp:
			blacklist.append(confitem.strip())
		

	exclude = []
	conf , cmd = conduit.getCmdLine()
	packageList = conduit.getPackages()
	skip = 0
	if cmd[0] == "install":
		for userpkg in cmd:
			for skippkg in blacklist:
				if userpkg == skippkg:
					skip = 1
			if not re.search("ppc64$", userpkg) and not skip:
				exclude.append(userpkg)
	else:
		return
	
	for pkg in packageList:
		if not re.search("ppc64$", pkg.arch):
			continue
		for expkg in exclude:
			if expkg == pkg.name:
				conduit.delPackage(pkg)
				conduit.info(3, "--> excluded " + pkg.name + "." + pkg.arch)

""" Only install sparc64 packages when told to do so 
    or when required """ 
def basearch_sparc(conduit):
	""" get blacklist from config file """
	blacklist = []
	conflist = conduit.confString('sparc', 'blacklist')
	if conflist:
		tmp = conflist.split(",")
		for confitem in tmp:
			blacklist.append(confitem.strip())

	exclude = []
	conf , cmd = conduit.getCmdLine()
	packageList = conduit.getPackages()
	skip = 0
	if cmd[0] == "install":
		for userpkg in cmd:
			for skippkg in blacklist:
				if userpkg == skippkg:
					skip = 1
			if not re.search("sparc64$", userpkg) and not skip:
				exclude.append(userpkg)
	else:
		return
	
	for pkg in packageList:
		if not re.search("sparc64$", pkg.arch):
			continue
		for expkg in exclude:
			if expkg == pkg.name:
				conduit.delPackage(pkg)
				conduit.info(3, "--> excluded " + pkg.name + "." + pkg.arch)


	
	

Attachment: basearchonly.conf
Description: Binary data

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

Reply via email to