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"