mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1585993 - Resolve symlinks when generating file paths for breakpad symbol file r=gsvelto
Some paths contain symlinks and Python normpath doesn't resolve them. So it results on having wrong paths in generated breakpad file. Differential Revision: https://phabricator.services.mozilla.com/D48075 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
49aac36888
commit
1ed4302759
@ -253,7 +253,7 @@ class GitFileInfo(VCSFileInfo):
|
||||
vcsFileInfoCache = {}
|
||||
|
||||
if platform.system() == 'Windows':
|
||||
def normpath(path):
|
||||
def realpath(path):
|
||||
'''
|
||||
Normalize a path using `GetFinalPathNameByHandleW` to get the
|
||||
path with all components in the case they exist in on-disk, so
|
||||
@ -298,7 +298,7 @@ if platform.system() == 'Windows':
|
||||
return result
|
||||
else:
|
||||
# Just use the os.path version otherwise.
|
||||
normpath = os.path.normpath
|
||||
realpath = os.path.realpath
|
||||
|
||||
def IsInDir(file, dir):
|
||||
# the lower() is to handle win32+vc8, where
|
||||
@ -381,9 +381,9 @@ def make_file_mapping(install_manifests):
|
||||
manifest.populate_registry(reg)
|
||||
for dst, src in reg:
|
||||
if hasattr(src, 'path'):
|
||||
# Any paths that get compared to source file names need to go through normpath.
|
||||
abs_dest = normpath(os.path.join(destination, dst))
|
||||
file_mapping[abs_dest] = normpath(src.path)
|
||||
# Any paths that get compared to source file names need to go through realpath.
|
||||
abs_dest = realpath(os.path.join(destination, dst))
|
||||
file_mapping[abs_dest] = realpath(src.path)
|
||||
return file_mapping
|
||||
|
||||
@memoize
|
||||
@ -451,8 +451,8 @@ class Dumper:
|
||||
self.archs = ['']
|
||||
else:
|
||||
self.archs = ['-a %s' % a for a in archs.split()]
|
||||
# Any paths that get compared to source file names need to go through normpath.
|
||||
self.srcdirs = [normpath(s) for s in srcdirs]
|
||||
# Any paths that get compared to source file names need to go through realpath.
|
||||
self.srcdirs = [realpath(s) for s in srcdirs]
|
||||
self.copy_debug = copy_debug
|
||||
self.vcsinfo = vcsinfo
|
||||
self.srcsrv = srcsrv
|
||||
@ -551,7 +551,7 @@ class Dumper:
|
||||
(x, index, filename) = line.rstrip().split(None, 2)
|
||||
# We want original file paths for the source server.
|
||||
sourcepath = filename
|
||||
filename = normpath(filename)
|
||||
filename = realpath(filename)
|
||||
if filename in self.file_mapping:
|
||||
filename = self.file_mapping[filename]
|
||||
if self.vcsinfo:
|
||||
@ -958,8 +958,8 @@ to canonical locations in the source repository. Specify
|
||||
parser.error(str(e))
|
||||
exit(1)
|
||||
file_mapping = make_file_mapping(manifests)
|
||||
# Any paths that get compared to source file names need to go through normpath.
|
||||
generated_files = {normpath(os.path.join(buildconfig.topobjdir, f)): f
|
||||
# Any paths that get compared to source file names need to go through realpath.
|
||||
generated_files = {realpath(os.path.join(buildconfig.topobjdir, f)): f
|
||||
for (f, _) in get_generated_sources()}
|
||||
_, bucket = get_s3_region_and_bucket()
|
||||
dumper = GetPlatformSpecificDumper(dump_syms=args[0],
|
||||
|
@ -21,7 +21,7 @@ from mozpack.manifests import InstallManifest
|
||||
import mozpack.path as mozpath
|
||||
|
||||
import symbolstore
|
||||
from symbolstore import normpath
|
||||
from symbolstore import realpath
|
||||
|
||||
# Some simple functions to mock out files that the platform-specific dumpers will accept.
|
||||
# dump_syms itself will not be run (we mock that call out), but we can't override
|
||||
@ -255,13 +255,13 @@ class TestGeneratedFilePath(HelperMixin, unittest.TestCase):
|
||||
|
||||
|
||||
if target_platform() == 'WINNT':
|
||||
class TestNormpath(HelperMixin, unittest.TestCase):
|
||||
def test_normpath(self):
|
||||
class TestRealpath(HelperMixin, unittest.TestCase):
|
||||
def test_realpath(self):
|
||||
# self.test_dir is going to be 8.3 paths...
|
||||
junk = os.path.join(self.test_dir, 'x')
|
||||
with open(junk, 'wb') as o:
|
||||
o.write('x')
|
||||
fixed_dir = os.path.dirname(normpath(junk))
|
||||
fixed_dir = os.path.dirname(realpath(junk))
|
||||
files = [
|
||||
'one\\two.c',
|
||||
'three\\Four.d',
|
||||
@ -274,7 +274,7 @@ if target_platform() == 'WINNT':
|
||||
self.make_dirs(full_path)
|
||||
with open(full_path, 'wb') as o:
|
||||
o.write('x')
|
||||
fixed_path = normpath(full_path.lower())
|
||||
fixed_path = realpath(full_path.lower())
|
||||
fixed_path = os.path.relpath(fixed_path, fixed_dir)
|
||||
self.assertEqual(rel_path, fixed_path)
|
||||
|
||||
@ -340,8 +340,8 @@ class TestInstallManifest(HelperMixin, unittest.TestCase):
|
||||
self.manifest = InstallManifest()
|
||||
self.canonical_mapping = {}
|
||||
for s in ['src1', 'src2']:
|
||||
srcfile = normpath(os.path.join(self.srcdir, s))
|
||||
objfile = normpath(os.path.join(self.objdir, s))
|
||||
srcfile = realpath(os.path.join(self.srcdir, s))
|
||||
objfile = realpath(os.path.join(self.objdir, s))
|
||||
self.canonical_mapping[objfile] = srcfile
|
||||
self.manifest.add_copy(srcfile, s)
|
||||
self.manifest_file = os.path.join(self.test_dir, 'install-manifest')
|
||||
@ -421,10 +421,10 @@ class TestFileMapping(HelperMixin, unittest.TestCase):
|
||||
for s, o in files:
|
||||
srcfile = os.path.join(self.srcdir, s)
|
||||
self.make_file(srcfile)
|
||||
expected_files.append(normpath(srcfile))
|
||||
expected_files.append(realpath(srcfile))
|
||||
objfile = os.path.join(self.objdir, o)
|
||||
self.make_file(objfile)
|
||||
file_mapping[normpath(objfile)] = normpath(srcfile)
|
||||
file_mapping[realpath(objfile)] = realpath(srcfile)
|
||||
dumped_files.append(os.path.join(self.objdir, 'x', 'y',
|
||||
'..', '..', o))
|
||||
# mock the dump_syms output
|
||||
|
Loading…
Reference in New Issue
Block a user