1#!/bin/sh 2 3# Find all symlink in toolchains/windows and windows-x86_64 directories 4WIN_DIRS=`find toolchains \( -name "windows" -o -name "windows-x86_64" \)` 5 6for WIN_DIR in $WIN_DIRS; do 7 while [ 1 ] 8 do 9 # Find all symlinks in this directory. 10 SYMLINKS=`find $WIN_DIR -type l` 11 if [ -z "$SYMLINKS" ]; then 12 break; 13 fi 14 # Iterate symlinks 15 for SYMLINK in $SYMLINKS; do 16 if [ -L "$SYMLINK" ]; then 17 DIR=`dirname "$SYMLINK"` 18 FILE=`basename "$SYMLINK"` 19 # Note that if `readlink $FILE` is also a link, we want to deal 20 # with it in the next iteration. There is potential infinite-loop 21 # situation for cicular link doesn't exist in our case, though. 22 (cd "$DIR" && \ 23 LINK=`readlink "$FILE"` && \ 24 test ! -L "$LINK" && \ 25 rm -f "$FILE" && \ 26 cp -a "$LINK" "$FILE") 27 fi 28 done 29 done 30done 31 32# The following should print nothing if we did good job 33find toolchains/ -type l | grep windows 34