forked from travelrepublic/docker-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract_dotnet.sh
executable file
·32 lines (26 loc) · 939 Bytes
/
extract_dotnet.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
#!/bin/bash
# Copy the dotnet core framework and all its dependencies to
# the specified directory
extract_to_dir=$1
mkdir -p $extract_to_dir
# Find dependencies of dotnet executable
# We aren't interested in file in /usr/share/dotnet as we will
# copy the whole directory
exe_deps=$(ldd /usr/bin/dotnet \
| grep -v '/usr/share/dotnet' \
| awk 'BEGIN{ORS=" "}$1 ~/^\//{print $1}$3 ~/^\//{print $3}' \
| sed 's/,$/\n/')
# Find dependencies of dotnet libraries
# We aren't interested in file in /usr/share/dotnet as we will
# copy the whole directory
lib_deps=$(find /usr/share/dotnet -name '*.so' \
| xargs ldd \
| grep -v '/usr/share/dotnet' \
| awk 'BEGIN{ORS=" "}$1 ~/^\//{print $1}$3 ~/^\//{print $3}' \
| sed 's/,$/\n/')
deps="$exe_deps $lib_deps"
deps=$(echo "$deps" | sort | uniq)
for file in $deps; do
cp --parents $file $extract_to_dir
done
cp -R --parents /usr/share/dotnet $extract_to_dir