From b0d6e9db3e4decb0e13e5e435874779923114c2a Mon Sep 17 00:00:00 2001 From: Benjamin Drung Date: Thu, 20 Apr 2017 12:49:33 +0200 Subject: [PATCH] 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. --- apport/sandboxutils.py | 2 +- backends/packaging-apt-dpkg.py | 9 +++++---- bin/apport-retrace | 7 ++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/apport/sandboxutils.py b/apport/sandboxutils.py index 41f0a7a..003f14b 100644 --- a/apport/sandboxutils.py +++ b/apport/sandboxutils.py @@ -171,7 +171,7 @@ def make_sandbox(report, config_dir, cache_dir=None, sandbox_dir=None, cache_dir = tempfile.mkdtemp(prefix='apport_cache_') atexit.register(shutil.rmtree, cache_dir) - pkgmap_cache_dir = os.path.join(cache_dir, report['DistroRelease']) + pkgmap_cache_dir = os.path.join(cache_dir, re.sub(' GNU/Linux', '', report['DistroRelease'])) pkgs = [] diff --git a/backends/packaging-apt-dpkg.py b/backends/packaging-apt-dpkg.py index 5e68745..d181601 100644 --- a/backends/packaging-apt-dpkg.py +++ b/backends/packaging-apt-dpkg.py @@ -714,6 +714,7 @@ Debug::NoLocking "true"; package servers down, etc.), this should raise a SystemError with a meaningful error message. ''' + sanitized_release = re.sub(' GNU/Linux', '', release) if not architecture: architecture = self.get_system_architecture() if not configdir: @@ -721,9 +722,9 @@ Debug::NoLocking "true"; self.current_release_codename = self.get_distro_codename() else: # support architecture specific config, fall back to global config - apt_sources = os.path.join(configdir, release, 'sources.list') + apt_sources = os.path.join(configdir, sanitized_release, 'sources.list') if architecture != self.get_system_architecture(): - arch_apt_sources = os.path.join(configdir, release, + arch_apt_sources = os.path.join(configdir, sanitized_release, architecture, 'sources.list') if os.path.exists(arch_apt_sources): apt_sources = arch_apt_sources @@ -735,7 +736,7 @@ Debug::NoLocking "true"; apport.warning('cannot determine mirror: %s' % str(e)) # set current release code name for _distro_release_to_codename - with open(os.path.join(configdir, release, 'codename')) as f: + with open(os.path.join(configdir, sanitized_release, 'codename')) as f: self.current_release_codename = f.read().strip() if not os.path.exists(apt_sources): @@ -749,7 +750,7 @@ Debug::NoLocking "true"; else: aptroot_arch = '' if configdir: - aptroot = os.path.join(cache_dir, release, aptroot_arch, 'apt') + aptroot = os.path.join(cache_dir, sanitized_release, aptroot_arch, 'apt') else: aptroot = os.path.join(cache_dir, 'system', aptroot_arch, 'apt') if not os.path.isdir(aptroot): diff --git a/bin/apport-retrace b/bin/apport-retrace index 75631cd..7c892f7 100755 --- a/bin/apport-retrace +++ b/bin/apport-retrace @@ -310,7 +310,7 @@ if options.gdb_sandbox: if options.sandbox: if options.sandbox_dir: sandbox_dir = '%s/%s/%s/report-sandbox/' % \ - (options.sandbox_dir, report['DistroRelease'], + (options.sandbox_dir, re.sub(' GNU/Linux', '', report['DistroRelease']), report['Architecture']) else: sandbox_dir = None @@ -341,7 +341,8 @@ if options.gdb_sandbox: fake_report['ProcMaps'] = '\n\n' if options.sandbox_dir: gdb_sandbox_dir = '%s/%s/%s/gdb-sandbox/' % \ - (options.sandbox_dir, report['DistroRelease'], system_arch) + (options.sandbox_dir, re.sub(' GNU/Linux', '', report['DistroRelease']), + system_arch) else: gdb_sandbox_dir = None gdb_sandbox, gdb_cache, gdb_outdated_msg = \ @@ -394,7 +395,7 @@ Thank you for your understanding, and sorry for the inconvenience! if options.sandbox == 'system': apt_root = os.path.join(cache, 'system', 'apt') elif options.sandbox: - apt_root = os.path.join(cache, report['DistroRelease'], 'apt') + apt_root = os.path.join(cache, re.sub(' GNU/Linux', '', report['DistroRelease']), 'apt') else: apt_root = None gen_source_stacktrace(report, apt_root) -- 2.11.0