~ubuntu-branches/ubuntu/precise/apport/precise-proposed

« back to all changes in this revision

Viewing changes to data/general-hooks/ubuntu.py

  • Committer: Package Import Robot
  • Author(s): Martin Pitt, Brian Murray, Martin Pitt
  • Date: 2012-09-20 21:45:51 UTC
  • Revision ID: package-import@ubuntu.com-20120920214551-5u9g3i8qw89xrii4
Tags: 2.0.1-0ubuntu14
[ Brian Murray ]
* data/general/ubuntu.py: check to see if a package installation duplicate
  signature has been encountered previously and if so prevent bug reporting
  (LP: #1007637)

[ Martin Pitt ]
* data/general-hooks/ubuntu.py: Add "package-from-proposed" tag if the
  installed package version is available from -proposed, but not from
  -security and -updates. Backported from Ubuntu branch r2088.
  (LP: #1050853)

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
    add_cloud_info(report)
27
27
 
 
28
    add_proposed_info(report)
 
29
 
28
30
    try:
29
31
        report['ApportVersion'] = apport.packaging.get_version('apport')
30
32
    except ValueError:
46
48
 
47
49
    for log in ['DpkgTerminalLog', 'VarLogDistupgradeApttermlog']:
48
50
        if log in report:
 
51
            untrimmed_dpkg_log = report[log]
49
52
            check_attachment_for_errors(report, log)
 
53
            trimmed_log = report['DpkgTerminalLog'].split('\n')
 
54
            lines = []
 
55
            for line in untrimmed_dpkg_log.decode('UTF-8').splitlines():
 
56
                if line not in trimmed_log:
 
57
                    lines.append(line)
 
58
                elif line in trimmed_log:
 
59
                    trimmed_log.remove(line)
 
60
            dpkg_log_without_error = '\n'.join(lines)
50
61
 
51
62
    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:
52
63
 
122
133
                        report['DuplicateSignature'] = dupe_sig
123
134
                        # the duplicate signature should be the first failure
124
135
                        break
 
136
                if dupe_sig:
 
137
                    if dupe_sig in dpkg_log_without_error:
 
138
                        report['UnreportableReason'] = _('You have already encountered this package installation failure.')
125
139
 
126
140
    # running Unity?
127
141
    username = pwd.getpwuid(os.geteuid()).pw_name
273
287
    else:
274
288
        report['UpgradeStatus'] = 'No upgrade log present (probably fresh install)'
275
289
 
 
290
def add_proposed_info(report):
 
291
    '''Tag if package comes from -proposed'''
 
292
 
 
293
    if 'Package' not in report:
 
294
        return
 
295
    try:
 
296
        (package, version) = report['Package'].split()[:2]
 
297
    except ValueError:
 
298
        print('WARNING: malformed Package field: ' + report['Package'])
 
299
        return
 
300
 
 
301
    apt_cache = subprocess.Popen(['apt-cache', 'showpkg', package],
 
302
                                 stdout=subprocess.PIPE,
 
303
                                 universal_newlines=True)
 
304
    out = apt_cache.communicate()[0]
 
305
    if apt_cache.returncode != 0:
 
306
        print('WARNING: apt-cache showpkg %s failed' % package)
 
307
        return
 
308
 
 
309
    found_proposed = False
 
310
    found_updates = False
 
311
    found_security = False
 
312
    for line in out.splitlines():
 
313
        if line.startswith(version + ' ('):
 
314
            if '-proposed_' in line:
 
315
                found_proposed = True
 
316
            if '-updates_' in line:
 
317
                found_updates = True
 
318
            if '-security' in line:
 
319
                found_security = True
 
320
 
 
321
    if found_proposed and not found_updates and not found_security:
 
322
        add_tag(report, 'package-from-proposed')
 
323
 
276
324
def add_cloud_info(report):
277
325
    # EC2 and Ubuntu Enterprise Cloud instances
278
326
    ec2_instance = False