3
# Dynamic Kernel Module Support (DKMS) <dkms-devel@dell.com>
4
# Copyright (C) 2009 Dell, Inc.
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.
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.
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
23
from apport.hookutils import *
25
import subprocess, optparse
27
from datetime import datetime
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]
38
if not options.module or not options.version:
39
sys.stderr.write('ERROR (dkms apport): both -m and -v are required\n')
42
package=packaging.get_file_package('/usr/src/' + options.module + '-' + options.version)
44
sys.stderr.write('ERROR (dkms apport): binary package for %s: %s not found\n' % (options.module,options.version))
48
# TODO: Ubuntu specific
49
kernel_package = "linux-headers-" + options.kernel
51
supported_kernel = True
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
58
if not supported_kernel:
59
sys.stderr.write('ERROR (dkms apport): kernel package %s is not supported\n' % (kernel_package))
62
make_log=os.path.join('/var','lib','dkms',options.module,options.version,'build','make.log')
64
report = apport.Report('Package')
65
report['Package'] = package
67
report['SourcePackage'] = apport.packaging.get_source(package)
69
sys.stderr.write('ERROR (dkms apport): unable to determine source package for %s\n' % package)
72
version = packaging.get_version(package)
74
version = '(not installed)'
76
version = '(not installed)'
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')
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')
91
for line in report['DKMSBuildLog'].split('\n'):
92
if line.endswith(this_year):
94
dupe_sig += line + '\n'
95
report['DuplicateSignature'] = dupe_sig
98
report['DKMSKernelVersion'] = options.kernel
99
with open(apport.fileutils.make_report_path(report), 'wb') as f: