forked from antoniofaccioli/libreoffice-appimage
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmake_libreoffice_appimage
More file actions
executable file
·394 lines (350 loc) · 13.2 KB
/
make_libreoffice_appimage
File metadata and controls
executable file
·394 lines (350 loc) · 13.2 KB
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
#!/bin/bash
# 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}"
argv7="${7}"
everylang="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"
# 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> <portable-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': package 32-bit binaries"
echo " 'x86-64': package 64-bit binaries"
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 " <custom>: includes one or more comma separated language-packs (for example 'de' or 'it,es')"
echo ""
echo " <help-yesno>: 'Y' or 'N' (Yes/No to include online help for each language pack installed for the previous '<lang>' parameter)"
echo " <custom>: includes help for one or more comma separated languages (for example 'de' or 'it,es')"
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 " <portable-yesno>: 'Y' or 'N' (Yes/No to include portable function)"
echo ""
echo " Example: \"${argv0} still x86-64 it N 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)
# 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
argv="x86-64"
case $argv3 in
standard|full)
echo " -- with localization language(es) \"${argv3}\";"
;;
N)
echo " -- without any extra localization language;"
;;
"$everylang")
echo " -- with localization language \"${argv3}\";"
;;
*)
if [ -z "$argv3" ]
then
echo "==> Wrong or unsupported language request '${argv3}' in argument no.3. <=="
echo "For correct usage of ${argv0} please see below:"
echo ""
usage
exit 0
fi
for lang in ${argv3//,/ }
do
for available in ${everylang//|/ }
do
[ "$lang" = "$available" ] && continue 2
done
echo "==> Wrong or unsupported language request '${lang}' in argument no.3. <=="
echo "For correct usage of ${argv0} please see below:"
echo ""
usage
exit 0
done
echo " -- with localization language(s) \"${argv3}\";"
;;
esac
case $argv4 in
Y|N)
# Do nothing, accepted!
echo " -- include offline help = \"${argv4}\";"
;;
*)
if [ -z "$argv4" ]
then
echo "==> Wrong or unsupported help language request '${argv4}' in argument no.4. <=="
echo "==> Must be either 'Y', 'N' or a comma separated list of languages to include <=="
echo "For correct usage of ${argv0} please see below:"
echo ""
usage
exit 0
fi
for helplang in ${argv4//,/ }
do
for available in ${everylang//|/ }
do
[ "$helplang" = "$available" ] && continue 2
done
echo "==> Wrong or unsupported help language request '${helplang}' in argument no.4. <=="
echo "==> Must be either 'Y', 'N' or a comma separated list of languages to include <=="
echo "For correct usage of ${argv0} please see below:"
echo ""
usage
exit 0
done
echo " -- include offline help language(s) \"${argv4}\";"
;;
esac
argv5="Y"
argv6="Y"
argv7="Y"
}
# Check number of arguments:
case $# in
7)
check
;;
0|1|2|3|4|5|6|*)
echo "==> Wrong number of arguments! (Used: ${#}) <=="
echo "For correct usage of ${argv0} please see below:"
echo ""
usage
exit 0
;;
esac
declare -A master_builds
todate() {
# change the date to Unix timestamp
local datestring="TZ=\"UTC\" ${1}"
date -d "$datestring" +%s
}
newestmaster() {
# Compare the dates as timestamps to find the newest one
# Access associative array with a name reference
# Key is relative path to file, value is date
local -n ar=$1
local max=0
local filepath=""
for i in "${!ar[@]}" ; do
timestamp=$(todate "${ar[$i]}")
(("$timestamp" > max)) && max="$timestamp" && filepath="$i"
done
echo "$filepath"
}
filtermasters() {
# Read a page listing the actually available builds
local current_masters=$(wget -q "https://dev-builds.libreoffice.org/daily/master/current.html" -O -)
# Put all the Linux build links into an array, but filter out any debug or rpm archives
mapfile -t master_links < <( grep -oP -e '<a href="\.\/Linux.*</a>' <<< "$current_masters" | grep -vE 'dbg|rpm\.tar\.gz' )
# Add relative file paths and dates into an associative array
for link in "${master_links[@]}"; do
key=$(grep -oP -e '(?<=<a href="\.\/)Linux.*(?=">)' <<< "$link")
value=$(grep -oP -e "(?<=<a href=\"\.\/${key}\">).*(?=<\/a>)" <<< "$link")
master_builds[$key]=$value
done
newestmaster master_builds
}
pathVersion=$1
arch="${2:-x86-64}"
language="${3:-N}"
optHelp="${4:-N}"
optSignature="${6:-N}"
optPortable="${7:-Y}"
gpgPass=""
if [[ $language == *"standard"* ]] ; then
languages=(en-GB it ar zh-CN zh-TW fr de ja ko pt pt-BR es ru)
elif [[ $language == *"full"* ]] ; then
languages=(${everylang//|/ })
elif [[ $language != "N" ]] ; then
languages=(${argv3//,/ })
# avoid long language lists in VERSION; and commas like in "fr,de"
# cause "LibreOffice-$VERSION.AppImage --appimage-mount" to fail
[ "${#languages[@]}" -le 4 ] && language="${language//,/_}" || language="custom"
else
languages=()
fi
if [[ $optHelp == *"Y"* ]] ; then
helplanguages=("${languages[@]}")
elif [[ $optHelp != "N" ]] ; then
helplanguages=(${argv4//,/ })
else
helplanguages=()
fi
pathArch="x86_64"
appimageArch="x86_64"
APP=LibreOffice
libreVersion=$pathVersion
if [[ $pathVersion == *"fresh"* ]] ; then
nrVersion_small=$(curl -Ls "https://download.documentfoundation.org/libreoffice/testing/" | grep -Eo "href.*[0-9]/" | tr '"></ ' '\n' | grep "^[0-9].*[0-9]$" | tail -1)
path="https://download.documentfoundation.org/libreoffice/testing/${nrVersion_small}/deb/${pathArch}/"
nrVersion=$(curl -Ls "$path" | tr '">< ' '\n' | grep "_deb.tar.gz" | sort --version-sort | tail -1 | tr '_' '\n' | grep "^[0-9].*[-0-9]$")
package="LibreOffice_${nrVersion}_Linux_${arch}_deb.tar.gz"
elif [[ $pathVersion == *"still"* ]] ; then
nrVersion_small=$(curl -Ls "https://download.documentfoundation.org/libreoffice/stable/" | grep -Eo "href.*[0-9]/" | tr '"></ ' '\n' | grep "^[0-9].*[0-9]$" | tail -1)
path="https://download.documentfoundation.org/libreoffice/stable/${nrVersion_small}/deb/${pathArch}/"
nrVersion=$(curl -Ls "$path" | tr '">< ' '\n' | grep "_deb.tar.gz" | sort --version-sort | tail -1 | tr '_' '\n' | grep "^[0-9].*[-0-9]$")
package="LibreOffice_${nrVersion}_Linux_${arch}_deb.tar.gz"
else
nrVersion=$libreVersion
path="https://downloadarchive.documentfoundation.org/libreoffice/old/${nrVersion}/deb/${pathArch}/"
package="LibreOffice_${nrVersion}_Linux_${arch}_deb.tar.gz"
fi
LibODownloadLink=$path$package
if [[ $optHelp != "N" ]] ; 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 || exit
[ ! -f "$package" ] && wget -c "$LibODownloadLink"
if [[ $language != "N" ]] ; then
langStart="LibreOffice_${nrVersion}_Linux_${arch}_deb_langpack_"
if [[ $language == *"standard"* || $language == *"full"* ]] ; then
for element in ${languages[*]}; do
langPackage="$langStart$element.tar.gz"
[ ! -f "$langPackage" ] && wget -c "$path$langPackage"
done
else
for element in ${languages[*]}; do
langPackage="$langStart${element}.tar.gz"
[ ! -f "$langPackage" ] && wget -c "$path$langPackage"
done
fi
fi
if [[ $optHelp != "N" ]] ; then
helpStart="LibreOffice_${nrVersion}_Linux_${arch}_deb_helppack_"
if [[ $language == *"standard"* || $language == *"full"* ]] ; then
for element in ${helplanguages[*]}; do
helpPackage="$helpStart$element.tar.gz"
[ ! -f "$helpPackage" ] && wget -c "$path$helpPackage"
done
else
if [[ "${#helplanguages[@]}" != "0" ]] ; then
for element in ${helplanguages[*]}; do
helpPackage="$helpStart${element}.tar.gz"
[ ! -f "$helpPackage" ] && wget -c "$path$helpPackage"
done
else
helpPackage="${helpStart}en-US.tar.gz"
[ ! -f "$helpPackage" ] && wget -c "$path$helpPackage"
fi
fi
fi
tar xfvz "$package"
if [[ $language == *"standard"* ]] ; then
languages="en-GB it ar zh-CN zh-TW fr de ja ko pt pt-BR es ru"
for l in $languages; do
for i in *.tar.gz; do
if echo "$i" | grep -q "langpack_$l.tar.gz"; then
tar xfvz "$i"
fi
if [ "$optHelp" != "N" ] && echo "$i" | grep -q "helppack_$l.tar.gz"; then
tar xfvz "$i"
fi
done
done
elif [[ $language == *"full"* ]] ; then
for i in *.tar.gz; do
tar xfvz "$i"
done
else
for i in *.tar.gz; do
if echo "$i" | grep -q "langpack_$language.tar.gz"; then
tar xfvz "$i"
fi
if [ "$optHelp" != "N" ] && echo "$i" | grep -q "helppack_$language.tar.gz"; then
tar xfvz "$i"
fi
done
fi
[ ! -f AppRun ] && wget -c https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-$appimageArch -O AppRun && chmod a+x AppRun
cd "$APP".AppDir/ || exit 1
find ../*deb/ -name "*.deb" -exec dpkg -x \{\} . \;
if [[ $language == *"standard"* ]] ; then
languages="en-GB it ar zh-CN zh-TW fr de ja ko pt pt-BR es ru"
for l in $languages; do
find ../*deb_langpack_"$l"/ -name "*.deb" -exec dpkg -x \{\} . \;
[ "$optHelp" != "N" ] && find ../*deb_helppack_"$l"/ -name "*.deb" -exec dpkg -x \{\} . \;
done
elif [[ $language == *"full"* ]] ; then
find ../*deb_langpack_*/ -name "*.deb" -exec dpkg -x \{\} . \;
[ "$optHelp" != "N" ] && find ../*deb_helppack_*/ -name "*.deb" -exec dpkg -x \{\} . \;
else
find ../*deb_langpack_"$language"/ -name "*.deb" -exec dpkg -x \{\} . \;
[ "$optHelp" != "N" ] && find ../*deb_helppack_"$language"/ -name "*.deb" -exec dpkg -x \{\} . \;
fi
if [[ $optPortable != "N" ]] ; then
find . -type f -iname "bootstraprc" -exec sed -i "s|^UserInstallation=.*|UserInstallation=\$SYSUSERCONFIG/libreoffice/$nrVersion|g" {} +
fi
find . -name startcenter.desktop -exec cp \{\} . \;
sed -i -e 's|Name=.*|Name=LibreOffice|g' startcenter.desktop
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/ || exit 1
rm ./"$BINARY"
find ../../opt -name soffice -path "*program*" -exec ln -s \{\} ./"$BINARY" \;
cd ../../ || exit 1
cp ../AppRun ./AppRun
cd .. || exit 1
if [[ $optHelp != "N" ]] ; then
variant="$language.help"
else
variant="$language"
fi
UPINFO="gh-releases-zsync|$GITHUB_REPOSITORY_OWNER|LibreOffice-appimage|continuous-$pathVersion|*$pathVersion*$variant-x86_64.AppImage.zsync"
FILENAME="LibreOffice-$pathVersion-$nrVersion-$variant-x86_64.AppImage "
ARCH=x86_64 appimagetool -u "$UPINFO" ./$APP.AppDir/ "$FILENAME"
rm -Rf ./"$APP".AppDir/*
#if [[ $optSignature == "Y" ]] ; then
# for i in $(find . -name "*.AppImage*" -print;); do gpg2 -b --batch --armor --passphrase "$gpgPass" "${i}"; done || true
#fi
mkdir -p ../out/ || true
mv *.AppImage* ../out/