bitbake/git.py: Move variable init into the localpath function

Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
This commit is contained in:
Richard Purdie 2009-12-11 17:09:26 +00:00
parent 7d937f0f4a
commit a94737f611
1 changed files with 17 additions and 19 deletions

View File

@ -45,6 +45,10 @@ class Git(Fetch):
ud.branch = ud.parm.get("branch", "master")
gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.'))
ud.mirrortarball = 'git_%s.tar.gz' % (gitsrcname)
ud.clonedir = os.path.join(data.expand('${GITDIR}', d), gitsrcname)
tag = Fetch.srcrev_internal_helper(ud, d)
if tag is True:
ud.tag = self.latest_revision(url, ud, d)
@ -70,24 +74,20 @@ class Git(Fetch):
else:
username = ""
gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.'))
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)
repofile = os.path.join(data.getVar("DL_DIR", d, 1), ud.mirrortarbal)
coname = '%s' % (ud.tag)
codir = os.path.join(repodir, coname)
codir = os.path.join(ud.clonedir, coname)
if not os.path.exists(repodir):
if Fetch.try_mirror(d, repofilename):
bb.mkdirhier(repodir)
os.chdir(repodir)
if not os.path.exists(ud.clonedir):
if Fetch.try_mirror(d, ud.mirrortarbal):
bb.mkdirhier(ud.clonedir)
os.chdir(ud.clonedir)
runfetchcmd("tar -xzf %s" % (repofile), d)
else:
runfetchcmd("git clone -n %s://%s%s%s %s" % (ud.proto, username, ud.host, ud.path, repodir), d)
runfetchcmd("git clone -n %s://%s%s%s %s" % (ud.proto, username, ud.host, ud.path, ud.clonedir), d)
os.chdir(repodir)
os.chdir(ud.clonedir)
# Remove all but the .git directory
if not self._contains_ref(ud.tag, d):
runfetchcmd("rm * -Rf", d)
@ -96,7 +96,7 @@ class Git(Fetch):
runfetchcmd("git prune-packed", d)
runfetchcmd("git pack-redundant --all | xargs -r rm", d)
os.chdir(repodir)
os.chdir(ud.clonedir)
mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True)
if mirror_tarballs != "0":
bb.msg.note(1, bb.msg.domain.Fetcher, "Creating tarball of git repository")
@ -106,7 +106,7 @@ class Git(Fetch):
bb.utils.prunedir(codir)
bb.mkdirhier(codir)
os.chdir(repodir)
os.chdir(ud.clonedir)
runfetchcmd("git read-tree %s" % (ud.tag), d)
runfetchcmd("git checkout-index -q -f --prefix=%s -a" % (os.path.join(codir, "git", "")), d)
@ -114,7 +114,7 @@ class Git(Fetch):
bb.msg.note(1, bb.msg.domain.Fetcher, "Creating tarball of git checkout")
runfetchcmd("tar -czf %s %s" % (ud.localpath, os.path.join(".", "*") ), d)
os.chdir(repodir)
os.chdir(ud.clonedir)
bb.utils.prunedir(codir)
def suppports_srcrev(self):
@ -157,8 +157,6 @@ class Git(Fetch):
We will have to get the updated revision.
"""
gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.'))
repodir = os.path.join(data.expand('${GITDIR}', d), gitsrcname)
key = "GIT_CACHED_REVISION-%s-%s" % (gitsrcname, ud.tag)
if bb.data.getVar(key, d):
@ -173,11 +171,11 @@ class Git(Fetch):
cwd = os.getcwd()
# Check if we have the rev already
if not os.path.exists(repodir):
if not os.path.exists(ud.clonedir):
print "no repo"
self.go(None, ud, d)
os.chdir(repodir)
os.chdir(ud.clonedir)
if not self._contains_ref(ud.tag, d):
self.go(None, ud, d)