-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinst.py
executable file
·550 lines (463 loc) · 26.3 KB
/
inst.py
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
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
#!/usr/bin/env python2
import os
import hashlib
import shutil
import re
import argparse
import subprocess
microideVersion = '0.3.3'
armGccToolchain_old_gcc5 = {
'filename' : 'gcc-arm-none-eabi-5_3-2016q1-20160330-linux.tar.bz2',
'size' : '0',
'version' : '6.2.0',
'url' : 'https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q1-update/+download/gcc-arm-none-eabi-5_3-2016q1-20160330-linux.tar.bz2',
'checksum' : {'md5' : '5a261cac18c62d8b7e8c70beba2004bd'},
'licenseUrl' : 'https://launchpadlibrarian.net/251686212/license.txt',
'installationLocation' : 'microideDir/toolchains/gcc-arm-none-eabi/microhal'
}
armGccToolchain_6_2016_q2 = {
'filename' : 'gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2',
'size' : '0',
'version' : '6.2.0',
'url' : 'https://developer.arm.com/-/media/Files/downloads/gnu-rm/6-2017q2/gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2?revision=2cc92fb5-3e0e-402d-9197-bdfc8224d8a5?product=GNU%20Arm%20Embedded%20Toolchain,64-bit,,Linux,6-2017-q2-update',
'checksum' : {'md5' : '13747255194398ee08b3ba42e40e9465'},
'licenseUrl' : 'https://developer.arm.com/GetEula?Id=2d916619-954e-4adb-895d-b1ec657ae305',
'installationLocation' : 'microideDir/toolchains/gcc-arm-none-eabi/microhal'
}
armGccToolchain_7_2017_q4 = {
'filename' : 'gcc-arm-none-eabi-7-2017-q4-major-linux.tar.bz2',
'size' : '0',
'version' : '7.2.0',
'url' : 'https://developer.arm.com/-/media/Files/downloads/gnu-rm/7-2017q4/gcc-arm-none-eabi-7-2017-q4-major-linux.tar.bz2?revision=375265d4-e9b5-41c8-bf23-56cbe927e156?product=GNU%20Arm%20Embedded%20Toolchain,64-bit,,Linux,7-2017-q4-major',
'checksum' : {'md5' : 'd3b00ae09e847747ef11316a8b04989a'},
'licenseUrl' : 'https://developer.arm.com/GetEula?Id=b8689563-35c9-4da7-b0cf-9c21f422343c',
'installationLocation' : 'microideDir/toolchains/gcc-arm-none-eabi/microhal'
}
openOCD = {
'filename' : 'openocd-0.10.0.tar.gz',
'size' : '0',
'version' : '0.10.0',
'url' : 'https://sourceforge.net/projects/openocd/files/openocd/0.10.0/openocd-0.10.0.tar.gz/download',
'checksum' : {'md5' : '8971d16aee5c2642b33ee55fc6c86239'},
'installationLocation' : 'tools/openocd/0.10.0'
}
eclipse = {
'filename' : 'eclipse-inst-linux64.tar.gz',
'size' : '0',
'version' : 'oxygen',
'url' : 'http://www.eclipse.org/downloads/download.php?file=/oomph/products/latest/eclipse-inst-linux64.tar.gz\&r=1',
'checksum' : {'' : ''},
'installationLocation' : 'eclipse'
}
# ------------------------------------- windows version
winArmGccToolchain_7_2017_q4 = {
'filename' : 'gcc-arm-none-eabi-7-2017-q4-major-win32.exe',
'size' : '0',
'version' : '7.2.0',
'url' : 'https://developer.arm.com/-/media/Files/downloads/gnu-rm/7-2017q4/gcc-arm-none-eabi-7-2017-q4-major-win32.exe?revision=732bae94-c929-403d-9520-0b2bccd81ad7?product=GNU%20Arm%20Embedded%20Toolchain,32-bit,,Windows,7-2017-q4-major',
'checksum' : {'md5' : 'bb4def39ff1cb3ff5d2931597d9aea4e'},
'licenseUrl' : 'https://developer.arm.com/GetEula?Id=b8689563-35c9-4da7-b0cf-9c21f422343c',
'installationLocation' : '{app}\\toolchains\\gcc-arm-none-eabi\\microhal'
}
winArmGccToolchain_5_3_2016 = {
'filename' : 'gcc-arm-none-eabi-5_3-2016q1-20160330-win32.exe',
'size' : '0',
'version' : '5.3.0',
'url' : 'https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q1-update/+download/gcc-arm-none-eabi-5_3-2016q1-20160330-win32.exe',
'checksum' : {'' : ''},
'licenseUrl' : 'https://launchpadlibrarian.net/251686212/license.txt',
'installationLocation' : '{app}\\toolchains\\gcc-arm-none-eabi\\microhal'
}
winClangToolchain_3_8_0 = {
'filename' : 'LLVM-3.8.0-win64.exe',
'size' : '0',
'version' : '3.8.0',
'url' : 'http://llvm.org/releases/3.8.0/LLVM-3.8.0-win64.exe',
'checksum' : {'' : ''},
'licenseUrl' : 'https://launchpadlibrarian.net/251686212/license.txt',
'installationLocation' : '{app}\\toolchains\\LLVM\\3.8.0'
}
winClangToolchain_6_0_0 = {
'filename' : 'LLVM-6.0.0-win64.exe',
'size' : '0',
'version' : '6.0.0',
'url' : 'http://releases.llvm.org/6.0.0/LLVM-6.0.0-win64.exe',
'checksum' : {'' : ''},
'licenseUrl' : 'https://launchpadlibrarian.net/251686212/license.txt',
'installationLocation' : '{app}\\toolchains\\LLVM\\6.0.0'
}
winMinGwToolchain_7_1_0 = {
'filename' : 'x86_64-7.1.0-release-win32-seh-rt_v5-rev2.7z',
'size' : '0',
'version' : '7.1.0',
'url' : 'https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/7.1.0/threads-win32/seh/x86_64-7.1.0-release-win32-seh-rt_v5-rev2.7z',
'checksum' : {'md5' : 'bd537f46793fc11b7b161f071e9ef31e'},
'licenseUrl' : 'http://sourceforge.net/projects/mingw-w64/',
'installationLocation' : '{app}\\toolchains\\mingw-w64'
}
winMinGwToolchain_7_3_0 = {
'filename' : 'x86_64-7.3.0-release-posix-seh-rt_v5-rev0.7z',
'size' : '0',
'version' : '7.3.0',
'url' : 'https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/7.3.0/threads-posix/seh/x86_64-7.3.0-release-posix-seh-rt_v5-rev0.7z',
'checksum' : {'md5' : '7240f9d64a06e2c71141380a6db0cf64'},
'licenseUrl' : 'http://sourceforge.net/projects/mingw-w64/',
'installationLocation' : '{app}\\toolchains\\mingw-w64'
}
winOpenOCD = {
'filename' : 'openocd-0.10.0.7z',
'size' : '0',
'version' : '0.10.0',
'url' : 'http://www.freddiechopin.info/en/download/category/4-openocd?download=154%3Aopenocd-0.10.0',
'checksum' : {'SHA256' : 'f46687cd783a7a86716c78474e8132e32de84b773914f23f2226f81509ffcfca'},
'installationLocation' : "{app}\\tools\\openocd\\0.10.0"
}
winDoxygen = {
'filename' : 'doxygen-1.8.13-setup.exe',
'size' : '0',
'version' : '1.8.13',
'url' : 'http://ftp.stack.nl/pub/users/dimitri/doxygen-1.8.13-setup.exe',
'checksum' : {'' : ''},
'licenseUrl' : 'http://www.stack.nl/~dimitri/doxygen/index.html',
'installationLocation' : "{app}\\tools\\doxygen\\1.8.13"
}
winEclipse = {
'filename' : 'eclipse-inst-win64.exe',
'size' : '0',
'version' : 'oxygen',
'url' : 'http://www.eclipse.org/downloads/download.php?file=/oomph/products/latest/eclipse-inst-win64.exe\&r=1',
'checksum' : {'' : ''},
'installationLocation' : 'eclipse'
}
winCppcheck = {
'filename' : 'cppcheck-1.83-x64-Setup.msi',
'size' : '0',
'version' : '1.83',
'url' : 'https://github.com/danmar/cppcheck/releases/download/1.83/cppcheck-1.83-x64-Setup.msi',
'checksum' : {'' : ''},
'licenseUrl' : 'https://github.com/danmar/cppcheck/blob/master/COPYING',
'installationLocation' : '{app}\\tools\\cppcheck\\1.83'
}
#------------------------------------ files required to prepare installer
innosetup = {
'filename' : 'is.exe',
'url' : 'http://www.jrsoftware.org/download.php/is.exe',
'checksum' : {'' : ''},
}
armGccToolchain = armGccToolchain_7_2017_q4
winArmGccToolchain = winArmGccToolchain_7_2017_q4
winClangToolchain = winClangToolchain_6_0_0
winMinGwToolchain = winMinGwToolchain_7_3_0
linuxFiles = [armGccToolchain, openOCD, eclipse]
windowsFiles = [winArmGccToolchain, winClangToolchain, winOpenOCD, winDoxygen, winEclipse, winCppcheck, winMinGwToolchain]
allFiles = linuxFiles + windowsFiles
# ------------------------------------ end of file declaration
def download(destynation, filename, url, checksum):
if destynation:
destynation = destynation + "/"
parameters = "wget -O ./" + destynation + filename + ' ' + url
os.system(parameters + " >> output.log")
if checksum.has_key('md5') == True:
if hashlib.md5(open('./' + destynation + filename,'rb').read()).hexdigest() != checksum['md5']:
return [False, 0]
if checksum.has_key('SHA512') == True:
if hashlib.sha512(open('./' + destynation + filename,'rb').read()).hexdigest() != checksum['SHA512']:
return [False, 0]
if checksum.has_key('SHA256') == True:
if hashlib.sha256(open('./' + destynation + filename,'rb').read()).hexdigest() != checksum['SHA256']:
return [False, 0]
return [True, os.stat('./' + destynation + filename).st_size]
def generateLinuxProductSetup():
with open('templates/microide.product.setup.template', 'r') as file:
content = file.read()
# toolchainPatch = armGccToolchain['installationLocation'] + '/' + re.sub('-\d{8}-linux.tar.bz2', '', armGccToolchain['filename']) // for gcc 5
toolchainPatch = armGccToolchain['installationLocation'] + '/' + re.sub('-.{5,6}-linux\.tar\.bz2', '', armGccToolchain['filename'])
content = content.replace("##microideToolchainPatch##", toolchainPatch)
content = content.replace("##clangFormatLocation##", "${binaryDir/clang-format-5.0|file}")
content = content.replace("##clangToolchainPatch##", "${binaryDir|file}")
# content = content.replace("##MinGWToolchainPatch##", "${binaryDir}")
content = content.replace("##DoxygenPatch##", "${binaryDir|file}")
with open('eclipse-installer/microideLocalSetups/microide.product.setup.linux', 'w') as file:
file.write(content)
def generateWindowsProductSetup():
with open('templates/microide.product.setup.template', 'r') as file:
content = file.read()
toolchainPatch = winArmGccToolchain['installationLocation'].replace('{app}', 'microideDir') + '/' + re.sub('-.{5,6}-win32\.exe', '', winArmGccToolchain['filename'])
content = content.replace("##microideToolchainPatch##", toolchainPatch.replace('\\', '/'))
clangPath = winClangToolchain['installationLocation']
clangPath = clangPath.replace('{app}', '${microideDir') + '/bin|file}'
clangFormatLocation = clangPath + '/clang-format.exe'
content = content.replace("##clangFormatLocation##", clangFormatLocation.replace('\\', '/' ))
content = content.replace("##clangToolchainPatch##", clangPath.replace('\\', '/' ))
mingwPath = winMinGwToolchain['installationLocation'] + '\\' + winMinGwToolchain['version']
mingwPath = mingwPath.replace('{app}', '${microideDir') + '|file}'
content = content.replace("##MinGWToolchainPatch##", mingwPath.replace('\\', '/' ))
doxygenPath = winDoxygen['installationLocation']
doxygenPath = doxygenPath.replace('{app}', '${microideDir') + '/bin|file}'
content = content.replace("##DoxygenPatch##", doxygenPath.replace('\\', '/' ))
with open('eclipse-installer/microideLocalSetups/microide.product.setup.windows', 'w') as file:
file.write(content)
def generateLinuxInstaller():
with open('templates/microide_install.template', 'r') as file:
content = file.read()
text = 'VERSION=' + microideVersion + '\n'
text = text + 'ARM_GCC_TOOLCHAIN_URL=' + armGccToolchain['url'] + '\n'
text = text + 'ARM_GCC_TOOLCHAIN_LICENSE_URL=' + armGccToolchain['licenseUrl'] + '\n'
text = text + 'ARM_GCC_TOOLCHAIN_FILENAME=' + armGccToolchain['filename'] + '\n'
text = text + 'ARM_GCC_TOOLCHAIN_VERSION=' + armGccToolchain['version'] + '\n'
text = text + 'ARM_GCC_TOOLCHAIN_SIZE=' + str(armGccToolchain['size']) + '\n'
text = text + 'ARM_GCC_TOOLCHAIN_CHECKSUM=' + armGccToolchain['checksum']['md5'] + '\n'
text = text + 'ARM_GCC_TOOLCHAIN_LOCATION=' + armGccToolchain['installationLocation'].replace('microideDir/', '')
text = text + '\n\nOPENOCD_URL=' + openOCD['url']
text = text + '\nOPENOCD_FILENAME=' + openOCD['filename']
text = text + '\nOPENOCD_VERSION=' + openOCD['version']
text = text + '\nOPENOCD_SIZE=' + str(openOCD['size'])
text = text + '\nOPENOCD_CHECKSUM=' + openOCD['checksum']['md5']
text = text + '\nOPENOCD_LOCATION=' + openOCD['installationLocation']
text = text + '\n\nECLIPSE_URL=' + eclipse['url'] + '\nECLIPSE_FILENAME=' + eclipse['filename'] + '\nECLIPSE_VERSION=' + eclipse['version'] + '\nECLIPSE_SIZE=' + str(eclipse['size']) + '\nECLIPSE_CHECKSUM=' + eclipse['checksum']['md5'] + '\nECLIPSE_LOCATION=' + eclipse['installationLocation']
content = content.replace("#replace this text with instalation files information", text)
with open('linux/microide_install_linux.sh', 'w') as file:
file.write(content)
def recursiveRemoveNotListedFiles(directory, filesToPath):
for root, subdirs, files in os.walk(directory, topdown=False):
for filename in files:
file_path = os.path.join(root, filename)
# print('\t- file %s (full path: %s)' % (filename, file_path))
if filename not in filesToPath:
os.remove(file_path)
for subdir in subdirs:
#print('\t- subdirectory ' + subdir)
if os.path.isdir(subdir):
if not os.listdir(subdir):
os.rmdir(subdir)
if not os.listdir(root):
os.rmdir(root)
def replaceRecursive(destination, sourcefiledir, sourcefilename):
replaceCounter = 0
for root, subdirs, files in os.walk(destination):
for filename in files:
file_path = os.path.join(root, filename)
if filename == sourcefilename:
shutil.copy(sourcefiledir + "/" + sourcefilename, file_path)
replaceCounter = replaceCounter + 1
print "Replaced " + str(replaceCounter) + " files"
def verifyWindowsDownloads(destdir):
destdir = destdir + '/windows'
if not os.path.exists(destdir):
os.makedirs(destdir)
files = windowsFiles
for file in files:
status = download(destdir, file['filename'], file['url'], file['checksum'])
if status[0] == False:
print "An error occurred"
exit(-1)
def verifyLinuxDownloads(destdir):
destdir = destdir + '/linux'
if not os.path.exists(destdir):
os.makedirs(destdir)
files = linuxFiles
for file in files:
status = download(destdir, file['filename'], file['url'], file['checksum'])
if status[0] == False:
print "An error occurred"
exit(-1)
def getFiles(destdir):
verifyLinuxDownloads(destdir)
verifyWindowsDownloads(destdir)
def fileExists(path):
try:
st = os.stat(path)
except os.error:
return False
return True
# this function will return path to first file with name passed as a parameter
def findFile(directory, filename):
for root, subdirs, files in os.walk(directory, topdown=False):
for file in files:
file_path = os.path.join(root, filename)
# print('\t- file %s (full path: %s)' % (filename, file_path))
if file == filename:
return file_path
return ''
def mergeFiles(fileA, fileB):
subprocess.check_call(["meld", fileA, fileB])
#this function will update:
# - file size
# - MD5 checksum
def updateFileinfo(destdir, files):
if destdir:
destdir = destdir + "/"
for file in files:
filePath = './' + destdir + file['filename']
if fileExists(filePath):
file['size'] = os.stat(filePath).st_size
if file['checksum'].has_key('md5') == False:
file['checksum']['md5'] = hashlib.md5(open(filePath,'rb').read()).hexdigest()
else:
print "An error occurred, while updating file info: " + filePath
exit(-1)
def getMissingFiles(destdir, files):
if not os.path.exists(destdir):
os.makedirs(destdir)
if destdir:
destdir = destdir + "/"
for file in files:
filePath = './' + destdir + file['filename']
if fileExists(filePath) == False:
download(destdir, file['filename'], file['url'], file['checksum'])
else:
print "File exist, no need to download: " + filePath
def generateInnoSetupFile():
with open('templates/microide.iss.template', 'r') as file:
content = file.read()
text = '#define AppVersion "' + microideVersion + '"\n\n'
text = text + '#define ARM_GCC_TOOLCHAIN_URL "' + winArmGccToolchain['url'] + '"\n'
text = text + '#define ARM_GCC_TOOLCHAIN_LICENSE_URL "' + winArmGccToolchain['licenseUrl'] + '"\n'
text = text + '#define ARM_GCC_TOOLCHAIN_FILENAME "' + winArmGccToolchain['filename'] + '"\n'
text = text + '#define ARM_GCC_TOOLCHAIN_VERSION "' + winArmGccToolchain['version'] + '"\n'
text = text + '#define ARM_GCC_TOOLCHAIN_SIZE ' + str(winArmGccToolchain['size']) + '\n'
text = text + '#define ARM_GCC_TOOLCHAIN_LOCATION "' + winArmGccToolchain['installationLocation'] + '\\' + re.sub('-.{5,6}-win32\.exe', '', winArmGccToolchain['filename']) + '"\n'
text = text + '#define CLANG_TOOLCHAIN_URL "' + winClangToolchain['url'] + '"\n'
text = text + '#define CLANG_TOOLCHAIN_FILENAME "' + winClangToolchain['filename'] + '"\n'
text = text + '#define CLANG_TOOLCHAIN_VERSION "' + winClangToolchain['version'] + '"\n'
text = text + '#define CLANG_TOOLCHAIN_SIZE ' + str(winClangToolchain['size']) + '\n'
text = text + '#define CLANG_TOOLCHAIN_LOCATION "' + winClangToolchain['installationLocation'] + '"\n'
text = text + '#define OPENOCD_URL "' + winOpenOCD['url'] + '"\n'
text = text + '#define OPENOCD_FILENAME "' + winOpenOCD['filename'] +'"\n'
text = text + '#define OPENOCD_VERSION "' + winOpenOCD['version'] + '"\n'
text = text + '#define OPENOCD_SIZE ' + str(winOpenOCD['size']) + '\n'
text = text + '#define OPENOCD_LOCATION "' + winOpenOCD['installationLocation'] + '"\n'
text = text + '#define DOXYGEN_URL "' + winDoxygen['url'] + '"\n'
text = text + '#define DOXYGEN_LICENSE_URL "' + winDoxygen['licenseUrl'] + '"\n'
text = text + '#define DOXYGEN_FILENAME "' + winDoxygen['filename'] +'"\n'
text = text + '#define DOXYGEN_VERSION "' + winDoxygen['version'] + '"\n'
text = text + '#define DOXYGEN_SIZE ' + str(winDoxygen['size']) + '\n'
text = text + '#define DOXYGEN_LOCATION "' + winDoxygen['installationLocation'] + '"\n'
text = text + '#define MINGW_URL "' + winMinGwToolchain['url'] + '"\n'
text = text + '#define MINGW_LICENSE_URL "' + winMinGwToolchain['licenseUrl'] + '"\n'
text = text + '#define MINGW_FILENAME "' + winMinGwToolchain['filename'] +'"\n'
text = text + '#define MINGW_VERSION "' + winMinGwToolchain['version'] + '"\n'
text = text + '#define MINGW_SIZE ' + str(winMinGwToolchain['size']) + '\n'
text = text + '#define MINGW_LOCATION "' + winMinGwToolchain['installationLocation'] + '"\n'
text = text + '#define CPPCHECK_URL "' + winCppcheck['url'] + '"\n'
text = text + '#define CPPCHECK_LICENSE_URL "' + winCppcheck['licenseUrl'] + '"\n'
text = text + '#define CPPCHECK_FILENAME "' + winCppcheck['filename'] +'"\n'
text = text + '#define CPPCHECK_VERSION "' + winCppcheck['version'] + '"\n'
text = text + '#define CPPCHECK_SIZE ' + str(winCppcheck['size']) + '\n'
text = text + '#define CPPCHECK_LOCATION "' + winCppcheck['installationLocation'] + '"\n'
content = content.replace("#replace this text with instalation files information", text)
with open('windows/microide.iss', 'w') as file:
file.write(content)
def download7zipStandaloneConsoleVersion():
filename = '7z1604-extra.7z'
dest = 'norepo/windows'
download(dest, filename, 'http://www.7-zip.org/a/7z1604-extra.7z', {})
os.system("mkdir -p windows/tools/7z1604-extra >> output.log")
parameters = '7za x ' + dest + '/' + filename + ' -y -owindows/tools/7z1604-extra'
os.system(parameters + " >> output.log")
def compileWindowsInstaller():
downloadDir = 'norepo/windows'
# do some clenup
shutil.rmtree('windows/eclipse-installer', ignore_errors=True)
shutil.rmtree('windows/toolchainPatch', ignore_errors=True)
# prepare installer
download7zipStandaloneConsoleVersion() # needed to unpack repositorys while installing on windows
getMissingFiles(downloadDir, [winEclipse]) # we need to download and include pathed version of eclipse installer into microide installer
#extracting eclipse files
command = '7za x ' + downloadDir + '/' + winEclipse['filename'] + ' -y -owindows/eclipse-installer'
os.system(command)
os.remove('windows/eclipse-installer/extractor.exe')
#pathing eclipse installer
with open('windows/eclipse-installer/eclipse-inst.ini', 'a') as iniFile:
iniFile.write('-Doomph.redirection.myProjectsCatalog=index:/redirectable.projects.setup->https://raw.githubusercontent.com/microHAL/microIDE/devel/eclipse-installer/microideSetups/microhal.projects.setup\n')
iniFile.write('-Doomph.setup.product.catalog.filter=microide')
generateWindowsProductSetup() # generate oomph setup files for windows
# copying oomph setup files
shutil.copytree('eclipse-installer/microideLocalSetups', 'windows/eclipse-installer/microideLocalSetups')
os.remove('windows/eclipse-installer/microideLocalSetups/microide.product.setup.linux')
os.rename('windows/eclipse-installer/microideLocalSetups/microide.product.setup.windows', 'windows/eclipse-installer/microideLocalSetups/microide.product.setup')
# include toolchain patch files into installer, firstly copy patch files into proper directory
patchDirectoryName = re.sub('-.{5,6}-win32\.exe', '', winArmGccToolchain['filename'])
shutil.copytree('toolchains/gcc-arm-none-eabi-patch/' + patchDirectoryName, 'windows/toolchainPatch/' + patchDirectoryName)
generateInnoSetupFile()
parameters = './iscc.sh windows/microide.iss'
os.system(parameters + " >> output.log")
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--onlyDownload', nargs='?', type=bool, const=True, help='Checking if all windows and linux files can be download from the internet.')
parser.add_argument('--verifyWindowsDownload', nargs='?', type=bool, const=True, help='Checking if all files required for windows installation can be download from the internet.')
parser.add_argument('--verifyLinuxDownload', nargs='?', type=bool, const=True, help='Checking if all files required for linux installation can be download from the internet.')
parser.add_argument('--replaceGthr', nargs='?', type=bool, const=True, help='Part of toolchain patching, replacing gthr.h file into microhal version.')
parser.add_argument('--createToolchainPatch', nargs='?', type=bool, const=True, help='Create toolchain patch.')
parser.add_argument('--makeLinuxInstaller', nargs='?', type=bool, const=True, help='Creating linux installation files.')
parser.add_argument('--makeWindowsInstaller', nargs='?', type=bool, const=True, help='Creating windows installation files. This will work on linux with wine where Inno Setup and Inno Download Plugin was installed')
parser.add_argument('--initEnvinronment', nargs='?', type=bool, const=True, help='This option will install on you computer wine and Inno Setup.')
args = parser.parse_args()
if args.onlyDownload == True:
getFiles('norepo')
if args.verifyWindowsDownload == True:
verifyWindowsDownloads('norepo')
if args.verifyLinuxDownload == True:
verifyLinuxDownloads('norepo')
if args.makeLinuxInstaller == True:
print "Generating instalation files..."
getMissingFiles('norepo/linux', linuxFiles)
updateFileinfo('norepo/linux', linuxFiles)
generateLinuxProductSetup()
generateLinuxInstaller()
if args.makeWindowsInstaller == True:
print "Generating windows instalation files..."
getMissingFiles('norepo/windows', windowsFiles)
updateFileinfo('norepo/windows', windowsFiles)
compileWindowsInstaller()
if args.replaceGthr == True:
print "Replacing gthr.h files..."
toolchainDir = 'norepo/toolchains/gcc-arm-none-eabi-patch/gcc-arm-none-eabi-6-2017-q2-update'
replaceRecursive(toolchainDir, 'toolchainPatchFiles', 'gthr.h')
if args.createToolchainPatch == True:
os.system("mkdir -p norepo/toolchains/gcc-arm-none-eabi-patch >> output.log")
copyLocation = "toolchainPatchFiles/gcc-arm-none-eabi-7-2017-q4-major"
toolchain = armGccToolchain_7_2017_q4
print "Creating toolchain patch."
getMissingFiles('norepo/linux', [toolchain])
print "Extracting toolchain files..."
os.system("tar --extract --file=" + 'norepo/linux/' + toolchain['filename'] + ' -C norepo/toolchains/gcc-arm-none-eabi-patch')
toolchainDir = 'norepo/toolchains/gcc-arm-none-eabi-patch/gcc-arm-none-eabi-7-2017-q4-major'
print "Create copy of original files"
#make directory for copies
os.system("mkdir -p " + copyLocation + " >> output.log")
#copy gthr.h
filePath = findFile(toolchainDir, 'gthr.h')
shutil.copyfile(filePath, copyLocation +'/gthr.h.oryg')
#copy thread
shutil.copyfile(toolchainDir + '/arm-none-eabi/include/c++/7.2.1/thread', copyLocation +'/thread.oryg')
#copy mutex
shutil.copyfile(toolchainDir + '/arm-none-eabi/include/c++/7.2.1/mutex', copyLocation +'/mutex.oryg')
#copy condition_variable
shutil.copyfile(toolchainDir + '/arm-none-eabi/include/c++/7.2.1/condition_variable', copyLocation +'/condition_variable.oryg')
print "Replacing gthr.h ..."
shutil.copyfile(copyLocation +'/gthr.h.oryg', copyLocation + '/gthr.h')
mergeFiles('toolchainPatchFiles/gthr.h', copyLocation + '/gthr.h')
replaceRecursive(toolchainDir, copyLocation, 'gthr.h')
print "Replacing thread ..."
mergeFiles('toolchainPatchFiles/thread', toolchainDir + '/arm-none-eabi/include/c++/7.2.1/thread')
print "Replacing mutex ..."
mergeFiles('toolchainPatchFiles/mutex', toolchainDir + '/arm-none-eabi/include/c++/7.2.1/mutex')
print "Replacing condition_variable ..."
mergeFiles('toolchainPatchFiles/condition_variable', toolchainDir + '/arm-none-eabi/include/c++/7.2.1/condition_variable')
print "Removing unchanged files"
recursiveRemoveNotListedFiles(toolchainDir, ['gthr.h', 'condition_variable', 'mutex', 'thread'])
print "Copying newly created patch to patches directory"
shutil.copytree('norepo/toolchains/gcc-arm-none-eabi-patch/gcc-arm-none-eabi-7-2017-q4-major', 'toolchains/gcc-arm-none-eabi-patch/gcc-arm-none-eabi-7-2017-q4')
if args.initEnvinronment == True:
try:
subprocess.call(["wine", "--version"])
except OSError as e:
if e.errno == os.errno.ENOET: #wine not installed
subprocess.call("sudo apt", "install", "wine")
else:
raise
#todo add innosetup instalation
getMissingFiles('norepo/linux', [innosetup])
if __name__ == "__main__":
main()