summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2
diff options
context:
space:
mode:
authorChristopher Larson <kergoth@gmail.com>2017-05-13 02:46:29 +0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-02 13:36:57 +0100
commitbf87c5cd194b5a24c388d6445b413b5f673bc1de (patch)
treebeef4530468ec0502c43a8692b0127fb613e2a4b /bitbake/lib/bb/fetch2
parent27d56982c7ba05e86a100b0cca2411ee5ac7a85e (diff)
downloadpoky-bf87c5cd194b5a24c388d6445b413b5f673bc1de.tar.gz
bitbake: fetch/git: support per-branch/per-url depths for shallow
Allow the user to explicitly adjust the depth for named urls/branches. The un-suffixed BB_GIT_SHALLOW_DEPTH is used as the default. Example usage: BB_GIT_SHALLOW_DEPTH = "1" BB_GIT_SHALLOW_DEPTH_doc = "0" BB_GIT_SHALLOW_DEPTH_meta = "0" (Bitbake rev: 9dfc517e5bcc6dd203a0ad685cc884676d2984c4) Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2')
-rw-r--r--bitbake/lib/bb/fetch2/git.py61
1 files changed, 40 insertions, 21 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index 0412f9ff51..250109bf9e 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -70,6 +70,7 @@ Supported SRC_URI options are:
70# with this program; if not, write to the Free Software Foundation, Inc., 70# with this program; if not, write to the Free Software Foundation, Inc.,
71# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 71# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
72 72
73import collections
73import errno 74import errno
74import os 75import os
75import re 76import re
@@ -178,12 +179,43 @@ class Git(FetchMethod):
178 if ud.bareclone: 179 if ud.bareclone:
179 ud.cloneflags += " --mirror" 180 ud.cloneflags += " --mirror"
180 181
182 ud.shallow = d.getVar("BB_GIT_SHALLOW") == "1"
183
184 depth_default = d.getVar("BB_GIT_SHALLOW_DEPTH")
185 if depth_default is not None:
186 try:
187 depth_default = int(depth_default or 0)
188 except ValueError:
189 raise bb.fetch2.FetchError("Invalid depth for BB_GIT_SHALLOW_DEPTH: %s" % depth_default)
190 else:
191 if depth_default < 0:
192 raise bb.fetch2.FetchError("Invalid depth for BB_GIT_SHALLOW_DEPTH: %s" % depth_default)
193 else:
194 depth_default = 1
195 ud.shallow_depths = collections.defaultdict(lambda: depth_default)
196
181 ud.branches = {} 197 ud.branches = {}
182 for pos, name in enumerate(ud.names): 198 for pos, name in enumerate(ud.names):
183 branch = branches[pos] 199 branch = branches[pos]
184 ud.branches[name] = branch 200 ud.branches[name] = branch
185 ud.unresolvedrev[name] = branch 201 ud.unresolvedrev[name] = branch
186 202
203 shallow_depth = d.getVar("BB_GIT_SHALLOW_DEPTH_%s" % name)
204 if shallow_depth is not None:
205 try:
206 shallow_depth = int(shallow_depth or 0)
207 except ValueError:
208 raise bb.fetch2.FetchError("Invalid depth for BB_GIT_SHALLOW_DEPTH_%s: %s" % (name, shallow_depth))
209 else:
210 if shallow_depth < 0:
211 raise bb.fetch2.FetchError("Invalid depth for BB_GIT_SHALLOW_DEPTH_%s: %s" % (name, shallow_depth))
212 ud.shallow_depths[name] = shallow_depth
213
214 if (ud.shallow and
215 all(ud.shallow_depths[n] == 0 for n in ud.names)):
216 # Shallow disabled for this URL
217 ud.shallow = False
218
187 if ud.usehead: 219 if ud.usehead:
188 ud.unresolvedrev['default'] = 'HEAD' 220 ud.unresolvedrev['default'] = 'HEAD'
189 221
@@ -222,23 +254,6 @@ class Git(FetchMethod):
222 mirrortarball = 'git2_%s.tar.gz' % gitsrcname 254 mirrortarball = 'git2_%s.tar.gz' % gitsrcname
223 ud.fullmirror = os.path.join(dl_dir, mirrortarball) 255 ud.fullmirror = os.path.join(dl_dir, mirrortarball)
224 ud.mirrortarballs = [mirrortarball] 256 ud.mirrortarballs = [mirrortarball]
225
226 ud.shallow = d.getVar("BB_GIT_SHALLOW") == "1"
227 if ud.shallow:
228 ud.shallow_depth = d.getVar("BB_GIT_SHALLOW_DEPTH")
229 if ud.shallow_depth is not None:
230 try:
231 ud.shallow_depth = int(ud.shallow_depth or 0)
232 except ValueError:
233 raise bb.fetch2.FetchError("Invalid depth for BB_GIT_SHALLOW_DEPTH: %s" % ud.shallow_depth)
234 else:
235 if not ud.shallow_depth:
236 ud.shallow = False
237 elif ud.shallow_depth < 0:
238 raise bb.fetch2.FetchError("Invalid depth for BB_GIT_SHALLOW_DEPTH: %s" % ud.shallow_depth)
239 else:
240 ud.shallow_depth = 1
241
242 if ud.shallow: 257 if ud.shallow:
243 tarballname = gitsrcname 258 tarballname = gitsrcname
244 if ud.bareclone: 259 if ud.bareclone:
@@ -246,10 +261,12 @@ class Git(FetchMethod):
246 261
247 for name, revision in sorted(ud.revisions.items()): 262 for name, revision in sorted(ud.revisions.items()):
248 tarballname = "%s_%s" % (tarballname, ud.revisions[name][:7]) 263 tarballname = "%s_%s" % (tarballname, ud.revisions[name][:7])
249 if not ud.nobranch: 264 depth = ud.shallow_depths[name]
250 tarballname = "%s-%s" % (tarballname, ud.branches[name]) 265 if depth:
266 tarballname = "%s-%s" % (tarballname, depth)
251 267
252 tarballname = "%s-%s" % (tarballname, ud.shallow_depth) 268 if not ud.nobranch:
269 tarballname = "%s_%s" % (tarballname, "_".join(sorted(ud.branches.values())).replace('/', '.'))
253 270
254 fetcher = self.__class__.__name__.lower() 271 fetcher = self.__class__.__name__.lower()
255 ud.shallowtarball = '%sshallow_%s.tar.gz' % (fetcher, tarballname) 272 ud.shallowtarball = '%sshallow_%s.tar.gz' % (fetcher, tarballname)
@@ -370,7 +387,9 @@ class Git(FetchMethod):
370 to_parse, shallow_branches = [], [] 387 to_parse, shallow_branches = [], []
371 for name in ud.names: 388 for name in ud.names:
372 revision = ud.revisions[name] 389 revision = ud.revisions[name]
373 to_parse.append('%s~%d^{}' % (revision, ud.shallow_depth - 1)) 390 depth = ud.shallow_depths[name]
391 if depth:
392 to_parse.append('%s~%d^{}' % (revision, depth - 1))
374 393
375 # For nobranch, we need a ref, otherwise the commits will be 394 # For nobranch, we need a ref, otherwise the commits will be
376 # removed, and for non-nobranch, we truncate the branch to our 395 # removed, and for non-nobranch, we truncate the branch to our