Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Joshua Watt <jpewhacker@gmail.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH] externalsrc: Handle .git not being a directory
Date: Sat,  5 Aug 2017 17:07:52 -0500	[thread overview]
Message-ID: <20170805220752.2047-1-JPEWhacker@gmail.com> (raw)

If EXTERNALSRC points to a git submodule, the .git entry will not be a
directory, but rather a file that points to the actual .git location (in
the parent repository). If this still can't be resolved to a directory,
ignore it and 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, 13 insertions(+), 1 deletion(-)

diff --git a/meta/classes/externalsrc.bbclass b/meta/classes/externalsrc.bbclass
index 9aabb426d9e..ab5cd636051 100644
--- a/meta/classes/externalsrc.bbclass
+++ b/meta/classes/externalsrc.bbclass
@@ -182,13 +182,25 @@ def srctree_hash_files(d, srcdir=None):
     import shutil
     import subprocess
     import tempfile
+    import re
 
     s_dir = srcdir or d.getVar('EXTERNALSRC')
     git_dir = os.path.join(s_dir, '.git')
+
+    if os.path.exists(git_dir) and os.path.isfile(git_dir):
+        with open(git_dir, 'r') as f:
+            m = re.match(r'gitdir: (.*)$', f.read())
+            if m is not None:
+                path = m.group(1)
+                if os.path.isabs(path):
+                    git_dir = path
+                else:
+                    git_dir = os.path.join(git_dir, path)
+
     oe_hash_file = os.path.join(git_dir, 'oe-devtool-tree-sha1')
 
     ret = " "
-    if os.path.exists(git_dir):
+    if os.path.exists(git_dir) and os.path.isdir(git_dir):
         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



             reply	other threads:[~2017-08-05 22:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-05 22:07 Joshua Watt [this message]
2017-08-05 23:37 ` [PATCH] externalsrc: Handle .git not being a directory Christopher Larson
2017-08-07  2:15   ` Joshua Watt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170805220752.2047-1-JPEWhacker@gmail.com \
    --to=jpewhacker@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox