createrepo run after mock

Seth Vidal skvidal at fedoraproject.org
Wed Feb 10 01:56:02 UTC 2010


This is a patch to run createrepo on the contents of the resultdir after a 
successful mock run. In theory this lets us suck those contents over for 
koji to have available.

-sv
-------------- next part --------------
commit 1915fd7199dded59860c5d79af4d52efbed6ab0f
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Tue Feb 9 20:52:15 2010 -0500

    createrepo_on_rpms
    
    add an option to have createrepo run on the rpms in the resultdir for a successful build.

diff --git a/etc/mock/site-defaults.cfg b/etc/mock/site-defaults.cfg
index 0ee2082..6da9290 100644
--- a/etc/mock/site-defaults.cfg
+++ b/etc/mock/site-defaults.cfg
@@ -45,6 +45,10 @@
 # config_opts['cleanup_on_success'] = 1
 # config_opts['cleanup_on_failure'] = 1
 
+# if you want mock to automatically run createrepo on the rpms in your 
+# resultdir.
+# config_opts['createrepo_on_rpms'] = True
+
 #############################################################################
 #
 # plugin related. Below are the defaults. Change to suit your site
diff --git a/mock.spec.in b/mock.spec.in
index 8b91b40..fe739fe 100644
--- a/mock.spec.in
+++ b/mock.spec.in
@@ -19,6 +19,7 @@ URL: http://fedoraproject.org/wiki/Projects/Mock
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildArch: noarch
 Requires: python >= 2.4, yum >= 2.4, tar, gzip, python-ctypes, python-decoratortools, usermode
+Requires: createrepo
 Requires(pre): shadow-utils
 BuildRequires: python-devel
 
diff --git a/py/mock.py b/py/mock.py
index f4794ac..eea493c 100755
--- a/py/mock.py
+++ b/py/mock.py
@@ -227,6 +227,7 @@ def setup_default_config_opts(config_opts, unprivUid):
     config_opts['cleanup_on_success'] = 1
     config_opts['cleanup_on_failure'] = 1
 
+    config_opts['createrepo_on_rpms'] = True
     # (global) plugins and plugin configs.
     # ordering constraings: tmpfs must be first.
     #    root_cache next.
@@ -378,6 +379,12 @@ def do_rebuild(config_opts, chroot, srpms):
         if config_opts["cleanup_on_success"]:
             log.info("Cleaning up build root ('clean_on_success=True')")
             chroot.clean()
+            
+        if config_opts["createrepo_on_rpms"]:
+            log.info("Running createrepo on binary rpms in resultdir")
+            cmd = ['/usr/bin/createrepo', '-d', '-q', '-x', '*.src.rpm', chroot.resultdir]
+            mock.util.do(cmd)
+            
     except (Exception, KeyboardInterrupt):
         elapsed = time.time() - start
         log.error("Exception(%s) Config(%s) %d minutes %d seconds"


More information about the buildsys mailing list