2
Creating tarball packages on GNU Linux
Grim Kriegor edited this page 2017-12-30 18:30:15 +00:00

The whole process has been automated with TES3MP-forge, there you will find better maintained steps to creating these packages

This package building process relies heavily on the TES3MP-deploy script make package feature, the following documentation suggests a few steps on how to create a proper build environment that will ensure compatibility with a large number of distros and distro versions.

Debian 8 is chosen as the base system as it's old enough to contain legacy libraries sure to fit most distros.

However, being so old requires the compilation of a bunch of tools and dependencies for TES3MP to even build.

Chroot

Create it

mkdir TES3MP-Forge
debootstrap jessie TES3MP-Forge

Enter it

sudo mount proc "$CHROOT_LOCATION/$CHROOT/proc/" -t proc 2>/dev/null
sudo mount --bind /dev/pts "$CHROOT_LOCATION/$CHROOT/dev/pts" 2>/dev/null
sudo mount --bind /dev/shm "$CHROOT_LOCATION/$CHROOT/dev/shm" 2>/dev/null
sudo chroot "$CHROOT_LOCATION"/"$CHROOT"

Initial system hackery

Create a user, give it sudo access and make it the default

This will make it easier to deal with permissions in the future.

apt-get install sudo vim
adduser user
usermod -a -G sudo user
echo "su - user" > .bashrc

Add source repositories to /etc/apt/sources.list

deb  http://deb.debian.org/debian jessie main
deb-src  http://deb.debian.org/debian jessie main
deb  http://deb.debian.org/debian jessie-updates main
deb-src  http://deb.debian.org/debian jessie-updates main
deb http://security.debian.org/ jessie/updates main
deb-src http://security.debian.org/ jessie/updates main

Do your work as user from now on

su - user

Toolchain

TES3MP-server utilizes some bleeding edge C++ features which require at least GCC 6 to build.

It is highly recommended that the toolchain is built before the dependencies to avoid problems down the road.

Install build dependencies

sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev
sudo build-dep gcc

Download and build GCC

wget ftp://ftp.uvsq.fr/pub/gcc/releases/gcc-6.4.0/gcc-6.4.0.tar.gz
tar xvf gcc-6.4.0.tar.gz
./configure --program-suffix=-6 --enable-languages=c,c++ --disable-multilib --prefix=/usr/local
make
sudo make install

Make GCC 6 the default systemwide

sudo update-alternatives --install /usr/bin/gcc gcc /usr/local/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/local/bin/g++-6

Dependencies

CMake

TES3MP-server needs at least CMake 3.5, build it and install it into /usr/local

sudo apt-get build-dep cmake
git clone https://github.com/Kitware/CMake.git
cd CMake
./configure --prefix=/usr/local
make
sudo make install

Boost

Boost has got to be built with the same toolchain as TES3MP, so we ignore the system one and build it ourselves.

sudo apt-get build-dep libboost-all-dev
wget https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.tar.gz
tar xvf boost_1_64_0.tar.gz
cd boost_1_64_0
./bootstrap.sh --prefix=/usr/local
sudo ./b2 --with=all -j 2 install

MyGUI

Debian's MyGUI is too old and upstream is incompatible with OpenMW, downgrade to this commit

sudo apt-get build-dep libmygui-dev
cd MyGUI
git checkout 82fa8d4fdcaa06cf96dfec8a057c39cbaeaca9c
mkdir build
cd build
cmake -DMYGUI_RENDERSYSTEM=1 -DMYGUI_BUILD_DEMOS=OFF -DMYGUI_BUILD_TOOLS=OFF -DMYGUI_BUILD_PLUGINS=OFF -DCMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install

OpenSceneGraph

Debian's OSG is also too old, we must build it from source. Besides, Scrawl's OSG fork will provide a performance boost.

sudo apt-get build-dep libopenscenegraph-dev
git clone https://github.com/scrawl/osg.git
cd osg
mkdir build
cd build
cmake -DBUILD_OSG_PLUGINS_BY_DEFAULT=0 -DBUILD_OSG_PLUGIN_OSG=1 -DBUILD_OSG_PLUGIN_DDS=1 -DBUILD_OSG_PLUGIN_TGA=1 -DBUILD_OSG_PLUGIN_BMP=1 -DBUILD_OSG_PLUGIN_JPEG=1 -DBUILD_OSG_PLUGIN_PNG=1 -DBUILD_OSG_DEPRECATED_SERIALIZERS=0 -DCMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install

QT5

The server browser requires at least QT 5.5.

git clone git://code.qt.io/qt/qt5.git
git checkout 5.5
./init-repository
./configure -opensource -nomake examples -nomake tests --prefix=/usr/local
make
sudo make install

FFMPEG

Jessie-backports has FFMPEG but it's linked to PulseAudio, better rebuild it ourselves for max compatibility.

sudo build-dep ffmpeg
sudo apt-get install yasm libmp3lame-dev libopus-dev
git clone https://github.com/FFmpeg/FFmpeg.git ffmpeg
cd ffmpeg
./configure --prefix=/usr/local --enable-shared --enable-gpl --enable-libvorbis --enable-libtheora --enable-libmp3lame --enable-libopus
make
sudo make install

Building TES3MP and creating the package

Get the TES3MP-deploy script

sudo apt-get lsb-release
git clone https://github.com/GrimKriegor/TES3MP-deploy.git
cd TES3MP-deploy

Build TES3MP and some of its dependencies

PATH and LD_LIBRARY_PATH are set to point to our neatly built and installed dependencies.

PATH=/usr/local/bin:$PATH LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib ./tes3mp-deploy.sh --install --commit tags/tes3mp-0.6.0

(Optional) Rebuild or upgrade TES3MP after the first installation

PATH=/usr/local/bin:$PATH LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib ./tes3mp-deploy.sh --rebuild --commit tags/tes3mp-0.6.1

Make the package

The script will grab the build, fetch libraries, clean up and pack it neatly into a tarball

./tes3mp-deploy.sh --make-package

Troubleshooting

TES3MP-server complains about libstdc++.so.6 on some old system

Might be a good idea to get a fresh copy of libstdc++.so.6 from a recent system and drop it into the package lib/ folder for extra compatibility with older systems

cp -r --preserve=links /usr/lib/libstdc++.so.6* .

CMake can't find OSG

Hack the script and add the following to CMAKE_PARAMS

-DCMAKE_LIBRARY_PATH=/usr/local/lib64

CMake can't find Boost

Hack the script and add the following to CMAKE_PARAMS

-DBOOST_ROOT=/usr/local -DBoost_NO_SYSTEM_PATHS=ON 

Missing XCB plugin on newer systems (Qt)

Run the browser with this debug variable set

QT_DEBUG_PLUGINS=1 ./tes3mp-browser

Chances are some included library is not supported by the host system's Qt (ex. libfreetype6.so)