-
Notifications
You must be signed in to change notification settings - Fork 17
/
make.sh
executable file
·216 lines (195 loc) · 6.48 KB
/
make.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
#!/usr/bin/env bash
# (c) 2005-2023 by Panayotis Katsaloulis
# SPDX-License-Identifier: AGPL-3.0-only
# This file is part of Jubler.
# Be strict with script
set -euo pipefail
# ANSI escape codes for colors
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
# Get the directory where the script is located
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
dist_dir=$script_dir/dist
valid_targets=("windows" "linux" "generic" "macos" "all")
display_help() {
echo -e "This is a helper script for building Jubler:"
echo -e " ${GREEN}version X.Y.Z${NC} Update Jubler version."
echo -e " ${GREEN}build TARGET1[,TARGET2]${NC} Build Jubler for the list of provided targets."
echo -e " ${GREEN}clean${NC} Clean build files."
echo -e " ${GREEN}headers${NC} Check header files for copyright notice."
echo -e " ${GREEN}--help${NC} Display information about this script."
echo
echo -e "Available build targets:"
(IFS=,; echo -e " ${GREEN}${valid_targets[*]}${NC}")
echo
echo -e "Additional parameters for specific targets:"
echo -e " ${GREEN}notarize${NC} Perform notarization for MacOS target."
echo -e " ${GREEN}nosign${NC} Skip signing for Windows and MacOS targets."
}
version_action() {
local version=$2
if [ $# -lt 2 ]; then
echo -e "${RED}Error:${NC} Missing argument for 'version'. Provide a value in X.Y.Z form."
exit 1
fi
if ! [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9_]+)?$ ]]; then
echo -e "${RED}Error:${NC} Invalid version format."
exit 1
fi
local version=$2
cd $script_dir
mvn versions:set -DnewVersion=$version -DgenerateBackupPoms=false -DprocessAllModules
# mkdir -p "$dist_dir/"
# if [ ! -e "$dist_dir/.Komac.jar" ]; then
# wget -O "$dist_dir/.Komac.jar" https://github.com/russellbanks/Komac/releases/download/v1.11.0/Komac-1.11.0-all.jar
# fi
# cd resources/winget/jubler/manifests/j/Jubler/
# java -jar $dist_dir/.Komac.jar update --version=$version
}
build_windows() {
echo -e "${GREEN}Building for Windows...${NC}"
cd "$script_dir"
# Check if extra arguments are provided
NOSIGN=$(if [[ $* == *"nosign"* ]]; then echo ",nosign"; else echo ""; fi)
mvn clean install -Pdist,win64${NOSIGN}
cd "$script_dir/modules/installer/target" || exit
if [ -e Jubler-*.x32.exe ]; then
echo -e "${GREEN}Copying x32 EXE file to dist.${NC}"
cp Jubler-*.x32.exe "$dist_dir/"
fi
if [ -e Jubler-*.x64.exe ]; then
echo -e "${GREEN}Copying x64 EXE file to dist.${NC}"
cp Jubler-*.x64.exe "$dist_dir/"
fi
if [ ! -e Jubler-*.x32.exe ] && [ ! -e Jubler-*.x64.exe ]; then
echo -e "${RED}Error:${NC} Could not find x32 or x64 EXE file for Jubler."
exit 1
fi
}
build_linux() {
echo -e "${GREEN}Building for Linux...${NC}"
cd "$script_dir"
mvn clean install -Pdist,linux
cd "$script_dir/modules/installer/target" || exit
if [ -e Jubler-*.appimage ]; then
echo -e "${GREEN}Copying AppImage file to dist.${NC}"
cp Jubler-*.appimage "$dist_dir/"
else
echo -e "${RED}Error:${NC} Could not find AppImage file for Jubler."
exit 1
fi
}
build_generic() {
echo -e "${GREEN}Building for Generic...${NC}"
cd "$script_dir"
mvn clean install -Pdist,generic
cd "$script_dir/modules/installer/target" || exit
if [ -e Jubler-*.tar.bz2 ]; then
echo -e "${GREEN}Copying TAR.BZ2 file to dist.${NC}"
cp Jubler-*.tar.bz2 "$dist_dir/"
else
echo -e "${RED}Error:${NC} Could not find TAR.BZ2 file for Jubler."
exit 1
fi
cd $script_dir
}
build_macos() {
echo -e "${GREEN}Building for MacOS...${NC}"
cd "$script_dir"
# Check if extra arguments are provided
NOTARIZE=$(if [[ $* == *"notarize"* ]]; then echo ",notarize"; else echo ""; fi)
NOSIGN=$(if [[ $* == *"nosign"* ]]; then echo ",nosign"; else echo ""; fi)
mvn clean install -Pdist,macos${NOTARIZE}${NOSIGN}
cd "$script_dir/modules/installer/target" || exit
if [ -e Jubler-*.dmg ]; then
echo -e "${GREEN}Copying DMG file to dist.${NC}"
cp Jubler-*.dmg "$dist_dir/"
else
if [ -e Jubler-*.zip ]; then
echo -e "${GREEN}Copying ZIP file to dist.${NC}"
cp Jubler-*.zip "$dist_dir/"
else
echo -e "${RED}Error:${NC} Could not find DMG or ZIP file for Jubler."
exit 1
fi
fi
}
clean_action() {
mvn clean
rm -rf "$dist_dir/"
}
check_headers() {
cd $script_dir/modules
for java_file in $(find . -name "*.java" | grep -v com/panayotis/jubler/subs/color/Quantize.java ) ; do
if ! grep -q 'SPDX-License-Identifier' "$java_file"; then
echo "${java_file}"
fi
done
}
build_action() {
# Check if targets are provided
if [ $# -lt 2 ]; then
echo -e "${RED}Error:${NC} Missing targets for 'build'. Provide one or more targets."
(IFS=,; echo -e "Valid build targets: ${valid_targets[*]}")
exit 1
fi
mkdir -p dist
targets=$2
IFS=',' read -ra target_array <<< "$targets"
for target in "${target_array[@]}"; do
case "$target" in
"windows")
build_windows "$@"
;;
"linux")
build_linux
;;
"generic")
build_generic
;;
"macos")
build_macos "$@"
;;
"all")
build_windows "$@"
build_macos "$@"
build_generic
build_linux
;;
*)
echo -e "${RED}Error:${NC} Unknown build target: $target"
(IFS=,; echo -e "Valid build targets: ${valid_targets[*]}")
exit 1
;;
esac
done
}
# Check if the script is called with an argument
if [ $# -eq 0 ]; then
echo -e "${RED}Error:${NC} Missing parameter. Use --help for information."
exit 1
fi
# Check the value of the first parameter
case "$1" in
"--help")
display_help
;;
"version")
version_action "$@"
;;
"build")
build_action "$@"
;;
"headers")
check_headers
;;
"clean")
clean_action
;;
*)
echo -e "${RED}Error:${NC} Unknown parameter. Use --help for information."
exit 1
;;
esac
exit 0