Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH v4] externalsrc: Handle .git not being a directory
@ 2017-08-10  2:18 Joshua Watt
  0 siblings, 0 replies; only message in thread
From: Joshua Watt @ 2017-08-10  2:18 UTC (permalink / raw)
  To: openembedded-core

Use git rev-parse to determine the location of the .git directory, in
case it is not an immediate child of EXTERNALSRC (e.g. when using
submodules). In the event git can't resolve the .git directory, fall
back to the non-git method for hashing.

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
 meta/classes/externalsrc.bbclass | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/meta/classes/externalsrc.bbclass b/meta/classes/externalsrc.bbclass
index 9aabb426d9e..8141f25e041 100644
--- a/meta/classes/externalsrc.bbclass
+++ b/meta/classes/externalsrc.bbclass
@@ -184,11 +184,19 @@ def srctree_hash_files(d, srcdir=None):
     import tempfile
 
     s_dir = srcdir or d.getVar('EXTERNALSRC')
-    git_dir = os.path.join(s_dir, '.git')
-    oe_hash_file = os.path.join(git_dir, 'oe-devtool-tree-sha1')
+    git_dir = None
+
+    try:
+        # git rev-parse returns the path relative to the current working
+        # directory
+        git_dir = os.path.join(s_dir,
+            subprocess.check_output(['git', 'rev-parse', '--git-dir'], cwd=s_dir).decode("utf-8").rstrip())
+    except subprocess.CalledProcessError:
+        pass
 
     ret = " "
-    if os.path.exists(git_dir):
+    if git_dir is not None:
+        oe_hash_file = os.path.join(git_dir, 'oe-devtool-tree-sha1')
         with tempfile.NamedTemporaryFile(prefix='oe-devtool-index') as tmp_index:
             # Clone index
             shutil.copyfile(os.path.join(git_dir, 'index'), tmp_index.name)
-- 
2.13.3



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-08-10  2:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-10  2:18 [PATCH v4] externalsrc: Handle .git not being a directory Joshua Watt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox