2021-10-09 10:29:37 +00:00
|
|
|
#! /usr/bin/env python3
|
2021-10-08 21:31:53 +00:00
|
|
|
|
2021-10-10 20:35:13 +00:00
|
|
|
import hashlib
|
|
|
|
import os
|
2021-10-09 12:01:50 +00:00
|
|
|
import sys
|
|
|
|
|
2021-10-08 21:31:53 +00:00
|
|
|
import arguments
|
2021-10-10 12:44:22 +00:00
|
|
|
import local
|
2021-10-09 17:46:11 +00:00
|
|
|
import synchronization
|
2021-10-09 10:25:45 +00:00
|
|
|
|
|
|
|
|
2021-10-10 17:02:34 +00:00
|
|
|
def build():
|
2021-10-12 21:34:13 +00:00
|
|
|
pass
|
2021-10-09 10:25:45 +00:00
|
|
|
|
|
|
|
|
2021-10-10 17:02:34 +00:00
|
|
|
def check():
|
2021-10-10 20:35:13 +00:00
|
|
|
packages = []
|
|
|
|
broken = []
|
|
|
|
lo = local.Local()
|
|
|
|
for architecture in lo.architectures:
|
|
|
|
for subsystem in architecture.subsystems.values():
|
|
|
|
for package in subsystem.catalog.packages.values():
|
|
|
|
packages.append((subsystem, package))
|
|
|
|
for index, items in enumerate(packages):
|
2021-10-12 21:03:17 +00:00
|
|
|
print('\r', index, '/', len(packages), '←', 'checked', end='')
|
2021-10-10 20:35:13 +00:00
|
|
|
subsystem, package = items
|
|
|
|
path = os.path.join(subsystem.path, package.filename)
|
|
|
|
with open(path, 'br') as f:
|
|
|
|
hash = hashlib.sha256(f.read()).hexdigest()
|
|
|
|
if hash != package.sha256sum:
|
|
|
|
broken.append(package)
|
2021-10-12 21:03:17 +00:00
|
|
|
print()
|
|
|
|
print('', str(len(broken)).rjust(len(str(len(packages)))),
|
|
|
|
'/', len(packages), '←', 'broken')
|
2021-10-09 10:25:45 +00:00
|
|
|
|
|
|
|
|
2021-10-10 17:02:34 +00:00
|
|
|
def info():
|
|
|
|
print(local.Local())
|
2021-10-09 10:25:45 +00:00
|
|
|
|
|
|
|
|
2021-10-10 17:02:34 +00:00
|
|
|
def sync():
|
|
|
|
sync = synchronization.Synchronization()
|
2021-10-09 17:46:11 +00:00
|
|
|
print(sync)
|
2021-10-10 11:45:02 +00:00
|
|
|
sync.run()
|
2021-10-08 21:31:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2021-10-10 17:02:34 +00:00
|
|
|
getattr(sys.modules[__name__], arguments.action)()
|
2021-10-08 21:31:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|