diff mbox series

[2/2] classes: go-vendor: Change symlink creation.

Message ID 20250123184740.1815534-2-alexander.v.yurkov@gmail.com
State Accepted, archived
Commit 2a154b79be5590ddae476563e8e1e9ea9356b28c
Headers show
Series [1/2] oeqa/selftest/recipetool: Update create_go test. | expand

Commit Message

alexander.v.yurkov@gmail.com Jan. 23, 2025, 6:47 p.m. UTC
From: Alexander Yurkov <alexander.v.yurkov@gmail.com>

Create missing directories required to create the symlink.

Use relative symlinks to stay in the build directory scope (to avoid sstate issue with absolute paths).

Signed-off-by: Alexander Yurkov <alexander.v.yurkov@gmail.com>
Signed-off-by: Vyacheslav Yurkov <uvv.mail@gmail.com>
---
 meta/classes/go-vendor.bbclass | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/meta/classes/go-vendor.bbclass b/meta/classes/go-vendor.bbclass
index f3268c1125..6ec6178add 100644
--- a/meta/classes/go-vendor.bbclass
+++ b/meta/classes/go-vendor.bbclass
@@ -201,11 +201,15 @@  python do_go_vendor() {
     for vendored_name, replaced_path in replaced_paths.items():
         symlink_target = os.path.join(source_dir, *['src', go_import, replaced_path])
         symlink_name = os.path.join(vendor_dir, vendored_name)
+        relative_symlink_target = os.path.relpath(symlink_target, os.path.dirname(symlink_name))
         bb.debug(1, "vendored name %s, symlink name %s" % (vendored_name, symlink_name))
-        oe.path.relsymlink(symlink_target, symlink_name)
+
+        os.makedirs(os.path.dirname(symlink_name), exist_ok=True)
+        os.symlink(relative_symlink_target, symlink_name)
 
     # Create a symlink to the actual directory
-    oe.path.relsymlink(vendor_dir, linkname)
+    relative_vendor_dir = os.path.relpath(vendor_dir, os.path.dirname(linkname))
+    os.symlink(relative_vendor_dir, linkname)
 }
 
 addtask go_vendor before do_patch after do_unpack