summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py2
-rw-r--r--bitbake/lib/bb/fetch2/git.py2
-rw-r--r--bitbake/lib/bb/fetch2/gitsm.py78
3 files changed, 81 insertions, 1 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 4cfe08957d..1bf67ddbdc 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -1497,6 +1497,7 @@ class Fetch(object):
1497 1497
1498from . import cvs 1498from . import cvs
1499from . import git 1499from . import git
1500from . import gitsm
1500from . import local 1501from . import local
1501from . import svn 1502from . import svn
1502from . import wget 1503from . import wget
@@ -1513,6 +1514,7 @@ methods.append(local.Local())
1513methods.append(wget.Wget()) 1514methods.append(wget.Wget())
1514methods.append(svn.Svn()) 1515methods.append(svn.Svn())
1515methods.append(git.Git()) 1516methods.append(git.Git())
1517methods.append(gitsm.GitSM())
1516methods.append(cvs.Cvs()) 1518methods.append(cvs.Cvs())
1517methods.append(svk.Svk()) 1519methods.append(svk.Svk())
1518methods.append(ssh.SSH()) 1520methods.append(ssh.SSH())
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index 63ff00b165..052802e602 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -234,7 +234,7 @@ class Git(FetchMethod):
234 def_destsuffix = "git/" 234 def_destsuffix = "git/"
235 235
236 destsuffix = ud.parm.get("destsuffix", def_destsuffix) 236 destsuffix = ud.parm.get("destsuffix", def_destsuffix)
237 destdir = os.path.join(destdir, destsuffix) 237 destdir = ud.destdir = os.path.join(destdir, destsuffix)
238 if os.path.exists(destdir): 238 if os.path.exists(destdir):
239 bb.utils.prunedir(destdir) 239 bb.utils.prunedir(destdir)
240 240
diff --git a/bitbake/lib/bb/fetch2/gitsm.py b/bitbake/lib/bb/fetch2/gitsm.py
new file mode 100644
index 0000000000..572b637c9a
--- /dev/null
+++ b/bitbake/lib/bb/fetch2/gitsm.py
@@ -0,0 +1,78 @@
1# ex:ts=4:sw=4:sts=4:et
2# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
3"""
4BitBake 'Fetch' git submodules implementation
5"""
6
7# Copyright (C) 2013 Richard Purdie
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License version 2 as
11# published by the Free Software Foundation.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License along
19# with this program; if not, write to the Free Software Foundation, Inc.,
20# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22import os
23import bb
24from bb import data
25from bb.fetch2.git import Git
26from bb.fetch2 import runfetchcmd
27from bb.fetch2 import logger
28
29class GitSM(Git):
30 def supports(self, url, ud, d):
31 """
32 Check to see if a given url can be fetched with git.
33 """
34 return ud.type in ['gitsm']
35
36 def uses_submodules(self, ud, d):
37 for name in ud.names:
38 try:
39 runfetchcmd("%s show %s:.gitmodules" % (ud.basecmd, ud.revisions[name]), d, quiet=True)
40 return True
41 except bb.fetch.FetchError:
42 pass
43 return False
44
45 def update_submodules(self, u, ud, d):
46 # We have to convert bare -> full repo, do the submodule bit, then convert back
47 tmpclonedir = ud.clonedir + ".tmp"
48 gitdir = tmpclonedir + os.sep + ".git"
49 bb.utils.remove(tmpclonedir, True)
50 os.mkdir(tmpclonedir)
51 os.rename(ud.clonedir, gitdir)
52 runfetchcmd("sed " + gitdir + "/config -i -e 's/bare.*=.*true/bare = false/'", d)
53 os.chdir(tmpclonedir)
54 runfetchcmd("git reset --hard", d)
55 runfetchcmd("git submodule init", d)
56 runfetchcmd("git submodule update", d)
57 runfetchcmd("sed " + gitdir + "/config -i -e 's/bare.*=.*false/bare = true/'", d)
58 os.rename(gitdir, ud.clonedir,)
59 bb.utils.remove(tmpclonedir, True)
60
61 def download(self, loc, ud, d):
62 Git.download(self, loc, ud, d)
63
64 os.chdir(ud.clonedir)
65 submodules = self.uses_submodules(ud, d)
66 if submodules:
67 self.update_submodules(loc, ud, d)
68
69 def unpack(self, ud, destdir, d):
70 Git.unpack(self, ud, destdir, d)
71
72 os.chdir(ud.destdir)
73 submodules = self.uses_submodules(ud, d)
74 if submodules:
75 runfetchcmd("cp -r " + ud.clonedir + "/modules " + ud.destdir + "/.git/", d)
76 runfetchcmd("git submodule init", d)
77 runfetchcmd("git submodule update", d)
78