BREAKING: Refactor repos loading
To avoid hardcoding repository names and make the code more easily extendable, we now use the keys from the config file as the repository names instead of hardcoding the fixed set of names. This means most config will require updating.
This commit is contained in:
parent
d15a93c39a
commit
816ff27123
@ -204,6 +204,12 @@ class Repository:
|
||||
dict(self.binaries),
|
||||
self.bits)
|
||||
|
||||
def copy_with_addon(self, new_name, binaries):
|
||||
extended = self.copy(new_name)
|
||||
extended.addon = binaries
|
||||
extended.update_indexes()
|
||||
return extended
|
||||
|
||||
@classmethod
|
||||
def _reverse_provides_index(cls, binaries):
|
||||
if not binaries:
|
||||
@ -246,8 +252,7 @@ class Repository:
|
||||
|
||||
@classmethod
|
||||
def load_from_config(cls, repo_name, config):
|
||||
r = config['repos'][repo_name]
|
||||
return cls.load(repo_name, r['path'], r['arch'])
|
||||
return cls.load(repo_name, config['path'], config['arch'])
|
||||
|
||||
def binaries_from(self, *source_names):
|
||||
'''Return binary packages build from this source'''
|
||||
@ -704,21 +709,25 @@ def colorize_stats(base_repo, target_repo):
|
||||
return '\n'.join(result)
|
||||
|
||||
|
||||
def load_repos(config):
|
||||
repos = {}
|
||||
for name, cfg in config['repos'].items():
|
||||
LOG.info('Loading %s', name)
|
||||
repos[name] = Repository.load_from_config(name, cfg)
|
||||
|
||||
for name, cfg in config['addons'].items():
|
||||
LOG.info('Loading %s', name)
|
||||
base = repos[cfg['base']]
|
||||
addon = Repository.load_from_config(name, cfg)
|
||||
repos[name] = base.copy_with_addon(name, addon.binaries)
|
||||
del addon
|
||||
|
||||
LOG.info("Loading DONE")
|
||||
return repos
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from repos_cmp.utils import interactive_setup
|
||||
from pydoc import pager # noqa
|
||||
CONFIG = interactive_setup()
|
||||
if 'sisyphus' in CONFIG['repos']:
|
||||
x86_64 = Repository.load_from_config('sisyphus', CONFIG)
|
||||
if 'sisyphus_riscv64' in CONFIG['repos']:
|
||||
riscv64 = Repository.load_from_config('sisyphus_riscv64', CONFIG)
|
||||
if 'sisyphus_mipsel' in CONFIG['repos']:
|
||||
mipsel = Repository.load_from_config('sisyphus_mipsel', CONFIG)
|
||||
if 'loongarch64' in CONFIG['repos']:
|
||||
la64 = Repository.load_from_config('loongarch64', CONFIG)
|
||||
if 'la64_addon' in CONFIG['repos']:
|
||||
la64_addon = Repository.load_from_config('la64_addon', CONFIG)
|
||||
la64x = la64.copy('loongarch64-plus')
|
||||
la64x.addon = la64_addon.binaries
|
||||
la64x.update_indexes()
|
||||
del la64_addon
|
||||
globals().update(load_repos(CONFIG))
|
||||
|
@ -26,12 +26,12 @@ cat > "$BASE_BASES/config.json" << EOF
|
||||
{
|
||||
"description": "Configuration for reports-secondary.office.basealt.ru",
|
||||
"repos": {
|
||||
"sisyphus": {
|
||||
"x86_64": {
|
||||
"path": "$BASE_BASES/x86_64",
|
||||
"arch": ["x86_64", "noarch"],
|
||||
"bits": 64
|
||||
},
|
||||
"sisyphus_riscv64": {
|
||||
"riscv64": {
|
||||
"path": "$BASE_BASES/riscv64",
|
||||
"arch": ["riscv64", "noarch"],
|
||||
"bits": 64
|
||||
|
Loading…
Reference in New Issue
Block a user