summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-02-10 15:14:49 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-02-10 15:24:31 +0000
commit59a08262aba2d2b9b8b299a2818fb4cfe13b9909 (patch)
treef0bbb476887e74ce2aade34bc0f62cff130ed250
parent5cac57179144e761eec6ccd8ffa43d5d9876fa04 (diff)
downloadpoky-59a08262aba2d2b9b8b299a2818fb4cfe13b9909.tar.gz
bitbake/fetch2/git: Write mirror tarballs if enabled and they don't exist, also set a default value for mirror tarball generation
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/fetch2/git.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index 4cb6693505..6d99406777 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -67,6 +67,7 @@ class Git(FetchMethod):
67 67
68 gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.')) 68 gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.'))
69 ud.mirrortarball = 'git2_%s.tar.gz' % (gitsrcname) 69 ud.mirrortarball = 'git2_%s.tar.gz' % (gitsrcname)
70 ud.fullmirror = os.path.join(data.getVar("DL_DIR", d, True), ud.mirrortarball)
70 ud.clonedir = os.path.join(data.expand('${GITDIR}', d), gitsrcname) 71 ud.clonedir = os.path.join(data.expand('${GITDIR}', d), gitsrcname)
71 72
72 ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git" 73 ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
@@ -76,6 +77,8 @@ class Git(FetchMethod):
76 if not ud.revisions[name] or len(ud.revisions[name]) != 40 or (False in [c in "abcdef0123456789" for c in ud.revisions[name]]): 77 if not ud.revisions[name] or len(ud.revisions[name]) != 40 or (False in [c in "abcdef0123456789" for c in ud.revisions[name]]):
77 ud.revisions[name] = self.latest_revision(ud.url, ud, d, name) 78 ud.revisions[name] = self.latest_revision(ud.url, ud, d, name)
78 79
80 ud.write_tarballs = (data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) or "0") != "0"
81
79 ud.localfile = ud.clonedir 82 ud.localfile = ud.clonedir
80 83
81 def localpath(self, url, ud, d): 84 def localpath(self, url, ud, d):
@@ -88,6 +91,8 @@ class Git(FetchMethod):
88 for name in ud.names: 91 for name in ud.names:
89 if not self._contains_ref(ud.revisions[name], d): 92 if not self._contains_ref(ud.revisions[name], d):
90 return True 93 return True
94 if ud.write_tarballs and not os.path.exists(ud.fullmirror):
95 return True
91 return False 96 return False
92 97
93 def try_premirror(self, u, ud, d): 98 def try_premirror(self, u, ud, d):
@@ -107,15 +112,13 @@ class Git(FetchMethod):
107 else: 112 else:
108 username = "" 113 username = ""
109 114
110 repofile = os.path.join(data.getVar("DL_DIR", d, True), ud.mirrortarball) 115 ud.repochanged = not os.path.exists(ud.fullmirror)
111
112 ud.repochanged = not os.path.exists(repofile)
113 116
114 # If the checkout doesn't exist and the mirror tarball does, extract it 117 # If the checkout doesn't exist and the mirror tarball does, extract it
115 if not os.path.exists(ud.clonedir) and os.path.exists(repofile): 118 if not os.path.exists(ud.clonedir) and os.path.exists(ud.fullmirror):
116 bb.mkdirhier(ud.clonedir) 119 bb.mkdirhier(ud.clonedir)
117 os.chdir(ud.clonedir) 120 os.chdir(ud.clonedir)
118 runfetchcmd("tar -xzf %s" % (repofile), d) 121 runfetchcmd("tar -xzf %s" % (ud.fullmirror), d)
119 122
120 # If the repo still doesn't exist, fallback to cloning it 123 # If the repo still doesn't exist, fallback to cloning it
121 if not os.path.exists(ud.clonedir): 124 if not os.path.exists(ud.clonedir):
@@ -144,13 +147,10 @@ class Git(FetchMethod):
144 147
145 def build_mirror_data(self, url, ud, d): 148 def build_mirror_data(self, url, ud, d):
146 # Generate a mirror tarball if needed 149 # Generate a mirror tarball if needed
147 repofile = os.path.join(data.getVar("DL_DIR", d, True), ud.mirrortarball) 150 if ud.write_tarballs and (ud.repochanged or not os.path.exists(ud.fullmirror)):
148 151 os.chdir(ud.clonedir)
149 os.chdir(ud.clonedir)
150 mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True)
151 if mirror_tarballs != "0" and ud.repochanged:
152 logger.info("Creating tarball of git repository") 152 logger.info("Creating tarball of git repository")
153 runfetchcmd("tar -czf %s %s" % (repofile, os.path.join(".") ), d) 153 runfetchcmd("tar -czf %s %s" % (ud.fullmirror, os.path.join(".") ), d)
154 154
155 def unpack(self, ud, destdir, d): 155 def unpack(self, ud, destdir, d):
156 """ unpack the downloaded src to destdir""" 156 """ unpack the downloaded src to destdir"""