for name in dirs:
os.rmdir(os.path.join(root, name))
-def rungitcmd(cmd,d):
+def runfetchcmd(cmd, d, quiet = False):
bb.debug(1, "Running %s" % cmd)
line = stdout_handle.readline()
if not line:
break
- print line
+ if not quiet:
+ print line
output += line
status = stdout_handle.close() or 0
return output
def contains_ref(tag, d):
- output = rungitcmd("git log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % tag, d)
+ output = runfetchcmd("git log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % tag, d, True)
return output.split()[0] != "0"
-def latest_revision(proto, user, host, path, branch):
+def latest_revision(proto, user, host, path, branch, d):
"""
Compute the HEAD revision for the url
"""
else:
username = ""
- output = rungitcmd("git ls-remote %s://%s%s%s %s" % (proto, username, host, path, branch), d)
+ output = runfetchcmd("git ls-remote %s://%s%s%s %s" % (proto, username, host, path, branch), d, True)
return output.split()[0]
def getbranch(parm):
return branch
-def gettag(parm, proto, user, host, path, branch):
+def gettag(parm, proto, user, host, path, branch, d):
if 'tag' in parm:
tag = parm['tag']
else:
- tag = latest_revision(proto, user, host, path, branch)
+ tag = latest_revision(proto, user, host, path, branch, d)
if not tag or tag == "master":
- tag = latest_revision(proto, user, host, path, branch)
+ tag = latest_revision(proto, user, host, path, branch, d)
return tag
proto = getprotocol(parm)
branch = getbranch(parm)
- tag = gettag(parm, proto, user, host, path, branch)
+ tag = gettag(parm, proto, user, host, path, branch, d)
return data.expand('git_%s%s_%s.tar.gz' % (host, path.replace('/', '.'), tag), d)
proto = getprotocol(parm)
branch = getbranch(parm)
- tag = gettag(parm, proto, user, host, path, branch)
+ tag = gettag(parm, proto, user, host, path, branch, d)
if user:
username = user + '@'
if Fetch.try_mirror(d, repofilename):
bb.mkdirhier(repodir)
os.chdir(repodir)
- rungitcmd("tar -xzf %s" % (repofile),d)
+ runfetchcmd("tar -xzf %s" % (repofile),d)
else:
- rungitcmd("git clone -n %s://%s%s%s %s" % (proto, username, host, path, repodir),d)
+ runfetchcmd("git clone -n %s://%s%s%s %s" % (proto, username, host, path, repodir),d)
os.chdir(repodir)
# Remove all but the .git directory
if not contains_ref(tag, d):
- rungitcmd("rm * -Rf", d)
- rungitcmd("git fetch %s://%s%s%s %s" % (proto, username, host, path, branch), d)
- rungitcmd("git fetch --tags %s://%s%s%s" % (proto, username, host, path), d)
- rungitcmd("git prune-packed", d)
- rungitcmd("git pack-redundant --all | xargs -r rm", d)
+ runfetchcmd("rm * -Rf", d)
+ runfetchcmd("git fetch %s://%s%s%s %s" % (proto, username, host, path, branch), d)
+ runfetchcmd("git fetch --tags %s://%s%s%s" % (proto, username, host, path), d)
+ runfetchcmd("git prune-packed", d)
+ runfetchcmd("git pack-redundant --all | xargs -r rm", d)
os.chdir(repodir)
bb.note("Creating tarball of git repository")
- rungitcmd("tar -czf %s %s" % (repofile, os.path.join(".", ".git", "*") ),d)
+ runfetchcmd("tar -czf %s %s" % (repofile, os.path.join(".", ".git", "*") ),d)
if os.path.exists(codir):
prunedir(codir)
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)
+ runfetchcmd("git read-tree %s" % (tag),d)
+ runfetchcmd("git checkout-index -q -f --prefix=%s -a" % (os.path.join(codir, "git", "")),d)
os.chdir(codir)
bb.note("Creating tarball of git checkout")
- rungitcmd("tar -czf %s %s" % (self.localpath(loc, d), os.path.join(".", "*") ),d)
+ runfetchcmd("tar -czf %s %s" % (self.localpath(loc, d), os.path.join(".", "*") ),d)