-
Notifications
You must be signed in to change notification settings - Fork 29
/
get_fluidsynth_deps.sh
executable file
·111 lines (92 loc) · 2.59 KB
/
get_fluidsynth_deps.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env bash
set -eo pipefail
shopt -s nullglob
CTRL='\033' # begin escape sequence
BC="${CTRL}[0;" # begin colour modification
Red="${BC}31m"
Purple="${BC}35m"
Cyan="${BC}36m"
NC="${BC}0m" # No Color
# deps such as libsndfile aren't available in clangarm64 repo
# declare -a ARCHS=("x64" "x86" "arm64")
declare -a ARCHS=("x64" "x86")
declare -A REPOS=( [x64]=clang64 [x86]=clang32 [arm64]=clangarm64 )
declare -A PKG_PREFIX_ARCHS=( [x64]=x86_64 [x86]=i686 [arm64]=aarch64 )
# https://waterlan.home.xs4all.nl/libintl.html
# apparently libintl is part of gettext
declare -a PKGS=("libiconv" "flac" "glib2" "libogg" "opus-1" "libvorbis" "pcre-" "libsndfile" "gettext")
pids=()
_term() {
echo "Caught SIGTERM signal!"
if [ ${#pids} -eq 0 ]
then
echo "No child processes; exiting."
return $?
fi
echo "Sending SIGTERM to ${#pids} child processes: ${pids[*]}"
for pid in ${arr[@]}
do
kill -TERM "$pid"
done
}
_int() {
echo "Caught fatal signal!"
if [ ${#pids} -eq 0 ]
then
echo "No child processes; exiting."
return $?
fi
echo "Sending SIGINT to ${#pids} child processes: ${pids[*]}"
for pid in ${arr[@]}
do
kill -INT "$pid"
done
}
trap '_int' SIGINT EXIT
trap '_term' SIGTERM
for ARCH in ${ARCHS[@]}; do
echo "arch: $ARCH"
REPO="${REPOS[$ARCH]}"
echo "repo: $REPO"
REPO_URL="https://repo.msys2.org/mingw/$REPO"
echo "repo URL: $REPO_URL"
REPO_FILE="repo-$ARCH.txt"
echo "repo file: $REPO_FILE"
wget -qO "$REPO_FILE" "$REPO_URL"
INSTALL_ROOT="/deps/$ARCH"
mkdir -p "$INSTALL_ROOT"
echo "install root: $INSTALL_ROOT"
for PKG in ${PKGS[@]}; do
echo "pkg: $PKG"
PKG_PREFIX_ARCH="${PKG_PREFIX_ARCHS[$ARCH]}"
echo "pkg prefix arch: $PKG_PREFIX_ARCH"
PKG_PREFIX="mingw-w64-clang-$PKG_PREFIX_ARCH-$PKG"
echo "pkg prefix: $PKG_PREFIX"
FILE=`cat $REPO_FILE | sed -n 's/.*href="\([^"]*\).*/\1/p' | grep -E "^$PKG_PREFIX" | egrep -v '.sig$' | sort | tail -1f`
if [[ $FILE == *.zst || $FILE == *.xz ]]
then
ASSET="$REPO_URL/$FILE"
echo -e "${Cyan}Downloading $ASSET...${NC}"
wget -q "$ASSET" &
pids+=("$!")
else
>&2 echo -e "${Red}$FILE cannot be extracted; unsupported extension${NC}"
exit 1
fi
done
done
echo -e "${Cyan}Waiting for ${#pids[@]} parallel downloads to complete...${NC}"
for pid in "${pids[@]}"; do
wait "$pid"
done
trap - SIGINT EXIT SIGTERM
for file in *.zst; do
echo -e "${Cyan}Extracting $file...${NC}"
tar -I zstd -xvf "$file" -C /
rm "$file"
done
for file in *.xz; do
echo -e "${Cyan}Extracting $file...${NC}"
tar xJvf "$file" -C /
rm "$file"
done