Option to add task repos
This commit is contained in:
parent
f3728292d7
commit
79d7557371
@ -1,6 +1,9 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
from collections.abc import Iterable
|
||||
|
||||
import argparse
|
||||
import yaml
|
||||
import sys
|
||||
|
||||
import cloud_build
|
||||
@ -9,6 +12,17 @@ PROG = 'cloud-build'
|
||||
|
||||
|
||||
def parse_args():
|
||||
def is_dict(string):
|
||||
raw_dict = dict(yaml.safe_load(string))
|
||||
result = {}
|
||||
for k, v in raw_dict.items():
|
||||
key = k.lower()
|
||||
if not isinstance(v, Iterable) or isinstance(v, str):
|
||||
result[key] = [v]
|
||||
else:
|
||||
result[key] = v
|
||||
return result
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
||||
)
|
||||
@ -23,6 +37,12 @@ def parse_args():
|
||||
action='store_true',
|
||||
help='disable running tests',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--tasks',
|
||||
default={},
|
||||
type=is_dict,
|
||||
help='add tasks to repositories',
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
return args
|
||||
@ -30,7 +50,7 @@ def parse_args():
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
cb = cloud_build.CB(config=args.config, no_tests=args.no_tests)
|
||||
cb = cloud_build.CB(**dict(args._get_kwargs()))
|
||||
cb.create_images()
|
||||
cb.copy_external_files()
|
||||
cb.sign()
|
||||
|
@ -52,15 +52,20 @@ class CB:
|
||||
self,
|
||||
config,
|
||||
*,
|
||||
data_dir=None,
|
||||
no_tests=False,
|
||||
create_remote_dirs=False
|
||||
data_dir: PathLike = None,
|
||||
no_tests: bool = False,
|
||||
create_remote_dirs: bool = False,
|
||||
tasks: dict = None,
|
||||
) -> None:
|
||||
self.initialized = False
|
||||
self._save_cwd = os.getcwd()
|
||||
self.parse_config(config)
|
||||
self.no_tests = no_tests
|
||||
self._create_remote_dirs = create_remote_dirs
|
||||
if tasks is None:
|
||||
self.tasks = {}
|
||||
else:
|
||||
self.tasks = tasks
|
||||
|
||||
if not data_dir:
|
||||
data_dir = (Path(self.expand_path(os.getenv('XDG_DATA_HOME',
|
||||
@ -284,6 +289,9 @@ Dir::Etc::preferencesparts "/var/empty";
|
||||
sources_list = f'rpm {repo} {arch} classic\n'
|
||||
if arch not in self.bad_arches:
|
||||
sources_list += f'rpm {repo} noarch classic\n'
|
||||
for task in self.tasks.get(branch.lower(), []):
|
||||
tr = 'http://git.altlinux.org'
|
||||
sources_list += f'rpm {tr} repo/{task}/{arch} task\n'
|
||||
f.write(sources_list)
|
||||
|
||||
def escape_branch(self, branch: str) -> str:
|
||||
|
Loading…
Reference in New Issue
Block a user