From b1727206c037c8271d91b49554e727365ca3b699 Mon Sep 17 00:00:00 2001
From: WolverinDEV <git@did.science>
Date: Sun, 26 Jan 2020 16:42:01 +0100
Subject: [PATCH] Adding stuff

---
 .gitignore                   |   1 +
 Jenkinsfile                  | 156 +++++++++++++++++++++++++++++++----
 TeaSpeak                     |   2 +-
 build-helpers                |   2 +-
 build_nice.md                |  26 +++---
 libraries/build_datapipes.sh |   2 +-
 setup_alpine                 |   2 +-
 setup_arm                    |  16 ++--
 8 files changed, 166 insertions(+), 41 deletions(-)

diff --git a/.gitignore b/.gitignore
index 5a2802a..80d0a96 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@ Web-Client
 WebClient.zip
 Web-Client-I18N
 .idea
+symbols
diff --git a/Jenkinsfile b/Jenkinsfile
index 8df910a..09486e3 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -3,7 +3,7 @@ pipeline {
 
     parameters {
        booleanParam(defaultValue: true, description: 'Deploy this build', name: 'deploy_build')
-       choice(choices: ['none', 'x86_debug', 'x86_release', 'x86_stable', 'x64_debug', 'x64_release', 'x64_stable'], description: 'Which target do you want to build?', name: 'target')
+       choice(choices: ['none', 'x86_debug', 'x86_release', 'x86_stable', 'amd64_debug', 'amd64_release', 'amd64_stable', 'arm32v7_debug', 'arm32v7_release', 'arm32v7_stable'], description: 'Which target do you want to build?', name: 'target')
     }
 
 	environment {
@@ -19,12 +19,12 @@ pipeline {
 	
 	stages {
 		/* build all amd64 stuff */
-		stage ('build::x64') {
+		stage ('build::amd64') {
 			agent {
 				label 'linux && amd64 && teaspeak'
 			}
 			when {
-				expression { params.target == "x64_debug" || params.target == "x64_release" || params.target == "x64_stable" }
+				expression { params.target == "amd64_debug" || params.target == "amd64_release" || params.target == "amd64_stable" }
 			}
 						
 			environment {
@@ -33,7 +33,7 @@ pipeline {
 			}
 			
 			stages {
-				stage ('build::x64::libraries') {
+				stage ('build::amd64::libraries') {
 					environment {
 						CMAKE_BUILD_TYPE="RelWithDebInfo" /* we build out libraries every time in release mode! (Performance improve) */
 					}
@@ -45,13 +45,13 @@ pipeline {
 				}
 				
 				
-				stage ('build::x64::debug') {
+				stage ('build::amd64::debug') {
 					when {
-						expression { params.target == "x64_debug" }
+						expression { params.target == "amd64_debug" }
 					}
 					
 					stages {
-						stage ('build::x64::debug::build') {
+						stage ('build::amd64::debug::build') {
 							environment {
 								TEASPEAK_BUILD_TYPE="Debug"
 								CMAKE_BUILD_TYPE="Debug"
@@ -76,13 +76,13 @@ pipeline {
 					}
 				}
 				
-				stage ('build::x64::release') {
+				stage ('build::amd64::release') {
 					when {
-						expression { params.target == "x64_release" }
+						expression { params.target == "amd64_release" }
 					}
 					
 					stages {
-						stage ('build::x64::release::build') {
+						stage ('build::amd64::release::build') {
 							environment {
 								TEASPEAK_BUILD_TYPE="Release"
 								CMAKE_BUILD_TYPE="RelWithDebInfo"
@@ -107,13 +107,13 @@ pipeline {
 					}
 				}
 				
-				stage ('build::x64::stable') {
+				stage ('build::amd64::stable') {
 					when {
-						expression { params.target == "x64_stable" }
+						expression { params.target == "amd64_stable" }
 					}
 					
 					stages {
-						stage ('build::x64::stable::build') {
+						stage ('build::amd64::stable::build') {
 							environment {
 								TEASPEAK_BUILD_TYPE="Release"
 								CMAKE_BUILD_TYPE="RelWithDebInfo"
@@ -187,7 +187,7 @@ pipeline {
 							}
 						}
 
-						stage ('build::amd64::debug::deploy') {
+						stage ('build::x86::debug::deploy') {
 							when {
 								expression { params.deploy_build }
 							}
@@ -218,7 +218,7 @@ pipeline {
 							}
 						}
 
-						stage ('build::amd64::release::deploy') {
+						stage ('build::x86::release::deploy') {
 							when {
 								expression { params.deploy_build }
 							}
@@ -230,7 +230,7 @@ pipeline {
 					}
 				}
 				
-				stage ('build::x64::stable') {
+				stage ('build::x86::stable') {
 					when {
 						expression { params.target == "x86_stable" }
 					}
@@ -249,7 +249,7 @@ pipeline {
 							}
 						}
 
-						stage ('build::amd64::stable::deploy') {
+						stage ('build::x86::stable::deploy') {
 							when {
 								expression { params.deploy_build }
 							}
@@ -262,5 +262,127 @@ pipeline {
 				}
 			}
 		}
+
+		/* build all arm32v7 stuff */
+		stage ('build::arm32v7') {
+			agent {
+				label 'linux && arm32v7 && teaspeak'
+			}
+			when {
+				expression { params.target == "arm32v7_debug" || params.target == "arm32v7_release" || params.target == "arm32v7_stable" }
+			}
+						
+			environment {
+				build_os_type="linux"
+				build_os_arch="arm32v7"
+			}
+			
+			stages {
+				stage ('build::arm32v7::libraries') {
+					environment {
+						CMAKE_BUILD_TYPE="RelWithDebInfo" /* we build out libraries every time in release mode! (Performance improve) */
+					}
+
+					steps {
+						sh './attach_modules.sh'
+						sh 'cd libraries; ./build.sh'
+					}
+				}
+				
+				
+				stage ('build::arm32v7::debug') {
+					when {
+						expression { params.target == "arm32v7_debug" }
+					}
+					
+					stages {
+						stage ('build::amd64::debug::build') {
+							environment {
+								TEASPEAK_BUILD_TYPE="Debug"
+								CMAKE_BUILD_TYPE="Debug"
+								
+								TEASPEAK_DEPLOY_TYPE_SPECIFIER="-DBUILD_TYPE=1 -DBUILD_TYPE_NAME='beta'"
+							}
+
+							steps {
+								sh './build_teaspeak.sh'
+							}
+						}
+
+						stage ('build::amd64::debug::deploy') {
+							when {
+								expression { params.deploy_build }
+							}
+
+							steps {
+								sh 'cd TeaSpeak/server/repro/; chmod 400 build_private_key; ./build.sh linux/arm32v7_debug'
+							}
+						}
+					}
+				}
+				
+				stage ('build::arm32v7::release') {
+					when {
+						expression { params.target == "arm32v7_release" }
+					}
+					
+					stages {
+						stage ('build::arm32v7::release::build') {
+							environment {
+								TEASPEAK_BUILD_TYPE="Release"
+								CMAKE_BUILD_TYPE="RelWithDebInfo"
+								
+								TEASPEAK_DEPLOY_TYPE_SPECIFIER="-DBUILD_TYPE=1 -DBUILD_TYPE_NAME='beta'"
+							}
+
+							steps {
+								sh './build_teaspeak.sh'
+							}
+						}
+
+						stage ('build::arm32v7::release::deploy') {
+							when {
+								expression { params.deploy_build }
+							}
+
+							steps {
+								sh 'cd TeaSpeak/server/repro/; chmod 400 build_private_key; ./build.sh linux/arm32v7_optimized'
+							}
+						}
+					}
+				}
+				
+				stage ('build::arm32v7::stable') {
+					when {
+						expression { params.target == "arm32v7_stable" }
+					}
+					
+					stages {
+						stage ('build::arm32v7::stable::build') {
+							environment {
+								TEASPEAK_BUILD_TYPE="Release"
+								CMAKE_BUILD_TYPE="RelWithDebInfo"
+								
+								TEASPEAK_DEPLOY_TYPE_SPECIFIER="-DBUILD_TYPE=0 -DBUILD_TYPE_NAME=''"
+							}
+
+							steps {
+								sh './build_teaspeak.sh'
+							}
+						}
+
+						stage ('build::arm32v7::stable::deploy') {
+							when {
+								expression { params.deploy_build }
+							}
+
+							steps {
+								sh 'cd TeaSpeak/server/repro/; chmod 400 build_private_key; ./build.sh linux/arm32v7_stable'
+							}
+						}
+					}
+				}
+			}
+		}
 	}
 }
diff --git a/TeaSpeak b/TeaSpeak
index 10092cf..8fc8e43 160000
--- a/TeaSpeak
+++ b/TeaSpeak
@@ -1 +1 @@
-Subproject commit 10092cfab0a3c6d751eb4e1b402bdc77119ea56c
+Subproject commit 8fc8e43b2cf6b6c0cec31df9f5c0cb11e7d79092
diff --git a/build-helpers b/build-helpers
index d7203d8..516071d 160000
--- a/build-helpers
+++ b/build-helpers
@@ -1 +1 @@
-Subproject commit d7203d854b75cb7954a2580c645729e7def8f297
+Subproject commit 516071dfe82a8af80a54adebdb13cfaabdf8c090
diff --git a/build_nice.md b/build_nice.md
index accdd4e..a6405eb 100644
--- a/build_nice.md
+++ b/build_nice.md
@@ -1,4 +1,9 @@
 # Dependencies
+## General dependencies
+```shell script
+sudo apt install -y texinfo bison flex libglib2.0-dev
+```
+
 ## Python 3.6
 ```shell script
 wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz && \
@@ -12,12 +17,7 @@ sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python3
 pip3.6 install --upgrade pip
 ```
 
-## Ninja
-### Using official version (may be outdated)
-```shell script
-sudo apt install ninja
-```
-### Building from source
+## Ninja (from source)
 ```shell script
 apt-get purge ninja
 
@@ -34,15 +34,15 @@ pip3.6 install meson
 ```
 
 ## objcopy
-`objcopy` must be build from source because the option "--add-symbol" is mouse likely not available...
+`objcopy` must be build from source because the option "--add-symbol" is mouse likely not available...  
+You might have to append `--target=i386-pc-linux-gnu` for 32 bit PCs  
 ```shell script
-apt-get install -y texinfo bison flex
-
-git clone git://sourceware.org/git/binutils-gdb.git && cd binutils-gdb && \
+git clone git://sourceware.org/git/binutils-gdb.git && cd binutils-gdb/binutils && \
 git checkout binutils-2_32-branch && \
 CXXFLAGS="-Wno-error=unused-function -O2" CFLAGS="-Wno-error=unused-function -O2" ./configure && \
 make -j32 && \
-make install
+make install && \
+cd ../..
 ```
 
 # Building GLIB2.0
@@ -87,7 +87,6 @@ Build libnice
 [[ -z "${build_os_type}" ]] && export build_os_type=linux
 [[ -z "${build_os_type}" ]] && export build_os_arch=amd64
 
-apt-get install -y gtk-doc-tools
 git clone https://github.com/libnice/libnice.git && cd libnice
 
 export glib20_dir="`pwd`/../glibc-prebuild/${build_os_type}_${build_os_arch}/"
@@ -101,7 +100,8 @@ export GLIB_CFLAGS="-I$glib20_dir/include/glib-2.0 -I`echo "$glib20_dir/lib/"*"/
 export GLIB_LIBS="-lgio-2.0 -lz -lresolv -lgmodule-2.0 -ldl -lgobject-2.0 -lffi -lglib-2.0 -lpcre -pthread" # Shared
 export LDFLAGS="-L$boringssl_path/crypto/ -L$boringssl_path/ssl/ -L$glib20_lib_path"
 
-./autogen.sh --prefix=`pwd`/out --with-pic --with-crypto-library=openssl --without-gstreamer --disable-assert --disable-gtk-doc --enable-static=no --enable-shared=yes && \
+sed 's/gtkdocize/#gtkdocize/g' autogen.sh # Fix for ARM
+CFLAGS="-Wno-error=cast-align" ./autogen.sh --prefix=`pwd`/out --with-pic --with-crypto-library=openssl --without-gstreamer --disable-assert --disable-gtk-doc --enable-static=no --enable-shared=yes && \
 make && \
 make install
 
diff --git a/libraries/build_datapipes.sh b/libraries/build_datapipes.sh
index 85d4566..2f90310 100755
--- a/libraries/build_datapipes.sh
+++ b/libraries/build_datapipes.sh
@@ -42,7 +42,7 @@ if [[ ${build_os_type} != "win32" && "${_datapipes_webrtc}" == "ON" ]]; then
 
     # TODO: pcre really required here?
     web_cmake_flags="$web_cmake_flags -DGLIB_PREBUILD_FLAGS=\"-I$glib20_dir/include -I$glib20_dir/include/glib-2.0/ -I$glib20_lib_path/glib-2.0/include/\""
-    web_cmake_flags="$web_cmake_flags -DGLIB_PREBUILD_LIBRARIES=\"$glib20_lib_path/libgio-2.0.so;z;resolv;$glib20_lib_path/libgmodule-2.0.so;$glib20_lib_path/libgobject-2.0.so;$glib20_lib_path/libffi.a;$glib20_lib_path/libglib-2.0.so;pcre\""
+    web_cmake_flags="$web_cmake_flags -DGLIB_PREBUILD_LIBRARIES=\"$glib20_lib_path/libgio-2.0.so;z;resolv;$glib20_lib_path/libgmodule-2.0.so;$glib20_lib_path/libgobject-2.0.so;$glib20_lib_path/libffi.so;$glib20_lib_path/libglib-2.0.so;pcre\""
     web_cmake_flags="$web_cmake_flags -DLIBNICE_PREBUILD_PATH=\"../libnice/linux_${build_os_arch}\""
     echo "WebRTC flags: $web_cmake_flags"
 fi
diff --git a/setup_alpine b/setup_alpine
index 335685c..7ddecc4 100644
--- a/setup_alpine
+++ b/setup_alpine
@@ -1,7 +1,7 @@
 # Basic Setup
 #linux-headers for unistd.h
 #bsd-compat-headers for sys/cdefs.h (arm only!)
-apk add bash coreutils build-base autoconf git wget sqlite-dev openssl-dev cmake patchelf go linux-headers bsd-compat-headers
+apk add bash coreutils build-base autoconf git wget sqlite-dev openssl-dev cmake patchelf go linux-headers bsd-compat-headers libexecinfo-dev
 git config --global credential.helper store
 
 # Create TeaSpeak
diff --git a/setup_arm b/setup_arm
index 204c9c2..75f7f48 100644
--- a/setup_arm
+++ b/setup_arm
@@ -1,17 +1,19 @@
 sudo apt-get update && \
 sudo apt-get install build-essential software-properties-common -y && \
 sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
-sudo apt-get update
-
+sudo apt-get update && \
 sudo apt-get install gcc-9 g++-9 -y && \
 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-9 && \
-sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-9 60 --slave /usr/bin/c++ c++ /usr/bin/c++-9
+sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-9 60 --slave /usr/bin/c++ c++ /usr/bin/c++-9 # THis fails for some reason
 
-apt-get install autoconf git wget libssl-dev realpath libsqlite3-dev libmysqlclient-dev
+Sometimes its required to build from source:
+https://raw.githubusercontent.com/darrenjs/howto/master/build_scripts/build_gcc_9.sh
 
-wget https://github.com/Kitware/CMake/releases/download/v3.16.3/cmake-3.16.3.tar.gz && tar xvf cmake-3.16.3.tar.gz
-cd cmake-3.16.3 && ./configure --parallel=16
-make -j16 && make install
+apt-get install -y autoconf git wget libssl-dev realpath libsqlite3-dev libmysqlclient-dev
+
+wget https://github.com/Kitware/CMake/releases/download/v3.16.3/cmake-3.16.3.tar.gz && tar xvf cmake-3.16.3.tar.gz && \
+cd cmake-3.16.3 && ./configure --parallel=16 && \
+make -j16 && make install && \
 cd ..
 
 git config --global credential.helper store