summaryrefslogtreecommitdiffstats
path: root/rpmci/rpmci_binrpm_builder_main.py
diff options
context:
space:
mode:
Diffstat (limited to 'rpmci/rpmci_binrpm_builder_main.py')
-rw-r--r--rpmci/rpmci_binrpm_builder_main.py92
1 files changed, 58 insertions, 34 deletions
diff --git a/rpmci/rpmci_binrpm_builder_main.py b/rpmci/rpmci_binrpm_builder_main.py
index d8dd02b..86ddf5d 100644
--- a/rpmci/rpmci_binrpm_builder_main.py
+++ b/rpmci/rpmci_binrpm_builder_main.py
@@ -57,49 +57,73 @@ class BinRPMBuilder(object):
return target
return None
+ def _srpm_for_target(self, repo, target):
+ for rpm in repo.iter_rpms():
+ basename = os.path.basename(rpm):
+ srpm_name = rpmutils.get_rpm_name(basename)
+ if srpm_name == target.module:
+ return rpm
+ return None
+
+ def _mock_root_from_os_arch(self, os, architecture):
+ fedora_os_master = config.get('fedora', 'master')
+ if buildtarget.os == fedora_os_master:
+ os = 'devel':
+ else:
+ os = buildtarget.os
+ if target.architecture == 'i686':
+ arch = 'i386'
+ else:
+ arch = target.architecture
+ return '%s-%s' % (os, arch)
+
def _on_srpm_message(self, q, messages):
msg_list = list(messages)
num_msgs = len(msg_list)
logging.debug("Starting processing of %d messages" % (num_msgs, ))
+ latest_repoversion = -1
for msg in msg_list:
- srpm_name = msg.payload['srpm']
- logging.debug("Processing update for SRPM %r" % (srpm_name, ))
- target = self._target_for_srpm(srpm_name)
- if target is None:
- logging.warn("Skipping unknown srpm %r" % (srpm_name, ))
- continue
- affected_artifacts = []
- for artifact in self._artifactset.artifacts:
- if target in artifact.targets:
- affected_artifacts.append(artifact)
-
- self._handle_srpm_message_name(q, srpm_name)
+ repoversion = msg.payload['version']
+ if repoversion > latest_repoversion:
+ latest_repoversion = repoversion
+ logging.debug("Processing update to repository version %r" % (repoversion, ))
q.consume(msg)
+
+ self._rebuild_to_repoversion(repoversion)
logging.debug("Processed %d messages successfully" % (num_msgs, ))
- def _handle_srpm_message_name(self, q, srpm_name):
+ def _rebuild_to_repoversion(self, repoversion):
exec_basedir = os.path.dirname(sys.argv[0])
-
- subtask.spawn_sync('mock-many-srpms' % (target.module, ),
- args, cwd=fedora_dir)
-
- args = ['rpmbuild']
- args.extend(self._get_base_rpmbuild_args(fedora_dir))
- args.extend(['-bs', specname])
- subtask.spawn_sync('rpmbuild-srpm-%s' % (target.module, ),
- args, cwd=fedora_dir)
- srpm_path = None
- srpm_basename = None
- for filename in os.listdir(fedora_dir):
- if filename.endswith('.src.rpm'):
- srpm_basename = filename
- srpm_path = os.path.join(fedora_dir, filename)
- break
- assert srpm_path is not None
- os.rename(srpm_path, os.path.join(self._srcdir, srpm_basename))
- self._srcrepo.update_repo_sync()
-
- self._srpm_msgqueue.append(msgqueue.Message(None, {'type': 'srpm'}, {'filename': srpm_basename}))
+
+ for artifact in self._artifactset.artifacts:
+ artifact_srpms = set()
+ failed = False
+ for target in artifact.targets:
+ srpm = self._srpm_for_target(target)
+ if srpm is None:
+ logger.warn("Couldn't find srpm for target %r of artifact %r" % (target.module, artifact.name))
+ failed = True
+ break
+ artifact_srpms.add(srpm)
+ if failed:
+ continue
+ taskid = 'mock-many-srpms-%s' % (artifact.name, )
+
+ arch_roots = []
+ for arch in artifact.architectures:
+ arch_roots.append(self._mock_root_from_os_arch(artifact.os, arch))
+ base_artifactdir = self._config.get('build', 'artifactdir')
+ artifactdir = os.path.join(base_artifactdir, artifact.name)
+ base_logdir = self._config.get('build', 'logdir')
+ logdir = os.path.join(base_logdir, artifact.name)
+
+ args = [os.path.join(exec_basedir, 'mock-many-srpms'),
+ '--skip-have-build',
+ '--resultdir=' + resultdir,
+ '--logdir=' + logdir]
+ for root in arch_roots:
+ args.append('--root=' + root)
+ subtask.spawn_sync(taskid, args)
def main():
glib.threads_init()