From 8b0142fe13641a42efa6ac160d3da85d56f7863b Mon Sep 17 00:00:00 2001
From: Joao Paulo Ventura <joaopfv@br.ibm.com>
Date: Tue, 19 Jul 2011 12:24:30 -0300
Subject: [PATCH] Allow mash to export arbitrary packages in multilib repositories.

---
 mash/__init__.py |   33 ++++++++++++++++++++++-----------
 mash/config.py   |    3 +++
 mash/multilib.py |   13 +++++++------
 3 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/mash/__init__.py b/mash/__init__.py
index 719f76b..f6e140d 100644
--- a/mash/__init__.py
+++ b/mash/__init__.py
@@ -429,23 +429,34 @@ class Mash:
             if len(pids) == 0:
                 break
         return rc
-    
+
+    def detectMultilibMethod(self):
+        try:
+            if self.config.multilib_file:
+                multilib_file = os.path.join(self.config.configdir, self.config.multilib_file)
+            else:
+                multilib_file = None
+
+            if   self.config.multilib_method == 'base'    : return multilib.MultilibMethod()
+            elif self.config.multilib_method == 'devel'   : return multilib.DevelMultilibMethod()
+            elif self.config.multilib_method == 'file'    : return multilib.FileMultilibMethod(multilib_file)
+            elif self.config.multilib_method == 'kernel'  : return multilib.KernelMultilibMethod()
+            elif self.config.multilib_method == 'all'     : return multilib.AllMultilibMethod()
+            elif self.config.multilib_method == 'none'    : return multilib.NoMultilibMethod()
+            elif self.config.multilib_method == 'runtime' : return multilib.RuntimeMultilibMethod()
+        except TypeError:
+            self.logger.error("Invalid multilib method %s" % (self.config.multilib_method,))
+            do_multi = False
+            return
+
     def doDepSolveAndMultilib(self, arch, repocache):
-        
         do_multi = self.config.multilib
-        
+
         try:
-            method = { 'base'    : multilib.MultilibMethod,
-                       'devel'   : multilib.DevelMultilibMethod,
-                       'file'    : multilib.FileMultilibMethod,
-                       'kernel'  : multilib.KernelMultilibMethod,
-                       'all'     : multilib.AllMultilibMethod,
-                       'none'    : multilib.NoMultilibMethod,
-                       'runtime' : multilib.RuntimeMultilibMethod}[self.config.multilib_method]()
+            method = self.detectMultilibMethod()
         except KeyError:
             self.logger.error("Invalid multilib method %s" % (self.config.multilib_method,))
             do_multi = False
-            return
         
         tmpdir = "%s/mash-%s/" % (self.config.workdir, self.config.name,)
         repocache = os.path.join(tmpdir,".createrepo-cache")
diff --git a/mash/config.py b/mash/config.py
index c94ea4a..4678bc9 100644
--- a/mash/config.py
+++ b/mash/config.py
@@ -28,6 +28,7 @@ class MashConfig(config.BaseConfig):
     debuginfo_path = config.Option('%(arch)s/debug')
     multilib = config.BoolOption(True)
     multilib_method = config.Option('devel')
+    multilib_file = config.Option()
     arches = config.ListOption()
     keys = config.ListOption()
     configdir = config.Option('/etc/mash')
@@ -62,10 +63,12 @@ class MashDistroConfig(config.BaseConfig):
     debuginfo_path = config.Inherit(MashConfig.debuginfo_path)
     multilib = config.Inherit(MashConfig.multilib)
     multilib_method = config.Inherit(MashConfig.multilib_method)
+    multilib_file   = config.Inherit(MashConfig.multilib_file)
     arches = config.Inherit(MashConfig.arches)
     tag = config.Option()
     inherit = config.BoolOption(True)
     keys = config.Inherit(MashConfig.keys)
+    configdir = config.Inherit(MashConfig.configdir)
     strict_keys = config.Inherit(MashConfig.strict_keys)
     buildhost = config.Inherit(MashConfig.buildhost)
     repodir = config.Inherit(MashConfig.repodir)
diff --git a/mash/multilib.py b/mash/multilib.py
index 1c4e6cb..a537751 100644
--- a/mash/multilib.py
+++ b/mash/multilib.py
@@ -42,18 +42,18 @@ class AllMultilibMethod(MultilibMethod):
         return True
     
 class FileMultilibMethod(MultilibMethod):
-    def __init__(self, file):
+    def __init__(self, multilib_file):
         self.name = 'file'
         self.list = []
-        if file:
-            f = open(file,'r')
+        if multilib_file:
+            f = open(multilib_file,'r')
             lines = f.readlines()
             f.close()
             for line in lines:
                 line = line.strip()
                 if not line.startswith('#'):
-                    list.append(line)
-    
+                    self.list.append(line)
+
     def select(self, po):
         for item in self.list:
             if fnmatch(po.name, item):
@@ -76,9 +76,10 @@ class RuntimeMultilibMethod(MultilibMethod):
         self.name = 'runtime'
     
     def select(self, po):
-        libdirs = [ '/usr/lib', '/usr/lib64', '/lib', '/lib64' ]
+        libdirs   = [ '/usr/lib', '/usr/lib64', '/lib', '/lib64' ]
         blacklist = [ 'tomcat-native' ]
         whitelist = [ 'libgnat', 'wine', 'lmms-vst', 'nspluginwrapper', 'libflashsupport', 'pulseaudio-utils', 'valgrind', 'perl-libs' ]
+
         if po.name in blacklist:
             return False
         if po.name in whitelist:
-- 
1.7.0.4

