diff mbox series

[meta-mingw,2/2] mingw_sdk_handle_symlink.bbclass: ensure no symlink

Message ID 20260119085542.173678-2-Qi.Chen@windriver.com
State New
Headers show
Series [meta-mingw,1/2] .gitignore: add more items to .gitignore | expand

Commit Message

Chen, Qi Jan. 19, 2026, 8:55 a.m. UTC
From: Chen Qi <Qi.Chen@windriver.com>

Previously, I deliberately left these dead links as they were.
The purpose was to give users more information. However, this
is not correct. Because on Windows, extracting the SDK will
give users error about these symlinks.

This patch fixes the above error by:
1. Remove original invalid/dead symlinks.
2. Remove newly generated symlinks.
   This might be a little confusing. Normally, there will be no
   such newly generated symlinks. But in case of multilib, there
   will be something like xxx/64/32/64. The last 64 is a dead
   symlink and it's useless.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 classes/mingw_sdk_handle_symlink.bbclass | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/classes/mingw_sdk_handle_symlink.bbclass b/classes/mingw_sdk_handle_symlink.bbclass
index e158d14..c009509 100644
--- a/classes/mingw_sdk_handle_symlink.bbclass
+++ b/classes/mingw_sdk_handle_symlink.bbclass
@@ -6,10 +6,13 @@  archive_sdk:prepend:sdkmingw32 () {
 			find "${SDK_OUTPUT}/${SDKPATH}" -type l -print | while read -r symlink; do
 				target=$(readlink -f "$symlink" || echo "NOTVALID")
 				if [ "$target" = "NOTVALID" ]; then
+					bbnote "Deleting invalid symlink: $symlink"
+					rm -f $symlink
 					continue
 				fi
 				if [ ! -e "$target" ]; then
-					continue
+					bbnote "Deleting dead symlink: $symlink"
+					rm -f $symlink
 				elif [ -d "$target" ]; then
 					if [ "$parse_type" = "directory" ]; then
 						rm "$symlink" && cp -r "$target" "$symlink"
@@ -21,5 +24,12 @@  archive_sdk:prepend:sdkmingw32 () {
 				fi
 			done
 		done
+		# With the above symlink handling, we've copied correct contents.
+		# But we still face possible newly generated symlinks in the above process.
+		# For example, in case of multilib, there will be links like below:
+		#   x86-64-v3-poky-linux/lib64/x86_64-poky-linux/15.2.0/32/64/32
+		# This xxx/32/64/32 is a useless dead link and we can just remove it.
+		# Anyway, all these newly generated symlinks can be deleted!
+		find "${SDK_OUTPUT}/${SDKPATH}" -type l -delete
 	fi
 }