summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/hg.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/fetch2/hg.py')
-rw-r--r--bitbake/lib/bb/fetch2/hg.py28
1 files changed, 10 insertions, 18 deletions
diff --git a/bitbake/lib/bb/fetch2/hg.py b/bitbake/lib/bb/fetch2/hg.py
index 3b743ff51d..20df8016da 100644
--- a/bitbake/lib/bb/fetch2/hg.py
+++ b/bitbake/lib/bb/fetch2/hg.py
@@ -169,25 +169,22 @@ class Hg(FetchMethod):
169 # If the checkout doesn't exist and the mirror tarball does, extract it 169 # If the checkout doesn't exist and the mirror tarball does, extract it
170 if not os.path.exists(ud.pkgdir) and os.path.exists(ud.fullmirror): 170 if not os.path.exists(ud.pkgdir) and os.path.exists(ud.fullmirror):
171 bb.utils.mkdirhier(ud.pkgdir) 171 bb.utils.mkdirhier(ud.pkgdir)
172 os.chdir(ud.pkgdir) 172 runfetchcmd("tar -xzf %s" % (ud.fullmirror), d, workdir=ud.pkgdir)
173 runfetchcmd("tar -xzf %s" % (ud.fullmirror), d)
174 173
175 if os.access(os.path.join(ud.moddir, '.hg'), os.R_OK): 174 if os.access(os.path.join(ud.moddir, '.hg'), os.R_OK):
176 # Found the source, check whether need pull 175 # Found the source, check whether need pull
177 updatecmd = self._buildhgcommand(ud, d, "update") 176 updatecmd = self._buildhgcommand(ud, d, "update")
178 os.chdir(ud.moddir)
179 logger.debug(1, "Running %s", updatecmd) 177 logger.debug(1, "Running %s", updatecmd)
180 try: 178 try:
181 runfetchcmd(updatecmd, d) 179 runfetchcmd(updatecmd, d, workdir=ud.moddir)
182 except bb.fetch2.FetchError: 180 except bb.fetch2.FetchError:
183 # Runnning pull in the repo 181 # Runnning pull in the repo
184 pullcmd = self._buildhgcommand(ud, d, "pull") 182 pullcmd = self._buildhgcommand(ud, d, "pull")
185 logger.info("Pulling " + ud.url) 183 logger.info("Pulling " + ud.url)
186 # update sources there 184 # update sources there
187 os.chdir(ud.moddir)
188 logger.debug(1, "Running %s", pullcmd) 185 logger.debug(1, "Running %s", pullcmd)
189 bb.fetch2.check_network_access(d, pullcmd, ud.url) 186 bb.fetch2.check_network_access(d, pullcmd, ud.url)
190 runfetchcmd(pullcmd, d) 187 runfetchcmd(pullcmd, d, workdir=ud.moddir)
191 try: 188 try:
192 os.unlink(ud.fullmirror) 189 os.unlink(ud.fullmirror)
193 except OSError as exc: 190 except OSError as exc:
@@ -200,17 +197,15 @@ class Hg(FetchMethod):
200 logger.info("Fetch " + ud.url) 197 logger.info("Fetch " + ud.url)
201 # check out sources there 198 # check out sources there
202 bb.utils.mkdirhier(ud.pkgdir) 199 bb.utils.mkdirhier(ud.pkgdir)
203 os.chdir(ud.pkgdir)
204 logger.debug(1, "Running %s", fetchcmd) 200 logger.debug(1, "Running %s", fetchcmd)
205 bb.fetch2.check_network_access(d, fetchcmd, ud.url) 201 bb.fetch2.check_network_access(d, fetchcmd, ud.url)
206 runfetchcmd(fetchcmd, d) 202 runfetchcmd(fetchcmd, d, workdir=ud.pkgdir)
207 203
208 # Even when we clone (fetch), we still need to update as hg's clone 204 # Even when we clone (fetch), we still need to update as hg's clone
209 # won't checkout the specified revision if its on a branch 205 # won't checkout the specified revision if its on a branch
210 updatecmd = self._buildhgcommand(ud, d, "update") 206 updatecmd = self._buildhgcommand(ud, d, "update")
211 os.chdir(ud.moddir)
212 logger.debug(1, "Running %s", updatecmd) 207 logger.debug(1, "Running %s", updatecmd)
213 runfetchcmd(updatecmd, d) 208 runfetchcmd(updatecmd, d, workdir=ud.moddir)
214 209
215 def clean(self, ud, d): 210 def clean(self, ud, d):
216 """ Clean the hg dir """ 211 """ Clean the hg dir """
@@ -246,10 +241,9 @@ class Hg(FetchMethod):
246 if os.path.islink(ud.fullmirror): 241 if os.path.islink(ud.fullmirror):
247 os.unlink(ud.fullmirror) 242 os.unlink(ud.fullmirror)
248 243
249 os.chdir(ud.pkgdir)
250 logger.info("Creating tarball of hg repository") 244 logger.info("Creating tarball of hg repository")
251 runfetchcmd("tar -czf %s %s" % (ud.fullmirror, ud.module), d) 245 runfetchcmd("tar -czf %s %s" % (ud.fullmirror, ud.module), d, workdir=ud.pkgdir)
252 runfetchcmd("touch %s.done" % (ud.fullmirror), d) 246 runfetchcmd("touch %s.done" % (ud.fullmirror), d, workdir=ud.pkgdir)
253 247
254 def localpath(self, ud, d): 248 def localpath(self, ud, d):
255 return ud.pkgdir 249 return ud.pkgdir
@@ -269,10 +263,8 @@ class Hg(FetchMethod):
269 logger.debug(2, "Unpack: creating new hg repository in '" + codir + "'") 263 logger.debug(2, "Unpack: creating new hg repository in '" + codir + "'")
270 runfetchcmd("%s init %s" % (ud.basecmd, codir), d) 264 runfetchcmd("%s init %s" % (ud.basecmd, codir), d)
271 logger.debug(2, "Unpack: updating source in '" + codir + "'") 265 logger.debug(2, "Unpack: updating source in '" + codir + "'")
272 os.chdir(codir) 266 runfetchcmd("%s pull %s" % (ud.basecmd, ud.moddir), d, workdir=codir)
273 runfetchcmd("%s pull %s" % (ud.basecmd, ud.moddir), d) 267 runfetchcmd("%s up -C %s" % (ud.basecmd, revflag), d, workdir=codir)
274 runfetchcmd("%s up -C %s" % (ud.basecmd, revflag), d)
275 else: 268 else:
276 logger.debug(2, "Unpack: extracting source to '" + codir + "'") 269 logger.debug(2, "Unpack: extracting source to '" + codir + "'")
277 os.chdir(ud.moddir) 270 runfetchcmd("%s archive -t files %s %s" % (ud.basecmd, revflag, codir), d, workdir=ud.moddir)
278 runfetchcmd("%s archive -t files %s %s" % (ud.basecmd, revflag, codir), d)