From 49bcf878ed9472cc23cf64780eb81bfecfb09b64 Mon Sep 17 00:00:00 2001
From: Luke Macken <lmacken@redhat.com>
Date: Tue, 12 Feb 2008 20:37:09 -0500
Subject: [PATCH] Add a 'use_repoview' option that allows us to toggle repoview generation.


diff --git a/configs/f7-updates-testing.mash b/configs/f7-updates-testing.mash
index 8518278..c77d9c1 100644
--- a/configs/f7-updates-testing.mash
+++ b/configs/f7-updates-testing.mash
@@ -10,6 +10,7 @@ tag = dist-fc7-updates-testing
 inherit = False
 strict_keys = True
 keys = 4F2A6FD2, 1AC70CE6, 30C9ECF8, DB42A60E, 897DA07A
+use_repoview = True
 repoviewurl = http://download.fedoraproject.org/pub/fedora/linux/updates/testing/7/%(arch)s/
 repoviewtitle = "Fedora 7 Updates Testing - %(arch)s"
 arches = i386 x86_64 ppc ppc64
diff --git a/configs/f7-updates.mash b/configs/f7-updates.mash
index 3baeb63..f921839 100644
--- a/configs/f7-updates.mash
+++ b/configs/f7-updates.mash
@@ -10,6 +10,7 @@ tag = dist-fc7-updates
 inherit = False
 strict_keys = True
 keys = 4F2A6FD2, 1AC70CE6, 30C9ECF8, DB42A60E, 897DA07A
+use_repoview = True
 repoviewurl = http://download.fedoraproject.org/pub/fedora/linux/updates/7/%(arch)s/
 repoviewtitle = "Fedora 7 Updates - %(arch)s"
 arches = i386 x86_64 ppc ppc64
diff --git a/configs/f8-updates-testing.mash b/configs/f8-updates-testing.mash
index 049964c..b39bc30 100644
--- a/configs/f8-updates-testing.mash
+++ b/configs/f8-updates-testing.mash
@@ -10,6 +10,7 @@ tag = dist-f8-updates-testing
 inherit = False
 strict_keys = True
 keys = 4F2A6FD2, 1AC70CE6, 30C9ECF8, DB42A60E, 897DA07A
+use_repoview = True
 repoviewurl = http://download.fedoraproject.org/pub/fedora/linux/updates/testing/8/%(arch)s/
 repoviewtitle = "Fedora 8 Updates Testing - %(arch)s"
 arches = i386 x86_64 ppc ppc64
diff --git a/configs/f8-updates.mash b/configs/f8-updates.mash
index 3b4e32c..f4f7534 100644
--- a/configs/f8-updates.mash
+++ b/configs/f8-updates.mash
@@ -10,6 +10,7 @@ tag = dist-f8-updates
 inherit = False
 strict_keys = True
 keys = 4F2A6FD2, 1AC70CE6, 30C9ECF8, DB42A60E, 897DA07A
+use_repoview = True
 repoviewurl = http://download.fedoraproject.org/pub/fedora/linux/updates/8/%(arch)s/
 repoviewtitle = "Fedora 8 Updates - %(arch)s"
 arches = i386 x86_64 ppc ppc64
diff --git a/configs/mash.conf b/configs/mash.conf
index cf1dc96..172683a 100644
--- a/configs/mash.conf
+++ b/configs/mash.conf
@@ -5,3 +5,4 @@ configdir = /etc/mash
 buildhost = http://koji.fedoraproject.org/kojihub
 repodir = file:///mnt/koji
 use_sqlite = True
+use_repoview = False
diff --git a/mash/__init__.py b/mash/__init__.py
index 678ccb4..8b4bf2d 100644
--- a/mash/__init__.py
+++ b/mash/__init__.py
@@ -77,7 +77,7 @@ class Mash:
         self.config = config
         self.session = koji.ClientSession(config.buildhost, {})
 
-    def _makeMetadata(self, path, cachedir, comps = False, repoview = False):
+    def _makeMetadata(self, path, cachedir, arch, comps = False):
         conf = createrepo.MetaDataConfig()
         conf.cachedir = cachedir
         conf.update  = True
@@ -90,17 +90,19 @@ class Mash:
         if self.config.debuginfo_path == os.path.join(self.config.rpm_path, 'debug'):
             conf.excludes.append("debug/*")
         repomatic = createrepo.MetaDataGenerator(conf)
-        repoview_cmd = ["/usr/bin/repoview","-q", "--title", self.config.repoviewtitle % { 'arch':arch }, "-u", self.config.repoviewurl % { 'arch':arch }, path]
         repomatic.doPkgMetadata()
         repomatic.doRepoMetadata()
         repomatic.doFinalMove()
-        if repoview:
+        if self.config.use_repoview:
+            repoview_cmd = ["/usr/bin/repoview","-q", "--title",
+                            self.config.repoviewtitle % { 'arch':arch }, "-u",
+                            self.config.repoviewurl % { 'arch':arch }, path]
             os.execv("/usr/bin/repoview", repoview_cmd)
         else:
             os._exit(0)
 
     def doCompose(self):
-        def _write_files(list, path, repo_path, comps = False, cachedir = None):
+        def _write_files(list, path, repo_path, comps = False, cachedir = None, arch = None):
             
             print "Writing out files for %s..." % (path,)
             os.makedirs(path)
@@ -142,7 +144,7 @@ class Mash:
                         except:
                             shutil.copyfile(result, dst)
                         
-            status = self._makeMetadata(repo_path, cachedir, comps, repoview = False)
+            status = self._makeMetadata(repo_path, cachedir, arch, comps)
 
         def has_any(l1, l2):
             if type(l1) not in (type(()), type([])):
@@ -282,17 +284,19 @@ class Mash:
         for arch in self.config.arches:
             path = os.path.join(outputdir, self.config.rpm_path % { 'arch':arch })
             repo_path = os.path.join(outputdir, self.config.repodata_path % { 'arch':arch })
-            pid = _write_files(packages[arch].packages(), path, repo_path, cachedir = cachedir, comps = True)
+            pid = _write_files(packages[arch].packages(), path, repo_path,
+                               cachedir = cachedir, comps = True, arch = arch)
             pids.append(pid)
             
             if self.config.debuginfo:
                 path = os.path.join(outputdir, self.config.debuginfo_path % { 'arch': arch })
-                pid = _write_files(debug[arch].packages(), path, path, cachedir = cachedir)
+                pid = _write_files(debug[arch].packages(), path, path,
+                                   cachedir = cachedir, arch = arch)
                 pids.append(pid)
                 
             
         path = os.path.join(outputdir, self.config.source_path)
-        pid = _write_files(source.packages(), path, path, cachedir = cachedir)
+        pid = _write_files(source.packages(), path, path, cachedir = cachedir, arch = 'SRPMS')
         pids.append(pid)
         
         print "Waiting for createrepo to finish..."
@@ -419,7 +423,7 @@ enabled=1
             
             shutil.rmtree(tmproot, ignore_errors = True)
             print "Running createrepo on %s..." %(repodir),
-            self._makeMetadata(repodir, cachedir, comps = True, repoview = False)
+            self._makeMetadata(repodir, cachedir, arch, comps = True)
 
         shutil.rmtree(tmproot, ignore_errors = True)
         os._exit(0)
diff --git a/mash/config.py b/mash/config.py
index 003183e..abe6066 100644
--- a/mash/config.py
+++ b/mash/config.py
@@ -37,6 +37,7 @@ class MashConfig(config.BaseConfig):
     repodir = config.Option('/mnt/koji')
     compsfile = config.Option()
     use_sqlite = config.BoolOption(True)
+    use_repoview = config.BoolOption(False)
     repoviewurl = config.Option('http://localhost/%(arch)s')
     repoviewtitle = config.Option('"Mash - %(arch)s"')
     distros = []
@@ -61,6 +62,7 @@ class MashDistroConfig(config.BaseConfig):
     workdir = config.Inherit(MashConfig.workdir)
     compsfile = config.Inherit(MashConfig.compsfile)
     use_sqlite = config.Inherit(MashConfig.use_sqlite)
+    use_repoview = config.BoolOption(False)
     repoviewurl = config.Inherit(MashConfig.repoviewurl)
     repoviewtitle = config.Inherit(MashConfig.repoviewtitle)
 
-- 
1.5.4

