-
Notifications
You must be signed in to change notification settings - Fork 10
/
.copy_dlls.sh
65 lines (60 loc) · 2.12 KB
/
.copy_dlls.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#recursivel collect Windows dependencies (DLLs) to include in the deployment
#dest_dir="./build/bin" #destination directory where to collect binary and DLLs
dest_dir=$1 #destination directory where to collect binary and DLLs
echo dest_dir: $dest_dir
dlls_l=`objdump -x "$dest_dir/wasa.exe" |grep "DLL Name" | sed -e 's/^.* //g'` #find names of required DLLs
echo "First order: $dlls"
dlls_a=($dlls_l) #convert list to array
dlls_l=`echo "${dlls_a[@]}" | xargs | tr ' ' '\n' | sort | uniq | tr -s '\n\r' ' '` #remove duplicates
dlls_a=($dlls_l) #convert list to array
#recursively collect necessary DLLs
while :
do
echo start loop
#echo DLL: "${dlls_a[@]}"
# echo length: "${#dlls_a[@]}"
#echo DLL_l_prior3:
#echo "$dlls_l"x
secondary_dependencies_l=$dlls_l #list of second-order dependencies, initialized with DLLs found so far
for dll in $dlls_l
do
#echo ""
echo Dependencies of $dll
full_path=`which $dll`
#echo ""
#echo full path:$full_path
further_dlls=`objdump -x "$full_path" |grep "DLL Name" | sed -e 's/^.* //g'` #find names of required DLLs
#echo ""
#echo further: $further_dlls
#further_dlls=$further_dlls
secondary_dependencies_l+=" $further_dlls" #collect further dependencies
#echo ""
#echo secondary_dependencies_l: $secondary_dependencies_l
done
echo ""
secondary_dependencies_a=($secondary_dependencies_l) #convert list to array
secondary_dependencies_l=`echo "${secondary_dependencies_a[@]}" | xargs | tr ' ' '\n' | sort | uniq | tr -s '\n\r' ' '` #remove duplicates
secondary_dependencies_a=($secondary_dependencies_l) #convert list to array
if [ "$dlls_l" == "$secondary_dependencies_l" ]
then
echo same
break
else
echo different, next loop
dlls_l=$secondary_dependencies_l
dlls_a=($dlls_l) #convert list to array
fi
done
echo Copy DLLs...
for dll in $dlls_l
do
#echo $dll
full_path=`which $dll`
echo $full_path
if echo $full_path | grep "Windows\|PowerShell" ; then
echo "is a Windows/PowerShell DLL, skipped."
else
echo "copying..."
cp "$full_path" "$dest_dir" #not in windows directory, copy to collect
fi
done