3 """ Utility functions for lintian checks in dak
5 @contact: Debian FTPMaster <ftpmaster@debian.org>
6 @copyright: 2009, 2010 Joerg Jaspert <joerg@debian.org>
7 @copyright: 2009 Chris Lamb <lamby@debian.org>
8 @license: GNU General Public License version 2 or later
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 ################################################################################
27 # <mhy> I often wonder if we should use NSA bot or something instead and get dinstall
28 # to send emails telling us about its progress :-)
29 # <mhy> dinstall: I'm processing openoffice
30 # <mhy> dinstall: I'm choking, please help me
31 # <Ganneff> yeah. get floods in here, for 600 accepted packages.
33 # <Ganneff> im not sure the other opers will like it if i oper up the bot, just so it
35 # <mhy> flood all debian related channels
36 # <mhy> just to be safe
37 # <Ganneff> /msg #debian-* dinstall: starting
38 # <Ganneff> more interesting would be the first message in #debian, the next in
39 # #d-devel, then #d-qa
40 # <Ganneff> and expect people to monitor all.
41 # <Ganneff> i bet we have enough debian channels to at least put the timestamps in
42 # seperate channels each
43 # <Ganneff> and if not - we can make it go multi-network
44 # <Ganneff> first oftc, then opn, then ircnet, then - we will find some. quakenet anyone?
45 # <mhy> I should know better than to give you ideas
47 ################################################################################
49 from regexes import re_parse_lintian
51 def parse_lintian_output(output):
53 Parses Lintian output and returns a generator with the data.
55 >>> list(parse_lintian_output('W: pkgname: some-tag path/to/file'))
56 [('W', 'pkgname', 'some-tag', 'path/to/file')]
59 @param output: The output from lintian
62 for line in output.split('\n'):
63 m = re_parse_lintian.match(line)
67 def generate_reject_messages(parsed_tags, tag_definitions, log=lambda *args: args):
69 Generates package reject messages by comparing parsed lintian output with
70 tag definitions. Returns a generator containing the reject messages.
72 @param parsed_tags: Parsed lintian tags as returned by L{parse_lintian_output}
74 @param tag_definitions: YAML.load lintian tag definitions to reject on
76 @return: Reject message(s), if any
80 for values in tag_definitions.values():
81 for tag_name in values:
84 for tag in parsed_tags:
87 if tag_name not in tags:
91 if tag['level'] == 'O':
93 if tag_name in tag_definitions['nonfatal']:
94 # Overriding this tag is allowed.
97 elif tag_name in tag_definitions['fatal']:
98 # Overriding this tag is NOT allowed.
100 log('ftpmaster does not allow tag to be overridable', tag_name)
101 yield "%(package)s: Overriden tag %(tag)s found, but this " \
102 "tag may not be overridden." % tag
105 # Tag is known and not overridden; reject
106 yield "%(package)s: lintian output: '%(tag)s %(description)s', " \
107 "automatically rejected package." % tag
109 # Now tell if they *might* override it.
110 if tag_name in tag_definitions['nonfatal']:
111 log("auto rejecting", "overridable", tag_name)
112 yield "%(package)s: If you have a good reason, you may " \
113 "override this lintian tag." % tag
115 log("auto rejecting", "not overridable", tag_name)