With this patch, mock grows a --chainbuild option (and a Require on createrepo).
The --chainbuild option work by creating a local yum repository in the resultdir path which is used during the BuildRequires installation step. The net result is that, when building more than one srpm in the same run, later builds can find required packages built in previous steps. --- py/mock.py | 11 +++++++++++ py/mock/backend.py | 8 ++++++++ py/mock/util.py | 7 +++++++ 3 files changed, 26 insertions(+), 0 deletions(-) diff --git a/py/mock.py b/py/mock.py index 408b421..a801807 100755 --- a/py/mock.py +++ b/py/mock.py @@ -113,6 +113,11 @@ def command_parse(config_opts): help="chroot name/config file name default: %default", default='default') + parser.add_option("--chainbuild", action="store_true", dest="chainbuild", + help="install all built RPMs in the chroot before continuing" + " with the next one", + default=False) + parser.add_option("--offline", action="store_false", dest="online", default=True, help="activate 'offline' mode.") @@ -216,6 +221,7 @@ def setup_default_config_opts(config_opts, unprivUid): config_opts['build_log_fmt_name'] = "unadorned" config_opts['root_log_fmt_name'] = "detailed" config_opts['state_log_fmt_name'] = "state" + config_opts['chainbuild'] = False config_opts['online'] = True config_opts['internal_dev_setup'] = True @@ -347,6 +353,7 @@ def set_config_opts_per_cmdline(config_opts, options, args): config_opts['cleanup_on_failure'] = False config_opts['online'] = options.online + config_opts['chainbuild'] = options.chainbuild decorate(traceLog()) def do_rebuild(config_opts, chroot, srpms): @@ -366,6 +373,10 @@ def do_rebuild(config_opts, chroot, srpms): log.info("Start(%s) Config(%s)" % (srpm, chroot.sharedRootName)) if config_opts['clean'] and chroot.state() != "clean": chroot.clean() + # if chainbuilding, prepare the local repository + if config_opts['chainbuild']: + mock.util.createRepo( chroot.resultdir ) + chroot.init() chroot.build(srpm, timeout=config_opts['rpmbuild_timeout']) elapsed = time.time() - start diff --git a/py/mock/backend.py b/py/mock/backend.py index 2bc63df..560fb03 100644 --- a/py/mock/backend.py +++ b/py/mock/backend.py @@ -57,6 +57,14 @@ class Root(object): self.chrootgid = config['chrootgid'] self.chrootgroup = 'mockbuild' self.yum_conf_content = config['yum.conf'] + + if config['chainbuild']: + self.yum_conf_content = self.yum_conf_content + '\n'.join([ + '[chainbuild]', + 'name=chainbuild', + 'baseurl=file://%s' % os.path.abspath(self.resultdir) + ]) + self.use_host_resolv = config['use_host_resolv'] self.chroot_file_contents = config['files'] self.chroot_setup_cmd = config['chroot_setup_cmd'] diff --git a/py/mock/util.py b/py/mock/util.py index f52003e..943d4bb 100644 --- a/py/mock/util.py +++ b/py/mock/util.py @@ -262,6 +262,13 @@ def logOutput(fds, logger, returnOutput=1, start=0, timeout=0): logger.debug(tail) return output + +decorate(traceLog()) +def createRepo(path): + cmd = 'createrepo %s' % path + mock.util.do( cmd, shell=True ) + + # logger = # output = [1|0] # chrootPath -- 1.6.0.6 -- Fedora-buildsys-list mailing list Fedora-buildsys-list@redhat.com https://www.redhat.com/mailman/listinfo/fedora-buildsys-list