2021-10-09 17:46:11 +00:00
|
|
|
import os
|
2021-10-10 11:45:02 +00:00
|
|
|
import shutil
|
2021-10-09 17:46:11 +00:00
|
|
|
|
2021-10-10 11:45:02 +00:00
|
|
|
import arguments
|
2021-10-10 12:07:15 +00:00
|
|
|
import file
|
2021-10-10 12:44:22 +00:00
|
|
|
import local
|
2021-10-10 11:45:02 +00:00
|
|
|
import msys
|
2021-10-09 17:46:11 +00:00
|
|
|
import remote
|
|
|
|
|
|
|
|
|
|
|
|
class Synchronization:
|
|
|
|
def __init__(self, args):
|
|
|
|
self.remote = remote.Remote(args)
|
2021-10-10 12:45:28 +00:00
|
|
|
self.repository = local.Local(args)
|
2021-10-09 17:46:11 +00:00
|
|
|
self.temporary = self.repository.get_temporary()
|
2021-10-10 11:45:02 +00:00
|
|
|
self.threads = args[arguments.THREADS]
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
for architecture in self.remote.architectures:
|
|
|
|
for subsystem in msys.get_subsystems(architecture,
|
|
|
|
self.remote.subsystems):
|
|
|
|
catalog = self.remote.catalogs[architecture][subsystem]
|
2021-10-10 12:07:15 +00:00
|
|
|
path = msys.get_subsystem(architecture, subsystem)
|
2021-10-10 11:45:02 +00:00
|
|
|
for _, package in sorted(catalog.packages.items()):
|
2021-10-10 12:07:15 +00:00
|
|
|
f = file.File(
|
|
|
|
os.path.join(self.remote.location, path),
|
|
|
|
package.name,
|
|
|
|
package.csize,
|
2021-10-10 13:01:24 +00:00
|
|
|
os.path.join(self.repository.location, path),
|
2021-10-10 12:07:15 +00:00
|
|
|
package.sha256sum,
|
|
|
|
)
|
2021-10-10 11:45:02 +00:00
|
|
|
print()
|
2021-10-10 12:07:15 +00:00
|
|
|
print(f)
|
2021-10-10 13:01:24 +00:00
|
|
|
tmp = os.path.join(self.repository.location,
|
2021-10-10 11:45:02 +00:00
|
|
|
self.repository.get_temporary())
|
|
|
|
os.makedirs(tmp)
|
|
|
|
# clean temporary directory
|
|
|
|
shutil.rmtree(tmp)
|
2021-10-09 17:46:11 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
lines = [
|
|
|
|
str(self.remote), str(),
|
|
|
|
str(self.repository), str(),
|
|
|
|
f'Temporary: {self.temporary}',
|
|
|
|
]
|
|
|
|
return os.linesep.join(lines)
|