Merge lp:~brian-murray/ubuntu/oneiric/apport/further-grub-handling into lp:~ubuntu-core-dev/ubuntu/oneiric/apport/ubuntu

Proposed by Brian Murray
Status: Merged
Merged at revision: 1801
Proposed branch: lp:~brian-murray/ubuntu/oneiric/apport/further-grub-handling
Merge into: lp:~ubuntu-core-dev/ubuntu/oneiric/apport/ubuntu
Diff against target: 165 lines (+40/-15)
2 files modified
data/general-hooks/ubuntu.py (+31/-15)
debian/changelog (+9/-0)
To merge this branch: bzr merge lp:~brian-murray/ubuntu/oneiric/apport/further-grub-handling
Reviewer Review Type Date Requested Status
Martin Pitt Approve
Review via email: mp+68457@code.launchpad.net

Description of the change

The match_error_messages function of the ubuntu general hook wasn't checking VarLogDistupgradeApttermlog at all which seemed like something worth fixing to me since dist-upgrades are likely to run into the same issues. The easiest way to check multiple files seemed to me to be creating a new function, check_attachment_for_errors, which would be passed a report and an attachment to search.

I also modified some of the grub_errors based off a discussion with cjwatson.

To post a comment you must log in.
Revision history for this message
Martin Pitt (pitti) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/general-hooks/ubuntu.py'
2--- data/general-hooks/ubuntu.py 2011-07-19 05:19:31 +0000
3+++ data/general-hooks/ubuntu.py 2011-07-19 20:18:34 +0000
4@@ -1,7 +1,8 @@
5 '''Attach generally useful information, not specific to any package.
6
7 Copyright (C) 2009 Canonical Ltd.
8-Author: Matt Zimmerman <mdz@canonical.com>
9+Authors: Matt Zimmerman <mdz@canonical.com>,
10+ Brian Murray <brian@ubuntu.com>
11
12 This program is free software; you can redistribute it and/or modify it
13 under the terms of the GNU General Public License as published by the
14@@ -17,6 +18,7 @@
15 from apport.hookutils import *
16 from apport import unicode_gettext as _
17
18+
19 def add_info(report):
20 add_release_info(report)
21
22@@ -26,6 +28,10 @@
23
24 match_error_messages(report)
25
26+ for log in ['DpkgTerminalLog', 'VarLogDistupgradeApttermlog']:
27+ if log in report:
28+ check_attachment_for_errors(report, log)
29+
30 wrong_grub_msg = _('''Your system was initially configured with grub version 2, but you have removed it from your system in favor of grub 1 without configuring it. To ensure your bootloader configuration is updated whenever a new kernel is available, open a terminal and run:
31
32 sudo apt-get install grub-pc
33@@ -69,24 +75,34 @@
34 stderr=subprocess.STDOUT) == 0:
35 add_tag(report, 'running-unity')
36
37+
38 def match_error_messages(report):
39 # There are enough of these now that it is probably worth refactoring...
40 # -mdz
41 if report['ProblemType'] == 'Package':
42+ if 'failed to install/upgrade: corrupted filesystem tarfile' in report.get('Title', ''):
43+ report['UnreportableReason'] = 'This failure was caused by a corrupted package download or file system corruption.'
44+
45+ if 'is already installed and configured' in report.get('ErrorMessage', ''):
46+ report['SourcePackage'] = 'dpkg'
47+
48+
49+def check_attachment_for_errors(report, attachment):
50+ if report['ProblemType'] == 'Package':
51 trim_dpkg_log(report)
52
53 if report['Package'] not in ['grub', 'grub2']:
54 # linux-image postinst emits this when update-grub fails
55 # https://wiki.ubuntu.com/KernelTeam/DebuggingUpdateErrors
56 grub_errors = [r'^User postinst hook script \[.*update-grub\] exited with value',
57- r'^run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code [1-9]+',
58+ r'^run-parts: /etc/kernel/post(inst|rm).d/zz-update-grub exited with return code [1-9]+',
59 r'^/usr/sbin/grub-probe: error']
60
61 for grub_error in grub_errors:
62- if 'DpkgTerminalLog' in report and re.search(grub_error, report['DpkgTerminalLog'], re.MULTILINE):
63+ if attachment in report and re.search(grub_error, report[attachment], re.MULTILINE):
64 # File these reports on the grub package instead
65 grub_package = apport.packaging.get_file_package('/usr/sbin/update-grub')
66- if grub_package is None or grub_package == 'grub':
67+ if grub_package is None or grub_package == 'grub' and not 'grub-probe' in report[attachment]:
68 report['SourcePackage'] = 'grub'
69 if os.path.exists('/boot/grub/grub.cfg') \
70 and grub_hook_failure:
71@@ -97,7 +113,7 @@
72 if report['Package'] != 'initramfs-tools':
73 # update-initramfs emits this when it fails, usually invoked from the linux-image postinst
74 # https://wiki.ubuntu.com/KernelTeam/DebuggingUpdateErrors
75- if 'DpkgTerminalLog' in report and re.search(r'^update-initramfs: failed for ', report['DpkgTerminalLog'], re.MULTILINE):
76+ if attachment in report and re.search(r'^update-initramfs: failed for ', report[attachment], re.MULTILINE):
77 # File these reports on the initramfs-tools package instead
78 report['SourcePackage'] = 'initramfs-tools'
79
80@@ -106,16 +122,16 @@
81 # we are very interested in reading the compilation log to determine
82 # where to reassign this report to
83 regex = r'^!! Byte-compilation for x?emacs\S+ failed!'
84- if 'DpkgTerminalLog' in report and re.search(regex, report['DpkgTerminalLog'], re.MULTILINE):
85- for line in report['DpkgTerminalLog'].split('\n'):
86+ if attachment in report and re.search(regex, report[attachment], re.MULTILINE):
87+ for line in report[attachment].split('\n'):
88 m = re.search(r'^!! and attach the file (\S+)', line)
89 if m:
90 path = m.group(1)
91 attach_file_if_exists(report, path)
92-
93- if report['Package'].startswith('linux-image-') and 'DpkgTerminalLog' in report:
94+
95+ if report['Package'].startswith('linux-image-') and attachment in report:
96 # /etc/kernel/*.d failures from kernel package postinst
97- m = re.search(r'^run-parts: (/etc/kernel/\S+\.d/\S+) exited with return code \d+', report['DpkgTerminalLog'], re.MULTILINE)
98+ m = re.search(r'^run-parts: (/etc/kernel/\S+\.d/\S+) exited with return code \d+', report[attachment], re.MULTILINE)
99 if m:
100 path = m.group(1)
101 package = apport.packaging.get_file_package(path)
102@@ -127,16 +143,12 @@
103 else:
104 report['UnreportableReason'] = 'This failure was caused by a program which did not originate from Ubuntu'
105
106- if 'failed to install/upgrade: corrupted filesystem tarfile' in report.get('Title', ''):
107- report['UnreportableReason'] = 'This failure was caused by a corrupted package download or file system corruption.'
108-
109- if 'is already installed and configured' in report.get('ErrorMessage', ''):
110- report['SourcePackage'] = 'dpkg'
111
112 def add_kernel_info(report):
113 # This includes the Ubuntu packaged kernel version
114 attach_file_if_exists(report, '/proc/version_signature', 'ProcVersionSignature')
115
116+
117 def add_release_info(report):
118 # https://bugs.launchpad.net/bugs/364649
119 attach_file_if_exists(report, '/var/log/installer/media-info',
120@@ -169,6 +181,7 @@
121 else:
122 report['UpgradeStatus'] = 'No upgrade log present (probably fresh install)'
123
124+
125 def add_cloud_info(report):
126 # EC2 and Ubuntu Enterprise Cloud instances
127 ec2_instance = False
128@@ -209,10 +222,12 @@
129 cloud = 'uec'
130 add_tag(report, 'uec-images')
131
132+
133 def add_tag(report, tag):
134 report.setdefault('Tags', '')
135 report['Tags'] += ' ' + tag
136
137+
138 def get_oem_project(report):
139 '''Determine OEM project name from Distribution Channel Descriptor
140
141@@ -223,6 +238,7 @@
142 return dcd.split('-')[2]
143 return None
144
145+
146 def trim_dpkg_log(report):
147 '''Trim DpkgTerminalLog to the most recent installation session.'''
148
149
150=== modified file 'debian/changelog'
151--- debian/changelog 2011-07-19 05:20:10 +0000
152+++ debian/changelog 2011-07-19 20:18:34 +0000
153@@ -1,3 +1,12 @@
154+apport (1.21.2-0ubuntu6) oneiric; urgency=low
155+
156+ * data/general-hooks/ubuntu.py:
157+ - In addition to DpkgTerminalLog also check VarLogDistupgradeApttermllog
158+ for package installation failure messages
159+ - Also move postrm.d/zz-update-grub errors to grub2
160+
161+ -- Brian Murray <brian@ubuntu.com> Tue, 19 Jul 2011 13:01:37 -0700
162+
163 apport (1.21.2-0ubuntu5) oneiric; urgency=low
164
165 * data/general-hooks/ubuntu.py:

Subscribers

People subscribed via source and target branches