[oe-commits] Daniel Markus : socorro-syms: Limit the search for repository to within the build directory

git at git.openembedded.org git at git.openembedded.org
Tue Apr 21 11:03:42 UTC 2015


Module: meta-openembedded.git
Branch: master
Commit: 5f60c8ce812cf9caab16aa50c0ba41c512314f14
URL:    http://git.openembedded.org/?p=meta-openembedded.git&a=commit;h=5f60c8ce812cf9caab16aa50c0ba41c512314f14

Author: Daniel Markus <daniel.markus at leica-geosystems.com>
Date:   Thu Apr  9 11:18:59 2015 +0200

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: Daniel Markus <daniel.markus at leica-geosystems.com>
Signed-off-by: Martin Jansa <Martin.Jansa at gmail.com>

---

 meta-oe/classes/socorro-syms.bbclass | 39 ++++++++++++++++++++++--------------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/meta-oe/classes/socorro-syms.bbclass b/meta-oe/classes/socorro-syms.bbclass
index 7a7b208..3f6ae63 100644
--- a/meta-oe/classes/socorro-syms.bbclass
+++ b/meta-oe/classes/socorro-syms.bbclass
@@ -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) = bb.process.run(command, 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(line))
+                socorro_sym_file.write(socorro_file_reference(d, line))
             else:
                 socorro_sym_file.write(line)
 
     return
 
 
-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) = bb.process.run("git status",
         cwd=os.path.dirname(source_file_path))
     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) = bb.process.run(command, cwd=directory)
-    if error:
-        raise bb.process.ExecutionError(command, error)
-
-    return output.rstrip()
-
-
 def is_local_url(url):
 
     return \



More information about the Openembedded-commits mailing list