This commit is contained in:
Marc Beninca 2021-10-10 21:30:40 +02:00 committed by Marc Beninca
parent 3763dce133
commit 2e366f71f1
6 changed files with 25 additions and 37 deletions

View file

@ -4,17 +4,21 @@ import tarfile
import package
CATALOG = '.files'
FILES = 'files'
PACKAGE = 'desc'
class Catalog:
def __init__(self, binary):
self.binary = binary
def __init__(self, subsystem):
self.subsystem = subsystem
self.path = os.path.join(self.subsystem.path,
f'{self.subsystem.name}{CATALOG}')
self.load()
def load(self):
f = io.BytesIO(self.binary)
binary = self.subsystem.architecture.repository.get_file(self.path)
f = io.BytesIO(binary)
archive = tarfile.open(fileobj=f)
m = {}
packages = {}

View file

@ -10,6 +10,10 @@ class Local(repository.Repository):
super().__init__(arguments.directory)
self.temporary = arguments.temporary
def get_file(self, path):
with open(os.path.join(self.location, path), 'br') as f:
return f.read()
def get_files(self, path):
*_, files = next(os.walk(os.path.join(self.location, path)))
return files

View file

@ -1,3 +1,2 @@
CATALOG = '.files'
CHARSET = 'u8'
REPOSITORY = 'https://repo.msys2.org'

View file

@ -2,33 +2,16 @@ import os
import requests
import arguments
import catalog
import hypertext
import msys
import repository
class Remote(repository.Repository):
def __init__(self):
super().__init__(arguments.remote)
self.load()
def load(self):
archives = {}
c = {}
for architecture in self.architectures:
subsystems = architecture.subsystems.keys()
#
c[architecture] = {}
for subsystem in subsystems:
location = os.path.join(self.location,
architecture.subsystems[subsystem]
.path,
f'{subsystem}{msys.CATALOG}')
binary = requests.get(location).content
c[architecture][subsystem] = catalog.Catalog(binary)
self.archives = archives
self.catalogs = c
def get_file(self, path):
return requests.get(os.path.join(self.location, path)).content
def get_files(self, path):
return hypertext.HyperText(os.path.join(self.location, path)).links
@ -36,11 +19,5 @@ class Remote(repository.Repository):
def __str__(self):
lines = [
super().__str__(),
'Archives:',
]
for architecture, archive in reversed(sorted(self.archives.items())):
lines.append(f'{architecture}{archive}')
lines.append('Subsystems:')
for arch, ss in reversed(sorted(self.catalogs.items())):
lines.append(f'{arch}{list(ss.keys())}')
return os.linesep.join(lines)

View file

@ -1,5 +1,7 @@
import os
import catalog
CRT = 'mingw'
MAIN = 'msys'
@ -18,6 +20,8 @@ class SubSystem:
if self.name == MAIN:
list.append(self.architecture.name)
self.path = os.sep.join(list)
# catalog
self.catalog = catalog.Catalog(self)
def __str__(self):
lines = [

View file

@ -16,15 +16,13 @@ class Synchronization:
def run(self):
for architecture in self.remote.architectures:
for subsystem in architecture.subsystems.keys():
catalog = self.remote.catalogs[architecture][subsystem]
path = architecture.subsystems[subsystem].path
for _, package in sorted(catalog.packages.items()):
for subsystem in architecture.subsystems.values():
for _, package in sorted(subsystem.catalog.packages.items()):
f = file.File(
os.path.join(self.remote.location, path),
os.path.join(self.remote.location, subsystem.path),
package.name,
package.csize,
os.path.join(self.repository.location, path),
os.path.join(self.repository.location, subsystem.path),
package.sha256sum,
)
print()
@ -37,8 +35,10 @@ class Synchronization:
def __str__(self):
lines = [
str(self.remote), str(),
str(self.repository), str(),
str(self.remote),
str(),
str(self.repository),
str(),
f'Temporary: {self.temporary}',
]
return os.linesep.join(lines)