~ubuntu-branches/ubuntu/saucy/dkms/saucy

« back to all changes in this revision

Viewing changes to .pc/apport_dup_signature.patch/dkms_apport.py

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2013-05-02 15:39:26 UTC
  • Revision ID: package-import@ubuntu.com-20130502153926-qls14qupjppifzas
Tags: 2.2.0.3-1.1ubuntu3
Add apport_dup_signature.patch: Don't use the whole DKMS build log as
duplicate signature, this is way too long. Just use the first actual
compiler error, together with the package name and version. (LP: #1175785)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python3
 
2
#
 
3
#  Dynamic Kernel Module Support (DKMS) <dkms-devel@dell.com>
 
4
#  Copyright (C) 2009 Dell, Inc.
 
5
#  by Mario Limonciello
 
6
#
 
7
#    This program is free software; you can redistribute it and/or modify
 
8
#    it under the terms of the GNU General Public License as published by
 
9
#    the Free Software Foundation; either version 2 of the License, or
 
10
#    (at your option) any later version.
 
11
#
 
12
#    This program is distributed in the hope that it will be useful,
 
13
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
#    GNU General Public License for more details.
 
16
#
 
17
#    You should have received a copy of the GNU General Public License
 
18
#    along with this program; if not, write to the Free Software
 
19
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
20
#
 
21
 
 
22
import apport
 
23
from apport.hookutils import *
 
24
import sys
 
25
import subprocess, optparse
 
26
 
 
27
from datetime import datetime
 
28
 
 
29
optparser = optparse.OptionParser('%prog [options]')
 
30
optparser.add_option('-m', help="Specify the DKMS module to find the package for",
 
31
                     action='store', type='string', dest='module')
 
32
optparser.add_option('-v', help="Specify the DKMS version to find the package for",
 
33
                     action='store', type='string', dest='version')
 
34
optparser.add_option('-k', help="Specify the kernel version",
 
35
                     action='store', type='string', dest='kernel')
 
36
options=optparser.parse_args()[0]
 
37
 
 
38
if not options.module or not options.version:
 
39
    sys.stderr.write('ERROR (dkms apport): both -m and -v are required\n')
 
40
    sys.exit(2)
 
41
 
 
42
package=packaging.get_file_package('/usr/src/' + options.module + '-' + options.version)
 
43
if package is None:
 
44
    sys.stderr.write('ERROR (dkms apport): binary package for %s: %s not found\n' % (options.module,options.version))
 
45
    sys.exit(1)
 
46
 
 
47
if options.kernel:
 
48
    # TODO: Ubuntu specific
 
49
    kernel_package = "linux-headers-" + options.kernel
 
50
 
 
51
    supported_kernel = True
 
52
    try:
 
53
        supported_kernel = apport.packaging.is_distro_package(kernel_package)
 
54
    except ValueError as e:
 
55
        if str(e) == 'package does not exist':
 
56
            supported_kernel = False
 
57
 
 
58
    if not supported_kernel:
 
59
        sys.stderr.write('ERROR (dkms apport): kernel package %s is not supported\n' % (kernel_package))
 
60
        sys.exit(1)
 
61
 
 
62
make_log=os.path.join('/var','lib','dkms',options.module,options.version,'build','make.log')
 
63
 
 
64
report = apport.Report('Package')
 
65
report['Package'] = package
 
66
try:
 
67
    report['SourcePackage'] = apport.packaging.get_source(package)
 
68
except ValueError:
 
69
    sys.stderr.write('ERROR (dkms apport): unable to determine source package for %s\n' % package)
 
70
    sys.exit(3)
 
71
try:
 
72
    version = packaging.get_version(package)
 
73
except ValueError:
 
74
    version = '(not installed)'
 
75
if version is None:
 
76
    version = '(not installed)'
 
77
 
 
78
if report['SourcePackage'] == 'fglrx-installer':
 
79
    fglrx_make_log = os.path.join('/var','lib','dkms',options.module,options.version,'build','make.sh.log')
 
80
    attach_file_if_exists(report, fglrx_make_log, 'FglrxBuildLog')
 
81
 
 
82
report['PackageVersion'] = version
 
83
report['Title'] = "%s %s: %s kernel module failed to build" % (package, version, options.module)
 
84
attach_file_if_exists(report, make_log, 'DKMSBuildLog')
 
85
if 'DKMSBuildLog' in report:
 
86
    this_year = str(datetime.today().year)
 
87
    if 'Segmentation fault' in report['DKMSBuildLog']:
 
88
        sys.stderr.write('ERROR (dkms apport): There was a segmentation fault when trying to build the module\n')
 
89
        sys.exit(1)
 
90
    dupe_sig = ''
 
91
    for line in report['DKMSBuildLog'].split('\n'):
 
92
        if line.endswith(this_year):
 
93
            continue
 
94
        dupe_sig += line + '\n'
 
95
    report['DuplicateSignature'] = dupe_sig
 
96
 
 
97
if options.kernel:
 
98
    report['DKMSKernelVersion'] = options.kernel
 
99
with open(apport.fileutils.make_report_path(report), 'wb') as f:
 
100
    report.write(f)