From: Anthony Towns Date: Mon, 18 Jun 2007 18:43:34 +0000 (+0100) Subject: * dak/override.py: More changes from Herr von Wifflepuck: warn X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1bf7e9753265747cb648a39899ff7def4768a8bc;p=dak * dak/override.py: More changes from Herr von Wifflepuck: warn if section of source is different to binary section; restore functionality on source-only overrides; croak if trying to set priority of a source override; never set priority of source overrides; correct typo in logging (s/priority/section/ at one place) --- diff --git a/ChangeLog b/ChangeLog index aefe1566..08b8389c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,12 @@ * daklib/logging.py: Set umask to not exclude group-writability so we don't get reminded at the start of each month. Thanks to Random J. + * dak/override.py: More changes from Herr von Wifflepuck: warn + if section of source is different to binary section; restore + functionality on source-only overrides; croak if trying to set + priority of a source override; never set priority of source + overrides; correct typo in logging (s/priority/section/ at + one place) 2007-06-18 Anthony Towns diff --git a/dak/override.py b/dak/override.py index 9b4b3f6d..50cf8068 100755 --- a/dak/override.py +++ b/dak/override.py @@ -106,31 +106,51 @@ def main (): daklib.utils.fubar("%s is not a valid section or priority" % (arg)) # Retrieve current section/priority... - # TODO: fetch dsc records and update them too, if needed. - q = projectB.query(""" + oldsection, oldsourcesection, oldpriority = None, None, None + for type in ['source', 'binary']: + eqdsc = '!=' + if type == 'source': + eqdsc = '=' + q = projectB.query(""" SELECT priority.priority AS prio, section.section AS sect, override_type.type AS type FROM override, priority, section, suite, override_type WHERE override.priority = priority.id AND override.type = override_type.id - AND override_type.type != 'dsc' + AND override_type.type %s 'dsc' AND override.section = section.id AND override.package = %s AND override.suite = suite.id AND suite.suite_name = %s - """ % (pg._quote(package,"str"), pg._quote(suite,"str"))) + """ % (eqdsc, pg._quote(package,"str"), pg._quote(suite,"str"))) - if q.ntuples() == 0: - daklib.utils.fubar("Unable to find package %s" % (package)) - if q.ntuples() > 1: - daklib.utils.fubar("%s is ambiguous. Matches %d packages" % (package,q.ntuples())) + if q.ntuples() == 0: + continue + if q.ntuples() > 1: + daklib.utils.fubar("%s is ambiguous. Matches %d packages" % (package,q.ntuples())) - r = q.getresult() - oldsection = r[0][1] - oldpriority = r[0][0] + r = q.getresult() + if type == 'binary': + oldsection = r[0][1] + oldpriority = r[0][0] + else: + oldsourcesection = r[0][1] + + if not oldpriority and not oldsourcesection: + daklib.utils.fubar("Unable to find package %s" % (package)) + if oldsection and oldsourcesection and oldsection != oldsourcesection: + # When setting overrides, both source & binary will become the same section + daklib.utils.warn("Source is in section '%s' instead of '%s'" % (oldsourcesection, oldsection)) + if not oldsection: + oldsection = oldsourcesection if not arguments: - print "%s is in section '%s' at priority '%s'" % ( - package,oldsection,oldpriority) + if oldpriority: + print "%s is in section '%s' at priority '%s'" % ( + package,oldsection,oldpriority) + elif oldsourcesection: + # no use printing this line if also binary + print "%s is in section '%s'" % ( + package,oldsourcesection) sys.exit(0) # At this point, we have a new section and priority... check they're valid... @@ -159,6 +179,9 @@ def main (): print "I: Doing nothing" sys.exit(0) + if newpriority and not oldpriority: + daklib.utils.fubar("Trying to set priority of a source-only package") + # If we're in no-action mode if Options["No-Action"]: if newpriority != oldpriority: @@ -192,9 +215,10 @@ def main (): UPDATE override SET priority=%d WHERE package=%s + AND override.type != %d AND suite = (SELECT id FROM suite WHERE suite_name=%s)""" % ( newprioid, - pg._quote(package,"str"), + pg._quote(package,"str"), get_override_type_id("dsc"), pg._quote(suite,"str") )) Logger.log(["changed priority",package,oldpriority,newpriority]) @@ -207,7 +231,7 @@ def main (): newsecid, pg._quote(package,"str"), pg._quote(suite,"str") )) - Logger.log(["changed priority",package,oldsection,newsection]) + Logger.log(["changed section",package,oldsection,newsection]) projectB.query("COMMIT WORK") if Options.has_key("Done"):