update script to build localy (on docker for debian strech)

This commit is contained in:
AleaJactaEst 2018-04-19 15:55:43 +02:00
parent 446eaa8b12
commit db0c5adb48
3 changed files with 152 additions and 83 deletions

View file

@ -31,77 +31,66 @@ MAINTAINER AleaJactaEst
ENV HOSTNAME builder
RUN apt-get update ; \
apt-get dist-upgrade -y ; \
DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server ; \
apt-get install -y apache2 \
php \
libapache2-mod-php \
php-mysql \
apache2-utils \
php-gd \
php-imagick ; \
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 \
libpng-dev \
libjpeg62-turbo-dev \
rrdtool \
bison \
libxmu-dev \
autoconf \
automake \
default-libmysqlclient-dev \
libgif-dev \
cpputest \
libssl-dev \
liblzma-dev \
unzip \
zlib1g-dev \
libssh2-1-dev \
libboost-all-dev \
libopenal-dev \
libgl1-mesa-dev \
libogg-dev \
mercurial \
wget \
autogen \
libtool \
libtool-bin
apt-get dist-upgrade -y; \
DEBIAN_FRONTEND=noninteractive apt-get install -y apache2 apache2-utils autoconf autogen automake bison build-essential cmake cpputest default-libmysqlclient-dev fakeroot git libapache2-mod-php libboost-all-dev libfreetype6-dev libgif-dev libgl1-mesa-dev libjpeg62-turbo-dev liblua5.2-0 liblua5.2-dev liblzma-dev libogg-dev libopenal-dev libpng-dev libssh2-1-dev libssl-dev libtool libtool-bin libvorbis-dev libx11-dev libxml2-dev libxmu-dev libxrandr-dev libxrender-dev libxxf86vm-dev mercurial mysql-server php php-gd php-imagick php-mysql rrdtool unzip wget zlib1g-dev
## Build & Install cpptest
# Impossible to build release 1.1.0, 1.1.1, 1.1.2
RUN mkdir -p /opt/src
RUN mkdir -p /opt/src/cpptest
RUN wget -q https://github.com/cpptest/cpptest/archive/1.0.5.tar.gz -O /opt/src/cpptest.tar.gz || exit 2
RUN rm -rf /opt/src/cpptest
RUN tar xvf /opt/src/cpptest.tar.gz -C /opt/src --strip 1 || exit 2
RUN tar xf /opt/src/cpptest.tar.gz -C /opt/src --strip 1 || exit 2
RUN cd /opt/src/cpptest && ./autogen.sh && ./configure && make && make install || exit 2
## Build & Install 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/common/squish-limit.patch /opt/squish-limit.patch
COPY common/squish-limit.patch /opt/squish-limit.patch
RUN cd /opt/src/squish-1.11; patch -i /opt/squish-limit.patch || exit 2
RUN cd /opt/src/squish-1.11; make || exit 2
RUN cd /opt/src/squish-1.11; make install || exit 2
## Build & Install CURL - 7.46.0
RUN wget -q https://curl.haxx.se/download/curl-7.55.1.tar.gz -O /opt/src/curl.tar.gz
## Build & Install CURL - 7.58.0
RUN wget -q https://curl.haxx.se/download/curl-7.58.0.tar.gz -O /opt/src/curl.tar.gz
RUN mkdir -p /opt/src/curl/build
RUN tar xvf /opt/src/curl.tar.gz -C /opt/src/curl --strip 1 || exit 2
RUN cd /opt/src/curl/build; cmake -DCMAKE_BUILD_TYPE=Release -DCURL_ZLIB=ON -DBUILD_CURL_EXE=OFF -DCURL_STATICLIB=ON -DHTTP_ONLY=ON -DENABLE_IPV6=ON -DCMAKE_USE_OPENSSL=ON -DOPENSSL_SSL_LIBRARIES=/usr/lib/libssl.a -DOPENSSL_CRYPTO_LIBRARIES=/usr/lib/libcrypto.a -DCMAKE_USE_LIBSSH2=OFF -DZLIB_LIBRARY=/usr/lib/x86_64-linux-gnu/libz.a .. || exit 2
RUN tar xf /opt/src/curl.tar.gz -C /opt/src/curl --strip 1 || exit 2
RUN cd /opt/src/curl/build; cmake -DCMAKE_BUILD_TYPE=Release -DCURL_ZLIB=ON -DBUILD_CURL_EXE=OFF -DCURL_STATICLIB=ON -DHTTP_ONLY=ON -DENABLE_IPV6=ON -DCMAKE_USE_OPENSSL=ON -DOPENSSL_SSL_LIBRARIES=/usr/lib/x86_64-linux-gnu/libssl.a -DOPENSSL_CRYPTO_LIBRARIES=/usr/lib/x86_64-linux-gnu/libcrypto.a -DCMAKE_USE_LIBSSH2=OFF -DZLIB_LIBRARY=/usr/lib/x86_64-linux-gnu/libz.a -DCMAKE_C_FLAGS='-fPIC' .. || exit 2
RUN cd /opt/src/curl/build; make || exit 2
RUN cd /opt/src/curl/build; make install || exit 2
## Build & Install luabind
RUN mkdir -p /opt/src/luabind
RUN wget -q http://http.debian.net/debian/pool/main/l/luabind/luabind_0.9.1+dfsg.orig.tar.gz -O /opt/src/luabind.tar.gz
RUN wget -q http://http.debian.net/debian/pool/main/l/luabind/luabind_0.9.1+dfsg-11.debian.tar.xz -O /opt/src/luabind-debian.tar.xz
RUN tar xf /opt/src/luabind.tar.gz -C /opt/src/luabind --strip 1 || exit 2
RUN tar xf /opt/src/luabind-debian.tar.xz -C /opt/src/luabind || exit 2
RUN cd /opt/src/luabind; for file in $(cat debian/patches/series); do patch -p1 < debian/patches/$file || exit 2; done
RUN cd /opt/src/luabind; DEB_HOST_MULTIARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH) bjam -d2 release debug install cflags="-fPIC $(dpkg-buildflags --get CFLAGS)" cxxflags="-fPIC $(dpkg-buildflags --get CXXFLAGS) -Wno-deprecated-declarations" linkflags=" $(dpkg-buildflags --get LDFLAGS)"
RUN cd /opt/src/luabind; DEB_HOST_MULTIARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH) bjam -d2 release debug install link=static cflags="-fPIC $(dpkg-buildflags --get CFLAGS)" cxxflags="-fPIC $(dpkg-buildflags --get CXXFLAGS) -Wno-deprecated-declarations" linkflags=" $(dpkg-buildflags --get LDFLAGS)"
# Build libogg
RUN mkdir -p /opt/src/libogg/build
RUN wget -q http://http.debian.net/debian/pool/main/libo/libogg/libogg_1.3.2.orig.tar.gz -O /opt/src/libogg.tar.gz
RUN wget -q http://http.debian.net/debian/pool/main/libo/libogg/libogg_1.3.2-1.diff.gz -O /opt/src/libogg.diff.gz
RUN tar xvf /opt/src/libogg.tar.gz -C /opt/src/libogg --strip 1 || exit 2
RUN gunzip /opt/src/libogg.diff.gz
RUN cd /opt/src/libogg/; patch -p1 < /opt/src/libogg.diff
RUN cd /opt/src/libogg/build; /opt/src/libogg/configure --disable-maintainer-mode --host=$(dpkg-architecture -qDEB_HOST_GNU_TYPE) --build=$(dpkg-architecture -qDEB_BUILD_GNU_TYPE) --libdir=/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH) --enable-static --prefix=/usr CPPFLAGS="-D_FORTIFY_SOURCE=2" CFLAGS="-Wformat=2 -g -fPIC" CXXFLAGS="-Wformat=2 -g -fPIC" LDFLAGS="-Wl,-z,now"
RUN cd /opt/src/libogg/build; make
RUN cd /opt/src/libogg/build; make install
# Build libvorbis
RUN mkdir -p /opt/src/libvorbis
RUN wget -q http://security.debian.org/debian-security/pool/updates/main/libv/libvorbis/libvorbis_1.3.5.orig.tar.gz -O /opt/src/libvorbis.tar.gz
RUN tar xvf /opt/src/libvorbis.tar.gz -C /opt/src/libvorbis --strip 1 || exit 2
RUN wget -q http://security.debian.org/debian-security/pool/updates/main/libv/libvorbis -O /opt/src/libvorbis/list_libvorbis
RUN line=$(egrep '(libvorbis_1.3.5)(.*)(tar[.]xz)' /opt/src/libvorbis/list_libvorbis | tail -n 1) ; tmp=${line#*href} ; tmp2=${tmp%%>*} ; tmp3=${tmp2#*\"} ; namepatch=${tmp3%\"*} ; wget -q http://security.debian.org/debian-security/pool/updates/main/libv/libvorbis/$namepatch -O /opt/src/libvorbis/libvorbis.debian.tar.xz
RUN tar xvf /opt/src/libvorbis/libvorbis.debian.tar.xz -C /opt/src/libvorbis || exit 2
RUN cd /opt/src/libvorbis/; for file in $(cat debian/patches/series); do patch -p1 < debian/patches/$file || exit 2; done
RUN cd /opt/src/libvorbis/; ./configure --enable-static --with-pic
RUN cd /opt/src/libvorbis/; make
RUN cd /opt/src/libvorbis/; make install
# Create directory
RUN mkdir -p /opt/ref ; chmod 777 /opt/ref

View file

@ -18,11 +18,23 @@
#
declare DIRBUILD="/opt/build/"
if [[ -n "$1" ]]
then
DIRBUILD="$1"
fi
declare LOGFILE="${DIRBUILD}/build.log"
declare DIRCODE="/opt/ref/opennel-code"
function usage()
{
cat << EOF
usage:$0 [options] <workdir>
internal script to build under docker
workdir: directory use to buid
options:
-h, --help : Show this help
-d, --debug : Show debug message
--add-opts-cmake="string" : add option use on command cmake (generate Makefile)
--add-opts-make="string" : add option use on command make
EOF
}
function chrashed()
{
@ -36,16 +48,61 @@ function msg_info()
echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $1" >> $LOGFILE
}
#
# MAIN
#
trap chrashed EXIT
while test $# -gt 0
do
case "$1" in
-h|--help)
usage
exit 1
;;
-d|--debug)
DEBUG=1
shift
;;
--add-opts-cmake=*)
CMAKEOPTS="$CMAKEOPTS ${1#*=}"
shift
;;
--add-opts-make=*)
MAKEOPTS="$MAKEOPTS ${1#*=}"
shift
;;
--build-dir=*)
DIRBUILD="${1#*=}"
shift
;;
--code-dir=*)
DIRCODE="${1#*=}"
shift
;;
*)
msg_error "options '$1' not recognize"
usage
exit 1
;;
esac
done
declare LOGFILE="${DIRBUILD}/build.log"
msg_info "CREATE BUILD DIRECTORY"
mkdir -p ${DIRBUILD}/ || exit 2
if [[ -f ${DIRBUILD}/envi.sh ]]
then
msg_info "LOAD ENVIRONMENT"
source ${DIRBUILD}/envi.sh
fi
msg_info "COPY CODE"
mkdir -p ${DIRBUILD}/opennel-code
cp -r $DIRCODE/* ${DIRBUILD}/opennel-code
msg_info "PATCH CODE"
cd ${DIRBUILD}/opennel-code/code
patch -t -i ${DIRBUILD}/opennel-code/patch/libcrypto.patch || exit 2
patch -t -i ${DIRBUILD}/opennel-code/patch/libicuuc.patch || exit 2
msg_info "PREPARE BUILD"
cd ${DIRBUILD}; cmake -DWITH_NEL=ON \
@ -57,7 +114,7 @@ cd ${DIRBUILD}; cmake -DWITH_NEL=ON \
-DWITH_RYZOM_PATCH=ON \
-DWITH_RYZOM_CUSTOM_PATCH_SERVER=ON \
${CMAKEOPTS} \
../../code 1>>$LOGFILE 2>&1 || exit 2
${DIRBUILD}/opennel-code/code 1>>$LOGFILE 2>&1 || exit 2
msg_info "BUILD START"
cd ${DIRBUILD}; make $MAKEOPTS 1>>$LOGFILE 2>&1 || exit 2

View file

@ -62,6 +62,7 @@ options:
-w, --clean-images-none : Remove images docker (with name 'none')
-m OPTS, --add-opts-docker=OPTS : Adding options on docker command (when build)
--only-build-server : adding option to build only server
--opennel-code-dir=<Directory> : localization code khanat (khanat-opennel-code)
Example :
cd [root Khanat directory]
@ -95,7 +96,8 @@ function msg_error()
calldir="$(dirname $0)"
basedir=$(cd $calldir; pwd)
rootdir="$(dirname $(dirname $(dirname $(dirname $(dirname $(dirname ${basedir}))))))"
rootdir="$(dirname $(dirname $(dirname $(dirname ${basedir}))))"
codedir="$(dirname $rootdir)/khanat-opennel-code"
while test $# -gt 0
do
@ -163,6 +165,10 @@ do
CMAKEOPTS="$CMAKEOPTS -DWITH_NEL_TESTS=OFF -DWITH_RYZOM_CLIENT=OFF -DWITH_DRIVER_OPENGL=OFF -DWITH_DRIVER_OPENAL=OFF -DWITH_NEL_SAMPLES=OFF -DWITH_SOUND=OFF"
shift
;;
--opennel-code-dir=*)
codedir="${1#*=}"
shift
;;
-w|--clean-images-none)
CLEANIMAGENONE=1
shift
@ -202,12 +208,28 @@ fi
DIRBUILD="${rootdir}/${LOCALBUILDDIR}"
msg_debug "calldir: $calldir"
msg_debug "basedir: $basedir"
msg_debug "rootdir: $rootdir"
msg_debug "JOBS: '$JOBS'"
msg_debug "CMAKEOPTS: '$CMAKEOPTS'"
msg_debug "DOCKEROPTS: '$DOCKEROPTS'"
msg_debug "[$(basename $0):$LINENO] calldir: $calldir"
msg_debug "[$(basename $0):$LINENO] basedir: $basedir"
msg_debug "[$(basename $0):$LINENO] rootdir: $rootdir"
msg_debug "[$(basename $0):$LINENO] JOBS: '$JOBS'"
msg_debug "[$(basename $0):$LINENO] CMAKEOPTS: '$CMAKEOPTS'"
msg_debug "[$(basename $0):$LINENO] DOCKEROPTS: '$DOCKEROPTS'"
msg_debug "[$(basename $0):$LINENO] DOCKERBUILDOPT: '$DOCKERBUILDOPT'"
msg_debug "[$(basename $0):$LINENO] codedir: '$codedir'"
msg_info "[$(basename $0):$LINENO] check khanat-opennel-code"
if [[ ! -d ${codedir} ]]
then
msg_error "[$(basename $0):$LINENO] Missing directory khanat-opennel-code [${codedir}]"
cat << EOF
You need clone repo khanat-opennel-code.
cd $(dirname ${rootdir})
git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-opennel-code.git
EOF
exit 2
fi
mkdir -p "${DIRBUILD}"
if [[ $REMOVE -ne 0 ]]
@ -227,7 +249,8 @@ EOF
if [[ $IMAGE -ne 0 ]]
then
msg_info "GENERATE DOCKER IMAGE"
cd $rootdir; docker build . ${DOCKERBUILDOPT} -t ${IMAGEDOCKER} \
msg_debug "cd $projectdir/builder; docker build . ${DOCKERBUILDOPT} -t ${IMAGEDOCKER} --file \"${basedir}/Dockerfile\""
cd $rootdir/builder; docker build . ${DOCKERBUILDOPT} -t ${IMAGEDOCKER} \
--file "${basedir}/Dockerfile" || exit 2
fi
@ -237,13 +260,13 @@ then
cd $rootdir; docker run -it \
--hostname=builder \
-u "$(id -u $USERNAME):$(id -g $USERNAME)" \
-v $rootdir/dist:/opt/dist:ro \
-v $rootdir/code:/opt/code:ro \
-v $rootdir/builder:/opt/ref/builder:ro \
-v $codedir:/opt/ref/opennel-code:ro \
-v $rootdir/build:/opt/build \
-v /etc/localtime:/etc/localtime:ro \
${DOCKEROPTS} \
${IMAGEDOCKER} \
/opt/dist/docker/builder/${LOCALSRC}/build-under-docker.sh "/opt/${LOCALBUILDDIR}" || exit 2
/opt/ref/builder/${LOCALSRC}/build-under-docker.sh --add-opts-make="$JOBS" --add-opts-cmake="$CMAKEOPTS" --build-dir="/opt/${LOCALBUILDDIR}" --code-dir="/opt/ref/opennel-code" || exit 2
fi
if [[ $BUILD -ne 0 ]]
@ -251,11 +274,11 @@ then
msg_info "COPY PACKAGES"
mkdir -p "$rootdir/$DIRPACKAGE"
cd ${rootdir}; tar czf ${PACKAGEREF} \
code/ryzom/server/shard.screen.rc \
code/ryzom/common/* \
code/ryzom/client/* \
code/ryzom/server/* \
code/web/* || exit 2
$codedir/code/ryzom/server/shard.screen.rc \
$codedir/code/ryzom/common/* \
$codedir/code/ryzom/client/* \
$codedir/code/ryzom/server/* \
$codedir/code/web/* || exit 2
cp ${rootdir}/${LOCALBUILDDIR}/ryzomcore-0.12.0..tar.gz ${PACKAGEBIN} || exit 2
fi