summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2015-06-01 22:49:11 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-06-27 22:51:20 +0100
commit43c6e8c0dd7a7139b476b94d69a0252c639393bf (patch)
tree72042a758f073b036e7ca99666e3c860a4e4acc9 /bitbake
parent3836d9b4ab0c74985195b9af58b1bd95bc0b6726 (diff)
downloadpoky-43c6e8c0dd7a7139b476b94d69a0252c639393bf.tar.gz
bitbake: bitbake: fetch2/hg.py: fix unpack error and mirror tarball
Fixed: * do_unpack error: abort: repository DL_DIR/hg/vim.googlecode.com/hg/vim not found! * The mirror tarball doesn't work - Add the build_mirror_data to create the tarball - Unpack the mirror tarball when needed * The hg files will put in the dir like git: DL_DIR/hg, it was DL_DIR/hg/path/to/src/uri/path in the past. (Bitbake rev: 378647281ae883dd726f1e1b775dd35ef6a0e8d1) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch2/hg.py79
1 files changed, 66 insertions, 13 deletions
diff --git a/bitbake/lib/bb/fetch2/hg.py b/bitbake/lib/bb/fetch2/hg.py
index cdef4aa110..d978630bac 100644
--- a/bitbake/lib/bb/fetch2/hg.py
+++ b/bitbake/lib/bb/fetch2/hg.py
@@ -59,10 +59,12 @@ class Hg(FetchMethod):
59 59
60 ud.module = ud.parm["module"] 60 ud.module = ud.parm["module"]
61 61
62 # Create paths to mercurial checkouts 62 if 'protocol' in ud.parm:
63 relpath = self._strip_leading_slashes(ud.path) 63 ud.proto = ud.parm['protocol']
64 ud.pkgdir = os.path.join(data.expand('${HGDIR}', d), ud.host, relpath) 64 elif not ud.host:
65 ud.moddir = os.path.join(ud.pkgdir, ud.module) 65 ud.proto = 'file'
66 else:
67 ud.proto = "hg"
66 68
67 ud.setup_revisons(d) 69 ud.setup_revisons(d)
68 70
@@ -71,10 +73,20 @@ class Hg(FetchMethod):
71 elif not ud.revision: 73 elif not ud.revision:
72 ud.revision = self.latest_revision(ud, d) 74 ud.revision = self.latest_revision(ud, d)
73 75
74 ud.localfile = ud.moddir 76 # Create paths to mercurial checkouts
77 hgsrcname = '%s_%s_%s' % (ud.module.replace('/', '.'), \
78 ud.host, ud.path.replace('/', '.'))
79 ud.mirrortarball = 'hg_%s.tar.gz' % hgsrcname
80 ud.fullmirror = os.path.join(d.getVar("DL_DIR", True), ud.mirrortarball)
75 81
82 hgdir = d.getVar("HGDIR", True) or (d.getVar("DL_DIR", True) + "/hg/")
83 ud.pkgdir = os.path.join(hgdir, hgsrcname)
84 ud.moddir = os.path.join(ud.pkgdir, ud.module)
85 ud.localfile = ud.moddir
76 ud.basecmd = data.getVar("FETCHCMD_hg", d, True) or "/usr/bin/env hg" 86 ud.basecmd = data.getVar("FETCHCMD_hg", d, True) or "/usr/bin/env hg"
77 87
88 ud.write_tarballs = d.getVar("BB_GENERATE_MIRROR_TARBALLS", True)
89
78 def need_update(self, ud, d): 90 def need_update(self, ud, d):
79 revTag = ud.parm.get('rev', 'tip') 91 revTag = ud.parm.get('rev', 'tip')
80 if revTag == "tip": 92 if revTag == "tip":
@@ -83,6 +95,15 @@ class Hg(FetchMethod):
83 return True 95 return True
84 return False 96 return False
85 97
98 def try_premirror(self, ud, d):
99 # If we don't do this, updating an existing checkout with only premirrors
100 # is not possible
101 if d.getVar("BB_FETCH_PREMIRRORONLY", True) is not None:
102 return True
103 if os.path.exists(ud.moddir):
104 return False
105 return True
106
86 def _buildhgcommand(self, ud, d, command): 107 def _buildhgcommand(self, ud, d, command):
87 """ 108 """
88 Build up an hg commandline based on ud 109 Build up an hg commandline based on ud
@@ -142,18 +163,36 @@ class Hg(FetchMethod):
142 def download(self, ud, d): 163 def download(self, ud, d):
143 """Fetch url""" 164 """Fetch url"""
144 165
166 ud.repochanged = not os.path.exists(ud.fullmirror)
167
145 logger.debug(2, "Fetch: checking for module directory '" + ud.moddir + "'") 168 logger.debug(2, "Fetch: checking for module directory '" + ud.moddir + "'")
146 169
170 # If the checkout doesn't exist and the mirror tarball does, extract it
171 if not os.path.exists(ud.pkgdir) and os.path.exists(ud.fullmirror):
172 bb.utils.mkdirhier(ud.pkgdir)
173 os.chdir(ud.pkgdir)
174 runfetchcmd("tar -xzf %s" % (ud.fullmirror), d)
175
147 if os.access(os.path.join(ud.moddir, '.hg'), os.R_OK): 176 if os.access(os.path.join(ud.moddir, '.hg'), os.R_OK):
148 updatecmd = self._buildhgcommand(ud, d, "pull") 177 # Found the source, check whether need pull
149 logger.info("Update " + ud.url) 178 updatecmd = self._buildhgcommand(ud, d, "update")
150 # update sources there
151 os.chdir(ud.moddir) 179 os.chdir(ud.moddir)
152 logger.debug(1, "Running %s", updatecmd) 180 logger.debug(1, "Running %s", updatecmd)
153 bb.fetch2.check_network_access(d, updatecmd, ud.url) 181 try:
154 runfetchcmd(updatecmd, d) 182 runfetchcmd(updatecmd, d)
155 183 except bb.fetch2.FetchError:
156 else: 184 # Runnning pull in the repo
185 pullcmd = self._buildhgcommand(ud, d, "pull")
186 logger.info("Pulling " + ud.url)
187 # update sources there
188 os.chdir(ud.moddir)
189 logger.debug(1, "Running %s", pullcmd)
190 bb.fetch2.check_network_access(d, pullcmd, ud.url)
191 runfetchcmd(pullcmd, d)
192 ud.repochanged = True
193
194 # No source found, clone it.
195 if not os.path.exists(ud.moddir):
157 fetchcmd = self._buildhgcommand(ud, d, "fetch") 196 fetchcmd = self._buildhgcommand(ud, d, "fetch")
158 logger.info("Fetch " + ud.url) 197 logger.info("Fetch " + ud.url)
159 # check out sources there 198 # check out sources there
@@ -174,6 +213,8 @@ class Hg(FetchMethod):
174 """ Clean the hg dir """ 213 """ Clean the hg dir """
175 214
176 bb.utils.remove(ud.localpath, True) 215 bb.utils.remove(ud.localpath, True)
216 bb.utils.remove(ud.fullmirror)
217 bb.utils.remove(ud.fullmirror + ".done")
177 218
178 def supports_srcrev(self): 219 def supports_srcrev(self):
179 return True 220 return True
@@ -195,8 +236,20 @@ class Hg(FetchMethod):
195 """ 236 """
196 return "hg:" + ud.moddir 237 return "hg:" + ud.moddir
197 238
239 def build_mirror_data(self, ud, d):
240 # Generate a mirror tarball if needed
241 if ud.write_tarballs == "1" and (ud.repochanged or not os.path.exists(ud.fullmirror)):
242 # it's possible that this symlink points to read-only filesystem with PREMIRROR
243 if os.path.islink(ud.fullmirror):
244 os.unlink(ud.fullmirror)
245
246 os.chdir(ud.pkgdir)
247 logger.info("Creating tarball of hg repository")
248 runfetchcmd("tar -czf %s %s" % (ud.fullmirror, ud.module), d)
249 runfetchcmd("touch %s.done" % (ud.fullmirror), d)
250
198 def localpath(self, ud, d): 251 def localpath(self, ud, d):
199 return ud.moddir 252 return ud.pkgdir
200 253
201 def unpack(self, ud, destdir, d): 254 def unpack(self, ud, destdir, d):
202 """ 255 """