libreoffice-online/docker/from-source/build.sh
Martin Hoffmann fff344afed fix build.sh: wrong directory after poco install
After compiling and installing poco the script is left in the wrong path, resulting core to be deployed underneath poco directory which breaks configure --with-lo-path later on.

Signed-off-by: Martin Hoffmann <mhoffmann@pro-nets.de>
Change-Id: I46c5b77e44eebead08c8a7fb857c229900a23570
2021-01-26 13:59:26 +01:00

137 lines
4.3 KiB
Bash
Executable file

#! /bin/bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# -- Available env vars --
# * DOCKER_HUB_REPO - which Docker Hub repo to use
# * DOCKER_HUB_TAG - which Docker Hub tag to create
# * CORE_BRANCH - which branch to build in core
# * COLLABORA_ONLINE_REPO - which git repo to clone online from
# * COLLABORA_ONLINE_BRANCH - which branch to build in online
# * CORE_BUILD_TARGET - which make target to run (in core repo)
# * ONLINE_EXTRA_BUILD_OPTIONS - extra build options for online
# * NO_DOCKER_IMAGE - if set, don't build the docker image itself, just do all the preps
# check we can sudo without asking a pwd
echo "Trying if sudo works without a password"
echo
echo "If you get a password prompt now, break, and fix your setup using 'sudo visudo'; add something like:"
echo "yourusername ALL=(ALL) NOPASSWD: /sbin/setcap"
echo
sudo echo "works"
# Check env variables
if [ -z "$DOCKER_HUB_REPO" ]; then
DOCKER_HUB_REPO="mydomain/collaboraonline"
fi;
if [ -z "$DOCKER_HUB_TAG" ]; then
DOCKER_HUB_TAG="latest"
fi;
echo "Using Docker Hub Repository: '$DOCKER_HUB_REPO' with tag '$DOCKER_HUB_TAG'."
if [ -z "$CORE_BRANCH" ]; then
CORE_BRANCH="distro/collabora/cp-6.4"
fi;
echo "Building core branch '$CORE_BRANCH'"
if [ -z "$COLLABORA_ONLINE_REPO" ]; then
COLLABORA_ONLINE_REPO="https://github.com/CollaboraOnline/online.git"
fi;
if [ -z "$COLLABORA_ONLINE_BRANCH" ]; then
COLLABORA_ONLINE_BRANCH="master"
fi;
echo "Building online branch '$COLLABORA_ONLINE_BRANCH' from '$COLLABORA_ONLINE_REPO'"
if [ -z "$CORE_BUILD_TARGET" ]; then
CORE_BUILD_TARGET=""
fi;
echo "LOKit (core) build target: '$CORE_BUILD_TARGET'"
SRCDIR=$(realpath `dirname $0`)
INSTDIR="$SRCDIR/instdir"
if [ -z "$(lsb_release -si)" ]; then
echo "WARNING: Unable to determine your distribution"
echo "(Is lsb_release installed?)"
echo "Using Ubuntu Dockerfile."
HOST_OS="Ubuntu"
else
HOST_OS=$(lsb_release -si)
fi
if ! [ -e "$SRCDIR/$HOST_OS" ]; then
echo "There is no suitable Dockerfile for your host system: $HOST_OS."
echo "Please fix this problem and re-run $0"
exit 1
fi
BUILDDIR="$SRCDIR/builddir"
mkdir -p "$BUILDDIR"
cd "$BUILDDIR"
rm -rf "$INSTDIR" || true
mkdir -p "$INSTDIR"
##### build static poco #####
if test ! -f poco/lib/libPocoFoundation.a ; then
wget https://github.com/pocoproject/poco/archive/poco-1.10.1-release.tar.gz
tar -xzf poco-1.10.1-release.tar.gz
cd poco-poco-1.10.1-release/
./configure --static --no-tests --no-samples --no-sharedlibs --cflags="-fPIC" --omit=Zip,Data,Data/SQLite,Data/ODBC,Data/MySQL,MongoDB,PDF,CppParser,PageCompiler,Redis,Encodings --prefix=$BUILDDIR/poco
make -j 8
make install
cd ..
fi
##### cloning & updating #####
# core repo
if test ! -d core ; then
git clone https://git.libreoffice.org/core || exit 1
fi
( cd core && git fetch --all && git checkout $CORE_BRANCH && ./g pull -r ) || exit 1
# online repo
if test ! -d online ; then
git clone "$COLLABORA_ONLINE_REPO" online || exit 1
fi
( cd online && git fetch --all && git checkout -f $COLLABORA_ONLINE_BRANCH && git clean -f -d && git pull -r ) || exit 1
##### LOKit (core) #####
# build
if [ "$CORE_BRANCH" == "distro/collabora/cp-6.4" ]; then
( cd core && ./autogen.sh --with-distro=CPLinux-LOKit --disable-epm --without-package-format ) || exit 1
else
( cd core && ./autogen.sh --with-distro=LibreOfficeOnline ) || exit 1
fi
( cd core && make $CORE_BUILD_TARGET ) || exit 1
# copy stuff
mkdir -p "$INSTDIR"/opt/
cp -a core/instdir "$INSTDIR"/opt/lokit
##### loolwsd & loleaflet #####
# build
( cd online && ./autogen.sh ) || exit 1
( cd online && ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-silent-rules --with-lokit-path="$BUILDDIR"/core/include --with-lo-path=/opt/lokit --with-poco-includes=$BUILDDIR/poco/include --with-poco-libs=$BUILDDIR/poco/lib $ONLINE_EXTRA_BUILD_OPTIONS) || exit 1
( cd online && make -j 8) || exit 1
# copy stuff
( cd online && DESTDIR="$INSTDIR" make install ) || exit 1
# Create new docker image
if [ -z "$NO_DOCKER_IMAGE" ]; then
cd "$SRCDIR"
cp ../from-packages/scripts/start-collabora-online.sh .
docker build --no-cache -t $DOCKER_HUB_REPO:$DOCKER_HUB_TAG -f $HOST_OS . || exit 1
else
echo "Skipping docker image build"
fi;