diff options
author | Stefan Koch <stefan-koch@siemens.com> | 2025-05-27 11:59:01 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-05-28 12:37:02 +0100 |
commit | 0e9ce41a1cc0e1158f84d5c5c08cf23b5c161155 (patch) | |
tree | d93d9545e6a498540b4c30c22ff076f37efb266c /bitbake | |
parent | a3bdd2144c39772c1217c30bc09fbc55fb967c6c (diff) | |
download | poky-0e9ce41a1cc0e1158f84d5c5c08cf23b5c161155.tar.gz |
bitbake: fetch2: Move the `ensure_symlink()` function into the `FetchMethod` class
(Bitbake rev: d934763f91b9bda85f273a44f12a04a3ca19fc28)
Signed-off-by: Stefan Koch <stefan-koch@siemens.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index 97cbd3567a..8504678dff 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py | |||
@@ -1151,25 +1151,6 @@ def try_mirror_url(fetch, origud, ud, ld, check = False): | |||
1151 | if ud.lockfile and ud.lockfile != origud.lockfile: | 1151 | if ud.lockfile and ud.lockfile != origud.lockfile: |
1152 | bb.utils.unlockfile(lf) | 1152 | bb.utils.unlockfile(lf) |
1153 | 1153 | ||
1154 | |||
1155 | def 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 | |||
1173 | def try_mirrors(fetch, d, origud, mirrors, check = False): | 1154 | def try_mirrors(fetch, d, origud, mirrors, check = False): |
1174 | """ | 1155 | """ |
1175 | Try to use a mirrored version of the sources. | 1156 | Try to use a mirrored version of the sources. |
@@ -1655,6 +1636,23 @@ class FetchMethod(object): | |||
1655 | """ | 1636 | """ |
1656 | bb.utils.remove(urldata.localpath) | 1637 | bb.utils.remove(urldata.localpath) |
1657 | 1638 | ||
1639 | def ensure_symlink(self, target, link_name): | ||
1640 | if not os.path.exists(link_name): | ||
1641 | dirname = os.path.dirname(link_name) | ||
1642 | bb.utils.mkdirhier(dirname) | ||
1643 | if os.path.islink(link_name): | ||
1644 | # Broken symbolic link | ||
1645 | os.unlink(link_name) | ||
1646 | |||
1647 | # In case this is executing without any file locks held (as is | ||
1648 | # the case for file:// URLs), two tasks may end up here at the | ||
1649 | # same time, in which case we do not want the second task to | ||
1650 | # fail when the link has already been created by the first task. | ||
1651 | try: | ||
1652 | os.symlink(target, link_name) | ||
1653 | except FileExistsError: | ||
1654 | pass | ||
1655 | |||
1658 | def try_premirror(self, urldata, d): | 1656 | def try_premirror(self, urldata, d): |
1659 | """ | 1657 | """ |
1660 | Should premirrors be used? | 1658 | Should premirrors be used? |