summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/fetch2')
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py50
-rw-r--r--bitbake/lib/bb/fetch2/git.py7
2 files changed, 35 insertions, 22 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 2de4f4f8c0..0ad987c596 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -1117,7 +1117,10 @@ def try_mirror_url(fetch, origud, ud, ld, check = False):
1117 origud.method.build_mirror_data(origud, ld) 1117 origud.method.build_mirror_data(origud, ld)
1118 return origud.localpath 1118 return origud.localpath
1119 # Otherwise the result is a local file:// and we symlink to it 1119 # Otherwise the result is a local file:// and we symlink to it
1120 ensure_symlink(ud.localpath, origud.localpath) 1120 # This may also be a link to a shallow archive
1121 # When using shallow mode, add a symlink to the original fullshallow
1122 # path to ensure a valid symlink even in the `PREMIRRORS` case
1123 origud.method.update_mirror_links(ud, origud)
1121 update_stamp(origud, ld) 1124 update_stamp(origud, ld)
1122 return ud.localpath 1125 return ud.localpath
1123 1126
@@ -1151,25 +1154,6 @@ def try_mirror_url(fetch, origud, ud, ld, check = False):
1151 if ud.lockfile and ud.lockfile != origud.lockfile: 1154 if ud.lockfile and ud.lockfile != origud.lockfile:
1152 bb.utils.unlockfile(lf) 1155 bb.utils.unlockfile(lf)
1153 1156
1154
1155def ensure_symlink(target, link_name):
1156 if not os.path.exists(link_name):
1157 dirname = os.path.dirname(link_name)
1158 bb.utils.mkdirhier(dirname)
1159 if os.path.islink(link_name):
1160 # Broken symbolic link
1161 os.unlink(link_name)
1162
1163 # In case this is executing without any file locks held (as is
1164 # the case for file:// URLs), two tasks may end up here at the
1165 # same time, in which case we do not want the second task to
1166 # fail when the link has already been created by the first task.
1167 try:
1168 os.symlink(target, link_name)
1169 except FileExistsError:
1170 pass
1171
1172
1173def try_mirrors(fetch, d, origud, mirrors, check = False): 1157def try_mirrors(fetch, d, origud, mirrors, check = False):
1174 """ 1158 """
1175 Try to use a mirrored version of the sources. 1159 Try to use a mirrored version of the sources.
@@ -1589,11 +1573,11 @@ class FetchMethod(object):
1589 datafile = None 1573 datafile = None
1590 if output: 1574 if output:
1591 for line in output.decode().splitlines(): 1575 for line in output.decode().splitlines():
1592 if line.startswith('data.tar.'): 1576 if line.startswith('data.tar.') or line == 'data.tar':
1593 datafile = line 1577 datafile = line
1594 break 1578 break
1595 else: 1579 else:
1596 raise UnpackError("Unable to unpack deb/ipk package - does not contain data.tar.* file", urldata.url) 1580 raise UnpackError("Unable to unpack deb/ipk package - does not contain data.tar* file", urldata.url)
1597 else: 1581 else:
1598 raise UnpackError("Unable to unpack deb/ipk package - could not list contents", urldata.url) 1582 raise UnpackError("Unable to unpack deb/ipk package - could not list contents", urldata.url)
1599 cmd = 'ar x %s %s && %s -p -f %s && rm %s' % (file, datafile, tar_cmd, datafile, datafile) 1583 cmd = 'ar x %s %s && %s -p -f %s && rm %s' % (file, datafile, tar_cmd, datafile, datafile)
@@ -1655,6 +1639,28 @@ class FetchMethod(object):
1655 """ 1639 """
1656 bb.utils.remove(urldata.localpath) 1640 bb.utils.remove(urldata.localpath)
1657 1641
1642 def ensure_symlink(self, target, link_name):
1643 if not os.path.exists(link_name):
1644 dirname = os.path.dirname(link_name)
1645 bb.utils.mkdirhier(dirname)
1646 if os.path.islink(link_name):
1647 # Broken symbolic link
1648 os.unlink(link_name)
1649
1650 # In case this is executing without any file locks held (as is
1651 # the case for file:// URLs), two tasks may end up here at the
1652 # same time, in which case we do not want the second task to
1653 # fail when the link has already been created by the first task.
1654 try:
1655 os.symlink(target, link_name)
1656 except FileExistsError:
1657 pass
1658
1659 def update_mirror_links(self, ud, origud):
1660 # For local file:// results, create a symlink to them
1661 # This may also be a link to a shallow archive
1662 self.ensure_symlink(ud.localpath, origud.localpath)
1663
1658 def try_premirror(self, urldata, d): 1664 def try_premirror(self, urldata, d):
1659 """ 1665 """
1660 Should premirrors be used? 1666 Should premirrors be used?
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index 784a45bda2..55dd084abc 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -348,6 +348,13 @@ class Git(FetchMethod):
348 def tarball_need_update(self, ud): 348 def tarball_need_update(self, ud):
349 return ud.write_tarballs and not os.path.exists(ud.fullmirror) 349 return ud.write_tarballs and not os.path.exists(ud.fullmirror)
350 350
351 def update_mirror_links(self, ud, origud):
352 super().update_mirror_links(ud, origud)
353 # When using shallow mode, add a symlink to the original fullshallow
354 # path to ensure a valid symlink even in the `PREMIRRORS` case
355 if ud.shallow and not os.path.exists(origud.fullshallow):
356 self.ensure_symlink(ud.localpath, origud.fullshallow)
357
351 def try_premirror(self, ud, d): 358 def try_premirror(self, ud, d):
352 # If we don't do this, updating an existing checkout with only premirrors 359 # If we don't do this, updating an existing checkout with only premirrors
353 # is not possible 360 # is not possible