From 158c9ea196ebe35fb1a1bde28b44c8d975da30d5 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Fri, 24 Jan 2020 19:39:43 +0100 Subject: [PATCH] Improved server packaging --- server/repro/build.sh | 30 +++++++++++++++-------------- server/repro/deploy_build.sh | 2 +- server/repro/env/install_libnice.sh | 1 - server/repro/generate_libraries.sh | 7 ++++++- server/repro/generate_version.sh | 6 +++--- server/repro/make_symbol.sh | 12 +++++++++--- server/repro/package_server.sh | 12 +----------- server/repro/test_docker.sh | 3 ++- 8 files changed, 38 insertions(+), 35 deletions(-) delete mode 120000 server/repro/env/install_libnice.sh diff --git a/server/repro/build.sh b/server/repro/build.sh index eaac7c0..5c46d98 100755 --- a/server/repro/build.sh +++ b/server/repro/build.sh @@ -1,25 +1,27 @@ -#!/usr/bin/env bash +#!/bin/bash BUILD_PATH=$1 -if [ -z ${BUILD_PATH} ]; then +if [[ -z "${BUILD_PATH}" ]]; then echo "Missing versions path!" exit 1 fi -./generate_version.sh ${BUILD_PATH} -if [ $? -ne 0 ]; then - echo "Failed to generate version!" +./generate_version.sh "${BUILD_PATH}" || { + echo "Failed to generate version! ($?)" exit 1 -fi +} -./package_server.sh ${BUILD_PATH} -if [ $? -ne 0 ]; then - echo "Failed to package server!" +./generate_libraries.sh || { + echo "Failed to generate libraries! ($?)" exit 1 -fi +} -./deploy_build.sh ${BUILD_PATH} -if [ $? -ne 0 ]; then - echo "Failed to deploy package!" +./package_server.sh "${BUILD_PATH}" || { + echo "Failed to package server! ($?)" exit 1 -fi \ No newline at end of file +} + +./deploy_build.sh "${BUILD_PATH}" || { + echo "Failed to deploy package! ($?)" + exit 1 +} \ No newline at end of file diff --git a/server/repro/deploy_build.sh b/server/repro/deploy_build.sh index 6465050..a1b5b64 100755 --- a/server/repro/deploy_build.sh +++ b/server/repro/deploy_build.sh @@ -3,7 +3,7 @@ BUILD_PATH=$1 if [[ -z ${BUILD_PATH} ]]; then echo "Missing versions path!" - #exit 1 + exit 1 fi BUILD_INFO=($(cat build_version.txt)) diff --git a/server/repro/env/install_libnice.sh b/server/repro/env/install_libnice.sh deleted file mode 120000 index 65420f7..0000000 --- a/server/repro/env/install_libnice.sh +++ /dev/null @@ -1 +0,0 @@ -../../../git-teaspeak/default_files/install_libnice.sh \ No newline at end of file diff --git a/server/repro/generate_libraries.sh b/server/repro/generate_libraries.sh index 2ee59e3..605fc6f 100755 --- a/server/repro/generate_libraries.sh +++ b/server/repro/generate_libraries.sh @@ -45,7 +45,8 @@ library_path=$(realpath "${library_base}/boringssl/${build_path}/crypto/libcrypt ln -s "$library_path" . || { echo "failed to link libcrypto.so"; exit 1; } # Setting up DataPipes -ln -s "${library_base}/DataPipes/${build_path}/lib/libDataPipes.so" . || { echo "failed to link libDataPipes.so"; exit 1; } +library_path=$(realpath "${library_base}//DataPipes/${build_path}/lib/libDataPipes.so") +ln -s "$library_path" . || { echo "failed to link libDataPipes.so"; exit 1; } # Setting up Sqlite3 query_system_link "libsqlite3.so.0" @@ -59,6 +60,10 @@ ln -s "${library_path}" . || { echo "failed to link libjemalloc.so.2"; exit 1; } library_path=$(realpath "../../../../MusicBot/libs/libTeaMusic.so") ln -s "$library_path" . || { echo "failed to link libTeaMusic.so"; exit 1; } +# Setting up libnice +library_path=$(realpath "${library_base}/libnice/${build_os_type}_${build_os_arch}/lib/libnice.so.10") +ln -s "$library_path" . || { echo "failed to link libnice.so.10"; exit 1; } + # Validate setup broken_links=$(find . -type l ! -exec test -e {} \; -print) [[ -n ${broken_links} ]] && { diff --git a/server/repro/generate_version.sh b/server/repro/generate_version.sh index 3523448..f3ad6a4 100755 --- a/server/repro/generate_version.sh +++ b/server/repro/generate_version.sh @@ -17,13 +17,13 @@ if [[ -z ${BUILD_PATH} ]]; then #exit 1 fi -CURRENT_VERSION=`cat env/buildVersion.txt` +CURRENT_VERSION=$(cat env/buildVersion.txt) CURRENT_VERSION_ESCAPED=$(echo "${CURRENT_VERSION}" | sed -e 's/[\/&\.\-]/\\&/g') -AVAILABLE_VERSIONS=`ssh -i build_private_key TeaSpeak-Jenkins@mcgalaxy.de " +AVAILABLE_VERSIONS=$(ssh -i build_private_key TeaSpeak-Jenkins@mcgalaxy.de " if [ -d versions/${BUILD_PATH} ]; then ls versions/${BUILD_PATH} | grep -E '^${CURRENT_VERSION_ESCAPED}(\-[0-9]+)?$' fi -"` +") debug "${AVAILABLE_VERSIONS}" TARGET_VERSION="" diff --git a/server/repro/make_symbol.sh b/server/repro/make_symbol.sh index d656db8..0a8fd1e 100755 --- a/server/repro/make_symbol.sh +++ b/server/repro/make_symbol.sh @@ -6,7 +6,7 @@ TMP_FILE="temp" function mkdir_not_exists() { if [[ ! -d $1 ]]; then - mkdir $1 + mkdir "$1" fi } @@ -15,7 +15,10 @@ function create_dump() { local BINARY_NAME=${2} echo "Creating dump file for ${BINARY_NAME} (${BINARY_PATH}/${BINARY_NAME})" - dump_syms ${BINARY_PATH}/${BINARY_NAME} > ${TMP_FILE} + dump_syms "${BINARY_PATH}/${BINARY_NAME}" > ${TMP_FILE} || { + echo "Failed to generate dump." + exit 1 + } SYM_INFO=$(head -n1 < ${TMP_FILE}) SYM_INFO=($SYM_INFO) DUMP_ID=${SYM_INFO[3]} @@ -26,7 +29,10 @@ function create_dump() { mkdir_not_exists ${SYMBOL_ROOT}/${BINARY_NAME}/${DUMP_ID} DUMP_PATH=${SYMBOL_ROOT}/${BINARY_NAME}/${DUMP_ID}/${BINARY_NAME}.sym - mv ${TMP_FILE} ${DUMP_PATH} + mv "$TMP_FILE" "$DUMP_PATH" || { + echo "Failed to move dump." + exit 1 + } } create_dump "env" "TeaSpeakServer" diff --git a/server/repro/package_server.sh b/server/repro/package_server.sh index 19af32a..8e89538 100755 --- a/server/repro/package_server.sh +++ b/server/repro/package_server.sh @@ -20,23 +20,13 @@ echo -e "# Version: ${BUILD_FULL_NAME} # TeaSpeak version: ${BUILD_NAME} # Build version: ${BUILD_VERSION} -{build_name: \"${BUILD_FULL_NAME}\", build_version: \"${BUILD_NAME}\", build_index: ${BUILD_VERSION}}" > buildVersion.txt +{\"build_name\": \"${BUILD_FULL_NAME}\", \"build_version\": \"${BUILD_NAME}\", \"build_index\": ${BUILD_VERSION}}" > buildVersion.txt #Create a copy and save unstripped cp TeaSpeakServer TeaSpeakServerTmp rm TeaSpeakServer mv TeaSpeakServerTmp TeaSpeakServer -#Copy libnice into place -if [[ -z ${build_os_type} || -z ${build_os_arch} ]]; then - echo "Missing build_os_type or build_os_arch." - exit 1 -fi -cp "../../../../libraries/libnice/${build_os_type}_${build_os_arch}/lib/libnice.so.10" ./libs/ || { - echo "failed to copy libnice" - exit 1 -} - strip -s -p -v TeaSpeakServer tar --dereference -czvf "../${BUILD_FILENAME}" * cd .. diff --git a/server/repro/test_docker.sh b/server/repro/test_docker.sh index 96b1a23..d595de1 100755 --- a/server/repro/test_docker.sh +++ b/server/repro/test_docker.sh @@ -3,8 +3,9 @@ BVERSION="$(cat env/buildVersion.txt)" FBUILD=0 +# shellcheck disable=SC2120 function buildName() { - if [ ! -z "$1" ]; then + if [ -n "$1" ]; then L_FBUILD="$1" else L_FBUILD="${FBUILD}"