forked from antoniofaccioli/libreoffice-appimage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_libreoffice_appimage
407 lines (369 loc) · 13.6 KB
/
make_libreoffice_appimage
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
#!/bin/bash -x
# Generate LibreOffice AppImage
# by Antonio Faccioli
# Added 'Usage' message and basic 'check' functions by Kurt Pfeifle
# Based on script by Simon Peter
# Released under the Mozilla Public License Version 2.0
# http://www.libreoffice.org/about-us/licenses/
argv0="${0}"
argv1="${1}"
argv2="${2}"
argv3="${3}"
argv4="${4}"
argv5="${5}"
argv6="${6}"
# Describe usage:
usage() {
echo ""
echo " Build an \"single-file\" AppImage executable for any (arbitrary) version of LibreOffice from The Document Foundation's official binary Debian package."
echo ""
echo " Usage: ${argv0} <version> <arch> <lang> <help-yesno> <zsync-yesno> <sign-yesno>"
echo ""
echo " where:"
echo " <version>: 'fresh': build from 'fresh' release channel (i.e. the latest official release)"
echo " 'still': build from 'still' release channel (i.e. the previous official release)"
echo " 'daily': build from 'daily' release channel (i.e. the current hot-of-the-stove development branch)"
echo " 'n.m.o.p': for example use '5.4.3.2'"
echo ""
echo " <arch>: 'x86-64' (only one currently supported -- 32bit doesn't work yet)"
echo ""
echo " <lang>: 'standard': includes en-GB, it, ar, zh-CN, zh-TW, fr, de, ja, ko, pt, pt-BR, es, ru language-packs"
echo " 'full': includes all available language-packs (for some releases more than 113 different ones!)"
echo " 'N': no extra language-pack (LibreOffice comes with default 'en-US')"
echo " <single>: includes the named language-pack (for example 'de', 'it' or 'es')"
echo ""
echo " <help-yesno>: 'Y' or 'N' (Yes/No to include online help -- depends on the previous '<lang>' parameter)"
echo ""
echo " <zsync-yesno>: 'Y' or 'N' (Yes/No to include capability for updating the AppImage with the help of 'AppImageUpdate')"
echo ""
echo " <sign-yesno>: 'Y' or 'N' (Yes/No to include a GPG signature)"
echo ""
echo " Example: \"${argv0} still x86-64 it N N N\""
echo " Build LO AppImage package with Italian language-pack, without offline help, not auto-updateable, without signing the package."
echo ""
echo " Example: \"${argv0} daily x86-64 de Y Y N\""
echo " Build LO AppImage package (development version) with German language-pack, with (German) offline help, updateable via zsync, without signing the package."
echo ""
echo " Example: \"${argv0} 3.5.7.2 x86-64 es Y N N\""
echo " Build LO v3.5.7.2 AppImage package with Spanish language-pack, with (Spanish) offline help, not auto-updateable, without signing the package."
echo ""
}
check() { # This is not a complete, but only a limited sanity check of the inputs
case $argv1 in
fresh|still|daily|3.*|4.*|5.*|6.*)
# Do nothing, accepted!
echo -e "\nBuilding LibreOffice AppImage from \"${argv1}\" channel or release:"
;;
*)
echo -e "\n ==> Argument no.1 must be either 'fresh', 'still', 'daily' or a specific LibreOffice version number released by The Document Foundation. <=="
echo "For correct usage of ${argv0} please see below:"
echo ""
usage
exit 0
;;
esac
case $argv2 in
x86-64)
# Do nothing, accepted!
echo " -- for architecture \"${argv2}\";"
;;
*)
echo "==> Wrong or unsupported architecture ${argv2} in argument no.2 -- must be 'x86-64' ('x86' is currently not supported). <=="
echo "For correct usage of ${argv0} please see below:"
echo ""
usage
exit 0
;;
esac
case $argv3 in
standard|full)
echo " -- with localization language(es) \"${argv3}\";"
;;
N)
echo " -- without any extra localization language;"
;;
af|am|ar|as|ast|be|bg|bn-IN|bn|bo|br|brx|bs|ca-valencia|ca|cs|cy|da|de|dgo|dz|el|en-GB|en-ZA|eo|es|et|eu|fa|fi|fr|ga|gd|gl|gu|gug|he|hi|hr|hsb|hu|id|is|it|ja|ka|kk|km|kmr|kn|ko|kok|ks|lb|lo|lt|lv|mai|mk|ml|mn|mni|mr|my|nb|ne|nl|nn|nr|nso|oc|om|or|pa-IN|pl|pt-BR|pt|qtz|ro|ru|rw|sa-IN|sat|sd|si|sid|sk|sl|sq|sr-Latn|sr|ss|st|sv|sw-TZ|ta|te|tg|th|tn|tr|ts|tt|ug|uk|uz|ve|vec|vi|xh|zh-CN|zh-TW|zu)
echo " -- with localization language \"${argv3}\";"
;;
*)
echo "==> Wrong or unsupported language request ${argv3} in argument no.3. <=="
echo "For correct usage of ${argv0} please see below:"
echo ""
usage
exit 0
;;
esac
case $argv4 in
Y|N)
# Do nothing, accepted!
echo " -- include online help = \"${argv4}\";"
;;
*)
echo "==> Wrong argument ${argv4} at position no.4! (Must be either 'Y' or 'N' to include offline help or not... <=="
echo "For correct usage of ${argv0} please see below:"
echo ""
usage
exit 0
;;
esac
case $argv5 in
Y|N)
# Do nothing, accepted!
echo " -- include AppImage zsync updatability feature = \"${argv4}\";"
;;
*)
echo "==> Wrong argument ${argv5} at position no.5! (Must be either 'Y' or 'N' to include update functions or not... <=="
echo "For correct usage of ${argv0} please see below:"
echo ""
usage
exit 0
;;
esac
case $argv6 in
Y|N)
# Do nothing, accepted!
echo " -- with signature for package = \"${argv4}\";"
;;
*)
echo "==> Wrong argument ${argv6} at position no. 6! (Must be either 'Y' or 'N' to include a signature or not... <=="
echo "For correct usage of ${argv0} please see below:"
echo ""
usage
exit 0
;;
esac
}
# Check number of arguments:
case $# in
6)
check
;;
0|1|2|3|4|5|*)
echo "==> Wrong number of arguments! (Used: ${#}) <=="
echo "For correct usage of ${argv0} please see below:"
echo ""
usage
exit 0
;;
esac
pathVersion=$1
arch="${2:-x86-64}"
language="${3:-N}"
optHelp="${4:-N}"
optSync="${5:-N}"
optSignature="${6:-N}"
linkZsync=""
gpgPass=""
standard=(en-GB it ar zh-CN zh-TW fr de ja ko pt pt-BR es ru)
full=(af am ar as ast be bg bn-IN bn bo br brx bs ca-valencia ca cs cy da de dgo dz el en-GB en-ZA eo es et eu fa fi fr ga gd gl gu gug he hi hr hsb hu id is it ja ka kk km kmr kn ko kok ks lb lo lt lv mai mk ml mn mni mr my nb ne nl nn nr nso oc om or pa-IN pl pt-BR pt qtz ro ru rw sa-IN sat sd si sid sk sl sq sr-Latn sr ss st sv sw-TZ ta te tg th tn tr ts tt ug uk uz ve vec vi xh zh-CN zh-TW zu)
if [[ $arch == *"x86-64"* ]] ; then
pathArch="x86_64"
fi
if [[ $pathVersion == *"daily"* ]] ; then
APP=LibreOfficeDev
else
APP=LibreOffice
fi
case "$pathVersion" in
"3.3.0.4")
libreVersion="3.3.0"
;;
"3.3.1.2")
libreVersion="3.3.1"
;;
"3.3.2.2")
libreVersion="3.3.2"
;;
"3.3.3.1")
libreVersion="3.3.3"
;;
"3.3.4.1")
libreVersion="3.3.4"
;;
"3.4.0.1")
libreVersion="3.4.0rc1"
;;
"3.4.1.3")
libreVersion="3.4.1"
;;
"3.4.2.3")
libreVersion="3.4.2"
;;
"3.4.3.2")
libreVersion="3.4.3"
;;
"3.4.4.1")
libreVersion="3.4.4rc1"
;;
"3.4.5.2")
libreVersion="3.4.5rc2"
;;
"3.4.6.2")
libreVersion="3.4.6rc2"
;;
"3.5.0.3")
libreVersion="3.5.0rc3"
;;
"3.5.1.2")
libreVersion="3.5.1rc2"
;;
"3.5.2.2")
libreVersion="3.5.2rc2"
;;
"3.5.3.2")
libreVersion="3.5.3rc2"
;;
"3.5.4.2")
libreVersion="3.5.4rc2"
;;
"3.5.5.3")
libreVersion="3.5.5rc3"
;;
"3.5.6.2")
libreVersion="3.5.6rc2"
;;
"3.5.7.2")
libreVersion="3.5.7rc2"
;;
*)
libreVersion=$pathVersion
;;
esac
set +e
if [[ $pathVersion == *"fresh"* ]] ; then
nrVersion=$(wget -q "https://www.libreoffice.org/download/download" -O - | grep -o -e "/stable/.*/" | cut -d "/" -f 3 | head -n 1)
path="https://download.documentfoundation.org/libreoffice/stable/"$nrVersion"/deb/"$pathArch"/"
package="LibreOffice_"$nrVersion"_Linux_"$arch"_deb.tar.gz"
elif [[ $pathVersion == *"still"* ]] ; then
nrVersion=$(wget -q "https://www.libreoffice.org/download/download" -O - | grep -o -e "/stable/.*/" | cut -d "/" -f 3 | head -n 3 | tail -n 1)
path="https://download.documentfoundation.org/libreoffice/stable/"$nrVersion"/deb/"$pathArch"/"
package="LibreOffice_"$nrVersion"_Linux_"$arch"_deb.tar.gz"
elif [[ $pathVersion == *"daily"* ]] ; then
path="http://dev-builds.libreoffice.org/daily/master/Linux-rpm_deb-"$pathArch"@70-TDF/current/"
package=$(wget -q "$path" -O - | grep -o -e ">mas.*Linux_x86-64_deb.tar.gz" | cut -d ">" -f 2)
tmpVersion1=$(echo $package | cut -d "_" -f 4)
tmpVersion2=$(echo $package | cut -d "_" -f 1 | cut -d "~" -f 2)
nrVersion=$tmpVersion1"_"$tmpVersion2
else
if [[ $pathVersion == "3."* ]] ; then
nrVersion=$libreVersion
path="https://downloadarchive.documentfoundation.org/libreoffice/old/"$pathVersion"/deb/"$pathArch"/"
package="LibO_"$nrVersion"_Linux_"$arch"_install-deb_en-US.tar.gz"
else
nrVersion=$libreVersion
path="https://download.documentfoundation.org/libreoffice/old/"$nrVersion"/deb/"$pathArch"/"
package="LibreOffice_"$nrVersion"_Linux_"$arch"_deb.tar.gz"
fi
fi
LibODownloadLink=$path$package
if [[ $optHelp == *"Y"* ]] ; then
if [[ $language != "N" ]] ; then
VERSION=$nrVersion"."$language".help"
else
VERSION=$nrVersion".help"
fi
else
if [[ $language != "N" ]] ; then
VERSION=$nrVersion"."$language
else
VERSION=$nrVersion
fi
fi
mkdir -p ./$APP/$APP.AppDir
cd ./$APP
wget -c $LibODownloadLink
if [[ $language != "N" ]] ; then
if [[ $language == *"standard"* ]] ; then
for element in ${standard[*]};
do
langPackage="LibreOffice_"$nrVersion"_Linux_"$arch"_deb_langpack_"$element".tar.gz"
wget -c $path$langPackage
done
elif [[ $language == *"full"* ]] ; then
for element in ${full[*]};
do
langPackage="LibreOffice_"$nrVersion"_Linux_"$arch"_deb_langpack_"$element".tar.gz"
wget -c $path$langPackage
done
else
if [[ $pathVersion == "3."* ]] ; then
langPackage="LibO_"$nrVersion"_Linux_"$arch"_langpack-deb_"$language".tar.gz"
wget -c $path$langPackage
else
langPackage="LibreOffice_"$nrVersion"_Linux_"$arch"_deb_langpack_"$language".tar.gz"
wget -c $path$langPackage
fi
fi
fi
if [[ $optHelp == *"Y"* ]] ; then
if [[ $language == *"standard"* ]] ; then
for element in ${standard[*]};
do
helpPackage="LibreOffice_"$nrVersion"_Linux_"$arch"_deb_helppack_"$element".tar.gz"
wget -c $path$helpPackage
done
elif [[ $language == *"full"* ]] ; then
for element in ${full[*]};
do
helpPackage="LibreOffice_"$nrVersion"_Linux_"$arch"_deb_helppack_"$element".tar.gz"
wget -c $path$helpPackage
done
else
if [[ $pathVersion == "3."* ]] ; then
if [[ $language != "N" ]] ; then
helpPackage="LibO_"$nrVersion"_Linux_"$arch"_helppack-deb_"$language".tar.gz"
wget -c $path$helpPackage
else
helpPackage="LibO_"$nrVersion"_Linux_"$arch"_helppack-deb_en-US.tar.gz"
wget -c $path$helpPackage
fi
else
if [[ $language != "N" ]] ; then
helpPackage="LibreOffice_"$nrVersion"_Linux_"$arch"_deb_helppack_"$language".tar.gz"
wget -c $path$helpPackage
else
helpPackage="LibreOffice_"$nrVersion"_Linux_"$arch"_deb_helppack_en-US.tar.gz"
wget -c $path$helpPackage
fi
fi
fi
fi
for i in *.tar.gz; do tar xfvz $i; done
cd $APP.AppDir/
find ../ -name *.deb -exec dpkg -x \{\} . \;
find . -type f -iname "bootstraprc" -exec sed -i "s|^UserInstallation=.*|UserInstallation=\$SYSUSERCONFIG/libreoffice/$nrVersion|g" {} +
find . -name startcenter.desktop -exec cp \{\} . \;
if [[ $pathVersion == *"daily"* ]] ; then
sed -i -e 's|Name=.*|Name=LibreOfficeDev|g' startcenter.desktop
else
sed -i -e 's|Name=.*|Name=LibreOffice|g' startcenter.desktop
fi
find -name *startcenter.png -path *hicolor*48x48* -exec cp \{\} . \;
BINARY=$(cat *.desktop | grep "Exec=" | head -n 1 | cut -d "=" -f 2 | cut -d " " -f 1)
mkdir -p usr/bin/
cd usr/bin/
rm ./$BINARY
find ../../opt -name soffice -path *program* -exec ln -s \{\} ./$BINARY \;
cd ../../
wget -c https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-x86_64 -O AppRun # 64-bit
chmod a+x AppRun
cd ..
URL="https://github.com/probonopd/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
wget -c "$URL" -O appimagetool
chmod a+x ./appimagetool
set +x
if [[ $optSync == "N" ]] ; then
VERSION=$VERSION ./appimagetool -v ./$APP.AppDir/
else
if [[ $language == "N" ]] ; then
VERSION="$pathVersion" ./appimagetool -u zsync|"$linkZsync$APP"-"$pathVersion".AppImage.zsync -v ./$APP.AppDir/
else
VERSION="$pathVersion"."$language" ./appimagetool -u zsync|"$linkZsync$APP"-"$pathVersion"."$language".AppImage.zsync -v ./$APP.AppDir/
fi
fi
set -x
if [[ $optSygnature == "Y" ]] ; then
for i in $(find . -name "*.AppImage*" -print;); do gpg -b --armor --passphrase "$gpgPass" ${i}; done || true
fi
mkdir -p ../out/ || true
mv *.AppImage* ../out/