bitbake/utils.py: Add prunedir function to utils collection
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@5065 311d38ba-8fff-0310-9ca6-ca027cbcb966
This commit is contained in:
parent
77c01014e0
commit
5ca566349c
|
@ -27,15 +27,6 @@ from bb.fetch import Fetch
|
||||||
from bb.fetch import FetchError
|
from bb.fetch import FetchError
|
||||||
from bb.fetch import runfetchcmd
|
from bb.fetch import runfetchcmd
|
||||||
|
|
||||||
def prunedir(topdir):
|
|
||||||
# Delete everything reachable from the directory named in 'topdir'.
|
|
||||||
# CAUTION: This is dangerous!
|
|
||||||
for root, dirs, files in os.walk(topdir, topdown=False):
|
|
||||||
for name in files:
|
|
||||||
os.remove(os.path.join(root, name))
|
|
||||||
for name in dirs:
|
|
||||||
os.rmdir(os.path.join(root, name))
|
|
||||||
|
|
||||||
class Git(Fetch):
|
class Git(Fetch):
|
||||||
"""Class to fetch a module or modules from git repositories"""
|
"""Class to fetch a module or modules from git repositories"""
|
||||||
def supports(self, url, ud, d):
|
def supports(self, url, ud, d):
|
||||||
|
@ -107,7 +98,7 @@ class Git(Fetch):
|
||||||
runfetchcmd("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):
|
if os.path.exists(codir):
|
||||||
prunedir(codir)
|
bb.utils.prunedir(codir)
|
||||||
|
|
||||||
bb.mkdirhier(codir)
|
bb.mkdirhier(codir)
|
||||||
os.chdir(repodir)
|
os.chdir(repodir)
|
||||||
|
@ -119,7 +110,7 @@ class Git(Fetch):
|
||||||
runfetchcmd("tar -czf %s %s" % (ud.localpath, os.path.join(".", "*") ), d)
|
runfetchcmd("tar -czf %s %s" % (ud.localpath, os.path.join(".", "*") ), d)
|
||||||
|
|
||||||
os.chdir(repodir)
|
os.chdir(repodir)
|
||||||
prunedir(codir)
|
bb.utils.prunedir(codir)
|
||||||
|
|
||||||
def suppports_srcrev(self):
|
def suppports_srcrev(self):
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -268,3 +268,13 @@ def sha256_file(filename):
|
||||||
for line in open(filename):
|
for line in open(filename):
|
||||||
s.update(line)
|
s.update(line)
|
||||||
return s.hexdigest()
|
return s.hexdigest()
|
||||||
|
|
||||||
|
def prunedir(topdir):
|
||||||
|
# Delete everything reachable from the directory named in 'topdir'.
|
||||||
|
# CAUTION: This is dangerous!
|
||||||
|
for root, dirs, files in os.walk(topdir, topdown=False):
|
||||||
|
for name in files:
|
||||||
|
os.remove(os.path.join(root, name))
|
||||||
|
for name in dirs:
|
||||||
|
os.rmdir(os.path.join(root, name))
|
||||||
|
os.rmdir(topdir)
|
||||||
|
|
Loading…
Reference in New Issue