2020-01-24 13:23:40 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#Required libraries:
|
|
|
|
# "libssl.so"
|
|
|
|
# "libcrypto.so"
|
|
|
|
# "libDataPipes.so"
|
|
|
|
# "libjemalloc.so.2"
|
|
|
|
# "libsqlite3.so.0"
|
|
|
|
# "libTeaMusic.so"
|
2020-01-25 08:37:59 -05:00
|
|
|
# "libnice.so.10"
|
|
|
|
# "libpcre.so.3" (only for web)
|
2020-01-25 10:00:21 -05:00
|
|
|
# "libgobject-2.0.so.0" (only for web)
|
|
|
|
# "libglib-2.0.so.0" (only for web)
|
|
|
|
# "libffi.so.7"
|
2020-01-24 13:23:40 -05:00
|
|
|
|
|
|
|
[[ -z "${build_os_type}" ]] && { echo "missing build os type"; exit 1; }
|
|
|
|
[[ -z "${build_os_arch}" ]] && { echo "missing build os arch"; exit 1; }
|
|
|
|
build_path="out/${build_os_type}_${build_os_arch}/"
|
|
|
|
|
|
|
|
function query_system_link() {
|
2020-02-16 09:15:30 -05:00
|
|
|
local _binary="$2"
|
|
|
|
[[ -z "$_binary" ]] && _binary="../../../environment/TeaSpeakServer"
|
|
|
|
data=$(ldd "$_binary" | grep "$1")
|
2020-01-24 13:23:40 -05:00
|
|
|
# shellcheck disable=SC2206
|
|
|
|
data=($data)
|
|
|
|
library_path=${data[2]}
|
|
|
|
|
2020-02-16 09:15:30 -05:00
|
|
|
[[ -z "${library_path}" ]] && { echo "failed to resolve library path for $1 in $_binary"; exit 1; }
|
|
|
|
[[ "${library_path}" == "not" ]] && { echo "failed to resolve library path for $1 in $_binary"; exit 1; }
|
2020-01-24 13:23:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
cd $(dirname $0) || exit 1
|
|
|
|
cd env || { echo "failed to enter env"; exit 1; }
|
|
|
|
|
|
|
|
[[ -d libs ]] && {
|
|
|
|
rm -r libs || { echo "failed to delete old lib folder"; exit 1; }
|
|
|
|
}
|
|
|
|
mkdir libs || { echo "failed to create lib directory"; exit 1; }
|
|
|
|
cd libs || { echo "failed to enter lib directory"; exit 1; }
|
|
|
|
|
2020-01-25 09:05:48 -05:00
|
|
|
# Creating copied
|
2020-01-24 13:23:40 -05:00
|
|
|
library_base=$(realpath ../../../../../libraries)
|
|
|
|
|
|
|
|
# Setting up ssl
|
2020-03-02 15:00:18 -05:00
|
|
|
query_system_link "libssl.so.1.1"
|
|
|
|
cp "${library_path}" . || { echo "failed to copy libssl.so.1.1"; exit 1; }
|
2020-01-24 13:23:40 -05:00
|
|
|
|
|
|
|
# Setting up crypto
|
2020-03-02 15:00:18 -05:00
|
|
|
query_system_link "libcrypto.so.1.1"
|
|
|
|
cp "${library_path}" . || { echo "failed to copy libcrypto.so.1.1"; exit 1; }
|
2020-01-24 13:23:40 -05:00
|
|
|
|
|
|
|
# Setting up DataPipes
|
2020-03-02 07:33:57 -05:00
|
|
|
library_path=$(realpath "${library_base}/DataPipes/${build_path}/lib/libDataPipes-RTC.so")
|
|
|
|
cp "$library_path" . || { echo "failed to copy libDataPipes-RTC.so"; exit 1; }
|
2020-02-16 09:15:30 -05:00
|
|
|
_dp_path="$library_path"
|
2020-01-24 13:23:40 -05:00
|
|
|
|
|
|
|
# Setting up Sqlite3
|
|
|
|
query_system_link "libsqlite3.so.0"
|
2020-01-25 09:05:48 -05:00
|
|
|
cp "${library_path}" . || { echo "failed to copy libsqlite3.so.0"; exit 1; }
|
2020-01-24 13:23:40 -05:00
|
|
|
|
|
|
|
# Setting up jemalloc
|
|
|
|
query_system_link "libjemalloc.so.2"
|
2020-01-25 09:05:48 -05:00
|
|
|
cp "${library_path}" . || { echo "failed to copy libjemalloc.so.2"; exit 1; }
|
2020-01-24 13:23:40 -05:00
|
|
|
|
|
|
|
# Setting up TeaMusic
|
|
|
|
library_path=$(realpath "../../../../MusicBot/libs/libTeaMusic.so")
|
2020-01-25 09:05:48 -05:00
|
|
|
cp "$library_path" . || { echo "failed to copy libTeaMusic.so"; exit 1; }
|
2020-01-24 13:23:40 -05:00
|
|
|
|
2020-01-25 08:37:59 -05:00
|
|
|
if ldd "../../../environment/TeaSpeakServer" | grep -q "libnice.so.10"; then
|
|
|
|
echo "Adding web libraries"
|
|
|
|
|
|
|
|
# Setting up libnice
|
|
|
|
library_path=$(realpath "${library_base}/libnice/${build_os_type}_${build_os_arch}/lib/libnice.so.10")
|
2020-01-25 10:00:21 -05:00
|
|
|
cp "$library_path" libnice.so.10 || { echo "failed to copy libnice.so.10"; exit 1; }
|
|
|
|
|
|
|
|
|
|
|
|
glib_libs=$(realpath "${library_base}//glibc/${build_os_type}_${build_os_arch}/lib/"*"/")
|
|
|
|
cp "$glib_libs/libgobject-2.0.so.0" . || { echo "failed to copy libgobject-2.0.so.0"; exit 1; }
|
|
|
|
cp "$glib_libs/libgmodule-2.0.so.0" . || { echo "failed to copy libgmodule-2.0.so.0"; exit 1; }
|
|
|
|
cp "$glib_libs/libglib-2.0.so.0" . || { echo "failed to copy libglib-2.0.so.0"; exit 1; }
|
|
|
|
cp "$glib_libs/libgio-2.0.so.0" . || { echo "failed to copy libgio-2.0.so.0"; exit 1; }
|
|
|
|
cp "$glib_libs/libffi.so.7" . || { echo "failed to copy libffi.so.7"; exit 1; }
|
|
|
|
|
|
|
|
# "libgobject-2.0.so.0" (only for web)
|
|
|
|
# "libglib-2.0.so.0" (only for web)
|
2020-01-25 08:37:59 -05:00
|
|
|
|
|
|
|
# Setting up libpcre
|
2020-02-16 09:15:30 -05:00
|
|
|
query_system_link "libpcre.so.3" "$_dp_path"
|
2020-01-25 09:05:48 -05:00
|
|
|
cp "${library_path}" . || { echo "failed to copy libpcre.so.3"; exit 1; }
|
2020-01-25 08:37:59 -05:00
|
|
|
fi
|
2020-01-24 13:39:43 -05:00
|
|
|
|
2020-01-25 10:00:21 -05:00
|
|
|
# Doing some prostprocessing
|
|
|
|
chmod 755 *
|
2020-01-25 09:05:48 -05:00
|
|
|
for file in *.so*; do
|
|
|
|
echo "Editing rpath for $file"
|
2020-01-25 10:00:21 -05:00
|
|
|
strip -s "$file"
|
2020-01-25 09:05:48 -05:00
|
|
|
patchelf --set-rpath "./libs/:./" "$file"
|
|
|
|
done
|
2020-01-24 13:23:40 -05:00
|
|
|
|
2020-02-16 09:15:30 -05:00
|
|
|
echo "All libraries have been copied successfully"
|