packages
This commit is contained in:
parent
279cab318a
commit
e90a4396fa
3 changed files with 30 additions and 10 deletions
|
@ -34,14 +34,7 @@ def info(args):
|
|||
def sync(args):
|
||||
sync = synchronization.Synchronization(args)
|
||||
print(sync)
|
||||
# TODO prepare temporary directory
|
||||
print('prepare…')
|
||||
# TODO fetch
|
||||
print('fetch…')
|
||||
# TODO purge useless files
|
||||
print('purge…')
|
||||
# TODO clean temporary directory
|
||||
print('clean…')
|
||||
sync.run()
|
||||
|
||||
|
||||
def main():
|
||||
|
|
13
package.py
13
package.py
|
@ -1,6 +1,7 @@
|
|||
import os
|
||||
|
||||
CHARSET = 'u8'
|
||||
import msys
|
||||
|
||||
KEY = '%'
|
||||
SEPARATOR = f'{os.linesep}{os.linesep}'
|
||||
|
||||
|
@ -8,7 +9,7 @@ SEPARATOR = f'{os.linesep}{os.linesep}'
|
|||
class Package:
|
||||
def __init__(self, package, files):
|
||||
for binary in [package, files]:
|
||||
text = binary.decode(CHARSET).strip()
|
||||
text = binary.decode(msys.CHARSET).strip()
|
||||
for item in text.split(SEPARATOR):
|
||||
line, *lines = item.split(os.linesep)
|
||||
key = line.split(KEY)[1].lower()
|
||||
|
@ -17,3 +18,11 @@ class Package:
|
|||
else:
|
||||
value = lines
|
||||
setattr(self, key, value)
|
||||
|
||||
def __str__(self):
|
||||
lines = [
|
||||
f'Name: {self.name}',
|
||||
f'Size: {self.csize}',
|
||||
f'Hash: {self.sha256sum}',
|
||||
]
|
||||
return os.linesep.join(lines)
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import os
|
||||
import shutil
|
||||
|
||||
import arguments
|
||||
import msys
|
||||
import remote
|
||||
import repository
|
||||
|
||||
|
@ -9,6 +12,21 @@ class Synchronization:
|
|||
self.remote = remote.Remote(args)
|
||||
self.repository = repository.Repository(args)
|
||||
self.temporary = self.repository.get_temporary()
|
||||
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]
|
||||
for _, package in sorted(catalog.packages.items()):
|
||||
print()
|
||||
print(package)
|
||||
tmp = os.path.join(self.repository.directory,
|
||||
self.repository.get_temporary())
|
||||
os.makedirs(tmp)
|
||||
# clean temporary directory
|
||||
shutil.rmtree(tmp)
|
||||
|
||||
def __str__(self):
|
||||
lines = [
|
||||
|
|
Loading…
Reference in a new issue