git.py: split download to download() and build_mirror_data()
the download is to fetch the source from URL, the build_mirror_data is to create the mirror tar ball. the original go() method mix them together, it is more clean to split them. Signed-off-by: Yu Ke <ke.yu@intel.com>
This commit is contained in:
parent
e2ac26e7b1
commit
ef918a72de
|
@ -294,6 +294,8 @@ def download(d, urls = None):
|
||||||
# Next try fetching from the original uri, u
|
# Next try fetching from the original uri, u
|
||||||
try:
|
try:
|
||||||
m.download(u, ud, d)
|
m.download(u, ud, d)
|
||||||
|
if hasattr(m, "build_mirror_data"):
|
||||||
|
m.build_mirror_data(u, ud, d)
|
||||||
localpath = ud.localpath
|
localpath = ud.localpath
|
||||||
except FetchError:
|
except FetchError:
|
||||||
# Remove any incomplete file
|
# Remove any incomplete file
|
||||||
|
@ -500,6 +502,8 @@ def try_mirrors(d, uri, mirrors, check = False, force = False):
|
||||||
return found
|
return found
|
||||||
else:
|
else:
|
||||||
ud.method.download(newuri, ud, ld)
|
ud.method.download(newuri, ud, ld)
|
||||||
|
if hasattr(ud.method,"build_mirror_data"):
|
||||||
|
ud.method.build_mirror_data(newuri, ud, ld)
|
||||||
return ud.localpath
|
return ud.localpath
|
||||||
except (bb.fetch2.MissingParameterError,
|
except (bb.fetch2.MissingParameterError,
|
||||||
bb.fetch2.FetchError,
|
bb.fetch2.FetchError,
|
||||||
|
|
|
@ -116,9 +116,6 @@ class Git(Fetch):
|
||||||
|
|
||||||
repofile = os.path.join(data.getVar("DL_DIR", d, 1), ud.mirrortarball)
|
repofile = os.path.join(data.getVar("DL_DIR", d, 1), ud.mirrortarball)
|
||||||
|
|
||||||
coname = '%s' % (ud.tag)
|
|
||||||
codir = os.path.join(ud.clonedir, coname)
|
|
||||||
|
|
||||||
# If we have no existing clone and no mirror tarball, try and obtain one
|
# If we have no existing clone and no mirror tarball, try and obtain one
|
||||||
if not os.path.exists(ud.clonedir) and not os.path.exists(repofile):
|
if not os.path.exists(ud.clonedir) and not os.path.exists(repofile):
|
||||||
try:
|
try:
|
||||||
|
@ -149,7 +146,12 @@ class Git(Fetch):
|
||||||
runfetchcmd("%s prune-packed" % ud.basecmd, d)
|
runfetchcmd("%s prune-packed" % ud.basecmd, d)
|
||||||
runfetchcmd("%s pack-redundant --all | xargs -r rm" % ud.basecmd, d)
|
runfetchcmd("%s pack-redundant --all | xargs -r rm" % ud.basecmd, d)
|
||||||
|
|
||||||
|
def build_mirror_data(self, url, ud, d):
|
||||||
# Generate a mirror tarball if needed
|
# Generate a mirror tarball if needed
|
||||||
|
coname = '%s' % (ud.tag)
|
||||||
|
codir = os.path.join(ud.clonedir, coname)
|
||||||
|
repofile = os.path.join(data.getVar("DL_DIR", d, 1), ud.mirrortarball)
|
||||||
|
|
||||||
os.chdir(ud.clonedir)
|
os.chdir(ud.clonedir)
|
||||||
mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True)
|
mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True)
|
||||||
if mirror_tarballs != "0" or 'fullclone' in ud.parm:
|
if mirror_tarballs != "0" or 'fullclone' in ud.parm:
|
||||||
|
|
Loading…
Reference in New Issue