prefix/winnt/profile.bashrc: no symlink usr/lib/NAME.dll
authorMichael Haubenwallner <haubi@gentoo.org>
Wed, 11 Mar 2020 14:26:12 +0000 (15:26 +0100)
committerMichael Haubenwallner <haubi@gentoo.org>
Wed, 11 Mar 2020 15:47:18 +0000 (16:47 +0100)
While moving usr/lib/NAME.dll into usr/bin/ is necessary, creating the
symlink usr/lib/NAME.dll -> ../bin/NAME.dll is problematic, because the
libtool .exe wrapper may add usr/lib to PATH, causing the native loader
to fail when attempting to load a dll but discovering a cygwin symlink.
Also, need to resolve symlinks while moving from usr/lib into usr/bin.

Signed-off-by: Michael Haubenwallner <haubi@gentoo.org>
profiles/prefix/windows/winnt/profile.bashrc

index c613a56cd98203cf7b8687e1e62b6494673e7c71..215ad93a94306effd62262044476f8184ac6db57 100644 (file)
@@ -175,18 +175,30 @@ winnt_post_src_install() {
                        eend $?
                fi
        done
-       [[ -d usr/$(get_libdir) ]] &&
-       find usr/$(get_libdir) -maxdepth 1 -type f -name '*.dll' |
-       while read f
-       do
-               if [[ ! -f usr/bin/${f##*/} ]]; then
-                       ebegin "moving ${f} to usr/bin for native loader"
+       if [[ -d usr/$(get_libdir) ]]
+       then
+               # The native loader does not understand symlinks to dlls,
+               # seen to be created by dev-libs/icu eventually.  For any
+               # dll we find in usr/lib we need to perform a real copy to
+               # usr/bin, to resolve potential symlinks (seen from icu),
+               # and perform the remove from usr/lib afterwards, to not
+               # break symlinks later on discovered by find.
+               local toremove=()
+               local f
+               while read f
+               do
+                       [[ -f usr/bin/${f##*/} ]] && continue
+                       ebegin "moving ${f} to usr/bin for the native loader"
                        dodir usr/bin || die
-                       mv -f "${f}" usr/bin/ || die
-                       ln -sf "../bin/${f##*/}" "${f}" || die
+                       cp -f "${f}" usr/bin/ || die
                        eend $?
+                       toremove=( "${toremove[@]}" "${f}" )
+               done < <(find usr/$(get_libdir) -maxdepth 1 -name '*.dll')
+               if [[ ${#toremove[@]} -gt 0 ]]
+               then
+                       rm -f "${toremove[@]}" || die "removing dlls from usr/$(get_libdir) failed"
                fi
-       done
+       fi
 }
 
 winnt_setup_dllhelper_cp() {