[yum-cvs] 2 commits - plugins/basearchonly

Tim Lauridsen timlau at linux.duke.edu
Tue Jul 31 14:27:49 UTC 2007


 plugins/basearchonly/basearchonly.conf |    8 +++
 plugins/basearchonly/basearchonly.py   |   75 +++++++++++++++++++++++++++++++++
 2 files changed, 83 insertions(+)

New commits:
commit 937f4599ae341f9d1303fa9462df5230f5e58cbf
Merge: 61d6957... f86151f...
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Tue Jul 31 16:23:11 2007 +0200

    Merge branch 'master' of ssh://login.linux.duke.edu/home/groups/yum/git/yum-utils

commit 61d6957dbc61964144cab959d0faf77aea8cde02
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Tue Jul 31 16:22:48 2007 +0200

    Added basearchonly plugin files

diff --git a/plugins/basearchonly/basearchonly.conf b/plugins/basearchonly/basearchonly.conf
new file mode 100644
index 0000000..3672778
--- /dev/null
+++ b/plugins/basearchonly/basearchonly.conf
@@ -0,0 +1,8 @@
+[main]
+enabled=1
+[x86]
+whitelist = firefox
+[ppc]
+whitelist = kernel, gdb, frysk, systemtap, ltrace, strace, valgrind
+[sparc]
+whitelist = kernel, gdb, frysk, systemtap, ltrace, strace, valgrind
diff --git a/plugins/basearchonly/basearchonly.py b/plugins/basearchonly/basearchonly.py
new file mode 100644
index 0000000..100cb57
--- /dev/null
+++ b/plugins/basearchonly/basearchonly.py
@@ -0,0 +1,75 @@
+#!/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):
+
+	""" Only install i386 packages when told to do so """
+	if os.uname()[-1] == 'x86_64':
+		basearch(conduit, "x86", "i?86$")
+	
+	""" Only install ppc64 packages when told to do so """	
+	if os.uname()[-1] == 'ppc64':
+		basearch(conduit, "ppc", "ppc64$")
+
+	""" Only install sparc64 packages when told to do so """	
+	if os.uname()[-1] == 'sparc64':
+		basearch(conduit, "sparc", "sparc64$")
+
+
+def basearch(conduit, barch, excludearchP):
+	
+	exclude = []
+	whitelist = []
+	conf , cmd = conduit.getCmdLine()
+	packageList = conduit.getPackages()
+	excludearch = re.compile(excludearchP);
+	
+	if not cmd:
+		return
+
+	if cmd[0] != "install":
+		return
+
+	""" get whitelist from config file """	
+	
+	conflist = conduit.confString(barch, 'whitelist')
+	if conflist:
+		tmp = conflist.split(",")
+		for confitem in tmp:
+			whitelist.append(confitem.strip())
+	
+	""" decide which packages we want to exclude """	
+
+	for userpkg in cmd:
+           if not userpkg in whitelist and not excludearch.search(userpkg):
+               exclude.append(userpkg)
+
+	""" exclude the packages """	
+	
+	for pkg in packageList:
+		if pkg.name in exclude and excludearch.search(pkg.arch):
+			conduit.delPackage(pkg)
+			conduit.info(3, "--> excluded %s.%s" % (pkg.name, pkg.arch))	
+



More information about the Yum-cvs-commits mailing list