-
Notifications
You must be signed in to change notification settings - Fork 1
/
lool-builder.sh
executable file
·279 lines (242 loc) · 8.21 KB
/
lool-builder.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#! /bin/bash
# ---------------------------------------------------------------------------------------
# Preparations
# Dieses Skript ist angedacht, in einem LXContainer ausgeführt zu werden
echo "deb https://collaboraoffice.com/repos/Poco/ /" >> /etc/apt/sources.list.d/poco.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0C54D189F4BA284D
apt-get update
if ! grep lool /etc/passwd
then
useradd -U -m -s /bin/bash lool
echo 'lool ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
fi
if id | grep -v lool
then
if [ -z "$SC_THEME" ]
then
sudo cp -rf data/office.css /home/lool/office.css
sudo cp -rf data/favicon-48.png /home/lool/favicon-48.png
else
sudo cp -rf data/office-n21.css /home/lool/office.css
sudo cp -rf data/logo.png /home/lool/favicon-48.png
fi
sudo cp -rf data/Makefile.am /home/lool
sudo cp -rf $0 /home/lool
chown lool: /home/lool/$0
chown lool: /home/lool/office.css
chown lool: /home/lool/favicon-48.png
chown lool: /home/lool/Makefile.am
echo "Als lool user ausfuehren"
exit 1
fi
sudo apt-get update
sudo apt-get install -y \
apt-transport-https \
zip \
git \
wget \
findutils \
build-essential \
locales-all \
openssl \
g++ \
libssl-dev \
libkrb5-dev \
libpng12-dev \
libcap-dev \
libpcap-dev \
libpam0g-dev \
libcunit1-dev \
libtool \
libxinerama1 \
libgl1-mesa-glx \
libfontconfig1 \
libfreetype6 \
libxrender1 \
libxcb-shm0 \
libxcb-render0 \
libpoco*60 \
libpoco-dev \
m4 \
automake \
autoconf \
cpio \
fontconfig \
translate-toolkit \
python-polib \
fonts-wqy-zenhei \
fonts-wqy-microhei \
fonts-droid-fallback \
fonts-noto-cjk \
|| exit 1
# use ccache binaries
if [ -d /usr/lib/ccache ]
then
echo "Install ccache"
sudo apt-get install -y ccache
# Update symlinks
sudo /usr/sbin/update-ccache-symlinks
# Prepend ccache into the PATH
echo 'export PATH="/usr/lib/ccache:$PATH"' | tee -a ~/.bashrc
# Source bashrc to test the new PATH
source ~/.bashrc
fi
if ! npm list -g | grep jake
then
echo "Install nodejs and jake"
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm install node
npm install -g jake
fi
# install libreoffice dependencies
sudo apt-get build-dep -y libreoffice || exit 1
git clone https://github.com/LibreOffice/online.git
echo 'Im Verzeichnis $HOME/online/docker liegt die nightly-build Datei "l10n-docker-nightly.sh".'
echo 'Die folgende Datei $HOME/online/docker/lool-build.sh basiert auf der nightly-build Datei.'
echo 'Also diese Datei vorher mit der nightly-build Datei manuell abgleichen!'
echo
echo 'Im Wesentlichen wird die nightly-build Datei um die compile Optionen:'
echo '--with-max-connections=100000 --with-max-documents=100000 erweitert'
echo 'Auch wird auf das Erstellen des docker images verzichtet'
cat <<'MYEOF' > $HOME/online/docker/lool-build.sh
#! /bin/bash
# This file is part of the LibreOffice project.
#
# 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/.
# 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: ALL"
echo
sudo echo "works"
# check if we have jake
which jake || { cat << EOF
jake is not installed, get it like:
npm install -g jake
EOF
exit 1 ; }
# do everything in the builddir
SRCDIR=$(realpath `dirname $0`)
INSTDIR="$SRCDIR/instdir"
BUILDDIR="$SRCDIR/builddir"
mkdir -p "$BUILDDIR"
cd "$BUILDDIR"
rm -rf "$INSTDIR"
mkdir -p "$INSTDIR"
##### cloning & updating #####
# libreoffice repo
if test ! -d libreoffice ; then
git clone git://anongit.freedesktop.org/libreoffice/core libreoffice || exit 1
fi
( cd libreoffice && git checkout master && ./g pull -r ) || exit 1
# online repo
if test ! -d online ; then
git clone git://anongit.freedesktop.org/libreoffice/online online || exit 1
( cd online && ./autogen.sh ) || exit 1
fi
( cd online && git checkout -f master && git pull -r ) || exit 1
##### LibreOffice #####
# add sc specific stuff
sudo cp -rf /home/lool/office.css /home/lool/online/docker/builddir/online/loleaflet/css/
sudo cp -rf /home/lool/favicon-48.png /home/lool/online/docker/builddir/online/loleaflet/images/
sudo cp -rf /home/lool/Makefile.am /home/lool/online/docker/builddir/online/loleaflet/
# build LibreOffice
cat > libreoffice/autogen.input << EOF
--disable-cups
--disable-dbus
--disable-dconf
--disable-epm
--disable-evolution2
--disable-ext-nlpsolver
--disable-ext-wiki-publisher
--disable-firebird-sdbc
--disable-gio
--disable-gstreamer-0-10
--disable-gstreamer-1-0
--disable-gtk
--disable-gtk3
--disable-kde4
--disable-odk
--disable-online-update
--disable-pdfimport
--disable-postgresql-sdbc
--disable-report-builder
--disable-scripting-beanshell
--disable-scripting-javascript
--disable-sdremote
--disable-sdremote-bluetooth
--enable-extension-integration
--enable-mergelibs
--enable-python=internal
--enable-release-build
--with-external-dict-dir=/usr/share/hunspell
--with-external-hyph-dir=/usr/share/hyphen
--with-external-thes-dir=/usr/share/mythes
--with-fonts
--with-galleries=no
--with-lang=ALL
--with-linker-hash-style=both
--with-system-dicts
--with-system-zlib
--with-theme=colibre
--without-branding
--without-help
--without-java
--without-junit
--with-myspell-dicts
--without-package-format
--without-system-cairo
--without-system-jars
--without-system-jpeg
--without-system-libpng
--without-system-libxml
--without-system-openssl
--without-system-poppler
--without-system-postgresql
EOF
( cd libreoffice && ./autogen.sh ) || exit 1
( cd libreoffice && make ) || exit 1
# copy stuff
mkdir -p "$INSTDIR"/opt/
cp -a libreoffice/instdir "$INSTDIR"/opt/libreoffice
##### loolwsd & loleaflet #####
# build
( cd online && ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-silent-rules --with-lokit-path="$BUILDDIR"/libreoffice/include --with-lo-path="$INSTDIR"/opt/libreoffice --with-max-connections=100000 --with-max-documents=100000 ) || exit 1
( cd online/loleaflet/po && ../../scripts/downloadpootle.sh )
( cd online/loleaflet && make l10n) || exit 1
( cd online && scripts/locorestrings.py "$BUILDDIR"/online "$BUILDDIR"/libreoffice/translations )
( cd online && scripts/unocommands.py --update "$BUILDDIR"/online "$BUILDDIR"/libreoffice )
( cd online && scripts/unocommands.py --translate "$BUILDDIR"/online "$BUILDDIR"/libreoffice/translations )
( cd online && make -j 8) || exit 1
# copy stuff
( cd online && DESTDIR="$INSTDIR" make install ) || exit 1
# Create new docker image
echo
echo 'OK'
echo
echo '# Wenn Docker auf dem Server laeuft'
echo 'cd /var/lib/lxd/containers/loolbuilder/rootfs/home/lool/online/docker'
echo
echo '# Wenn Docker im LXC lauffaehig ist'
echo 'cd /home/lool/online/docker'
echo
echo 'export SRCDIR=$(pwd)'
echo 'export INSTDIR="$SRCDIR/instdir"'
echo 'export BUILDDIR="$SRCDIR/builddir"'
echo 'cd "$SRCDIR"'
echo 'TAGSHORT="schulcloud/libreoffice"'
echo 'TAG="$TAGSHORT:latest${SC_THEME}"'
echo 'dockerid="$(docker build -q --no-cache -t "$TAG" . )" || exit 1'
echo 'echo $dockerid'
echo 'docker save "${TAGSHORT}" |xz > "${BUILDDIR}/docker-image-libreoffice-online.tar.xz"'
echo 'echo "${dockerid}" > "${BUILDDIR}/docker-image-libreoffice-online.id"'
echo 'docker login'
echo 'docker push $TAG'
MYEOF
bash $HOME/online/docker/lool-build.sh