forked from eMoflon/emoflon-ibex-eclipse-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·310 lines (267 loc) · 9.84 KB
/
build.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
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
#!/bin/bash
set -e
# Parse arguments
if [[ -z "$1" ]]; then
echo "=> No parameter(s) given. Exit."; exit 1 ;
fi
while [[ "$#" -gt 0 ]]; do
case $1 in
-m|--mode) MODE="$2"; shift ;;
-o|--os) OS="$2"; shift ;;
--skip-theme) SKIP_THEME=1 ;;
*) echo "=> Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done
# Check for existing ENVs
if [[ -z "$VERSION" ]]; then
echo "=> No version ENV found. Exit."; exit 1 ;
fi
#
# Config and URLs
#
VERSION=$VERSION # version comes from the CI env
ARCHIVE_FILE_LINUX="eclipse-dsl-$VERSION-R-linux-gtk-x86_64.tar.gz"
ARCHIVE_FILE_WINDOWS="eclipse-dsl-$VERSION-R-win32-x86_64.zip"
ARCHIVE_FILE_MACOS="eclipse-dsl-$VERSION-R-macosx-cocoa-x86_64.dmg"
OUTPUT_FILE_PREFIX_LINUX="eclipse-emoflon-linux"
OUTPUT_FILE_PREFIX_WINDOWS="eclipse-emoflon-windows"
OUTOUT_FILE_PREFIX_MACOS="eclipse-emoflon-macos"
MIRROR="https://ftp.fau.de"
UPDATESITES="https://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/,https://hallvard.github.io/plantuml/,https://www.kermeta.org/k2/update,https://www.genuitec.com/updates/devstyle/ci/,https://download.eclipse.org/releases/$VERSION,https://www.codetogether.com/updates/ci/,http://update.eclemma.org/,https://pmd.github.io/pmd-eclipse-plugin-p2-site/,https://checkstyle.org/eclipse-cs-update-site/,https://spotbugs.github.io/eclipse/,https://emoflon.org/emoflon-neo-updatesite/snapshot/"
EMOFLON_HEADLESS_SRC="https://api.github.com/repos/eMoflon/emoflon-headless/releases/latest"
# Import plug-in:
IMPORT_PLUGIN_VERSION="2.0.0"
IMPORT_PLUGIN_FILENAME="com.seeq.eclipse.importprojects_$IMPORT_PLUGIN_VERSION.jar"
IMPORT_PLUGIN_SRC="https://api.github.com/repos/maxkratz/eclipse-import-projects-plugin/releases/tags/v$IMPORT_PLUGIN_VERSION"
# Array with the order to install the plugins with.
ORDER_LINUX=("xtext" "plantuml" "kermeta" "misc" "emoflon-headless" "emoflon" "theme" "additional")
#
# Configure OS specific details
#
if [[ "$OS" = "linux" ]]; then
ARCHIVE_FILE=$ARCHIVE_FILE_LINUX
OUTPUT_FILE_PREFIX=$OUTPUT_FILE_PREFIX_LINUX
ORDER=("${ORDER_LINUX[@]}")
ECLIPSE_BIN_PATH="./eclipse/eclipse"
ECLIPSE_BASE_PATH="./eclipse"
elif [[ "$OS" = "windows" ]]; then
ARCHIVE_FILE=$ARCHIVE_FILE_WINDOWS
OUTPUT_FILE_PREFIX=$OUTPUT_FILE_PREFIX_WINDOWS
# Windows now uses the linux install order too
ORDER=("${ORDER_LINUX[@]}")
ECLIPSE_BIN_PATH="./eclipse/eclipsec.exe"
ECLIPSE_BASE_PATH="./eclipse"
elif [[ "$OS" = "macos" ]]; then
ARCHIVE_FILE=$ARCHIVE_FILE_MACOS
OUTPUT_FILE_PREFIX=$OUTOUT_FILE_PREFIX_MACOS
# Lets try with linux install order
ORDER=("${ORDER_LINUX[@]}")
ECLIPSE_BIN_PATH="./eclipse/Eclipse.app/Contents/MacOS/eclipse"
ECLIPSE_BASE_PATH="./eclipse/Eclipse.app/Contents/Eclipse"
else
echo "=> OS $OS not known."
exit 1
fi
#
# Utils
#
# Parses a given list and returns the packages as String (comma separated).
parse_package_list () {
OUTPUT=""
while IFS= read -r line
do
OUTPUT+=$line","
done < "$1"
echo "$OUTPUT"
}
# Installs a given list of packages from a given update site.
install_packages () {
if [[ "$OS" = "macos" ]]; then
chmod +x $ECLIPSE_BIN_PATH
fi
set -o pipefail
$ECLIPSE_BIN_PATH -nosplash \
-application org.eclipse.equinox.p2.director \
-repository "$1" \
-installIU "$(parse_package_list $2)" \
| grep -v 'DEBUG'
set +o pipefail
}
# Uninstalls a given list of packages.
uninstall_packages () {
if [[ "$OS" = "macos" ]]; then
chmod +x $ECLIPSE_BIN_PATH
fi
set -o pipefail
$ECLIPSE_BIN_PATH -nosplash \
-application org.eclipse.equinox.p2.director \
-repository "$1" \
-uninstallIU "$(parse_package_list $2)" \
| grep -v 'DEBUG'
set +o pipefail
}
# Displays the given input including "=> " on the console.
log () {
echo "=> $1"
}
# Setup the local updatesite of the emoflon headless
setup_emoflon_headless_local_updatesite () {
log "Get emoflon-headless and extract its updatesite."
if [[ ! -f "./tmp/emoflon-headless/updatesite.zip" ]]; then
log "Create local tmp folder."
rm -rf ./tmp && mkdir -p ./tmp/emoflon-headless
log "emoflon-headless ZIP not found"
CURL_RET=$(curl -s $EMOFLON_HEADLESS_SRC)
log "curl: $CURL_RET"
EMOFLON_HEADLESS_LATEST_UPDATESITE=$(echo "$CURL_RET" \
| grep "updatesite.*zip" \
| cut -d : -f 2,3 \
| tr -d \")
if [[ -z "${EMOFLON_HEADLESS_LATEST_UPDATESITE// }" ]]; then
log "This runner propably reached it's Github API rate limit. Exit."
exit 1
fi
log "Using updatesite URL $(echo $EMOFLON_HEADLESS_LATEST_UPDATESITE \
| grep "/updatesite.*zip" \
| sed 's/^[ \t]*//;s/[ \t]*$//')."
wget -P ./tmp/emoflon-headless -qi $EMOFLON_HEADLESS_LATEST_UPDATESITE
fi
unzip ./tmp/emoflon-headless/updatesite.zip -d tmp/emoflon-headless
# Append local folder to path (has to be absolute and, therefore, dynamic)
if [[ ! -z ${GITHUB_WORKSPACE} ]] && [[ "$OS" = "windows" ]]; then
log "Using a Github-hosted runner on Windows."
UPDATESITES+=",file:/D:/a/emoflon-neo-eclipse-build/emoflon-neo-eclipse-build/tmp/emoflon-headless/"
elif [[ "$OS" = "linux" ]]; then
log "Using a runner on Linux."
UPDATESITES+=",file://$PWD/tmp/emoflon-headless/"
elif [[ "$OS" = "windows" ]]; then
log "Using a runner on Windows."
UPDATESITES+=",file://$(echo $PWD | sed -e 's/\/mnt\///g' | sed -e 's/^\///' -e 's/\//\\/g' -e 's/^./\0:/')\tmp\emoflon-headless\\"
elif [[ "$OS" = "macos" ]]; then
log "Using a runner on macOS."
UPDATESITES+=",file://$PWD/tmp/emoflon-headless/"
fi
}
# Install eclipse import projects plug-in
install_eclipse_import_projects () {
log "Install Eclipse import projects plug-in."
# Check if plugin JAR file is present at current location
if [[ -f "com.seeq.eclipse.importprojects.jar" ]]; then
log "Found local file of eclipse import plugin."
mv ./com.seeq.eclipse.importprojects.jar $ECLIPSE_BASE_PATH/plugins
else
log "Download JAR file from Github API."
IMPORT_PROJECTS_JAR=$(curl -s $IMPORT_PLUGIN_SRC \
| grep "$IMPORT_PLUGIN_FILENAME" \
| cut -d : -f 2,3 \
| tr -d \")
wget -P $ECLIPSE_BASE_PATH/plugins -qi $IMPORT_PROJECTS_JAR
fi
}
# Install custom global configuration
install_global_eclipse_settings () {
log "Install global Eclipse settings."
if [[ "$MODE" = "user" ]]; then
cp ./resources/emoflon_user.properties $ECLIPSE_BASE_PATH/emoflon.properties
elif [[ "$MODE" = "dev" ]] || [[ "$MODE" = "hipedev" ]]; then
cp ./resources/emoflon_dev.properties $ECLIPSE_BASE_PATH/emoflon.properties
else
log "Mode argument invalid."; exit 1 ;
fi
echo "-Declipse.pluginCustomization=emoflon.properties" >> $ECLIPSE_BASE_PATH/eclipse.ini
}
# Remove all configured update sites
remove_update_sites () {
log "Remove all update sites."
UPDATE_SITE_CONFIG_PATH="$ECLIPSE_BASE_PATH/p2/org.eclipse.equinox.p2.engine/profileRegistry/epp.package.dsl.profile/.data/.settings"
UPDATE_SITE_METADATA="org.eclipse.equinox.p2.metadata.repository.prefs"
UPDATE_SITE_ARTIFACT="org.eclipse.equinox.p2.artifact.repository.prefs"
# First, create a ZIP as "backup"
zip -q -r $UPDATE_SITE_CONFIG_PATH/update-sites.zip $UPDATE_SITE_CONFIG_PATH/$UPDATE_SITE_ARTIFACT $UPDATE_SITE_CONFIG_PATH/$UPDATE_SITE_METADATA
rm -rf $UPDATE_SITE_CONFIG_PATH/$UPDATE_SITE_ARTIFACT
rm -rf $UPDATE_SITE_CONFIG_PATH/$UPDATE_SITE_METADATA
}
#
# Script
#
# Check if script needs to download the initial Eclipse archive.
if [[ ! -f "./$ARCHIVE_FILE" ]]; then
log "Downloading Eclipse $VERSION archive from $MIRROR."
wget -q $MIRROR/eclipse/technology/epp/downloads/release/$VERSION/R/$ARCHIVE_FILE
fi
if [[ "$MODE" = "user" ]]; then
INSTALL_EMOFLON=1
OUTPUT_FILE="$OUTPUT_FILE_PREFIX-user.zip"
elif [[ "$MODE" = "dev" ]]; then
INSTALL_EMOFLON=0
OUTPUT_FILE="$OUTPUT_FILE_PREFIX-dev.zip"
elif [[ "$MODE" = "hipedev" ]]; then
INSTALL_EMOFLON=0
SKIP_HIPE=1
OUTPUT_FILE="$OUTPUT_FILE_PREFIX-dev-hipe.zip"
else
log "Mode argument invalid."; exit 1 ;
fi
# Setup the emoflon headless (special snowflake because of the zipped update site)
setup_emoflon_headless_local_updatesite
# Extract new Eclipse
log "Clean-up Eclipse folder and extract downloaded archive."
rm -rf ./eclipse/*
if [[ "$OS" = "linux" ]]; then
tar -xzf $ARCHIVE_FILE_LINUX
elif [[ "$OS" = "windows" ]]; then
unzip -qq -o $ARCHIVE_FILE_WINDOWS
elif [[ "$OS" = "macos" ]]; then
7z x $ARCHIVE_FILE_MACOS
# Rename folder because "Eclipse" is inconsistent
mv Eclipse eclipse
fi
# Install global Eclipse settings from config file
install_global_eclipse_settings
log "Install Eclipse plug-ins."
for p in ${ORDER[@]}; do
# Check if eMoflon packages must be skipped (for dev builds).
if [[ "$p" = "emoflon" ]] && [[ $INSTALL_EMOFLON -eq 0 ]]; then
log "Skipping plug-in: $p."
continue
fi
# Check if Dark Theme packages must be skipped (for CI builds = completely headless).
if [[ "$p" = "theme" ]] && [[ $SKIP_THEME -eq 1 ]]; then
log "Skipping plug-in: $p."
continue
fi
# Check if additional packages must be skipped (for CI builds).
if [[ "$p" = "additional" ]] && [[ $SKIP_THEME -eq 1 ]]; then
log "Skipping additional plug-ins."
continue
fi
# Check if HiPE must be skipped (for hipe-dev builds).
if [[ "$p" = "hipe" ]] && [[ $SKIP_HIPE -eq 1 ]]; then
log "Skipping plug-in: $p."
continue
fi
# Check if Xtext (old version) must be uninstalled first.
if [[ "$p" = "xtext" ]]; then
log "Uninstalling plug-in: $p."
uninstall_packages "$UPDATESITES" "./packages/$p-uninstall-packages.list"
fi
log "Installing plug-in: $p."
install_packages "$UPDATESITES" "./packages/$p-packages.list"
done
# Install com.seeq.eclipse.importprojects (by hand because there is no public update site)
install_eclipse_import_projects
# Remove all configured update sites
remove_update_sites
# Deploy custom splash image
if [[ $SKIP_THEME -eq 1 ]]; then
# Skip UI customization for CI builds
log "Skipping custom splash image."
else
log "Deploy custom splash image."
chmod +x splash.sh && ./splash.sh deploy $VERSION $ECLIPSE_BASE_PATH
fi
log "Clean-up old archives and create new archive."
rm -f ./$OUTPUT_FILE
zip -q -r $OUTPUT_FILE eclipse
log "Build finished."