From 9fb4bb811ab61a6afa2d67eb29d4a230338a0907 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 8 Oct 2010 09:27:17 -0400 Subject: srpm: Process repository updates as a group --- rpmci/rpmci_srpm_builder_main.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/rpmci/rpmci_srpm_builder_main.py b/rpmci/rpmci_srpm_builder_main.py index 32cbbd8..47fe0ba 100644 --- a/rpmci/rpmci_srpm_builder_main.py +++ b/rpmci/rpmci_srpm_builder_main.py @@ -94,14 +94,27 @@ class SRPMBuilder(object): msg_list = list(messages) num_msgs = len(msg_list) logging.debug("Starting processing of %d messages" % (num_msgs, )) + updated_vcs_urls = set() for msg in msg_list: url = msg.payload['url'] - logging.debug("Processing update for VCS url %r" % (url, )) - self._handle_vcs_message_url(q, url) + updated_vcs_urls.add(url) q.consume(msg) + + logging.debug("Creating SRPMs for VCS urls: %r" % (updated_vcs_urls, )) + work_dir = tempfile.mkdtemp('.tmp', 'srpm-builder') + updated_srpms = [] + updated_srpm_names = [] + for url in updated_vcs_urls: + srpm = self._create_srpm_for_updated_vcs_url(work_dir, url) + updated_srpms.append(srpm) + updated_srpm_names.append(rpmutils.get_rpm_name(os.path.basename(srpm))) + commitid = self._srcrepo.commit_sync(updated_srpms) + logging.info("New repository revision %d updates SRPMs=%r" % (commitid, updated_srpm_names)) + shutil.rmtree(work_dir) + self._srpm_msgqueue.append(msgqueue.Message(None, {'type': 'srpm'}, {'version': commitid})) logging.debug("Processed %d messages successfully" % (num_msgs, )) - def _handle_vcs_message_url(self, q, url): + def _create_srpm_for_updated_vcs_url(self, work_dir, url): is_fedora = False target = None valid_urls = [] @@ -118,7 +131,6 @@ class SRPMBuilder(object): assert target is not None, ("Couldn't find target for url %r; valid=%r" % (url, valid_urls)) (fedora_vcs, upstream_vcs) = self._target_vcs[target] - work_dir = tempfile.mkdtemp('.tmp', 'srpm-builder') logging.debug("Creating new SRPM for %r in %r" % (target.module, work_dir)) fedora_dir = os.path.join(work_dir, target.module) fedora_vcs.export_directory('HEAD', fedora_dir, sys.stderr) @@ -181,9 +193,7 @@ class SRPMBuilder(object): srpm_path = os.path.join(fedora_dir, filename) break assert srpm_path is not None - self._srcrepo.commit_sync([srpm_path]) - shutil.rmtree(work_dir) - self._srpm_msgqueue.append(msgqueue.Message(None, {'type': 'srpm'}, {'version': srpm_basename})) + return srpm_path def main(): glib.threads_init() -- cgit