Patches for shared configurations items and specifying additional dependencies

Andreas Thienemann andreas at bawue.net
Sat May 13 21:53:44 UTC 2006


Hi Seth,

On Fri, 12 May 2006, seth vidal wrote:

>  Can you recheck both of these patches against a cvs check out of mock -
> make sure they apply?
Done.
The shared-defaults patch had to be refactored a bit, but they do apply 
now.

Both are attached.

regards,
 andreas

-- 
Bawue.Net               http://www.bawue.net
Demetriusweg 15         Tel: +49 7033-4007956
70563 Stuttgart         Fax: +49 7033-4007955
-------------- 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

 etc/defaults.cfg |    8 ++++++++
 mock.py          |    8 ++++++++
 2 files changed, 16 insertions(+)

diff -uNr mock-20060513.orig/etc/defaults.cfg mock-20060513/etc/defaults.cfg
--- mock-20060513.orig/etc/defaults.cfg	1970-01-01 01:00:00.000000000 +0100
+++ mock-20060513/etc/defaults.cfg	2006-05-13 16:46:19.480038297 +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 -uNr mock-20060513.orig/mock.py mock-20060513/mock.py
--- mock-20060513.orig/mock.py	2006-05-13 16:38:46.487358000 +0200
+++ mock-20060513/mock.py	2006-05-13 16:47:52.874952632 +0200
@@ -735,6 +735,14 @@
     if options.configdir:
         config_path = options.configdir
     
+    # 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'):
         cfg = '%s/%s' % (config_path, options.chroot)
-------------- 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

 mock.py |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

diff -uNr mock-20060513.orig/mock.py mock-20060513/mock.py
--- mock-20060513.orig/mock.py	2006-05-13 16:38:46.487358000 +0200
+++ mock-20060513/mock.py	2006-05-13 23:46:51.789001516 +0200
@@ -289,7 +289,7 @@
         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:
             
@@ -495,7 +495,7 @@
         
         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"""
            
@@ -513,6 +513,23 @@
             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):
@@ -722,6 +739,7 @@
     
 """ % 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