diff --git a/tools/linux_builder.sh b/tools/linux_builder.sh index 874d567d2..6046054a6 100755 --- a/tools/linux_builder.sh +++ b/tools/linux_builder.sh @@ -49,7 +49,7 @@ export DIRNAME="$(dirname "$(readlink -f "$0")")" ######################## CONFIG ######################## -export STK_VERSION="git20200711" +export STK_VERSION="git`date +%Y%m%d`" export THREADS_NUMBER=`nproc` export SCHROOT_32BIT_NAME="chroot-jessie32" export SCHROOT_64BIT_NAME="chroot-jessie64" @@ -63,10 +63,8 @@ export BLACKLIST_LIBS="ld-linux libbsd.so libc.so libdl.so libdrm libexpat \ libGL libgl libm.so libmvec.so libpthread libresolv \ librt.so libX libxcb libxshm" -export BUILD_DIR_32BIT="build-linux-32bit" -export BUILD_DIR_64BIT="build-linux-64bit" -export DEPENDENCIES_DIR_32BIT="$STKCODE_DIR/dependencies-linux-32bit" -export DEPENDENCIES_DIR_64BIT="$STKCODE_DIR/dependencies-linux-64bit" +export BUILD_DIR="build-linux" +export DEPENDENCIES_DIR="$STKCODE_DIR/dependencies-linux" export STK_INSTALL_DIR="$STKCODE_DIR/build-linux-install" # Use it if you build STK with Debian Jessie @@ -96,7 +94,6 @@ write_run_game_sh() echo '#!/bin/sh' > "$FILE" echo '' >> "$FILE" echo 'export DIRNAME="$(dirname "$(readlink -f "$0")")"' >> "$FILE" - echo 'export MACHINE_TYPE=`uname -m`' >> "$FILE" echo 'export SYSTEM_LD_LIBRARY_PATH="$LD_LIBRARY_PATH"' >> "$FILE" echo '' >> "$FILE" echo 'export SUPERTUXKART_DATADIR="$DIRNAME"' >> "$FILE" @@ -104,15 +101,9 @@ write_run_game_sh() echo '' >> "$FILE" echo 'cd "$DIRNAME"' >> "$FILE" echo '' >> "$FILE" - echo 'if [ $MACHINE_TYPE = "x86_64" ]; then' >> "$FILE" - echo ' echo "Running 64-bit version..."' >> "$FILE" - echo ' export LD_LIBRARY_PATH="$DIRNAME/lib-64:$LD_LIBRARY_PATH"' >> "$FILE" - echo ' "$DIRNAME/bin-64/supertuxkart" "$@"' >> "$FILE" - echo 'else' >> "$FILE" - echo ' echo "Running 32-bit version..."' >> "$FILE" - echo ' export LD_LIBRARY_PATH="$DIRNAME/lib:$LD_LIBRARY_PATH"' >> "$FILE" - echo ' "$DIRNAME/bin/supertuxkart" "$@"' >> "$FILE" - echo 'fi' >> "$FILE" + echo 'export LD_LIBRARY_PATH="$DIRNAME/lib:$LD_LIBRARY_PATH"' >> "$FILE" + echo '"$DIRNAME/bin/supertuxkart" "$@"' >> "$FILE" + echo '' >> "$FILE" } build_stk() @@ -456,9 +447,9 @@ copy_libraries() return fi - export DEPENDENCIES_DIR=$1 - export BUILD_DIR=$2 - export LIB_INSTALL_DIR=$3 + export DEPENDENCIES_DIR="$1" + export BUILD_DIR="$2" + export LIB_INSTALL_DIR="$3" if [ -z "$DEPENDENCIES_DIR" ] || [ -z "$BUILD_DIR" ] || [ -z "$LIB_INSTALL_DIR" ]; then return @@ -496,24 +487,15 @@ test_package() fi PACKAGE_DIR="$1" + BINARY_ARCH="$2" - if [ `objdump -a "$PACKAGE_DIR/bin/supertuxkart" | grep -c "elf32-i386"` -eq 0 ]; then - echo "Error: bin/supertuxkart is not 32-bit" + if [ `objdump -a "$PACKAGE_DIR/bin/supertuxkart" | grep -c "$BINARY_ARCH"` -eq 0 ]; then + echo "Error: bin/supertuxkart is not $BINARY_ARCH" exit 1 fi - if [ `objdump -a "$PACKAGE_DIR/bin/supertuxkart-editor" | grep -c "elf32-i386"` -eq 0 ]; then - echo "Error: bin/supertuxkart-editor is not 32-bit" - exit 1 - fi - - if [ `objdump -a "$PACKAGE_DIR/bin-64/supertuxkart" | grep -c "elf64-x86-64"` -eq 0 ]; then - echo "Error: bin-64/supertuxkart is not 64-bit" - exit 1 - fi - - if [ `objdump -a "$PACKAGE_DIR/bin-64/supertuxkart-editor" | grep -c "elf64-x86-64"` -eq 0 ]; then - echo "Error: bin-64/supertuxkart-editor is not 64-bit" + if [ `objdump -a "$PACKAGE_DIR/bin/supertuxkart-editor" | grep -c "$BINARY_ARCH"` -eq 0 ]; then + echo "Error: bin/supertuxkart-editor is not $BINARY_ARCH" exit 1 fi @@ -527,43 +509,91 @@ test_package() exit 1 fi - if [ `LD_LIBRARY_PATH="$PACKAGE_DIR/lib-64" ldd "$PACKAGE_DIR/bin-64/supertuxkart" | grep -c "not found"` -gt 0 ]; then - echo "Error: bin-64/supertuxkart has some missing libraries" - exit 1 - fi - - if [ `ldd "$PACKAGE_DIR/bin-64/supertuxkart-editor" | grep -c "not found"` -gt 0 ]; then - echo "Error: bin-64/supertuxkart-editor has some missing libraries" - exit 1 - fi - LD_LIBRARY_PATH="$PACKAGE_DIR/lib" "$PACKAGE_DIR/bin/supertuxkart" --version if [ $? -ne 0 ]; then echo "Error: Couldn't start bin/supertuxkart" exit 1 fi +} + +create_package() +{ + SCHROOT_NAME="$1" + ARCH="$2" + BINARY_ARCH="$3" - LD_LIBRARY_PATH="$PACKAGE_DIR/lib-64" "$PACKAGE_DIR/bin-64/supertuxkart" --version + echo "Building $ARCH version..." - if [ $? -ne 0 ]; then - echo "Error: Couldn't start bin-64/supertuxkart" + schroot -c $SCHROOT_NAME -- "$0" build_stk "$DEPENDENCIES_DIR-$ARCH" "$BUILD_DIR-$ARCH" "-DDEBUG_SYMBOLS=1" + + if [ ! -f "$STKCODE_DIR/$BUILD_DIR-$ARCH/bin/supertuxkart" ]; then + echo "Couldn't build $ARCH version." exit 1 fi + + echo "Prepare package..." + + STK_PACKAGE_DIR="$STK_INSTALL_DIR/SuperTuxKart-$STK_VERSION-linux-$ARCH" + + if [ -f "$STK_PACKAGE_DIR" ]; then + rm -rf "$STK_PACKAGE_DIR" + fi + + mkdir -p "$STK_PACKAGE_DIR" + mkdir -p "$STK_PACKAGE_DIR/bin" + mkdir -p "$STK_PACKAGE_DIR/lib" + + schroot -c $SCHROOT_NAME -- "$0" copy_libraries "$DEPENDENCIES_DIR-$ARCH" "$BUILD_DIR-$ARCH" "$STK_PACKAGE_DIR/lib" + + find "$STK_PACKAGE_DIR/lib" -type f -exec strip -s {} \; + + mv "$STK_PACKAGE_DIR/lib/libgcc_s.so.1" "$STK_PACKAGE_DIR/lib/libgcc_s.so.1-orig" + mv "$STK_PACKAGE_DIR/lib/libstdc++.so.6" "$STK_PACKAGE_DIR/lib/libstdc++.so.6-orig" + + write_run_game_sh "$STK_PACKAGE_DIR" + + cp "$STKCODE_DIR/$BUILD_DIR-$ARCH/bin/supertuxkart" "$STK_INSTALL_DIR/supertuxkart-$STK_VERSION-linux-$ARCH-symbols" + cp "$STKEDITOR_DIR/$BUILD_DIR-$ARCH/bin/supertuxkart-editor" "$STK_INSTALL_DIR/supertuxkart-editor-$STK_VERSION-linux-$ARCH-symbols" + + cp -a "$STKCODE_DIR/$BUILD_DIR-$ARCH/bin/supertuxkart" "$STK_PACKAGE_DIR/bin/" + cp -a "$STKEDITOR_DIR/$BUILD_DIR-$ARCH/bin/supertuxkart-editor" "$STK_PACKAGE_DIR/bin/" + + cp -a "$STKCODE_DIR/data/." "$STK_PACKAGE_DIR/data" + cp -a "$STKASSETS_DIR/editor" "$STK_PACKAGE_DIR/data/" + cp -a "$STKASSETS_DIR/karts" "$STK_PACKAGE_DIR/data/" + cp -a "$STKASSETS_DIR/library" "$STK_PACKAGE_DIR/data/" + cp -a "$STKASSETS_DIR/models" "$STK_PACKAGE_DIR/data/" + cp -a "$STKASSETS_DIR/music" "$STK_PACKAGE_DIR/data/" + cp -a "$STKASSETS_DIR/sfx" "$STK_PACKAGE_DIR/data/" + cp -a "$STKASSETS_DIR/textures" "$STK_PACKAGE_DIR/data/" + cp -a "$STKASSETS_DIR/tracks" "$STK_PACKAGE_DIR/data/" + cp -a "$STKASSETS_DIR/licenses.txt" "$STK_PACKAGE_DIR/data/" + + strip --strip-debug "$STK_PACKAGE_DIR/bin/supertuxkart" + strip --strip-debug "$STK_PACKAGE_DIR/bin/supertuxkart-editor" + + chmod a+rwx "$STK_PACKAGE_DIR" -R + find "$STK_PACKAGE_DIR" -type f -exec chmod a-x {} \; + find "$STK_PACKAGE_DIR/bin" -type f -exec chmod a+x {} \; + chmod a+x "$STK_PACKAGE_DIR/run_game.sh" + + test_package "$STK_PACKAGE_DIR" "$BINARY_ARCH" + + # Compress package + + echo "Compress package..." + + cd "$STK_INSTALL_DIR" + tar cf - "SuperTuxKart-$STK_VERSION-linux-$ARCH" | xz -z -e -f - > "SuperTuxKart-$STK_VERSION-linux-$ARCH.tar.xz" + cd - } # Handle clean command if [ ! -z "$1" ] && [ "$1" = "clean" ]; then - rm -rf "$DEPENDENCIES_DIR_32BIT" - rm -rf "$DEPENDENCIES_DIR_64BIT" - rm -rf "$STKCODE_DIR/$BUILD_DIR_32BIT" - rm -rf "$STKCODE_DIR/$BUILD_DIR_64BIT" - rm -rf "$STKCODE_DIR/$BUILD_DIR_32BIT-symbols" - rm -rf "$STKCODE_DIR/$BUILD_DIR_64BIT-symbols" - rm -rf "$STKEDITOR_DIR/$BUILD_DIR_32BIT" - rm -rf "$STKEDITOR_DIR/$BUILD_DIR_64BIT" - rm -rf "$STKEDITOR_DIR/$BUILD_DIR_32BIT-symbols" - rm -rf "$STKEDITOR_DIR/$BUILD_DIR_64BIT-symbols" + rm -rf "$DEPENDENCIES_DIR-"* + rm -rf "$STKCODE_DIR/$BUILD_DIR-"* + rm -rf "$STKEDITOR_DIR/$BUILD_DIR-"* rm -rf "$STK_INSTALL_DIR" exit 0 fi @@ -581,106 +611,8 @@ if [ ! -z "$1 " ] && [ "$1" = "copy_libraries" ]; then fi # Building STK -echo "Building 32-bit version..." -schroot -c $SCHROOT_32BIT_NAME -- "$0" build_stk "$DEPENDENCIES_DIR_32BIT" "$BUILD_DIR_32BIT" - -if [ ! -f "$STKCODE_DIR/$BUILD_DIR_32BIT/bin/supertuxkart" ]; then - echo "Couldn't build 32-bit version." - exit 1 -fi - -echo "Building 64-bit version..." - -schroot -c $SCHROOT_64BIT_NAME -- "$0" build_stk "$DEPENDENCIES_DIR_64BIT" "$BUILD_DIR_64BIT" - -if [ ! -f "$STKCODE_DIR/$BUILD_DIR_64BIT/bin/supertuxkart" ]; then - echo "Couldn't build 64-bit version." - exit 1 -fi - -echo "Building 32-bit version with symbols..." - -schroot -c $SCHROOT_32BIT_NAME -- "$0" build_stk "$DEPENDENCIES_DIR_32BIT" "$BUILD_DIR_32BIT-symbols" "-DDEBUG_SYMBOLS=1" - -if [ ! -f "$STKCODE_DIR/$BUILD_DIR_32BIT/bin/supertuxkart" ]; then - echo "Couldn't build 32-bit version with symbols." - exit 1 -fi - -echo "Building 64-bit version with symbols..." - -schroot -c $SCHROOT_64BIT_NAME -- "$0" build_stk "$DEPENDENCIES_DIR_64BIT" "$BUILD_DIR_64BIT-symbols" "-DDEBUG_SYMBOLS=1" - -if [ ! -f "$STKCODE_DIR/$BUILD_DIR_64BIT/bin/supertuxkart" ]; then - echo "Couldn't build 64-bit version with symbols." - exit 1 -fi - -# Making package - -echo "Prepare package..." - -STK_PACKAGE_DIR="$STK_INSTALL_DIR/SuperTuxKart-$STK_VERSION-linux" - -if [ -f "$STK_PACKAGE_DIR" ]; then - rm -rf "$STK_PACKAGE_DIR" -fi - -mkdir -p "$STK_PACKAGE_DIR" -mkdir -p "$STK_PACKAGE_DIR/bin" -mkdir -p "$STK_PACKAGE_DIR/bin-64" -mkdir -p "$STK_PACKAGE_DIR/lib" -mkdir -p "$STK_PACKAGE_DIR/lib-64" - -schroot -c $SCHROOT_32BIT_NAME -- "$0" copy_libraries "$DEPENDENCIES_DIR_32BIT" "$BUILD_DIR_32BIT" "$STK_PACKAGE_DIR/lib" -schroot -c $SCHROOT_64BIT_NAME -- "$0" copy_libraries "$DEPENDENCIES_DIR_64BIT" "$BUILD_DIR_64BIT" "$STK_PACKAGE_DIR/lib-64" - -find "$STK_PACKAGE_DIR/lib" -type f -exec strip -s {} \; -find "$STK_PACKAGE_DIR/lib-64" -type f -exec strip -s {} \; - -mv "$STK_PACKAGE_DIR/lib/libgcc_s.so.1" "$STK_PACKAGE_DIR/lib/libgcc_s.so.1-orig" -mv "$STK_PACKAGE_DIR/lib-64/libgcc_s.so.1" "$STK_PACKAGE_DIR/lib-64/libgcc_s.so.1-orig" -mv "$STK_PACKAGE_DIR/lib/libstdc++.so.6" "$STK_PACKAGE_DIR/lib/libstdc++.so.6-orig" -mv "$STK_PACKAGE_DIR/lib-64/libstdc++.so.6" "$STK_PACKAGE_DIR/lib-64/libstdc++.so.6-orig" - -write_run_game_sh "$STK_PACKAGE_DIR" - -cp "$STKCODE_DIR/$BUILD_DIR_32BIT-symbols/bin/supertuxkart" "$STK_INSTALL_DIR/supertuxkart-$STK_VERSION-linux32-symbols" -cp "$STKCODE_DIR/$BUILD_DIR_64BIT-symbols/bin/supertuxkart" "$STK_INSTALL_DIR/supertuxkart-$STK_VERSION-linux64-symbols" -cp "$STKEDITOR_DIR/$BUILD_DIR_32BIT-symbols/bin/supertuxkart-editor" "$STK_INSTALL_DIR/supertuxkart-editor-$STK_VERSION-linux32-symbols" -cp "$STKEDITOR_DIR/$BUILD_DIR_64BIT-symbols/bin/supertuxkart-editor" "$STK_INSTALL_DIR/supertuxkart-editor-$STK_VERSION-linux64-symbols" - -cp -a "$STKCODE_DIR/$BUILD_DIR_32BIT/bin/supertuxkart" "$STK_PACKAGE_DIR/bin/" -cp -a "$STKCODE_DIR/$BUILD_DIR_64BIT/bin/supertuxkart" "$STK_PACKAGE_DIR/bin-64/" -cp -a "$STKEDITOR_DIR/$BUILD_DIR_32BIT/bin/supertuxkart-editor" "$STK_PACKAGE_DIR/bin/" -cp -a "$STKEDITOR_DIR/$BUILD_DIR_64BIT/bin/supertuxkart-editor" "$STK_PACKAGE_DIR/bin-64/" - -cp -a "$STKCODE_DIR/data/." "$STK_PACKAGE_DIR/data" -cp -a "$STKASSETS_DIR/editor" "$STK_PACKAGE_DIR/data/" -cp -a "$STKASSETS_DIR/karts" "$STK_PACKAGE_DIR/data/" -cp -a "$STKASSETS_DIR/library" "$STK_PACKAGE_DIR/data/" -cp -a "$STKASSETS_DIR/models" "$STK_PACKAGE_DIR/data/" -cp -a "$STKASSETS_DIR/music" "$STK_PACKAGE_DIR/data/" -cp -a "$STKASSETS_DIR/sfx" "$STK_PACKAGE_DIR/data/" -cp -a "$STKASSETS_DIR/textures" "$STK_PACKAGE_DIR/data/" -cp -a "$STKASSETS_DIR/tracks" "$STK_PACKAGE_DIR/data/" -cp -a "$STKASSETS_DIR/licenses.txt" "$STK_PACKAGE_DIR/data/" - -chmod a+rwx "$STK_PACKAGE_DIR" -R -find "$STK_PACKAGE_DIR" -type f -exec chmod a-x {} \; -find "$STK_PACKAGE_DIR/bin" -type f -exec chmod a+x {} \; -find "$STK_PACKAGE_DIR/bin-64" -type f -exec chmod a+x {} \; -chmod a+x "$STK_PACKAGE_DIR/run_game.sh" - -test_package "$STK_PACKAGE_DIR" - -# Compress package - -echo "Compress package..." - -cd "$STK_INSTALL_DIR" -tar cf - "SuperTuxKart-$STK_VERSION-linux" | xz -z -e -f - > "SuperTuxKart-$STK_VERSION-linux.tar.xz" -cd - +create_package "$SCHROOT_32BIT_NAME" "32bit" "elf32-i386" +create_package "$SCHROOT_64BIT_NAME" "64bit" "elf64-x86-64" echo "Success."