-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakeCpp17ARM.py
39 lines (30 loc) · 1.09 KB
/
makeCpp17ARM.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
import hashlib
import json
import os.path
import sys
import tarfile
def make_tarfile(output_filename, source_dir):
with tarfile.open(output_filename, 'w:gz') as tar:
tar.add(source_dir, arcname=os.path.basename(source_dir))
hasher = hashlib.sha256()
with open(output_filename, 'rb') as fh:
data = fh.read()
hasher.update(data)
return hasher.hexdigest(), len(data)
version = sys.argv[1]
tar_name = 'Cpp17ARM-package-'+version+'.tar.gz'
print( tar_name , version )
digest, size = make_tarfile(tar_name, 'Cpp17ARM-package/.')
print( digest, "\nsize = ", str(size))
with open('package_Cpp17ARM_index.json', 'r+') as index_file:
data=json.load(index_file)
for p in data['packages'][0]['platforms']:
if p['version'] == version:
p['archiveFileName']=tar_name
p['checksum']='SHA-256:'+digest
p['size']=str(size)
p['url']='file://localhost/Users/sop/Arduino/ArduinoCore-Cpp17/'+tar_name
break
index_file.seek(0)
json.dump(data, index_file, indent=4, sort_keys=True)
index_file.truncate()