summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@windriver.com>2019-03-12 18:46:18 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-03-24 16:42:22 +0000
commitd5a6da8b3d1a8639f945586828ecd4d8481f5100 (patch)
tree31693840ce7b00d4848673a2d9915b192029f2ff /bitbake/lib/bb/fetch2
parent506ec088e58b616f544eebac6d5dcbf3da6ea924 (diff)
downloadpoky-d5a6da8b3d1a8639f945586828ecd4d8481f5100.tar.gz
bitbake: gitsm.py: Fix when a submodule is defined, but not initialized
It is possible for a submodule to be defined in the .gitmodules file, but never initialized in the repository itself. This shows itself when searching for the defined module hash you will get back a empty value. Similarly we need to identify and skip defined but not initialized submodules during the unpack stages as well. Thanks to raphael.lisicki@siemens.com for their help is figuring out how to resolve this issue. Additionally a problem was found where, while unlikely, it may be possible for the wrong revision to have been searched using ls-tree. This has been resolved in the update_submodules function by keeping the correct revision along with the submodule path. (Bitbake rev: e9c965bd816c8e4e5cc8e45db8e0dab597ce5a6f) Signed-off-by: Mark Hatle <mark.hatle@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 49e1ff920143dcd4e7f73933d7ab8a84b8ffa1a3) Signed-off-by: Scott Murray <scott.murray@konsulko.com> Signed-off-by: Armin Kuster <akuster@mvista.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2')
-rw-r--r--bitbake/lib/bb/fetch2/gitsm.py32
1 files changed, 28 insertions, 4 deletions
diff --git a/bitbake/lib/bb/fetch2/gitsm.py b/bitbake/lib/bb/fetch2/gitsm.py
index 35729dbc0f..b7959ff5d1 100644
--- a/bitbake/lib/bb/fetch2/gitsm.py
+++ b/bitbake/lib/bb/fetch2/gitsm.py
@@ -64,6 +64,7 @@ class GitSM(Git):
64 def update_submodules(self, ud, d): 64 def update_submodules(self, ud, d):
65 submodules = [] 65 submodules = []
66 paths = {} 66 paths = {}
67 revision = {}
67 uris = {} 68 uris = {}
68 local_paths = {} 69 local_paths = {}
69 70
@@ -77,6 +78,7 @@ class GitSM(Git):
77 for m, md in self.parse_gitmodules(gitmodules).items(): 78 for m, md in self.parse_gitmodules(gitmodules).items():
78 submodules.append(m) 79 submodules.append(m)
79 paths[m] = md['path'] 80 paths[m] = md['path']
81 revision[m] = ud.revisions[name]
80 uris[m] = md['url'] 82 uris[m] = md['url']
81 if uris[m].startswith('..'): 83 if uris[m].startswith('..'):
82 newud = copy.copy(ud) 84 newud = copy.copy(ud)
@@ -84,7 +86,17 @@ class GitSM(Git):
84 uris[m] = Git._get_repo_url(self, newud) 86 uris[m] = Git._get_repo_url(self, newud)
85 87
86 for module in submodules: 88 for module in submodules:
87 module_hash = runfetchcmd("%s ls-tree -z -d %s %s" % (ud.basecmd, ud.revisions[name], paths[module]), d, quiet=True, workdir=ud.clonedir) 89 try:
90 module_hash = runfetchcmd("%s ls-tree -z -d %s %s" % (ud.basecmd, revision[module], paths[module]), d, quiet=True, workdir=ud.clonedir)
91 except:
92 # If the command fails, we don't have a valid file to check. If it doesn't
93 # fail -- it still might be a failure, see next check...
94 module_hash = ""
95
96 if not module_hash:
97 logger.debug(1, "submodule %s is defined, but is not initialized in the repository. Skipping", module)
98 continue
99
88 module_hash = module_hash.split()[2] 100 module_hash = module_hash.split()[2]
89 101
90 # Build new SRC_URI 102 # Build new SRC_URI
@@ -143,7 +155,7 @@ class GitSM(Git):
143 if not ud.shallow or ud.localpath != ud.fullshallow: 155 if not ud.shallow or ud.localpath != ud.fullshallow:
144 self.update_submodules(ud, d) 156 self.update_submodules(ud, d)
145 157
146 def copy_submodules(self, submodules, ud, destdir, d): 158 def copy_submodules(self, submodules, ud, name, destdir, d):
147 if ud.bareclone: 159 if ud.bareclone:
148 repo_conf = destdir 160 repo_conf = destdir
149 else: 161 else:
@@ -156,6 +168,18 @@ class GitSM(Git):
156 srcpath = os.path.join(ud.clonedir, 'modules', md['path']) 168 srcpath = os.path.join(ud.clonedir, 'modules', md['path'])
157 modpath = os.path.join(repo_conf, 'modules', md['path']) 169 modpath = os.path.join(repo_conf, 'modules', md['path'])
158 170
171 # Check if the module is initialized
172 try:
173 module_hash = runfetchcmd("%s ls-tree -z -d %s %s" % (ud.basecmd, ud.revisions[name], md['path']), d, quiet=True, workdir=ud.clonedir)
174 except:
175 # If the command fails, we don't have a valid file to check. If it doesn't
176 # fail -- it still might be a failure, see next check...
177 module_hash = ""
178
179 if not module_hash:
180 logger.debug(1, "submodule %s is defined, but is not initialized in the repository. Skipping", module)
181 continue
182
159 if os.path.exists(srcpath): 183 if os.path.exists(srcpath):
160 if os.path.exists(os.path.join(srcpath, '.git')): 184 if os.path.exists(os.path.join(srcpath, '.git')):
161 srcpath = os.path.join(srcpath, '.git') 185 srcpath = os.path.join(srcpath, '.git')
@@ -188,7 +212,7 @@ class GitSM(Git):
188 continue 212 continue
189 213
190 submodules = self.parse_gitmodules(gitmodules) 214 submodules = self.parse_gitmodules(gitmodules)
191 self.copy_submodules(submodules, ud, dest, d) 215 self.copy_submodules(submodules, ud, name, dest, d)
192 216
193 def unpack(self, ud, destdir, d): 217 def unpack(self, ud, destdir, d):
194 Git.unpack(self, ud, destdir, d) 218 Git.unpack(self, ud, destdir, d)
@@ -211,7 +235,7 @@ class GitSM(Git):
211 continue 235 continue
212 236
213 submodules = self.parse_gitmodules(gitmodules) 237 submodules = self.parse_gitmodules(gitmodules)
214 self.copy_submodules(submodules, ud, ud.destdir, d) 238 self.copy_submodules(submodules, ud, name, ud.destdir, d)
215 239
216 submodules_queue = [(module, os.path.join(repo_conf, 'modules', md['path'])) for module, md in submodules.items()] 240 submodules_queue = [(module, os.path.join(repo_conf, 'modules', md['path'])) for module, md in submodules.items()]
217 while len(submodules_queue) != 0: 241 while len(submodules_queue) != 0: