2021-12-09 08:47:20 +00:00
|
|
|
#!/usr/bin/python3
|
|
|
|
import hashlib
|
|
|
|
import sys
|
|
|
|
|
2022-07-06 15:36:55 +00:00
|
|
|
def sha256_from_data(data):
|
|
|
|
hash_sha256 = hashlib.sha256()
|
|
|
|
hash_sha256.update(data)
|
|
|
|
return hash_sha256.hexdigest()
|
2021-12-09 08:47:20 +00:00
|
|
|
|
|
|
|
contents = open('90-enable-all.lua', 'r', encoding='utf-8').read()
|
|
|
|
|
2022-07-06 15:36:55 +00:00
|
|
|
sha256sum = sha256_from_data(contents.encode('utf-8'))
|
2023-11-26 11:24:38 +00:00
|
|
|
expected_sha256sum = '86888e9d3fcc952c41e778ab4edae4a0eb1f9f51b62ae0772befa9f0fdef611d'
|
2021-12-09 08:47:20 +00:00
|
|
|
|
2022-07-06 15:36:55 +00:00
|
|
|
if sha256sum != expected_sha256sum:
|
2021-12-09 08:47:20 +00:00
|
|
|
print('The script has to be updated for new changes in 90-enable-all.lua')
|
2022-07-06 15:36:55 +00:00
|
|
|
print(f'File sha256sum: {sha256sum}')
|
|
|
|
print(f'expected sha256sum: {expected_sha256sum}')
|
2021-12-09 08:47:20 +00:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
content_sections = contents.split('\n\n')
|
|
|
|
|
|
|
|
sections = ['enable-metadata',
|
|
|
|
'default-access-policy',
|
|
|
|
'load-devices',
|
2022-02-07 17:43:50 +00:00
|
|
|
'track-user-choices-devices',
|
|
|
|
'track-user-choices-streams',
|
2021-12-09 08:47:20 +00:00
|
|
|
'link-nodes-by-roles',
|
2023-11-26 11:24:38 +00:00
|
|
|
'suspend-idle-nodes',
|
|
|
|
'allow-loading-objects-on-demand']
|
2021-12-09 08:47:20 +00:00
|
|
|
|
|
|
|
if len(content_sections) != len(sections):
|
|
|
|
print('The script has to be updated for new changes in 90-enable-all.lua')
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
for i, (content, sec) in enumerate(zip(content_sections, sections)):
|
|
|
|
if sec == 'load-devices':
|
|
|
|
lines = content.split('\n')
|
|
|
|
open(f'90-{i}-1-enable-alsa.lua', 'w',
|
|
|
|
encoding='utf-8').write(lines[1])
|
|
|
|
open(f'90-{i}-2-enable-v4l2.lua', 'w',
|
|
|
|
encoding='utf-8').write(lines[2])
|
2023-11-26 11:24:38 +00:00
|
|
|
open(f'90-{i}-3-enable-libcamera.lua', 'w',
|
|
|
|
encoding='utf-8').write(lines[3])
|
2021-12-09 08:47:20 +00:00
|
|
|
continue
|
|
|
|
|
|
|
|
filename = f'90-{i}-{sec}.lua'
|
|
|
|
open(filename, 'w', encoding='utf-8').write(content)
|