Skip to contentSkip to conversation

fetch2: Ensure directory exists before creating symlink

PATCH New Richard Purdie 1 participant 1 message Jul 14, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fetch2: Ensure directory exists before creating symlink

If the mirrors code is trying to create a symlink and the parent directory doesn't exist, as might be the case for sstate mirrors where the fetch is into a subdir, it can silently fail.

Ensure the directory exists in this case to avoid issues.

---
 lib/bb/fetch2/__init__.py | 2 ++
 1 file changed, 2 insertions(+)
lib/bb/fetch2/__init__.py +2 -0
index f9c23681bc..e20d19ce4a 100644
@@ -1097,6 +1097,8 @@ def try_mirror_url(fetch, origud, ud, ld, check = False):
 
 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)
Signature · 1 line
2.34.1