]> code.ossystems Code Review - openembedded-core.git/commitdiff
bitbake/fetch2/git: Write mirror tarballs if enabled and they don't exist, also set...
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 10 Feb 2011 15:14:49 +0000 (15:14 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 10 Feb 2011 15:24:31 +0000 (15:24 +0000)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bitbake/lib/bb/fetch2/git.py

index 4cb6693505ca1d5b41466bf3bb1401b6b42e3adc..6d9940677706b59ded1e9771a2d8cd2d1098335e 100644 (file)
@@ -67,6 +67,7 @@ class Git(FetchMethod):
 
         gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.'))
         ud.mirrortarball = 'git2_%s.tar.gz' % (gitsrcname)
+        ud.fullmirror = os.path.join(data.getVar("DL_DIR", d, True), ud.mirrortarball)
         ud.clonedir = os.path.join(data.expand('${GITDIR}', d), gitsrcname)
 
         ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
@@ -76,6 +77,8 @@ class Git(FetchMethod):
             if not ud.revisions[name] or len(ud.revisions[name]) != 40  or (False in [c in "abcdef0123456789" for c in ud.revisions[name]]):
                 ud.revisions[name] = self.latest_revision(ud.url, ud, d, name)
 
+        ud.write_tarballs = (data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) or "0") != "0"
+
         ud.localfile = ud.clonedir
 
     def localpath(self, url, ud, d):
@@ -88,6 +91,8 @@ class Git(FetchMethod):
         for name in ud.names:
             if not self._contains_ref(ud.revisions[name], d):
                 return True
+        if ud.write_tarballs and not os.path.exists(ud.fullmirror):
+            return True
         return False
 
     def try_premirror(self, u, ud, d):
@@ -107,15 +112,13 @@ class Git(FetchMethod):
         else:
             username = ""
 
-        repofile = os.path.join(data.getVar("DL_DIR", d, True), ud.mirrortarball)
-
-        ud.repochanged = not os.path.exists(repofile)
+        ud.repochanged = not os.path.exists(ud.fullmirror)
 
         # If the checkout doesn't exist and the mirror tarball does, extract it
-        if not os.path.exists(ud.clonedir) and os.path.exists(repofile):
+        if not os.path.exists(ud.clonedir) and os.path.exists(ud.fullmirror):
             bb.mkdirhier(ud.clonedir)
             os.chdir(ud.clonedir)
-            runfetchcmd("tar -xzf %s" % (repofile), d)
+            runfetchcmd("tar -xzf %s" % (ud.fullmirror), d)
 
         # If the repo still doesn't exist, fallback to cloning it
         if not os.path.exists(ud.clonedir):
@@ -144,13 +147,10 @@ class Git(FetchMethod):
 
     def build_mirror_data(self, url, ud, d):
         # Generate a mirror tarball if needed
-        repofile = os.path.join(data.getVar("DL_DIR", d, True), ud.mirrortarball)
-
-        os.chdir(ud.clonedir)
-        mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True)
-        if mirror_tarballs != "0" and ud.repochanged:
+        if ud.write_tarballs and (ud.repochanged or not os.path.exists(ud.fullmirror)):
+            os.chdir(ud.clonedir)
             logger.info("Creating tarball of git repository")
-            runfetchcmd("tar -czf %s %s" % (repofile, os.path.join(".") ), d)
+            runfetchcmd("tar -czf %s %s" % (ud.fullmirror, os.path.join(".") ), d)
 
     def unpack(self, ud, destdir, d):
         """ unpack the downloaded src to destdir"""