mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 13:09:50 +00:00
bitbake/fetch2: Move symlink handling into try_mirror where is belongs instead of the main download function
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -421,14 +421,31 @@ def try_mirrors(d, origud, mirrors, check = False):
|
|||||||
found = ud.method.checkstatus(newuri, ud, ld)
|
found = ud.method.checkstatus(newuri, ud, ld)
|
||||||
if found:
|
if found:
|
||||||
return found
|
return found
|
||||||
else:
|
continue
|
||||||
if not ud.method.need_update(newuri, ud, ld):
|
|
||||||
return ud.localpath
|
if ud.method.need_update(newuri, ud, ld):
|
||||||
ud.method.download(newuri, ud, ld)
|
ud.method.download(newuri, ud, ld)
|
||||||
if hasattr(ud.method,"build_mirror_data"):
|
if hasattr(ud.method,"build_mirror_data"):
|
||||||
ud.method.build_mirror_data(newuri, ud, ld)
|
ud.method.build_mirror_data(newuri, ud, ld)
|
||||||
|
|
||||||
|
if not ud.localpath or not os.path.exists(ud.localpath):
|
||||||
|
continue
|
||||||
|
|
||||||
|
if ud.localpath == origud.localpath:
|
||||||
return ud.localpath
|
return ud.localpath
|
||||||
|
|
||||||
|
# We may be obtaining a mirror tarball which needs further processing by the real fetcher
|
||||||
|
# If that tarball is a local file:// we need to provide a symlink to it
|
||||||
|
dldir = ld.getVar("DL_DIR", True)
|
||||||
|
if not ud.localpath.startswith(dldir):
|
||||||
|
if os.path.basename(ud.localpath) != os.path.basename(origud.localpath):
|
||||||
|
os.symlink(ud.localpath, os.path.join(dldir, os.path.basename(ud.localpath)))
|
||||||
|
return None
|
||||||
|
# Otherwise the result is a local file:// and we symlink to it
|
||||||
|
if not os.path.exists(origud.localpath):
|
||||||
|
os.symlink(ud.localpath, origud.localpath)
|
||||||
|
return ud.localpath
|
||||||
|
|
||||||
except bb.fetch2.BBFetchException:
|
except bb.fetch2.BBFetchException:
|
||||||
logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (newuri, origud.url))
|
logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (newuri, origud.url))
|
||||||
if os.path.isfile(ud.localpath):
|
if os.path.isfile(ud.localpath):
|
||||||
@@ -836,11 +853,7 @@ class Fetch(object):
|
|||||||
localpath = ud.localpath
|
localpath = ud.localpath
|
||||||
elif m.try_premirror(u, ud, self.d):
|
elif m.try_premirror(u, ud, self.d):
|
||||||
mirrors = mirror_from_string(bb.data.getVar('PREMIRRORS', self.d, True))
|
mirrors = mirror_from_string(bb.data.getVar('PREMIRRORS', self.d, True))
|
||||||
mirrorpath = try_mirrors(self.d, ud, mirrors, False)
|
localpath = try_mirrors(self.d, ud, mirrors, False)
|
||||||
if mirrorpath and os.path.basename(mirrorpath) == os.path.basename(ud.localpath):
|
|
||||||
localpath = mirrorpath
|
|
||||||
elif mirrorpath and os.path.exists(mirrorpath) and not mirrorpath.startswith(self.d.getVar("DL_DIR", True)):
|
|
||||||
os.symlink(mirrorpath, os.path.join(self.d.getVar("DL_DIR", True), os.path.basename(mirrorpath)))
|
|
||||||
|
|
||||||
if bb.data.getVar("BB_FETCH_PREMIRRORONLY", self.d, True) is None:
|
if bb.data.getVar("BB_FETCH_PREMIRRORONLY", self.d, True) is None:
|
||||||
bb.data.setVar("BB_NO_NETWORK", "1", self.d)
|
bb.data.setVar("BB_NO_NETWORK", "1", self.d)
|
||||||
@@ -862,10 +875,6 @@ class Fetch(object):
|
|||||||
if not localpath or not os.path.exists(localpath):
|
if not localpath or not os.path.exists(localpath):
|
||||||
raise FetchError("Unable to fetch URL %s from any source." % u, u)
|
raise FetchError("Unable to fetch URL %s from any source." % u, u)
|
||||||
|
|
||||||
# The local fetcher can return an alternate path so we symlink
|
|
||||||
if os.path.exists(localpath) and not os.path.exists(ud.localpath):
|
|
||||||
os.symlink(localpath, ud.localpath)
|
|
||||||
|
|
||||||
if os.path.exists(ud.donestamp):
|
if os.path.exists(ud.donestamp):
|
||||||
# Touch the done stamp file to show active use of the download
|
# Touch the done stamp file to show active use of the download
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user