Package daklib :: Module lintian
[hide private]
[frames] | no frames]

Source Code for Module daklib.lintian

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