Commit 5f60c8ce authored by Daniel Markus's avatar Daniel Markus Committed by Martin Jansa

socorro-syms: Limit the search for repository to within the build directory

When we search for the git repository associated with a file and the there's no
repository associated, we incorrectly find the yocto repository itself.

To prevent the search from finding an incorrect repository, we only accept
repositories found within the build directory.
Signed-off-by: default avatarDaniel Markus <>
Signed-off-by: default avatarMartin Jansa <>
parent 324b300b
......@@ -42,7 +42,7 @@ python symbol_file_preprocess() {
breakpad_sym_file_path = os.path.join(breakpad_syms_dir, sym_file_name)
socorro_sym_file_path = os.path.join(socorro_syms_dir, sym_file_name)
create_socorro_sym_file(breakpad_sym_file_path, socorro_sym_file_path)
create_socorro_sym_file(d, breakpad_sym_file_path, socorro_sym_file_path)
arrange_socorro_sym_file(socorro_sym_file_path, socorro_syms_dir)
......@@ -50,7 +50,16 @@ python symbol_file_preprocess() {
def create_socorro_sym_file(breakpad_sym_file_path, socorro_sym_file_path):
def run_command(command, directory):
(output, error) =, cwd=directory)
if error:
raise bb.process.ExecutionError(command, error)
return output.rstrip()
def create_socorro_sym_file(d, breakpad_sym_file_path, socorro_sym_file_path):
# In the symbol file, all source files are referenced like the following.
# FILE 123 /path/to/some/File.cpp
......@@ -61,18 +70,19 @@ def create_socorro_sym_file(breakpad_sym_file_path, socorro_sym_file_path):
for line in breakpad_sym_file:
if line.startswith("FILE "):
socorro_sym_file.write(socorro_file_reference(d, line))
def socorro_file_reference(line):
def socorro_file_reference(d, line):
# The 3rd position is the file path. See example above.
source_file_path = line.split()[2]
source_file_repo_path = repository_path(os.path.normpath(source_file_path))
source_file_repo_path = repository_path(
d, os.path.normpath(source_file_path))
# If the file could be found in any repository then replace it with the
# repository's path.
......@@ -82,7 +92,7 @@ def socorro_file_reference(line):
return line
def repository_path(source_file_path):
def repository_path(d, source_file_path):
if not os.path.isfile(source_file_path):
return None
......@@ -91,6 +101,14 @@ def repository_path(source_file_path):
(output, error) ="git status",
if not error:
# Make sure the git repository we just found wasn't the yocto repository
# itself, i.e. the root of the repository we're looking for must be a
# child of the build directory TOPDIR.
git_root_dir = run_command(
"git rev-parse --show-toplevel", os.path.dirname(source_file_path))
if not git_root_dir.startswith(d.getVar("TOPDIR", True)):
return None
return git_repository_path(source_file_path)
# Here we can add support for other VCSs like hg, svn, cvs, etc.
......@@ -99,15 +117,6 @@ def repository_path(source_file_path):
return None
def run_command(command, directory):
(output, error) =, cwd=directory)
if error:
raise bb.process.ExecutionError(command, error)
return output.rstrip()
def is_local_url(url):
return \
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment