summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2006-03-01 23:06:59 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2006-03-01 23:06:59 +0000
commitc40815faf4e83d77bd7febf93edec435892357be (patch)
tree3c3fd625becc5ead049217f40f62860dc402783e
parent4f807c93f8f72eb73b8600d1f73a3e26014a3167 (diff)
downloadbitbake-c40815faf4e83d77bd7febf93edec435892357be.tar.gz
bitbake/lib/bb/fetch/git.py:
Improvements to the git fetcher including using the src mirrors, updates to use modern git commands, making the code more efficent and remove some old debug.
-rw-r--r--ChangeLog1
-rw-r--r--lib/bb/fetch/git.py81
2 files changed, 43 insertions, 39 deletions
diff --git a/ChangeLog b/ChangeLog
index 05b7332b3..3dfba1ed8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@ Changes in BitBake 1.3.x:
- Fix a RDEPENDS parsing bug in utils:explode_deps()
- Update git fetcher behaviour to match git changes
- ASSUME_PROVIDED allowed to include runtime packages
+ - git fetcher cleanup and efficency improvements
Changes in BitBake 1.3.3:
- Create a new Fetcher module to ease the
diff --git a/lib/bb/fetch/git.py b/lib/bb/fetch/git.py
index f38709d2b..439d52218 100644
--- a/lib/bb/fetch/git.py
+++ b/lib/bb/fetch/git.py
@@ -58,6 +58,28 @@ def gettag(parm):
return tag
+def getprotocol(parm):
+ if 'protocol' in parm:
+ proto = parm['protocol']
+ else:
+ proto = ""
+ if not proto:
+ proto = "rsync"
+
+ return proto
+
+def localfile(url, d):
+ """Return the filename to cache the checkout in"""
+ (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(url, d))
+
+ #if user sets localpath for file, use it instead.
+ if "localpath" in parm:
+ return parm["localpath"]
+
+ tag = gettag(parm)
+
+ return data.expand('git_%s%s_%s.tar.gz' % (host, path.replace('/', '.'), tag), d)
+
class Git(Fetch):
"""Class to fetch a module or modules from git repositories"""
def supports(url, d):
@@ -69,17 +91,8 @@ class Git(Fetch):
supports = staticmethod(supports)
def localpath(url, d):
- (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(url, d))
-
- #if user sets localpath for file, use it instead.
- if "localpath" in parm:
- return parm["localpath"]
- tag = gettag(parm)
-
- localname = data.expand('git_%s%s_%s.tar.gz' % (host, path.replace('/', '.'), tag), d)
-
- return os.path.join(data.getVar("DL_DIR", d, 1),data.expand('%s' % (localname), d))
+ return os.path.join(data.getVar("DL_DIR", d, 1), localfile(url, d))
localpath = staticmethod(localpath)
@@ -92,10 +105,12 @@ class Git(Fetch):
(type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(loc, d))
tag = gettag(parm)
+ proto = getprotocol(parm)
gitsrcname = '%s%s' % (host, path.replace('/', '.'))
- repofile = os.path.join(data.getVar("DL_DIR", d, 1), 'git_%s.tar.gz' % (gitsrcname))
+ repofilename = 'git_%s.tar.gz' % (gitsrcname)
+ repofile = os.path.join(data.getVar("DL_DIR", d, 1), repofilename)
repodir = os.path.join(data.expand('${GITDIR}', d), gitsrcname)
coname = '%s' % (tag)
@@ -103,49 +118,37 @@ class Git(Fetch):
cofile = self.localpath(loc, d)
- # Always update to current if tag=="master"
- #if os.access(cofile, os.R_OK) and (tag != "master"):
- if os.access(cofile, os.R_OK):
- bb.debug(1, "%s already exists, skipping git checkout." % cofile)
+ # tag=="master" must always update
+ if (tag != "master") and Fetch.try_mirror(d, localfile(loc, d)):
+ bb.debug(1, "%s already exists (or was stashed). Skipping git checkout." % cofile)
continue
-# Still Need to add GIT_TARBALL_STASH Support...
-# if Fetch.try_mirror(d, tarfn):
-# continue
-
- #if os.path.exists(repodir):
- #prunedir(repodir)
-
- #print("Changing to %s" % repodir)
+ if not os.path.exists(repodir):
+ if Fetch.try_mirror(d, repofilename):
+ bb.mkdirhier(repodir)
+ os.chdir(repodir)
+ rungitcmd("tar -xzf %s" % (repofile),d)
+ else:
+ rungitcmd("git clone %s://%s%s %s" % (proto, host, path, repodir),d)
- if os.access(repofile, os.R_OK):
- bb.mkdirhier(repodir)
- os.chdir(repodir)
- rungitcmd("tar -xzf %s" % (repofile),d)
- else:
- rungitcmd("git clone rsync://%s%s %s" % (host, path, repodir),d)
-
- rungitcmd("rsync -a --verbose --stats --progress rsync://%s%s/ %s" % (host, path, os.path.join(repodir, ".git", "")),d)
-
- #print("Changing to %s" % repodir)
os.chdir(repodir)
- rungitcmd("git pull rsync://%s%s" % (host, path),d)
+ rungitcmd("git pull %s://%s%s" % (proto, host, path),d)
+ rungitcmd("git pull --tags %s://%s%s" % (proto, host, path),d)
+ # old method of downloading tags
+ #rungitcmd("rsync -a --verbose --stats --progress rsync://%s%s/ %s" % (host, path, os.path.join(repodir, ".git", "")),d)
- #print("Changing to %s" % repodir)
os.chdir(repodir)
+ bb.note("Creating tarball of git repository")
rungitcmd("tar -czf %s %s" % (repofile, os.path.join(".", ".git", "*") ),d)
if os.path.exists(codir):
prunedir(codir)
- #print("Changing to %s" % repodir)
bb.mkdirhier(codir)
os.chdir(repodir)
rungitcmd("git read-tree %s" % (tag),d)
-
rungitcmd("git checkout-index -q -f --prefix=%s -a" % (os.path.join(codir, "git", "")),d)
- #print("Changing to %s" % codir)
os.chdir(codir)
+ bb.note("Creating tarball of git checkout")
rungitcmd("tar -czf %s %s" % (cofile, os.path.join(".", "*") ),d)
-