Patches for shared configurations items and specifying additional dependencies

Andreas Thienemann andreas at bawue.net
Wed May 10 20:26:42 UTC 2006


Hello List,

as it seems to be patch submission time, I'm pushing two patches to the 
list, I had lying around for some time now.

The first patch allows mock to parse a generic side-wide config file, 
where general configuration-items can be stored and later overridden by 
specific chroot-definitions.


The second patch, is a bit different:
While pushing the Fedora Core SRPMS through the mock buildsystem we 
noticed many SRPMS which do not correctly define their buildrequirements. 
Until the fedora core developer responsible for the package has updated 
the spec in cvs and pushed an updated srpm into rawhide, there is no way 
to make the package in question build in mock without having to change the 
.spec.
Thus, in order to allow even these broken packages being built, we needed 
a way to work around these broken dependencies to see if anything else was 
missing.
This is done by the second patch, which adds a more_buildreqs config 
option. If set the given dependencies are installed _in addition_ to the 
ones from the .spec file.

While the second patch should not be used during normal use and is 
definetly not for the fedora-extras buildservers, it still is of interest 
to other parties, using mock.



regards,
 andreas
-------------- next part --------------
Provide generic config defaults.

  * Support a generic /etc/mock/defaults.cfg config file. The values
    defined in this file are overwritten by any definitions in the
    specific /etc/mock/CHROOT.cfg files.

    This part just introduces mock-0.4/etc/defaults.cfg and
    adds the last chunk in the patch to mock-0.4/mock.py.


 This patch was written in 2006 for bawue.net by Hans Ulrich Niedermann in
 2006 after an idea by Andreas Thienemann. Testing and final clean-up was 
 one by Andreas Thienemann.

 The source code this patch is based on has been downloaded from

    http://fedoraproject.org/projects/mock/releases/mock-0.4.tar.gz


diff -Nurp mock-0.4.orig/etc/defaults.cfg mock-0.4.bawue/etc/defaults.cfg
--- mock-0.4.orig/etc/defaults.cfg	1970-01-01 01:00:00.000000000 +0100
+++ mock-0.4.bawue/etc/defaults.cfg	2006-04-05 21:59:22.000000000 +0200
@@ -0,0 +1,8 @@
+# mock defaults
+#
+# Define default values here.
+# These values are overwritten in the /etc/mock/CHROOT.cfg files.
+#
+# Example:
+#
+# config_opts['foo'] = bar
diff -Nurp mock-0.4.orig/mock.py mock-0.4.bawue/mock.py
--- mock-0.4.orig/mock.py	2005-07-26 22:33:52.000000000 +0200
+++ mock-0.4.bawue/mock.py	2006-04-06 06:59:51.000000000 +0200
@@ -683,6 +701,14 @@ def main():
     if len(args) < 1:
         error("No srpm or command specified - nothing to do")
         sys.exit(50)
+
+    # Read in the default values which can be overwritten
+    # with the more specific config being loaded below.
+    cfg = os.path.join(config_path, 'defaults.cfg')
+    if os.path.exists(cfg):
+        execfile(cfg)
+    else:
+        pass # not finding the defaults.cfg file is no error
     
     # read in the config file by chroot name
     if options.chroot.endswith('.cfg'):
-------------- next part --------------
Provide extra build requirements for packages.

  * Introduce a new config variable 'more_buildreqs' which allows
    defining additional build dependencies for specific packages.
    This is useful for buggy SRPMs or SRPMs which compile some
    parts conditionally, depending on the software installed.

    This mechanism should not be used in normal operation.

 The extra build requirements can be configured like in the following
 example, in which we use the example of a fictitional SRPM file
 called 'ser-0.9.6-3'.

    # matches only the 'ser-0.9.6-3' package
    config_opts['more_buildreqs']['ser-0.9.6-3'] = [ 'smtp-devel >= 1.2', 
        'mysql-devel >= 5.0', 'png-devel < 0.1', 'tcsh' ]

    # matches all 'ser-0.9.6-*' packages
    config_opts['more_buildreqs']['ser-0.9.6'] = [ 'smtp-devel >= 1.2', 
        'mysql-devel >= 5.0', 'png-devel < 0.1', 'tcsh' ]

    # matches all 'ser-*-*' packages
    config_opts['more_buildreqs']['ser'] = [ 'smtp-devel >= 1.2', 
        'mysql-devel >= 5.0', 'png-devel < 0.1', 'tcsh' ]

 The most specific match is used, i.e. if requirements for
 'ser-0.9.6-3' are defined, the definitions for 'ser-0.9.6' and 'ser'
 are ignored. Each time, /etc/mock/CHROOT.cfg is checked first, and
 only if there is no dependency definition here, the definition from
 /etc/mock/defaults.cfg is checked.

 This patch was written in 2006 for bawue.net by Hans Ulrich Niedermann in
 2006 after an idea by Andreas Thienemann. Testing and final clean-up was
 done by Andreas Thienemann.

 The source code this patch is based on has been downloaded from

    http://fedoraproject.org/projects/mock/releases/mock-0.4.tar.gz


diff -Nurp mock-0.4.orig/mock.py mock-0.4.bawue/mock.py
--- mock-0.4.orig/mock.py	2005-07-26 22:33:52.000000000 +0200
+++ mock-0.4.bawue/mock.py	2006-04-06 06:59:51.000000000 +0200
@@ -278,7 +278,7 @@ class Root:
         hdr = rpmUtils.miscutils.hdrFromPackage(ts, srpm)
         
         # get text buildreqs
-        buildreqs = self._text_requires_from_hdr(hdr)
+        buildreqs = self._text_requires_from_hdr(hdr, srpm)
         arg_string = ""
         for item in buildreqs:
             
@@ -469,7 +469,7 @@ class Root:
         
         return (ret, output)
 
-    def _text_requires_from_hdr(self, hdr):
+    def _text_requires_from_hdr(self, hdr, srpm):
         """take a header and hand back a unique'd list of the requires as
            strings"""
            
@@ -487,6 +487,23 @@ class Root:
             req = rpmUtils.miscutils.formatRequire(n, v, f)
             reqlist.append(req)
         
+        # Extract SRPM name components - still not nice, shouldn't this
+        # be somewhere in the "hdr" parameter?
+        fname = os.path.split(str(srpm))[1]
+        name, ver, rel, epoch, arch = rpmUtils.miscutils.splitFilename(fname)
+
+        # Add the 'more_buildreqs' for this SRPM (if defined)
+        for this_srpm in ['-'.join([name,ver,rel]),
+                          '-'.join([name,ver]),
+                          '-'.join([name]),]:
+            if self.config['more_buildreqs'].has_key(this_srpm):
+                more_reqs = self.config['more_buildreqs'][this_srpm]
+                if type(more_reqs) in (type(u''), type(''),):
+                    more_reqs = [more_reqs] # be nice if we get a string
+                for req in more_reqs:
+                    reqlist.append(req)
+                break
+        
         return rpmUtils.miscutils.unique(reqlist)
     
     def _prep_install(self):
@@ -674,6 +691,7 @@ def main():
     
 """ % config_opts['chroothome']
     
+    config_opts['more_buildreqs'] = {}
     config_opts['files']['/etc/resolv.conf'] = "nameserver 192.168.1.1\n"
     config_opts['files']['/etc/hosts'] = "127.0.0.1 localhost localhost.localdomain\n"
     


More information about the Fedora-buildsys-list mailing list