summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/bb/fetch2/git.py27
-rw-r--r--bitbake/lib/bb/tests/fetch.py4
2 files changed, 21 insertions, 10 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index e8ddf2c761..51b616bad7 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -516,13 +516,24 @@ class Git(FetchMethod):
516 def unpack(self, ud, destdir, d): 516 def unpack(self, ud, destdir, d):
517 """ unpack the downloaded src to destdir""" 517 """ unpack the downloaded src to destdir"""
518 518
519 subdir = ud.parm.get("subpath", "") 519 subdir = ud.parm.get("subdir")
520 if subdir != "": 520 subpath = ud.parm.get("subpath")
521 readpathspec = ":%s" % subdir 521 readpathspec = ""
522 def_destsuffix = "%s/" % os.path.basename(subdir.rstrip('/')) 522 def_destsuffix = "git/"
523 else: 523
524 readpathspec = "" 524 if subpath:
525 def_destsuffix = "git/" 525 readpathspec = ":%s" % subpath
526 def_destsuffix = "%s/" % os.path.basename(subpath.rstrip('/'))
527
528 if subdir:
529 # If 'subdir' param exists, create a dir and use it as destination for unpack cmd
530 if os.path.isabs(subdir):
531 if not os.path.realpath(subdir).startswith(os.path.realpath(destdir)):
532 raise bb.fetch2.UnpackError("subdir argument isn't a subdirectory of unpack root %s" % destdir, ud.url)
533 destdir = subdir
534 else:
535 destdir = os.path.join(destdir, subdir)
536 def_destsuffix = ""
526 537
527 destsuffix = ud.parm.get("destsuffix", def_destsuffix) 538 destsuffix = ud.parm.get("destsuffix", def_destsuffix)
528 destdir = ud.destdir = os.path.join(destdir, destsuffix) 539 destdir = ud.destdir = os.path.join(destdir, destsuffix)
@@ -569,7 +580,7 @@ class Git(FetchMethod):
569 bb.note("Repository %s has LFS content but it is not being fetched" % (repourl)) 580 bb.note("Repository %s has LFS content but it is not being fetched" % (repourl))
570 581
571 if not ud.nocheckout: 582 if not ud.nocheckout:
572 if subdir != "": 583 if subpath:
573 runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.revisions[ud.names[0]], readpathspec), d, 584 runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.revisions[ud.names[0]], readpathspec), d,
574 workdir=destdir) 585 workdir=destdir)
575 runfetchcmd("%s checkout-index -q -f -a" % ud.basecmd, d, workdir=destdir) 586 runfetchcmd("%s checkout-index -q -f -a" % ud.basecmd, d, workdir=destdir)
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index a008e7cc5b..e1638bc478 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -2157,7 +2157,7 @@ class GitLfsTest(FetcherTest):
2157 def test_lfs_enabled(self): 2157 def test_lfs_enabled(self):
2158 import shutil 2158 import shutil
2159 2159
2160 uri = 'git://%s;protocol=file;subdir=${S};lfs=1' % self.srcdir 2160 uri = 'git://%s;protocol=file;lfs=1' % self.srcdir
2161 self.d.setVar('SRC_URI', uri) 2161 self.d.setVar('SRC_URI', uri)
2162 2162
2163 # Careful: suppress initial attempt at downloading until 2163 # Careful: suppress initial attempt at downloading until
@@ -2182,7 +2182,7 @@ class GitLfsTest(FetcherTest):
2182 def test_lfs_disabled(self): 2182 def test_lfs_disabled(self):
2183 import shutil 2183 import shutil
2184 2184
2185 uri = 'git://%s;protocol=file;subdir=${S};lfs=0' % self.srcdir 2185 uri = 'git://%s;protocol=file;lfs=0' % self.srcdir
2186 self.d.setVar('SRC_URI', uri) 2186 self.d.setVar('SRC_URI', uri)
2187 2187
2188 # In contrast to test_lfs_enabled(), allow the implicit download 2188 # In contrast to test_lfs_enabled(), allow the implicit download