Patch for alicia: better handling source + binary overrides
Hi,
Please find below (or in spohr:~jeroen/katie/alicia{,.diff,.changelog})
a reasonable smallish patch for alicia, to get her to work properly with
binary vs source overrides, instead of bailing out if an override exists
for both (could happen in the past, happens much more now that cindy
will add missing source overrides). Without this patch, override
handling is harder to do, natalie isn't very convenient, in usage nor in
logging.
It'd even better to have a tool that can more easily manipulate for
example a whole source package, and/or one that will apply heuristics
for sections & priorty, and guard for violating rules like "Depends: can
only happen to packages of same or higher priority", but that's
something for the longer term -- not even debcheck[1] of the QA team
implements all those rules correctly, and it's around for a long time
already.
Thanks,
--Jeroen
[1] http://qa.debian.org/debcheck.php
2005-11-27 Jeroen van Wolffelaar <jeroen@wolffelaar.nl>
* alicia: add -S switch so that she works for the separated source and
binary overrides. Fix logging typo.
Index: alicia
===================================================================
RCS file: /cvs/dak/dak/alicia,v
retrieving revision 1.6
diff -u -r1.6 alicia
--- alicia 27 Nov 2004 17:58:13 -0000 1.6
+++ alicia 21 Dec 2005 01:05:26 -0000
@@ -46,12 +46,14 @@
def usage (exit_code=0):
- print """Usage: alicia [OPTIONS] package [section] [priority]
+ print """Usage: alicia [OPTIONS] binpackage [section] [priority]
+ || alicia [OPTIONS] -S srcpackage [section]
Make microchanges or microqueries of the overrides
-h, --help show this help and exit
-d, --done=BUG# send priority/section change as closure to bug#
-n, --no-action don't do anything
+ -S, --source act on source package rather than binary package
-s, --suite specify the suite to use
"""
sys.exit(exit_code)
@@ -65,8 +67,9 @@
('d',"done","Alicia::Options::Done", "HasArg"),
('n',"no-action","Alicia::Options::No-Action"),
('s',"suite","Alicia::Options::Suite", "HasArg"),
+ ('S',"source","Alicia::Options::Source"),
];
- for i in ["help", "no-action"]:
+ for i in ["help", "no-action", "source"]:
if not Cnf.has_key("Alicia::Options::%s" % (i)):
Cnf["Alicia::Options::%s" % (i)] = "";
if not Cnf.has_key("Alicia::Options::Suite"):
@@ -84,6 +87,9 @@
if not arguments:
utils.fubar("package name is a required argument.");
+ typestr = 'binary'
+ if Options["Source"]: typestr = 'source'
+
package = arguments.pop(0);
suite = Options["Suite"]
if arguments and len(arguments) > 2:
@@ -105,6 +111,10 @@
utils.fubar("%s is not a valid section or priority" % (arg));
+ eqifsource = "!="
+ if Options["Source"]:
+ eqifsource = "="
+
# Retrieve current section/priority...
q = projectB.query("""
SELECT priority.priority AS prio, section.section AS sect
@@ -114,25 +124,34 @@
AND override.package = %s
AND override.suite = suite.id
AND suite.suite_name = %s
- """ % (pg._quote(package,"str"), pg._quote(suite,"str")));
+ AND priority.priority %s 'source'
+ """ % (pg._quote(package,"str"), pg._quote(suite,"str"), eqifsource));
if q.ntuples() == 0:
- utils.fubar("Unable to find package %s" % (package));
+ utils.fubar("Unable to find %s package %s" % (typestr, package));
if q.ntuples() > 1:
- utils.fubar("%s is ambiguous. Matches %d packages" % (package,q.ntuples()));
+ utils.fubar(("%s is ambiguous (%d). Package possibly "+\
+ "moving among components") % (package,q.ntuples()));
r = q.getresult();
oldsection = r[0][1];
oldpriority = r[0][0];
if not arguments:
- print "%s is in section '%s' at priority '%s'" % (
- package,oldsection,oldpriority);
+ if Options["Source"]:
+ print "Source %s is in section '%s'" % (
+ package,oldsection);
+ else:
+ print "Binary %s is in section '%s' at priority '%s'" % (
+ package,oldsection,oldpriority);
sys.exit(0);
# At this point, we have a new section and priority... check they're valid...
newsection, newpriority = arguments;
+ if Options["Source"] and newpriority != ".":
+ utils.fubar("Source packages have no priority, that's inferred")
+
if newsection == ".":
newsection = oldsection;
if newpriority == ".":
@@ -189,9 +208,11 @@
UPDATE override
SET priority=%d
WHERE package=%s
+ AND priority %s (SELECT id FROM priority WHERE priority='source')
AND suite = (SELECT id FROM suite WHERE suite_name=%s)""" % (
newprioid,
pg._quote(package,"str"),
+ eqifsource,
pg._quote(suite,"str") ));
Logger.log(["changed priority",package,oldpriority,newpriority]);
@@ -200,11 +221,13 @@
UPDATE override
SET section=%d
WHERE package=%s
+ AND priority %s (SELECT id FROM priority WHERE priority='source')
AND suite = (SELECT id FROM suite WHERE suite_name=%s)""" % (
newsecid,
pg._quote(package,"str"),
+ eqifsource,
pg._quote(suite,"str") ));
- Logger.log(["changed priority",package,oldsection,newsection]);
+ Logger.log(["changed section",typestr,package,oldsection,newsection]);
projectB.query("COMMIT WORK");
if Options.has_key("Done"):
@@ -225,7 +248,7 @@
Subst["__DISTRO__"] = Cnf["Dinstall::MyDistribution"];
Subst["__WHOAMI__"] = utils.whoami();
- summary = "Concerning package %s...\n" % (package);
+ summary = "Concerning %s package %s...\n" % (typestr, package);
summary += "Operating on the %s suite\n" % (suite);
if newpriority != oldpriority:
summary += "Changed priority from %s to %s\n" % (oldpriority,newpriority);
--
Jeroen van Wolffelaar
jeroen@wolffelaar.nl
http://jeroen.A-Eskwadraat.nl
Reply to: