Merge lp:~stolowski/unity-scopes-api/support-apport into lp:unity-scopes-api

Proposed by Paweł Stołowski
Status: Merged
Approved by: Pete Woods
Approved revision: 285
Merged at revision: 301
Proposed branch: lp:~stolowski/unity-scopes-api/support-apport
Merge into: lp:unity-scopes-api
Diff against target: 124 lines (+101/-0)
3 files modified
data/CMakeLists.txt (+4/-0)
data/libunity-scopes.py (+96/-0)
debian/libunity-scopes3.install (+1/-0)
To merge this branch: bzr merge lp:~stolowski/unity-scopes-api/support-apport
Reviewer Review Type Date Requested Status
Pete Woods (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Michi Henning (community) Approve
Brian Murray Approve
Review via email: mp+248217@code.launchpad.net

Commit message

Provide script for apport package hooks to handle scoperunner crashes. This script alters 'Package' and 'SourcePackage' fields of the crash report to distribute error reports to correct scopes.

Description of the change

Provide script for apport package hooks to handle scoperunner crashes. This script alters 'Package' and 'SourcePackage' fields of the crash report to distribute error reports to correct scopes.

There are three cases it handles:
1) a scope comes from a deb package: the script executes dpkg query to find its deb and from that, get source package name.
2) a scope comes from a click package: the script gets the 'name' field from click manifest.
 a) if we know this scope (currently vimeo and youtube are well known), we remap src package to unity-scope-vimeo/youtube.
 b) otherwise we just use the dotted click name as source package (similar to how clicks are handled by default with generic click hook of apport).

Example reports:

https://errors.staging.ubuntu.com/oops/f7bae794-aab3-11e4-af2c-fa163e1893a8
https://errors.staging.ubuntu.com/oops/6e2cd734-aab4-11e4-af2c-fa163e1893a8
https://errors.staging.ubuntu.com/oops/57840d6c-aab5-11e4-af2c-fa163e1893a8

This hook can be tested against a testing server, ping me for instructions if you're interested in giving it a try.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Brian Murray (brian-murray) wrote :

This looks good to me but see my in-line comment regarding the function collect_dpkg_info.

Revision history for this message
Brian Murray (brian-murray) :
review: Needs Fixing
283. By Paweł Stołowski

Simplified collect_dpkg_info.

284. By Paweł Stołowski

Installation fixes.

Revision history for this message
Paweł Stołowski (stolowski) wrote :

> This looks good to me but see my in-line comment regarding the function
> collect_dpkg_info.

Thank you, this was a very good suggestion. I've simplified it.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Brian Murray (brian-murray) :
review: Approve
Revision history for this message
Michi Henning (michihenning) wrote :

I tried accessing the sample report links you posted, but was told that I'm not trustworthy enough... I've filled in the relevant bit of webwork. Hopefully someone will give me permission.

Looks good to me, but I'm not a package/click person. Pete, would you mind looking through this too please?

review: Approve
285. By Paweł Stołowski

Added mapping for soundcloud scope.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Pete Woods (pete-woods) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/CMakeLists.txt'
2--- data/CMakeLists.txt 2014-05-06 09:00:45 +0000
3+++ data/CMakeLists.txt 2015-02-04 09:48:00 +0000
4@@ -10,6 +10,10 @@
5 configure_file(scope-registry.conf.in scope-registry.conf @ONLY)
6 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/scope-registry.conf DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/sessions)
7
8+# apport package hook
9+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libunity-scopes.py libunity-scopes${UNITY_SCOPES_SOVERSION}.py COPYONLY)
10+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libunity-scopes${UNITY_SCOPES_SOVERSION}.py DESTINATION /usr/share/apport/package-hooks)
11+
12 # Empty directory for scopes to put their conf files into
13 # If we start install our own conf files here, this can be
14 # removed (installing files implicitly creates the subdirs)
15
16=== added file 'data/libunity-scopes.py'
17--- data/libunity-scopes.py 1970-01-01 00:00:00 +0000
18+++ data/libunity-scopes.py 2015-02-04 09:48:00 +0000
19@@ -0,0 +1,96 @@
20+#
21+# Copyright (C) 2015 Canonical Ltd.
22+# Author: Pawel Stolowski <pawel.stolowski@canonical.com>
23+#
24+# This program is free software; you can redistribute it and/or modify
25+# it under the terms of the GNU General Public License as published by
26+# the Free Software Foundation; version 3.
27+#
28+# This program is distributed in the hope that it will be useful,
29+# but WITHOUT ANY WARRANTY; without even the implied warranty of
30+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31+# GNU General Public License for more details.
32+#
33+# You should have received a copy of the GNU General Public License
34+# along with this program. If not, see <http://www.gnu.org/licenses/>.
35+#
36+
37+
38+#
39+# This script parses ProcCmdline to check if this is a crash of scoperunner process.
40+# If so, it checks what scope made it crash and adjusts Package and SourcePackage
41+# attributes of the crash report to point at the crashing scope.
42+#
43+
44+from os import path
45+import subprocess, json, configparser
46+import apport
47+import apport.fileutils
48+from apport.packaging_impl import impl as packaging
49+
50+# map 'name' from click package manifest to LP project (if known)
51+click_name_to_src = {
52+ 'com.ubuntu.scopes.youtube': 'unity-scope-youtube',
53+ 'com.ubuntu.scopes.vimeo': 'unity-scope-vimeo',
54+ 'com.ubuntu.scopes.soundcloud': 'unity-scope-soundcloud'
55+}
56+
57+def get_scope_display_name(ini_file_path):
58+ try:
59+ cfg = configparser.ConfigParser()
60+ cfg.read(ini_file_path)
61+ return cfg.get('ScopeConfig', 'DisplayName')
62+ except:
63+ pass
64+ return ''
65+
66+def collect_dpkg_info(report, inifile):
67+ try:
68+ # find deb package that owns this inifile
69+ pkg = apport.fileutils.find_file_package(inifile)
70+ ver = packaging.get_version(pkg)
71+ report['Package'] = '%s %s' % (pkg, ver)
72+ report['SourcePackage'] = packaging.get_source(pkg)
73+ except:
74+ pass
75+
76+def collect_click_info(report, inifile):
77+ try:
78+ # get click manifest of a click package that owns this inifile
79+ click_info = subprocess.check_output(['click', 'info', inifile], universal_newlines=True)
80+ manifest = json.loads(click_info)
81+ report['Package'] = '%s %s' % (manifest['name'], manifest['version'])
82+ name = manifest['name']
83+ if name in click_name_to_src:
84+ report['SourcePackage'] = click_name_to_src[name]
85+ else:
86+ report['SourcePackage'] = name
87+ report['PackageArchitecture'] = manifest['architecture']
88+ except:
89+ pass
90+
91+def add_info(report, ui):
92+ exec_path = report.get('ExecutablePath')
93+ if not exec_path:
94+ return
95+ cmd_line = report.get('ProcCmdline')
96+ if not cmd_line:
97+ return
98+ if exec_path.find("scoperunner") < 0:
99+ return
100+ args = cmd_line.split()
101+ if len(args) != 2:
102+ return
103+
104+ scope_ini_path = args[1]
105+ scope_name = get_scope_display_name(scope_ini_path)
106+ if scope_name:
107+ report['Scope'] = scope_name
108+
109+ #
110+ # check whether it's a click package or deb and collect additional pkg info
111+ if scope_ini_path.find('.local/share') >= 0:
112+ report['ClickPackage'] = 'True'
113+ collect_click_info(report, scope_ini_path)
114+ else:
115+ collect_dpkg_info(report, scope_ini_path)
116
117=== modified file 'debian/libunity-scopes3.install'
118--- debian/libunity-scopes3.install 2015-01-15 04:56:00 +0000
119+++ debian/libunity-scopes3.install 2015-02-04 09:48:00 +0000
120@@ -4,3 +4,4 @@
121 usr/lib/*/unity-scopes/scoperunner
122 usr/lib/*/unity-scopes/smartscopesproxy
123 usr/share/upstart/sessions/*.conf
124+usr/share/apport/package-hooks/*.py

Subscribers

People subscribed via source and target branches

to all changes: