/usr/share/pyshared/dput/hooks/lintian.py is in python-dput 1.7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | # -*- coding: utf-8 -*-
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
# Copyright (c) 2012 dput authors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
"""
Lintian checker implementation
"""
import subprocess
from dput.core import logger
from dput.exceptions import HookException, DputConfigurationError
from dput.interface import BUTTON_NO
class LintianHookException(HookException):
pass
def process(output):
ret = []
for line in output.splitlines():
flag, line = line.split(":", 1)
flag = flag.strip()
if flag == "N":
continue
line = line.strip()
component, line = line.split(":", 1)
component = component.strip()
line = line.strip()
payload = line.split(" ", 1)
if len(payload) > 1:
tag, info = payload
else:
tag = payload[0]
info = ""
tag = tag.strip()
info = info.strip()
ret.append({
"severity": flag,
"component": component,
"tag": tag,
"info": info
})
return ret
def lint(path, pedantic=False, info=False, experimental=False):
args = ["lintian", "--show-overrides"]
if pedantic:
args.append("--pedantic")
if info:
args.append("-I")
if experimental:
args.append("-E")
args.append(path)
try:
output = subprocess.check_output(args)
except subprocess.CalledProcessError as e:
output = e.output
except OSError as e:
logger.warning("Failed to execute lintian: %s" % (e))
raise DputConfigurationError("lintian: %s" % (e))
return process(output)
def lintian(changes, profile, interface):
"""
The ``lintian`` checker is a stock dput checker that checks packages
intended for upload for common mistakes, using the static checking
tool, `lintian <http://lintian.debian.org/>`.
Profile key: ``lintian``
Example profile::
{
"run_lintian": true
"lintian": {
}
}
No keys are current supported, but there are plans to set custom
ignore lists, etc.
"""
if "run_lintian" in profile:
logger.warning("Setting 'run_lintian' is deprecated. "
"Please configure the lintian checker instead.")
if not profile['run_lintian']: # XXX: Broken. Fixme.
logger.info("skipping lintian checking, enable with "
"run_lintian = 1 in your dput.cf")
return
tags = lint(
changes._absfile,
pedantic=True,
info=True,
experimental=True
)
sorted_tags = {}
for tag in tags:
if not tag['severity'] in sorted_tags:
sorted_tags[tag['severity']] = {}
if tag['tag'] not in sorted_tags[tag['severity']]:
sorted_tags[tag['severity']][tag['tag']] = tag
tags = sorted_tags
# XXX: Make this configurable
if not "E" in tags:
return
for tag in set(tags["E"]):
print " - %s: %s" % (tags["E"][tag]['severity'], tag)
inp = interface.boolean('Lintian Checker',
'Upload despite of Lintian finding issues?',
default=BUTTON_NO)
if not inp:
raise LintianHookException(
"User didn't own up to the "
"Lintian issues"
)
else:
logger.warning("Uploading with outstanding Lintian issues.")
|