From 0e9ce41a1cc0e1158f84d5c5c08cf23b5c161155 Mon Sep 17 00:00:00 2001 From: Stefan Koch Date: Tue, 27 May 2025 11:59:01 +0200 Subject: [PATCH] bitbake: fetch2: Move the `ensure_symlink()` function into the `FetchMethod` class (Bitbake rev: d934763f91b9bda85f273a44f12a04a3ca19fc28) Signed-off-by: Stefan Koch Signed-off-by: Richard Purdie --- bitbake/lib/bb/fetch2/__init__.py | 36 +++++++++++++++---------------- 1 file 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): if ud.lockfile and ud.lockfile != origud.lockfile: bb.utils.unlockfile(lf) - -def ensure_symlink(target, link_name): - if not os.path.exists(link_name): - dirname = os.path.dirname(link_name) - bb.utils.mkdirhier(dirname) - if os.path.islink(link_name): - # Broken symbolic link - os.unlink(link_name) - - # In case this is executing without any file locks held (as is - # the case for file:// URLs), two tasks may end up here at the - # same time, in which case we do not want the second task to - # fail when the link has already been created by the first task. - try: - os.symlink(target, link_name) - except FileExistsError: - pass - - def try_mirrors(fetch, d, origud, mirrors, check = False): """ Try to use a mirrored version of the sources. @@ -1655,6 +1636,23 @@ class FetchMethod(object): """ bb.utils.remove(urldata.localpath) + def ensure_symlink(self, target, link_name): + if not os.path.exists(link_name): + dirname = os.path.dirname(link_name) + bb.utils.mkdirhier(dirname) + if os.path.islink(link_name): + # Broken symbolic link + os.unlink(link_name) + + # In case this is executing without any file locks held (as is + # the case for file:// URLs), two tasks may end up here at the + # same time, in which case we do not want the second task to + # fail when the link has already been created by the first task. + try: + os.symlink(target, link_name) + except FileExistsError: + pass + def try_premirror(self, urldata, d): """ Should premirrors be used?