summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/gitsm.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/fetch2/gitsm.py')
-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: