/
build
executable file
·94 lines (76 loc) · 2.33 KB
/
build
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
#! /usr/bin/env bash
# This is a script to build LibreSymbols extensions.
#
# LibreSymbols
#
# Stefan Schmidhuber (stefan.schmidhuber@gmx.at)
# target directory for extension files
EXTENSIONS=.
# get the last git tag as vesion number
VERSION=$(git tag | tail -n 1)
print_help() {
echo -e 'Usage:\tbuild\t\t\tbuild extensions'
echo -e '\tbuild -h | --help\tprint this help\n'
echo -e '\tBuilds a LibreSymbols extension of the currently ckecked out commit.'
echo -e '\tIndependet of the actual version, the latest git tag will be used as'
echo -e '\tversion number.\n'
exit 0
}
build_extension() {
for LANG in $(ls gallery); do
# create temporary directory
TEMP_DIR=$(mktemp -d)
# copy files
cp description.xml ${TEMP_DIR}/description.xml
cp doc/icon_100.png ${TEMP_DIR}/icon.png
cp Paths.xcu ${TEMP_DIR}/Paths.xcu
cp -r license ${TEMP_DIR}/license
cp -r META-INF ${TEMP_DIR}/META-INF
mkdir ${TEMP_DIR}/gallery
cp gallery/${LANG}/* ${TEMP_DIR}/gallery/
cd ${TEMP_DIR}
# set meta data
awk '{sub(/VERSION/, '${VERSION}'); print $0}' description.xml > description.xml_changed
mv description.xml_changed description.xml
# zip files
zip -rq LibreSymbols_${VERSION}_${LANG}.zip *
mv LibreSymbols_${VERSION}_${LANG}.zip ${WORKING_DIR}/${EXTENSIONS}/LibreSymbols_${VERSION}_${LANG}.oxt
# clean up
cd ${WORKING_DIR}
rm -r ${TEMP_DIR}
done
return 0
}
# entry point
echo '' # just an empty line for better readability of the following output
if [[ $# -gt 1 ]]; then
echo -e 'ERROR: Invalid number of arguments.\n'
print_help
exit 1
fi
if [[ ! -z $1 ]]; then
if [[ $1 = "-h" ]] || [[ $1 = "-help" ]] || [[ $1 = "--help" ]] || [[ $1 = "-?" ]]; then
print_help
else
echo -e 'ERROR: Invalid argument "'$1'"\n'
print_help
exit 1
fi
fi
# remember current directory and branch
WORKING_DIR=$(pwd)
# remove old builds
if [[ $(ls ${EXTENSIONS}/LibreSymbols_${VERSION}_* 2>/dev/null | wc -w) -gt 0 ]]; then
echo 'delete old builds ...'
rm ${EXTENSIONS}/LibreSymbols_${VERSION}_*
fi
echo 'building LibreSymbols '${VERSION}' ... '
build_extension
# success or error message
if [[ $(ls -l ${EXTENSIONS}/LibreSymbols_${VERSION}_* 2>/dev/null | wc -l) -eq $(ls gallery | wc -w) ]]; then
echo -e 'finished successful\n'
else
echo -e 'failed\n'
exit 1
fi
exit 0