-
Notifications
You must be signed in to change notification settings - Fork 3
/
build
executable file
·426 lines (366 loc) · 15.6 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
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
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
#!/bin/bash
#Commandline argument
#build --robotframework-version=version --itrack-service==URL --config-file=repo_config_file
#
# import common bash scripts
#
. ./include/bash/common.sh
echo
echo -e "${COL_GREEN}####################################################################################${COL_RESET}"
echo -e "${COL_GREEN}# #${COL_RESET}"
echo -e "${COL_GREEN}# Compiling RobotFramework AIO setup... #${COL_RESET}"
echo -e "${COL_GREEN}# #${COL_RESET}"
echo -e "${COL_GREEN}####################################################################################${COL_RESET}"
# Load version information from versions.conf
source ./install/versions.conf
echo "VS Codium version $VERSION_VSCODIUM"
echo "Node.js version $VERSION_NODEJS"
echo "Android SDK Build Tool version $VERSION_BUILD_TOOL"
echo "Android SDK Platform Tool version $VERSION_PLATFORM_TOOL"
echo "Appium Inspector version $VERSION_APPIUM_INSPECTOR"
RobotFrameworkVersion=""
ITrackService="NONE"
UNAME=$(uname)
ConfigFile='./config/repositories/repositories.conf'
SubVersion=""
arguments=""
if [ "$#" -eq 0 ]; then
echo you can run the build with optional arguments
echo ./build --robotframework-version=version --itrack-service==URL --config-file=repo_config_file --sub-version=extended
echo version will be part of resulting installer executable and
echo will be displayed when setup is started at initial screeen.
echo repo_config_file contains the repository for building.
echo
else
for i in "$@"
do
case $i in
--robotframework-version=*)
RobotFrameworkVersion=`echo $i | sed 's/[-a-zA-Z0-9/]*=//'`
;;
--itrack-service=*)
ITrackService=`echo $i | sed 's/[-a-zA-Z0-9/]*=//'`
ITrackService=`echo $ITrackService | sed -e 's/\\\\/\//g'`
curl -s --head "$ITrackService" | head -n 1 | grep "HTTP/1.[01] [23].." > /dev/null
if [ "$?" -ne 0 ]; then
echo -e $COL_RED"ITrackService not available:"$COL_RESET $ITrackService
echo -e $COL_RED"build terminated."$COL_RESET
exit 1
fi
;;
--config-file=*)
ConfigFile="${i#*=}"
;;
--project-config-file=*)
ProjectConfigFile=`cygpath -wa "${i#*=}"`
;;
--sub-version=*)
SubVersion="${i#*=}"
;;
*)
echo -e $COL_RED"Argument not allowed:"$COL_RESET $i
echo -e $COL_RED"build terminated."$COL_RESET
exit 1
;;
esac
done
fi
if [ -f $ConfigFile ]; then
echo -e $COL_GREEN"ConfigFile = $ITrackService"$COL_RESET
else
errormsg "Repo configuration '$config_file' is not existing"
fi
if [ "$ITrackService" != "NONE" ]; then
echo -e $COL_GREEN"ITrackService = $ITrackService"$COL_RESET
arguments+="//DITrackService=$ITrackService "
fi
if [ "$RobotFrameworkVersion" == "" ]; then
if [[ "$TRIGGER_BY" =~ $TAG_REGEX || "$TRIGGER_BY" == "tag" ]] && [[ "$TAG_NAME" =~ $TAG_REGEX ]]; then
# Triggered by a TAG
RobotFrameworkVersion=`echo $TAG_NAME | sed -E -e "s/(rel|dev)\///g" | sed -E -e "s/aio\///g"`
elif [ -n "$REF_NAME" ]; then
if [ "$REF_NAME" == "$DEFAULT_REF" ]; then
# Triggered by a merged pull request branch
RobotFrameworkVersion=`echo merged_$REF_NAME | sed -e "s/\//-/g"`
elif [ -n "$REPOSITORY" ] && [ -n "$PULL_REQUEST_BRANCH" ]; then
# Triggered by other repository
RobotFrameworkVersion=`echo triggered_by_$REPOSITORY | sed -e "s/\//-/g"`
else
# Triggered by any branch manually
RobotFrameworkVersion=`echo dev_$REF_NAME | sed -e "s/\//-/g"`
fi
else
# Triggered on local
RobotFrameworkVersion="manual_build"
fi
fi
echo -e $COL_GREEN"RobotFrameworkVersion = $RobotFrameworkVersion"$COL_RESET
arguments+="//DRobotFrameworkVersion=$RobotFrameworkVersion "
echo
PackageFilenameLinux=RobotFramework_AIO_${RobotFrameworkVersion}-0_amd64.deb
if [ "$SubVersion" != "" ]; then
arguments+="//DSubVersion=$SubVersion "
PackageFilenameLinux=RobotFramework_AIO_${RobotFrameworkVersion}-0_amd64_$SubVersion.deb
fi
#read -n1 -r -p "Press space to continue..." key
echo -e "${COL_GREEN}####################################################################################${COL_RESET}"
echo -e "${COL_GREEN}# Installing/Updating libraries #${COL_RESET}"
echo -e "${COL_GREEN}####################################################################################${COL_RESET}"
CURDIR=$(pwd)
if [ "$UNAME" == "Linux" ] ; then
PYDIR=$(cd ../python39lx; pwd)
PYBIN=${PYDIR}/install/bin/python3
elif [[ "$UNAME" == CYGWIN* || "$UNAME" == MINGW* ]] ; then
PYDIR=$(cd ../python39; pwd -W)
PYBIN=${PYDIR}/python.exe
else
errormsg "Operation system '$UNAME' is not supported."
fi
cd $CURDIR
#
# import common bash scripts
#
. ./include/bash/common.sh
function get_server_url()
{
conf_file=$1
echo $(git config -f $conf_file --get supported-server.$2)
return
}
function install_texlive () {
CDIR=$(pwd)
mkdir -p download
cd download
# Try this if the mirror.foobar.to can't be download
if [ ! -f "install-tl-unx.tar.gz" ]; then
curl -L https://mirror.foobar.to/CTAN/systems/texlive/tlnet/install-tl-unx.tar.gz -o ./install-tl-unx.tar.gz
fi
zcat install-tl-unx.tar.gz | tar xf -
cd install-tl-20*
sudo perl ./install-tl --no-interaction
cd $CDIR
}
function check_and_install_texlive () {
if [ ! -z "$GENDOC_LATEXPATH" ]; then
return 0
fi
echo "install texlive"
# get last word of pdflatex version text
# If pdflatex exist
ver=`pdflatex -v | head -n 1 | awk 'NF>1{print $NF}'`
if [ ! -z "$ver" ]; then
release_year=${ver:0:4}
if [ $release_year -lt 2019 ]; then
if [ -f "/usr/local/texlive/$(date +%Y)/bin/x86_64-linux/pdflatex" ]; then
export GENDOC_LATEXPATH=/usr/local/texlive/$(date +%Y)/bin/x86_64-linux
return 0
fi
else
export PDFLATEXPATH=`which pdflatex`
export GENDOC_LATEXPATH=`dirname $PDFLATEXPATH`
return 0
fi
fi
install_texlive
export GENDOC_LATEXPATH="/usr/local/texlive/$(date +%Y)/bin/x86_64-linux"
}
function parse_repo () {
repo_type=$2
list_repo=($(git config -f $1 --list --name-only | grep "${repo_type}."))
for repo in "${list_repo[@]}"
do
reponame=${repo#${repo_type}.}
echo -e "$COL_BLUE$BG_WHITE---- $repo$COL_RESET$COL_BLUE$BG_WHITE -----------------------------------------$COL_RESET"
cd "../$reponame"
# if script is called without commandline paramteters,
# then print "git status", else handover command line parameters
# to git call
#using force option setup.py to overwrite old files
if [ -f "./setup.py" ]; then
PACKNAME=""
if grep -w setuptools ./setup.py | grep -w import; then
PACKNAME=$(${PYBIN} ./setup.py --name | tail -n 1)
if [[ -n "$PACKNAME" ]]; then
/usr/bin/yes | ${PYBIN} -m pip uninstall ${PACKNAME}
logresult "$?" "uninstalled ${PACKNAME}" "uninstall ${PACKNAME}"
fi
fi
${PYBIN} ./setup.py clean --all install
# Avoid build egg: ${PYBIN} -m pip install .
logresult "$?" "installed ${reponame}" "install ${reponame}"
fi
cd $CURDIR
done
}
function parse_config () {
echo "Using config file $1"
if [ ! -f "$1" ]; then
errormsg "File '$1' is not exist."
fi
echo "git config -f $1 --list --name-only | sed "s/.[^.]*$//" | uniq"
conf_section=($(git config -f $1 --list --name-only | sed "s/.[^.]*$//" | uniq))
#echo $conf_section
for section in "${conf_section[@]}"
do
section_server=$(get_server_url "$1" "$section")
echo "section server is $section_server"
if [ "$section_server" != "" ]; then
echo "Parsing $section"
parse_repo $1 $section
elif [ "$section" != "supported-server" ]; then
sec_name=$(git config -f "$1" --get ${section}.name);
if [ "$sec_name" == "" ]; then
sec_name=${section}
fi
echo -e "$COL_BLUE$BG_WHITE---- $sec_name$COL_RESET$COL_BLUE$BG_WHITE -----------------------------------------$COL_RESET"
sec_path=$(git config -f $1 --get ${section}.path);
if [ "$sec_path" == "" ]; then
sec_path="../${sec_name}"
fi
sec_prebuild=$(git config -f $1 --get ${section}.prebuild);
cd "$sec_path"
if [ "$sec_prebuild" != "" ]; then
$CURDIR/config/repositories/prebuild/$sec_prebuild
fi
if [ -f "./setup.py" ]; then
PACKNAME=""
if grep -w setuptools ./setup.py | grep -w import; then
PACKNAME=$(${PYBIN} ./setup.py --name | tail -n 1)
/usr/bin/yes | ${PYBIN} -m pip uninstall ${PACKNAME}
logresult "$?" "uninstalled ${PACKNAME}" "uninstall ${PACKNAME}"
fi
${PYBIN} ./setup.py install
${PYBIN} ./setup.py clean --all
logresult "$?" "installed ${sec_name}" "install ${sec_name}"
fi
fi
cd $CURDIR
done
}
add_line_to_file() {
echo "$1" >> version.txt
}
function generate_version_info() {
add_line_to_file "Installer version:"
add_line_to_file "******************"
add_line_to_file "RobotFramework AIO (${VARIANT}) ${RobotFrameworkVersion} (${SubVersion} core)"
add_line_to_file ""
add_line_to_file "Web sites:"
add_line_to_file "**********"
add_line_to_file "List of RobotFramework AIO components:"
add_line_to_file " https://htmlpreview.github.io/?https://github.com/test-fullautomation/robotframework-documentation/blob/develop/RobotFrameworkAIO/Components.html"
add_line_to_file ""
add_line_to_file "RobotFramework AIO project:"
add_line_to_file " https://github.com/test-fullautomation/RobotFramework_AIO"
add_line_to_file ""
add_line_to_file "Author:"
add_line_to_file "*******"
add_line_to_file "Thomas Pollerspöck <[email protected]>"
add_line_to_file ""
add_line_to_file "Other tools:"
add_line_to_file "************"
add_line_to_file " + VS Codium version: $VERSION_VSCODIUM"
add_line_to_file " + Node.js version: $VERSION_NODEJS"
add_line_to_file " + Android SDK Build Tool version: $VERSION_BUILD_TOOL"
add_line_to_file " + Android SDK Platform Tool version: $VERSION_PLATFORM_TOOL"
add_line_to_file " + Appium Inspector version: $VERSION_APPIUM_INSPECTOR"
}
function build_debian()
{
generate_version_info
check_and_install_texlive
create_testsuitmanagement_package_context_file
update_debian_control_file
parse_config $ConfigFile
cd $CURDIR
echo -e "${COL_GREEN}####################################################################################${COL_RESET}"
echo -e "${COL_GREEN}# Executing dpkg to create installer... #${COL_RESET}"
echo -e "${COL_GREEN}####################################################################################${COL_RESET}"
PACK_NAME=RobotFramework_AIO_${AIO_VERSION}
#first cleanup
rm -rf ./output_lx/${PACK_NAME}/
#now create package new
mkdir -p ./output_lx/${PACK_NAME}/opt/rfwaio/tools
mkdir -p ./output_lx/${PACK_NAME}/opt/rfwaio/linux
mkdir -p ./output_lx/${PACK_NAME}/opt/rfwaio/linux/icon
mkdir -p ./output_lx/${PACK_NAME}/usr/local/bin
mkdir -p ./output_lx/${PACK_NAME}/DEBIAN
# DEBIAN installation scripts
cp ./config/build/dpkg_build/control ./output_lx/${PACK_NAME}/DEBIAN
cp ./config/build/dpkg_build/preinst.sh ./output_lx/${PACK_NAME}/DEBIAN/preinst
chmod 755 ./output_lx/${PACK_NAME}/DEBIAN/preinst
cp ./config/build/dpkg_build/postinst.sh ./output_lx/${PACK_NAME}/DEBIAN/postinst
chmod 755 ./output_lx/${PACK_NAME}/DEBIAN/postinst
cp ./config/build/dpkg_build/prerm.sh ./output_lx/${PACK_NAME}/DEBIAN/prerm
chmod 755 ./output_lx/${PACK_NAME}/DEBIAN/prerm
# executable scripts and applications
cp ./config/build/dpkg_build/robot.ico ./output_lx/${PACK_NAME}/opt/rfwaio/linux/icon
cp ./config/build/dpkg_build/codium.png ./output_lx/${PACK_NAME}/opt/rfwaio/linux/icon
cp ./config/build/dpkg_build/appium.png ./output_lx/${PACK_NAME}/opt/rfwaio/linux/icon
cp ./config/build/dpkg_build/appium-inspector.png ./output_lx/${PACK_NAME}/opt/rfwaio/linux/icon
cp ./config/build/dpkg_build/robot.desktop ./output_lx/${PACK_NAME}/opt/rfwaio/linux/
cp ./config/build/dpkg_build/appium.desktop ./output_lx/${PACK_NAME}/opt/rfwaio/linux/
cp ./config/build/dpkg_build/appiumInspector.desktop ./output_lx/${PACK_NAME}/opt/rfwaio/linux/
cp ./config/build/dpkg_build/set_robotenv.sh ./output_lx/${PACK_NAME}/opt/rfwaio/linux/
chmod +x ./output_lx/${PACK_NAME}/opt/rfwaio/linux/set_robotenv.sh
#cp ./config/build/dpkg_build/install_dlt.sh ./output_lx/${PACK_NAME}/opt/rfwaio/linux/
cp ./config/build/dpkg_build/robot ./output_lx/${PACK_NAME}/usr/local/bin
chmod +x ./output_lx/${PACK_NAME}/usr/local/bin/robot
# Vscodium package and RobotTest workspace
cp -R -a ../robotvscode/. ./output_lx/${PACK_NAME}/opt/rfwaio/robotvscode
cp -R -a ./config/RobotTest/. ./output_lx/${PACK_NAME}/opt/rfwaio/robotvscode/RobotTest
cp ./install/install-github-copilot-exts.sh ./output_lx/${PACK_NAME}/opt/rfwaio/robotvscode/install-github-copilot-exts.sh
chmod +x ./output_lx/${PACK_NAME}/opt/rfwaio/robotvscode/install-github-copilot-exts.sh
# Tutorial and Documentation packages
mkdir -p ./output_lx/${PACK_NAME}/opt/rfwaio/tutorial
cp -R -a ../robotframework-tutorial/[0-9][0-9][0-9]_* ./output_lx/${PACK_NAME}/opt/rfwaio/tutorial/
mkdir -p ./output_lx/${PACK_NAME}/opt/rfwaio/documentation
cp ../robotframework-documentation/book/RobotFrameworkAIO_Reference*${SubVersion}.pdf ./output_lx/${PACK_NAME}/opt/rfwaio/documentation/
# Python package: core framework and libraries
cp -R -a ../python39lx/. ./output_lx/${PACK_NAME}/opt/rfwaio/python39
cp -R -a ./test/aio-analyzer ./output_lx/${PACK_NAME}/opt/rfwaio/tools/aio-analyzer
# Devtools: Android package
mkdir -p ./output_lx/${PACK_NAME}/opt/rfwaio/devtools
cp -R -a ../devtools/. ./output_lx/${PACK_NAME}/opt/rfwaio/devtools
chmod +x ./output_lx/${PACK_NAME}/opt/rfwaio/devtools/Appium-Inspector.AppImage
cp ./config/tools/appium.sh ./output_lx/${PACK_NAME}/opt/rfwaio/devtools/appium
chmod +x ./output_lx/${PACK_NAME}/opt/rfwaio/devtools/appium
# initial script to setup environment for multiple users
cp ./config/build/dpkg_build/postinst.sh ./output_lx/${PACK_NAME}/usr/local/bin/initRobotFrameworkAIO.sh
chmod +x ./output_lx/${PACK_NAME}/usr/local/bin/initRobotFrameworkAIO.sh
# Update version
cp ./version.txt ./output_lx/${PACK_NAME}/opt/rfwaio/
logresult "$?" "prepared package build" "prepare package build"
dpkg-deb --root-owner-group --build ./output_lx/${PACK_NAME} ./output_lx/${PackageFilenameLinux}
logresult "$?" "built deb package" "build deb package"
dpkg -I ./output_lx/${PackageFilenameLinux}
goodmsg "done."
}
function build_windows() {
# Add pandoc to PATH env
mypath=$(realpath $(dirname $0))
export PATH=$PATH:$mypath/../pandoc/pandoc-2.18
echo $PATH
# set $GENDOC_LATEXPATH var for building document
if [ -z "$GENDOC_LATEXPATH" ]; then
errormsg "Environment variable 'GENDOC_LATEXPATH' is not set."
fi
generate_version_info
create_testsuitmanagement_package_context_file
parse_config $ConfigFile
cd $CURDIR
echo -e "${COL_GREEN}####################################################################################${COL_RESET}"
echo -e "${COL_GREEN}# Executing InnoSetup to create installer... #${COL_RESET}"
echo -e "${COL_GREEN}####################################################################################${COL_RESET}"
./scripts/precompile.bat $ProjectConfigFile
./tools/InnoSetup5.5.1/ISCC ${arguments} ./scripts/RobotFrameworkSetup.iss
logresult "$?" "built RobotFramework AIO installer" "build RobotFramework AIO installer"
./scripts/postcompile.bat
}
if [ "$UNAME" == "Linux" ] ; then
build_debian
elif [[ "$UNAME" == CYGWIN* || "$UNAME" == MINGW* ]] ; then
build_windows
else
errormsg "Operation system '$UNAME' is not supported."
fi