From 97a14f5f074496266e4dbc8a21333e624837c55d Mon Sep 17 00:00:00 2001 From: alichinese Date: Fri, 11 Oct 2024 15:58:55 +0800 Subject: [PATCH] generate: alter repos struce in compile.yaml * all repository information comes from manifest.yaml. For repositories in the template files, we directly convert them to a list and then retrieve the download information from manifest.yaml. Signed-off-by: alichinese --- src/oebuild/parse_template.py | 23 +++++++++-------------- src/oebuild/struct.py | 19 +++++++++++++++---- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/oebuild/parse_template.py b/src/oebuild/parse_template.py index 0860a58..42e16e8 100644 --- a/src/oebuild/parse_template.py +++ b/src/oebuild/parse_template.py @@ -20,7 +20,6 @@ from ruamel.yaml.scalarstring import LiteralScalarString import oebuild.util as oebuild_util import oebuild.const as oebuild_const -from oebuild.struct import RepoParam @dataclass @@ -114,8 +113,7 @@ class ParseTemplate: data = oebuild_util.read_yaml(config_dir) repo_list = None if 'repos' in data: - repo_list = oebuild_util.trans_dict_key_to_list( - self.parse_oebuild_repo(data['repos'])) + repo_list = self.parse_repos_list(data['repos']) layers = None if 'layers' not in data else data['layers'] local_conf = None if 'local_conf' not in data else data['local_conf'] @@ -274,20 +272,17 @@ class ParseTemplate: return compile_conf @staticmethod - def parse_oebuild_repo(repos): + def parse_repos_list(repos): ''' parse repo json object to OebuildRepo ''' - repo_cict = {} - for name, repo in repos.items(): - try: - repo_cict[name] = RepoParam( - remote_url=repo['url'], - version=repo['refspec']) - except AttributeError: - repo_cict[name] = "" - - return repo_cict + if isinstance(repos, list): + return repos + repo_list = [] + for name, _ in repos.items(): + repo_list.append(name) + + return repo_list def get_docker_param_dict(docker_image, dir_list): diff --git a/src/oebuild/struct.py b/src/oebuild/struct.py index 7d79489..7514e7d 100644 --- a/src/oebuild/struct.py +++ b/src/oebuild/struct.py @@ -19,8 +19,8 @@ class RepoParam: ''' object repo is to record template repo info, repo struct is: repo_name: - url: str - refspec: str + remote_url: str + version: str object repo transfer string to struct to use it next easily ''' remote_url: str @@ -53,7 +53,7 @@ class CompileLocalParam: @dataclass -class CompileParamComm: +class CompileParamComm1: ''' this is for common param to compile.yaml ''' @@ -61,6 +61,13 @@ class CompileParamComm: machine: str toolchain_type: str no_layer: Optional[bool] + + +@dataclass +class CompileParamComm2: + ''' + this is for common param to compile.yaml + ''' repos: Optional[list] layers: Optional[list] local_conf: Optional[LiteralScalarString] @@ -88,7 +95,11 @@ class CompileParamBitbakeCmds: @dataclass -class CompileParam(CompileParamComm, CompileLocalParam, CompileParamSDK, CompileParamBitbakeCmds): +class CompileParam(CompileParamComm1, + CompileParamComm2, + CompileLocalParam, + CompileParamSDK, + CompileParamBitbakeCmds): ''' Compile is the parsed object of compile.yaml and is used to manipulate the build file ''' -- Gitee