Merge lp:~bdrung/apport/lp-1684600-gnu-linux into lp:~apport-hackers/apport/trunk

Proposed by Benjamin Drung
Status: Needs review
Proposed branch: lp:~bdrung/apport/lp-1684600-gnu-linux
Merge into: lp:~apport-hackers/apport/trunk
Diff against target: 48 lines (+9/-11)
2 files modified
apport/packaging.py (+7/-11)
bin/apport-retrace (+2/-0)
To merge this branch: bzr merge lp:~bdrung/apport/lp-1684600-gnu-linux
Reviewer Review Type Date Requested Status
Apport upstream developers Pending
Review via email: mp+389659@code.launchpad.net

Description of the change

Fix stripping GNU/Linux from DistroRelease

The DistroRelease contains GNU/Linux on Debian (example: "Debian
GNU/Linux 8"). The containing slash is very confusing when using the
DistroRelease as path.

name[1:-2] strips one leading characters and two trailing characters and
removes one character too much at the end. Thus the name.endswith check
fails to match 'GNU/Linux' and does nothing. If it was matching
GNU/Linux, it would set name to a list.

Fix the parsing of /etc/os-release by using shlex.

To post a comment you must log in.
3283. By Benjamin Drung

Strip GNU/Linux from DistroRelease

The DistroRelease contains GNU/Linux on Debian (example: "Debian
GNU/Linux 8"). The containing slash is very confusing when using the
DistroRelease as path. Thus just strip GNU/Linux from the DistroRelease
before using it as part of a path.

LP: #1684600

Unmerged revisions

3283. By Benjamin Drung

Strip GNU/Linux from DistroRelease

The DistroRelease contains GNU/Linux on Debian (example: "Debian
GNU/Linux 8"). The containing slash is very confusing when using the
DistroRelease as path. Thus just strip GNU/Linux from the DistroRelease
before using it as part of a path.

LP: #1684600

3282. By Benjamin Drung

Fix stripping GNU/Linux from DistroRelease

The DistroRelease contains GNU/Linux on Debian (example: "Debian
GNU/Linux 8"). The containing slash is very confusing when using the
DistroRelease as path.

name[1:-2] strips one leading characters and two trailing characters and
removes one character too much at the end. Thus the name.endswith check
fails to match 'GNU/Linux' and does nothing. If it was matching
GNU/Linux, it would set name to a list.

Fix the parsing of /etc/os-release by using shlex.

LP: #1684600

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'apport/packaging.py'
2--- apport/packaging.py 2017-06-12 23:42:53 +0000
3+++ apport/packaging.py 2020-09-21 14:14:56 +0000
4@@ -12,6 +12,7 @@
5 import os
6 import sys
7 import re
8+import shlex
9 import subprocess
10
11
12@@ -284,17 +285,12 @@
13 version = None
14 with open('/etc/os-release') as f:
15 for l in f:
16- if l.startswith('NAME='):
17- name = l.split('=', 1)[1]
18- if name.startswith('"'):
19- name = name[1:-2].strip()
20- # work around inconsistent "Debian GNU/Linux" in os-release
21- if name.endswith('GNU/Linux'):
22- name = name.split()[0:-1]
23- elif l.startswith('VERSION_ID='):
24- version = l.split('=', 1)[1]
25- if version.startswith('"'):
26- version = version[1:-2].strip()
27+ key, value = shlex.split(l)[0].split("=", 1)
28+ if key == "NAME":
29+ # The OS name might be used as path later. Thus avoid / in the name.
30+ name = value[:-9].strip() if value.endswith("GNU/Linux") else value
31+ if key == "VERSION_ID":
32+ version = value
33 if name and version:
34 self._os_version = (name, version)
35 return self._os_version
36
37=== modified file 'bin/apport-retrace'
38--- bin/apport-retrace 2018-01-09 00:58:33 +0000
39+++ bin/apport-retrace 2020-09-21 14:14:56 +0000
40@@ -303,6 +303,8 @@
41
42 apport.memdbg('sanity checks passed')
43
44+report["DistroRelease"] = re.sub(" GNU/Linux", "", report["DistroRelease"])
45+
46 if options.gdb_sandbox:
47 system_arch = apport.packaging.get_system_architecture()
48 if system_arch != 'amd64':

Subscribers

People subscribed via source and target branches