-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.bash
executable file
·109 lines (93 loc) · 3.35 KB
/
build.bash
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
#!/usr/bin/env bash
#shellcheck disable=SC2034
# Comments prefixed by BASHDOC: are hints to specific GNU Bash Manual's section:
# https://www.gnu.org/software/bash/manual/
## init function: program entrypoint
init(){
local package_version
export GIT_DIR="${RUNTIME_EXECUTABLE_DIRECTORY}/.git"
package_version="$(git describe --tags --dirty --always)"
export_svgs_to_pngs
tar\
--create\
--bzip\
--verbose\
--file\
"${RUNTIME_EXECUTABLE_DIRECTORY}/Software Releases/libreoffice-tw-logo-${package_version}.tar.bz2"\
--\
*.markdown\
*.svg\
*.png
printf "\nBuild finished\n"
exit 0
}; declare -fr init
check_runtime_dependencies(){
for executable_name in \
basename\
dirname\
realpath\
git\
tar\
inkscape
do
if ! command -v "${executable_name}" &>/dev/null; then
printf\
"%s: Error: \"%s\" executable not found in executable search path!\n"\
"${FUNCNAME[0]}"\
"${executable_name}"\
1>&2
printf\
"%s: Error: Please check your runtime dependency installation.\n"\
"${FUNCNAME[0]}"\
1>&2
exit 1
fi
done
}; declare -fr check_runtime_dependencies; check_runtime_dependencies
export_svgs_to_pngs(){
for svg_file in "${RUNTIME_EXECUTABLE_DIRECTORY}"/*.svg; do
inkscape\
--without-gui\
--export-width=350\
--export-width=350\
--export-background-opacity=0.0\
--export-png="${svg_file}.350px.png"\
"${svg_file}"
done
}; declare -fr export_svgs_to_pngs
## Makes debuggers' life easier - Unofficial Bash Strict Mode
## http://redsymbol.net/articles/unofficial-bash-strict-mode/
## BASHDOC: Shell Builtin Commands - Modifying Shell Behavior - The Set Builtin
### Exit prematurely if a command's return value is not 0(with some exceptions), triggers ERR trap if available.
set -o errexit
### Trap on `ERR' is inherited by shell functions, command substitutions, and subshell environment as well
set -o errtrace
### Exit prematurely if an unset variable is expanded, causing parameter expansion failure.
set -o nounset
### Let the return value of a pipeline be the value of the last (rightmost) command to exit with a non-zero status
set -o pipefail
## Non-overridable Primitive Variables
##
## BashFAQ/How do I determine the location of my script? I want to read some config files from the same place. - Greg's Wiki
## http://mywiki.wooledge.org/BashFAQ/028
RUNTIME_EXECUTABLE_FILENAME="$(basename "${BASH_SOURCE[0]}")"
declare -r RUNTIME_EXECUTABLE_FILENAME
declare -r RUNTIME_EXECUTABLE_NAME="${RUNTIME_EXECUTABLE_FILENAME%.*}"
RUNTIME_EXECUTABLE_DIRECTORY="$(dirname "$(realpath --strip "${0}")")"
declare -r RUNTIME_EXECUTABLE_DIRECTORY
declare -r RUNTIME_EXECUTABLE_PATH_ABSOLUTE="${RUNTIME_EXECUTABLE_DIRECTORY}/${RUNTIME_EXECUTABLE_FILENAME}"
declare -r RUNTIME_EXECUTABLE_PATH_RELATIVE="${0}"
declare -r RUNTIME_COMMAND_BASE="${RUNTIME_COMMAND_BASE:-${0}}"
trap_errexit(){
printf "An error occurred and the script is prematurely aborted\n" 1>&2
return 0
}; declare -fr trap_errexit; trap trap_errexit ERR
trap_exit(){
return 0
}; declare -fr trap_exit; trap trap_exit EXIT
init "${@}"
## This script is based on the GNU Bash Shell Script Template project
## https://github.com/Lin-Buo-Ren/GNU-Bash-Shell-Script-Template
## and is based on the following version:
declare -r META_BASED_ON_GNU_BASH_SHELL_SCRIPT_TEMPLATE_VERSION="v1.24.1"
## You may rebase your script to incorporate new features and fixes from the template