Implement --noaggregate command line and config option
authorEd Bartosh <eduard.bartosh@intel.com>
Tue, 17 Jun 2014 20:22:28 +0000 (23:22 +0300)
committerEd Bartosh <eduard.bartosh@intel.com>
Tue, 17 Jun 2014 20:56:12 +0000 (23:56 +0300)
After adding arm targets to Tizen:IVI and Tizen:Common it
became impossible for repa to create groups as every submission
contains mic-bootstrap and qemu aggregated packages. Repa doesn't
allow to group submissions if they contain the same packages.

This is quite ugly solution. repa group should be refactored
to allow proper implementation.

With this line in config:
   noaggregate = mic-bootstrap-x86-arm.rpm|mic-bootstrap.rpm|\
                 mic-bootstrap-debugsource.rpm|qemu-accel-armv7l.rpm|\
                 qemu-accel-armv7l-cross-arm.rpm|qemu-linux-user-cross-arm.rpm
it should be possible to create groups again.

Fixes: #1990
Change-Id: I4d13a95e6947634df87eead2821efbd943d85822
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
repa.1
repa/group.py

diff --git a/repa.1 b/repa.1
index dadeb4b926ebf5960316cd5d869e6cb7070f6ab1..6a14762c6cddfa7818b487d417483cf46c128a8a 100644 (file)
--- a/repa.1
+++ b/repa.1
@@ -285,6 +285,12 @@ Add  comment to created submit group. It will be shown by list command.
 Force group creation for submissions without binary packages. Useful when grouping failed submissions for rejection.
 .RE
 
+.PP
+\--noaggregate <regexp>
+.RS 2
+Do not aggregate binary packages matching regexp. This is useful to skip aggregates, propagated by OBS from target project to prerlease projects, e.g. qemu-accel-*, mic-bootstrap, etc.
+.RE
+
 .\"
 .\" The "rmgroup" command description
 .\"
@@ -389,6 +395,9 @@ showurls = off
 .RS 2
 ignore = arm-.*/armv7./.*_aggregate$
 .RE
+.RS 2
+noaggregate = mic-bootstrap-x86-arm.rpm|mic-bootstrap.rpm|mic-bootstrap-debugsource.rpm|qemu-accel-armv7l.rpm|qemu-accel-armv7l-cross-arm.rpm|qemu-linux-user-cross-arm.rpm
+.RE
 
 
 .RS 2
@@ -396,7 +405,7 @@ Mandatory options: apiurl, apiuser, apipasswd and project
 .RE
 
 .RS 2
-Some options (project, processes, colorize, showurls, ignore) can be overridden by commandline options (--project, --processes, --colorize, --showurls, --ignore)
+Some options (project, processes, colorize, showurls, ignore, noaggregate) can be overridden by commandline options (--project, --processes, --colorize, --showurls, --ignore, --noaggregate)
 .RE
 
 .SH BUGS
index 49c86191c198099c269dfba8c579e487c8cf0c8f..4a9c2e99d865c356a8392e259968927910b67e46 100755 (executable)
@@ -32,6 +32,7 @@ Group submissions.
 import sys
 import time
 import json
+import re
 
 from collections import defaultdict
 from StringIO import StringIO
@@ -66,7 +67,7 @@ def check_build_results(bresults):
             # target project: for pkg, status in res['packages'] ...
 
 
-def check_binary_pkgs(obs, submissions, force=False):
+def check_binary_pkgs(obs, submissions, force=False, noaggregate=''):
     """
     Check if submissions have common binary packages.
     Check if binary packages exist.
@@ -82,6 +83,9 @@ def check_binary_pkgs(obs, submissions, force=False):
             for subm, info in binaries.iteritems():
                 if repo in info:
                     common = set(info[repo]).intersection(bins)
+                    if common and noaggregate:
+                        common = set(pkg for pkg in common \
+                                      if not re.match(noaggregate, pkg))
                     if common:
                         print '%s and %s have %d common packages,' \
                               ' skipping %s' % (subm, submission,
@@ -91,7 +95,6 @@ def check_binary_pkgs(obs, submissions, force=False):
                         break
             else:
                 binaries[submission][repo] = bins
-
     return result
 
 
@@ -149,7 +152,7 @@ def aggregate(obs, bresults, gproject, processes):
 
 
 def group_submissions(obs, submissions, target, comment,
-                      force=False, processes=0):
+                      force=False, processes=0, noaggregate=''):
     """Group multiple submissions into one group."""
     # find correspondent prerelease projects
     info = {}
@@ -167,7 +170,7 @@ def group_submissions(obs, submissions, target, comment,
     check_build_results(bresults)
 
     # filter out conflicting submissions
-    filtered = check_binary_pkgs(obs, info, force)
+    filtered = check_binary_pkgs(obs, info, force, noaggregate)
     bresults = [item for item in bresults if item[0] in filtered]
     info = dict(item for item in info.iteritems() if item[0] in filtered)
 
@@ -200,13 +203,16 @@ class Group(object):
         parser.add_argument('-c', '--comment', help='comment', default='')
         parser.add_argument('-f', '--force', action='store_true',
                             help='force group creation')
+        parser.add_argument('--noaggregate', default=config.get('noaggregate', ''),
+                            help='do not aggregate packages matching regexp')
 
     @staticmethod
     def run(argv):
         """Command line entry point. Called from [sub_]main."""
         obs = OBS(argv.apiurl, argv.apiuser, argv.apipasswd)
         return group_submissions(obs, argv.submission, argv.project,
-                                 argv.comment, argv.force, argv.processes)
+                                 argv.comment, argv.force, argv.processes,
+                                 argv.noaggregate)
 
 
 if __name__ == '__main__':