]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
git fetcher: add support for rebaseable git repo
authorYu Ke <ke.yu@intel.com>
Sun, 15 May 2011 14:33:30 +0000 (22:33 +0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 17 May 2011 14:19:19 +0000 (15:19 +0100)
Some upstream git repo may rebase in the future, which means current
revision may disappear from the upstream repo after the rebase.

current git fetcher can not handle this case, because the git mirror
tar ball is per repo, and may also change in the rebase and lost the
current revision info.

To fix this issue, this patch
- add rebaseable tag in the SRC_URI
- for rebaseable repo, make git mirror tar ball per revision, in this
  case, even upstream rebase, the git mirror still has the current
  revision info.
- for rebaseable repo, generate mirror tar ball by default, since the
  repo may change in the future.

Signed-off-by: Yu Ke <ke.yu@intel.com>
lib/bb/fetch2/git.py

index 811acbf6c67ff8318a6fbd92652125703e334c99..82721c6cfaf66504b3f8c564c1db8e3c1e8721ce 100644 (file)
@@ -57,6 +57,11 @@ class Git(FetchMethod):
         if 'nocheckout' in ud.parm:
             ud.nocheckout = True
 
+        # rebaseable means the upstream git repo may rebase in the future,
+        # and current revision may disappear from upstream repo
+        # rebaseable is false by default. set rebaseable=1 in SRC_URI if rebaseable.
+        ud.rebaseable = ud.parm.get("rebaseable","0") == "1"
+
         branches = ud.parm.get("branch", "master").split(',')
         if len(branches) != len(ud.names):
             raise bb.fetch2.ParameterError("The number of name and branch parameters is not balanced", ud.url)
@@ -65,16 +70,9 @@ class Git(FetchMethod):
             branch = branches[ud.names.index(name)]
             ud.branches[name] = branch
 
-        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"
 
-        ud.write_tarballs = (data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) or "0") != "0"
-
-        ud.localfile = ud.clonedir
+        ud.write_tarballs = ((data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) or "0") != "0") or ud.rebaseable
 
         ud.setup_revisons(d)
 
@@ -84,6 +82,20 @@ class Git(FetchMethod):
                 ud.branches[name] = ud.revisions[name]
                 ud.revisions[name] = self.latest_revision(ud.url, ud, d, name)
 
+        gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.'))
+        # for rebaseable git repo, it is necessary to keep mirror tar ball
+        # per revision, so that even the revision disappears from the
+        # upstream repo in the future, the mirror will remain intact and still
+        # contains the revision
+        if ud.rebaseable:
+            for name in ud.names:
+                gitsrcname = gitsrcname + '_' + ud.revisions[name]
+        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.localfile = ud.clonedir
+
     def localpath(self, url, ud, d):
         return ud.clonedir