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