From 9f7332eea4c18d13e67391b6d3302e09a83679fe Mon Sep 17 00:00:00 2001 From: aleajactaest Date: Wed, 2 Aug 2017 13:05:12 +0200 Subject: [PATCH] adding script & config to build on docker (for debian i686 & x86_64) --- README.md | 23 ++ dist/docker/builder/debian-8-amd64/Dockerfile | 48 +++++ .../debian-8-amd64/build-under-docker.sh | 41 ++++ dist/docker/builder/debian-8-amd64/build.sh | 200 ++++++++++++++++++ dist/docker/builder/debian-8-i686/Dockerfile | 48 +++++ .../debian-8-i686/build-under-docker.sh | 41 ++++ dist/docker/builder/debian-8-i686/build.sh | 200 ++++++++++++++++++ 7 files changed, 601 insertions(+) create mode 100644 dist/docker/builder/debian-8-amd64/Dockerfile create mode 100755 dist/docker/builder/debian-8-amd64/build-under-docker.sh create mode 100755 dist/docker/builder/debian-8-amd64/build.sh create mode 100644 dist/docker/builder/debian-8-i686/Dockerfile create mode 100755 dist/docker/builder/debian-8-i686/build-under-docker.sh create mode 100755 dist/docker/builder/debian-8-i686/build.sh diff --git a/README.md b/README.md index 1fa4cc8ef..56a90040d 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,26 @@ Ryzom Core is the open-source project related to Ryzom Game. Written in C++, Ryz Ryzom Core is open source and released under the terms of the GNU Affero General Public License 3.0 (GNU/AGPLv3) for the source code and the Creative Commons Attributions-ShareAlike 3.0 (CC-BY-SA) for the art assets. Which means you can create your own game using Ryzom Core, for more information on doing so check out Creating Your Own Game Using Ryzom Core. Modification par la Team Khaganat + +## BUILD +(use docker) + +### archi i686: + +command: + ./dist/docker/builder/debian-8-i686/build.sh -j 4 -a '-DWITH_SYMBOLS=ON' -c -r + +result: + package : ./code/build_linux32/ryzomcore-*.tar.gz + log build : ./code/build_linux32/build.log + all file generated on build : ./code/build_linux32/ + +### archi x64_86: + +command : + ./dist/docker/builder/debian-8-amd64/build.sh -j 4 -a '-DWITH_SYMBOLS=ON' -c -r + +result: + package : ./code/build_linux64/ryzomcore-*.tar.gz + log build : ./code/build_linux64/build.log + all file generated on build : ./code/build_linux64/ diff --git a/dist/docker/builder/debian-8-amd64/Dockerfile b/dist/docker/builder/debian-8-amd64/Dockerfile new file mode 100644 index 000000000..e9ccb1fb7 --- /dev/null +++ b/dist/docker/builder/debian-8-amd64/Dockerfile @@ -0,0 +1,48 @@ +# Dockerfile - Build new package server +# Build for server debian-8 (amd64) +# +# Copyright : GNU/AGPLv3 +# +# Created : 1 AUG 2017 +# Created by : AleaJactaEst + +# to build : +# $ docker build . -t builder_debian_8_adm64 --file dist/docker/builder/debian-8-amd64/Dockerfile + +# to use this image : +# (on root) +# $ docker run -it --hostname=builder -v $PWD/dist:/opt/dist -v $PWD/code:/opt/code builder_debian_8_adm64 /bin/bash +# (with your account) +# $ docker run -it --hostname=builder -u "$(id -u $USERNAME):$(id -g $USERNAME)" -v $PWD/dist:/opt/dist -v $PWD/code:/opt/code builder_debian_8_adm64 /bin/bash + +FROM amd64/debian:8 +MAINTAINER AleaJactaEst + +ENV HOSTNAME builder + +RUN apt-get update +RUN apt-get dist-upgrade + +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server +RUN apt-get install -y apache2 php5 libapache2-mod-php5 php5-mysql apache2-utils php5-gd php5-imagick +RUN apt-get install -y git libcurl4-openssl-dev libluabind-dev libfreetype6-dev libx11-dev libgl1-mesa-dev libxxf86vm-dev libxrandr-dev libxrender-dev libopenal-dev libogg-dev libvorbis-dev libxml2-dev cmake build-essential libpng12-dev libjpeg62-turbo-dev rrdtool bison libxmu-dev autoconf automake libmysqlclient-dev libgif-dev cpputest libssl-dev liblzma-dev unzip + +RUN apt-get install -y wget + +## Build & Install cpptest +# Impossible to build release 1.1.0, 1.1.1, 1.1.2 +#RUN apt-get install -y wget autogen autoconf automake libtool libtool-bin +#RUN mkdir -p /opt/src +#RUN wget -q https://github.com/cpptest/cpptest/archive/1.0.5.tar.gz -O /opt/src/cpptest.tar.gz +#RUN rm -rf /opt/src/cpptest +#RUN tar xvf /opt/src/cpptest.tar.gz -C /opt/src --strip 1 +#RUN cd /opt/src/cpptest && ./autogen.sh && ./configure && make && make install + +## Build & Install Build squish +RUN mkdir -p /opt/src +RUN cd /opt/src; wget -c https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/libsquish/squish-1.11.zip +RUN cd /opt/src; unzip squish-1.11.zip +COPY dist/docker/builder/squish-limit.patch /opt/squish-limit.patch +RUN cd /opt/src/squish-1.11; patch -i /opt/squish-limit.patch +RUN cd /opt/src/squish-1.11; make +RUN cd /opt/src/squish-1.11; make install diff --git a/dist/docker/builder/debian-8-amd64/build-under-docker.sh b/dist/docker/builder/debian-8-amd64/build-under-docker.sh new file mode 100755 index 000000000..53eaf4ddc --- /dev/null +++ b/dist/docker/builder/debian-8-amd64/build-under-docker.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Script to build Khaganat +# Copyright : GNU/AGPLv3 +# +# Created : 1 AUG 2017 +# Created by : AleaJactaEst + +declare DIRBUILD="/opt/code/build/" +if [[ -n "$1" ]] +then + DIRBUILD="$1" +fi +declare LOGFILE="${DIRBUILD}/build.log" + +function chrashed() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") BUILD FAILED (code:$?)" >> $LOGFILE + exit 2 +} + +trap chrashed EXIT + +mkdir -p ${DIRBUILD}/ || exit 2 + +if [[ -f ${DIRBUILD}/envi.sh ]] +then + echo "$(date "+%Y/%m/%d %H:%M:%S") LOAD ENVI" >> $LOGFILE + source ${DIRBUILD}/envi.sh +fi + +echo "$(date "+%Y/%m/%d %H:%M:%S") BUILD START" >> $LOGFILE + +cd ${DIRBUILD}; cmake -DWITH_NEL_TESTS=OFF -DWITH_RYZOM_CLIENT=OFF -DWITH_NEL=ON -DWITH_STATIC=ON -DWITH_STATIC_DRIVERS=ON -DWITH_DRIVER_OPENGL=OFF -DWITH_DRIVER_OPENAL=OFF -DWITH_NEL_SAMPLES=OFF -DWITH_SOUND=OFF ${CMAKEOPTS} .. 1>>$LOGFILE 2>&1 || exit 2 + +cd ${DIRBUILD}; make $MAKEOPTS 1>>$LOGFILE 2>&1 || exit 2 + +echo "$(date "+%Y/%m/%d %H:%M:%S") PACKAGE" > $LOGFILE +cd ${DIRBUILD}; make package 1>>$LOGFILE 2>&1 || exit 2 + +trap '' EXIT +echo "$(date "+%Y/%m/%d %H:%M:%S") BUILD END" >> $LOGFILE diff --git a/dist/docker/builder/debian-8-amd64/build.sh b/dist/docker/builder/debian-8-amd64/build.sh new file mode 100755 index 000000000..e335226a0 --- /dev/null +++ b/dist/docker/builder/debian-8-amd64/build.sh @@ -0,0 +1,200 @@ +#!/bin/bash +# +# Script to build under docker +# +# Copyright : GNU/AGPLv3 +# +# Created : 1 AUG 2017 +# Created by : AleaJactaEst + +declare -i REMOVE=0 +declare -i IMAGE=1 +declare -i BUILD=1 +declare -i DEBUG=0 +declare JOBS="" +declare CMAKEOPTS="" +declare DIRBUILD="" +declare CLEANDOCKER=0 + +declare IMAGEDOCKER="builder_debian_8_amd64" +declare LOCALBUILDDIR="build_linux64" +declare LOCALSRC="debian-8-amd64" + + +usage() +{ +cat << EOF +usage:$0 [options] + script to build under docker + + Step: + 1) clean old build directory + 2) create image builder + 3) launch build under docker (launch script build-under-docker.sh) + 4) remove docker container with state exited + +options: + -h, --help : Show this help + -d, --debug : Show debug message + -r, --remove : Remove old build repository + -i, --image-only : Just create image (no build) + -b, --build-only : Just build (no create new image) + -j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg. + -a OPTS, --add-opts-cmake=OPTS : Adding options on cmake command (before build) + -c, --clean-container : remove all container in state Exited + +Example : + cd [root Khanat directory] + dist/docker/builder/${LOCALSRC}/build.sh -c -r + dist/docker/builder/${LOCALSRC}/build.sh -c -r -j 4 -a '-DWITH_SYMBOLS=ON' -a '-DWITH_RYZOM_TOOLS=OFF' -a '-DWITH_NEL_TOOLS=OFF' +EOF +} + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + DEBUG=1 + shift + ;; + -c|--clean-container) + CLEANDOCKER=1 + shift + ;; + -r|--remove) + REMOVE=1 + shift + ;; + -i|--image-only) + BUILD=0 + IMAGE=1 + shift + ;; + -b|--build-only) + BUILD=1 + IMAGE=0 + shift + ;; + -j) + shift + # search next argument is value or new argument + if [[ ${1:0:1} == "-" ]] + then + JOBS="-j" + else + JOBS="-j $1" + shift + fi + ;; + --jobs*) + if [[ ${1#*=} == "" ]] + then + JOBS="-j" + else + JOBS="-j ${1#*=}" + fi + shift + ;; + -a) + shift + CMAKEOPTS="$CMAKEOPTS $1" + shift + ;; + --add-opts-cmake=*) + CMAKEOPTS="$CMAKEOPTS ${1#*=}" + shift + ;; + *) + echo "*** ERROR : options '$1' not recoginze" + usage + exit 1 + ;; + esac +done + +function chrashed() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") BUILD FAILED (code:$?)" + exit 2 +} + +trap chrashed EXIT + +if [[ $DEBUG -ne 0 ]] +then + echo "prg: $0" +fi + +calldir="$(dirname $0)" +if [[ ${calldir:0:1} == "/" ]] +then + basedir="${calldir}" +else + basedir="$(pwd)/${calldir}" +fi + +rootdir="$(dirname $(dirname $(dirname $(dirname ${basedir}))))" + +docker -v 1>/dev/null +if [[ $? -ne 0 ]] +then + echo "*** ERROR docker not installed" + exit 2 +fi + +DIRBUILD="${rootdir}/code/${LOCALBUILDDIR}" + +if [[ $DEBUG -ne 0 ]] +then + echo "calldir: $calldir" + echo "basedir: $basedir" + echo "rootdir: $rootdir" + echo "JOBS: '$JOBS'" + echo "CMAKEOPTS: '$CMAKEOPTS'" +fi + +mkdir -p "${DIRBUILD}" +if [[ $REMOVE -ne 0 ]] +then + echo "$(date "+%Y/%m/%d %H:%M:%S") REMOVE OLD BUILD" + rm -rf ${DIRBUILD}/* || exit 2 +fi + +touch ${DIRBUILD}/build.log + +cat << EOF > ${DIRBUILD}/envi.sh +#!/bin/bash +export MAKEOPTS="$JOBS" +export CMAKEOPTS="$CMAKEOPTS" +EOF + +if [[ $IMAGE -ne 0 ]] +then + echo "$(date "+%Y/%m/%d %H:%M:%S") GENERATE DOCKER IMAGE" + cd $rootdir; docker build . -t ${IMAGEDOCKER} \ + --file "${basedir}/Dockerfile" || exit 2 +fi + +if [[ $BUILD -ne 0 ]] +then + echo "$(date "+%Y/%m/%d %H:%M:%S") BUILD" + cd $rootdir; docker run -it \ + --hostname=builder \ + -u "$(id -u $USERNAME):$(id -g $USERNAME)" \ + -v $rootdir/dist:/opt/dist \ + -v $rootdir/code:/opt/code \ + ${IMAGEDOCKER} \ + /opt/dist/docker/builder/${LOCALSRC}/build-under-docker.sh "/opt/code/${LOCALBUILDDIR}/" || exit 2 +fi + +if [[ $CLEANDOCKER -ne 0 ]] +then + docker rm --force `docker ps -qf 'status=exited' -f "ancestor=${IMAGEDOCKER}"` || exit 2 +fi + +trap '' EXIT +echo "$(date "+%Y/%m/%d %H:%M:%S") END" diff --git a/dist/docker/builder/debian-8-i686/Dockerfile b/dist/docker/builder/debian-8-i686/Dockerfile new file mode 100644 index 000000000..f8f05c33f --- /dev/null +++ b/dist/docker/builder/debian-8-i686/Dockerfile @@ -0,0 +1,48 @@ +# Dockerfile - Build new package server +# Build for server debian-8 (amd64) +# +# Copyright : GNU/AGPLv3 +# +# Created : 1 AUG 2017 +# Created by : AleaJactaEst + +# to build : +# $ docker build . -t builder_debian_8_i686 --file dist/docker/builder/debian-8-i686/Dockerfile + +# to use this image : +# (on root) +# $ docker run -it --hostname=builder -v $PWD/dist:/opt/dist -v $PWD/code:/opt/code builder_debian_8_i686 /bin/bash +# (with your account) +# $ docker run -it --hostname=builder -u "$(id -u $USERNAME):$(id -g $USERNAME)" -v $PWD/dist:/opt/dist -v $PWD/code:/opt/code builder_debian_8_i686 /bin/bash + +FROM debian:8 +MAINTAINER AleaJactaEst + +ENV HOSTNAME builder + +RUN apt-get update +RUN apt-get dist-upgrade -y + +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server +RUN apt-get install -y apache2 php5 libapache2-mod-php5 php5-mysql apache2-utils php5-gd php5-imagick +RUN apt-get install -y git libcurl4-openssl-dev libluabind-dev libfreetype6-dev libx11-dev libgl1-mesa-dev libxxf86vm-dev libxrandr-dev libxrender-dev libopenal-dev libogg-dev libvorbis-dev libxml2-dev cmake build-essential libpng12-dev libjpeg62-turbo-dev rrdtool bison libxmu-dev autoconf automake libmysqlclient-dev libgif-dev cpputest libssl-dev liblzma-dev unzip + +RUN apt-get install -y wget + +## Build & Install cpptest +# Impossible to build release 1.1.0, 1.1.1, 1.1.2 +#RUN apt-get install -y wget autogen autoconf automake libtool libtool-bin +#RUN mkdir -p /opt/src +#RUN wget -q https://github.com/cpptest/cpptest/archive/1.0.5.tar.gz -O /opt/src/cpptest.tar.gz +#RUN rm -rf /opt/src/cpptest +#RUN tar xvf /opt/src/cpptest.tar.gz -C /opt/src --strip 1 +#RUN cd /opt/src/cpptest && ./autogen.sh && ./configure && make && make install + +## Build & Install Build squish +RUN mkdir -p /opt/src +RUN cd /opt/src; wget -c https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/libsquish/squish-1.11.zip +RUN cd /opt/src; unzip squish-1.11.zip +COPY dist/docker/builder/squish-limit.patch /opt/squish-limit.patch +RUN cd /opt/src/squish-1.11; patch -i /opt/squish-limit.patch +RUN cd /opt/src/squish-1.11; make +RUN cd /opt/src/squish-1.11; make install diff --git a/dist/docker/builder/debian-8-i686/build-under-docker.sh b/dist/docker/builder/debian-8-i686/build-under-docker.sh new file mode 100755 index 000000000..53eaf4ddc --- /dev/null +++ b/dist/docker/builder/debian-8-i686/build-under-docker.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Script to build Khaganat +# Copyright : GNU/AGPLv3 +# +# Created : 1 AUG 2017 +# Created by : AleaJactaEst + +declare DIRBUILD="/opt/code/build/" +if [[ -n "$1" ]] +then + DIRBUILD="$1" +fi +declare LOGFILE="${DIRBUILD}/build.log" + +function chrashed() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") BUILD FAILED (code:$?)" >> $LOGFILE + exit 2 +} + +trap chrashed EXIT + +mkdir -p ${DIRBUILD}/ || exit 2 + +if [[ -f ${DIRBUILD}/envi.sh ]] +then + echo "$(date "+%Y/%m/%d %H:%M:%S") LOAD ENVI" >> $LOGFILE + source ${DIRBUILD}/envi.sh +fi + +echo "$(date "+%Y/%m/%d %H:%M:%S") BUILD START" >> $LOGFILE + +cd ${DIRBUILD}; cmake -DWITH_NEL_TESTS=OFF -DWITH_RYZOM_CLIENT=OFF -DWITH_NEL=ON -DWITH_STATIC=ON -DWITH_STATIC_DRIVERS=ON -DWITH_DRIVER_OPENGL=OFF -DWITH_DRIVER_OPENAL=OFF -DWITH_NEL_SAMPLES=OFF -DWITH_SOUND=OFF ${CMAKEOPTS} .. 1>>$LOGFILE 2>&1 || exit 2 + +cd ${DIRBUILD}; make $MAKEOPTS 1>>$LOGFILE 2>&1 || exit 2 + +echo "$(date "+%Y/%m/%d %H:%M:%S") PACKAGE" > $LOGFILE +cd ${DIRBUILD}; make package 1>>$LOGFILE 2>&1 || exit 2 + +trap '' EXIT +echo "$(date "+%Y/%m/%d %H:%M:%S") BUILD END" >> $LOGFILE diff --git a/dist/docker/builder/debian-8-i686/build.sh b/dist/docker/builder/debian-8-i686/build.sh new file mode 100755 index 000000000..e69ee09a5 --- /dev/null +++ b/dist/docker/builder/debian-8-i686/build.sh @@ -0,0 +1,200 @@ +#!/bin/bash +# +# Script to build under docker +# +# Copyright : GNU/AGPLv3 +# +# Created : 1 AUG 2017 +# Created by : AleaJactaEst + +declare -i REMOVE=0 +declare -i IMAGE=1 +declare -i BUILD=1 +declare -i DEBUG=0 +declare JOBS="" +declare CMAKEOPTS="" +declare DIRBUILD="" +declare CLEANDOCKER=0 + +declare IMAGEDOCKER="builder_debian_8_i686" +declare LOCALBUILDDIR="build_linux32" +declare LOCALSRC="debian-8-i686" + + +usage() +{ +cat << EOF +usage:$0 [options] + script to build under docker + + Step: + 1) clean old build directory + 2) create image builder + 3) launch build under docker (launch script build-under-docker.sh) + 4) remove docker container with state exited + +options: + -h, --help : Show this help + -d, --debug : Show debug message + -r, --remove : Remove old build repository + -i, --image-only : Just create image (no build) + -b, --build-only : Just build (no create new image) + -j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg. + -a OPTS, --add-opts-cmake=OPTS : Adding options on cmake command (before build) + -c, --clean-container : remove all container in state Exited + +Example : + cd [root Khanat directory] + dist/docker/builder/${LOCALSRC}/build.sh -c -r + dist/docker/builder/${LOCALSRC}/build.sh -c -r -j 4 -a '-DWITH_SYMBOLS=ON' -a '-DWITH_RYZOM_TOOLS=OFF' -a '-DWITH_NEL_TOOLS=OFF' +EOF +} + +while test $# -gt 0 +do + case "$1" in + -h|--help) + usage + exit 1 + ;; + -d|--debug) + DEBUG=1 + shift + ;; + -c|--clean-container) + CLEANDOCKER=1 + shift + ;; + -r|--remove) + REMOVE=1 + shift + ;; + -i|--image-only) + BUILD=0 + IMAGE=1 + shift + ;; + -b|--build-only) + BUILD=1 + IMAGE=0 + shift + ;; + -j) + shift + # search next argument is value or new argument + if [[ ${1:0:1} == "-" ]] + then + JOBS="-j" + else + JOBS="-j $1" + shift + fi + ;; + --jobs*) + if [[ ${1#*=} == "" ]] + then + JOBS="-j" + else + JOBS="-j ${1#*=}" + fi + shift + ;; + -a) + shift + CMAKEOPTS="$CMAKEOPTS $1" + shift + ;; + --add-opts-cmake=*) + CMAKEOPTS="$CMAKEOPTS ${1#*=}" + shift + ;; + *) + echo "*** ERROR : options '$1' not recoginze" + usage + exit 1 + ;; + esac +done + +function chrashed() +{ + echo "$(date "+%Y/%m/%d %H:%M:%S") BUILD FAILED (code:$?)" + exit 2 +} + +trap chrashed EXIT + +if [[ $DEBUG -ne 0 ]] +then + echo "prg: $0" +fi + +calldir="$(dirname $0)" +if [[ ${calldir:0:1} == "/" ]] +then + basedir="${calldir}" +else + basedir="$(pwd)/${calldir}" +fi + +rootdir="$(dirname $(dirname $(dirname $(dirname ${basedir}))))" + +docker -v 1>/dev/null +if [[ $? -ne 0 ]] +then + echo "*** ERROR docker not installed" + exit 2 +fi + +DIRBUILD="${rootdir}/code/${LOCALBUILDDIR}" + +if [[ $DEBUG -ne 0 ]] +then + echo "calldir: $calldir" + echo "basedir: $basedir" + echo "rootdir: $rootdir" + echo "JOBS: '$JOBS'" + echo "CMAKEOPTS: '$CMAKEOPTS'" +fi + +mkdir -p "${DIRBUILD}" +if [[ $REMOVE -ne 0 ]] +then + echo "$(date "+%Y/%m/%d %H:%M:%S") REMOVE OLD BUILD" + rm -rf ${DIRBUILD}/* || exit 2 +fi + +touch ${DIRBUILD}/build.log + +cat << EOF > ${DIRBUILD}/envi.sh +#!/bin/bash +export MAKEOPTS="$JOBS" +export CMAKEOPTS="$CMAKEOPTS" +EOF + +if [[ $IMAGE -ne 0 ]] +then + echo "$(date "+%Y/%m/%d %H:%M:%S") GENERATE DOCKER IMAGE" + cd $rootdir; docker build . -t ${IMAGEDOCKER} \ + --file "${basedir}/Dockerfile" || exit 2 +fi + +if [[ $BUILD -ne 0 ]] +then + echo "$(date "+%Y/%m/%d %H:%M:%S") BUILD" + cd $rootdir; docker run -it \ + --hostname=builder \ + -u "$(id -u $USERNAME):$(id -g $USERNAME)" \ + -v $rootdir/dist:/opt/dist \ + -v $rootdir/code:/opt/code \ + ${IMAGEDOCKER} \ + /opt/dist/docker/builder/${LOCALSRC}/build-under-docker.sh "/opt/code/${LOCALBUILDDIR}/" || exit 2 +fi + +if [[ $CLEANDOCKER -ne 0 ]] +then + docker rm --force `docker ps -qf 'status=exited' -f "ancestor=${IMAGEDOCKER}"` || exit 2 +fi + +trap '' EXIT +echo "$(date "+%Y/%m/%d %H:%M:%S") END"