openubmc-bingo 0.5.277__py3-none-any.whl → 0.6.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of openubmc-bingo might be problematic. Click here for more details.

Files changed (52) hide show
  1. bmcgo/__init__.py +1 -1
  2. bmcgo/bmcgo_config.py +22 -10
  3. bmcgo/cli/cli.py +86 -39
  4. bmcgo/cli/config.conan2.yaml +9 -0
  5. bmcgo/codegen/lua/codegen.py +1 -1
  6. bmcgo/codegen/lua/script/gen_intf_rpc_json.py +15 -14
  7. bmcgo/component/analysis/analysis.py +8 -8
  8. bmcgo/component/analysis/intf_validation.py +23 -12
  9. bmcgo/component/build.py +76 -14
  10. bmcgo/component/component_dt_version_parse.py +3 -2
  11. bmcgo/component/component_helper.py +43 -15
  12. bmcgo/component/coverage/incremental_cov.py +2 -2
  13. bmcgo/component/deploy.py +68 -14
  14. bmcgo/component/gen.py +1 -1
  15. bmcgo/component/package_info.py +128 -38
  16. bmcgo/component/template_v2/conanbase.py.mako +352 -0
  17. bmcgo/component/template_v2/conanfile.deploy.py.mako +26 -0
  18. bmcgo/component/test.py +53 -20
  19. bmcgo/frame.py +7 -3
  20. bmcgo/functional/analysis.py +3 -2
  21. bmcgo/functional/check.py +10 -6
  22. bmcgo/functional/conan_index_build.py +79 -20
  23. bmcgo/functional/csr_build.py +1 -1
  24. bmcgo/functional/diff.py +1 -1
  25. bmcgo/functional/fetch.py +1 -1
  26. bmcgo/functional/full_component.py +32 -24
  27. bmcgo/functional/git_history.py +220 -0
  28. bmcgo/functional/maintain.py +55 -12
  29. bmcgo/functional/new.py +1 -1
  30. bmcgo/functional/schema_valid.py +2 -2
  31. bmcgo/logger.py +2 -3
  32. bmcgo/misc.py +130 -9
  33. bmcgo/tasks/conan/__init__.py +10 -0
  34. bmcgo/tasks/conan/conanfile.py +45 -0
  35. bmcgo/tasks/task.py +27 -4
  36. bmcgo/tasks/task_build_conan.py +399 -52
  37. bmcgo/tasks/task_buildgppbin.py +8 -2
  38. bmcgo/tasks/task_download_buildtools.py +76 -0
  39. bmcgo/tasks/task_download_dependency.py +1 -0
  40. bmcgo/tasks/task_hpm_envir_prepare.py +1 -1
  41. bmcgo/utils/build_conans.py +231 -0
  42. bmcgo/utils/component_post.py +6 -4
  43. bmcgo/utils/component_version_check.py +10 -5
  44. bmcgo/utils/config.py +76 -40
  45. bmcgo/utils/fetch_component_code.py +44 -25
  46. bmcgo/utils/tools.py +239 -117
  47. bmcgo/worker.py +2 -2
  48. {openubmc_bingo-0.5.277.dist-info → openubmc_bingo-0.6.0.dist-info}/METADATA +4 -2
  49. {openubmc_bingo-0.5.277.dist-info → openubmc_bingo-0.6.0.dist-info}/RECORD +52 -45
  50. {openubmc_bingo-0.5.277.dist-info → openubmc_bingo-0.6.0.dist-info}/WHEEL +0 -0
  51. {openubmc_bingo-0.5.277.dist-info → openubmc_bingo-0.6.0.dist-info}/entry_points.txt +0 -0
  52. {openubmc_bingo-0.5.277.dist-info → openubmc_bingo-0.6.0.dist-info}/top_level.txt +0 -0
bmcgo/functional/new.py CHANGED
@@ -54,7 +54,7 @@ _TEMPLATES = {
54
54
  class BmcgoCommand:
55
55
  def __init__(self, bconfig: BmcgoConfig, *args):
56
56
  self.bconfig = bconfig
57
- parser = argparse.ArgumentParser(prog="bingo new", description="创建组件", add_help=True,
57
+ parser = argparse.ArgumentParser(prog=f"{misc.tool_name()} new", description="创建组件", add_help=True,
58
58
  formatter_class=argparse.RawTextHelpFormatter)
59
59
  for item in _REQUIRES:
60
60
  parser.add_argument(f"-{item[0]}", f"--{item[1]}", help=f"指定{item[2]}", required=True)
@@ -43,8 +43,8 @@ class BmcgoCommand:
43
43
  bconfig (BmcgoConfig): bmcgo 配置
44
44
  """
45
45
  self.bconfig = bconfig
46
- parser = argparse.ArgumentParser(prog="bingo validate_yml", description="Validate yaml files", add_help=True,
47
- formatter_class=argparse.RawTextHelpFormatter)
46
+ parser = argparse.ArgumentParser(prog=f"{misc.tool_name()} validate_yml", description="Validate yaml files",
47
+ add_help=True, formatter_class=argparse.RawTextHelpFormatter)
48
48
  parser.add_argument("-t", "--target", help="目标文件夹或单个yaml文件,默认当前目录", default=".")
49
49
 
50
50
  parsed_args = parser.parse_args(*args)
bmcgo/logger.py CHANGED
@@ -61,7 +61,7 @@ class CustomFormatter(logging.Formatter):
61
61
 
62
62
 
63
63
  class Logger(logging.Logger):
64
- def __init__(self, name="bmcgo", level=logging.INFO, log_file=None):
64
+ def __init__(self, name="bingo", level=logging.INFO, log_file=None):
65
65
  """初始化一个日志记录器
66
66
 
67
67
  Args:
@@ -79,7 +79,7 @@ class Logger(logging.Logger):
79
79
  ch = logging.FileHandler(filename=log_file)
80
80
  ch.setFormatter(formatter)
81
81
  self.addHandler(ch)
82
- self.is_debug = True
82
+ self.is_debug = True if self.log_level_env else False
83
83
  if self.log_level_env == "info":
84
84
  self.setLevel(logging.INFO)
85
85
  elif self.log_level_env == "warn":
@@ -89,7 +89,6 @@ class Logger(logging.Logger):
89
89
  elif self.log_level_env == "debug":
90
90
  self.setLevel(logging.DEBUG)
91
91
  else:
92
- self.is_debug = False
93
92
  self.setLevel(level)
94
93
  ch = logging.StreamHandler()
95
94
  ch.setFormatter(formatter)
bmcgo/misc.py CHANGED
@@ -11,11 +11,10 @@
11
11
  # See the Mulan PSL v2 for more details.
12
12
  import re
13
13
  import os
14
+ import sys
14
15
  from enum import Enum
15
- from bmcgo import errors
16
- from bmcgo.logger import Logger
16
+ from conan import conan_version
17
17
 
18
- log = Logger("work_prepare")
19
18
 
20
19
  CACHE_DIR = f"{os.path.expanduser('~')}/.bmcgo_log"
21
20
  CONAN_REPO = "openubmc_dev"
@@ -23,7 +22,7 @@ CONAN_USER = 'openUBMC'
23
22
 
24
23
  STORE_TRUE = "store_true"
25
24
  STORE_FALSE = "store_false"
26
- SCHEMA_FILE_PATH = "/usr/share/bmcgo/schema"
25
+ SCHEMA_FILE_PATH = "/usr/share/bingo/schema"
27
26
  GLOBAL_CFG_FILE = "/etc/bmcgo.conf"
28
27
  CONAN = "conan"
29
28
  # bmcgo.conf中用于定义路径的选项名
@@ -103,6 +102,12 @@ HPM_ENCRYPT = "hpm_encrypt"
103
102
  HPM_ENCRYPT_ENABLE = "enable"
104
103
  HPM_ENCRYPT_TOOL = "crypto_tool"
105
104
 
105
+ # CONAN包每一段的正则表达式
106
+ CONAN_NAME_RESTR = "[a-z0-9_][a-z0-9_+.-]{1,100}"
107
+
108
+ # 工具名称
109
+ BINGO_NAME = "bingo"
110
+
106
111
 
107
112
  class StageEnum(Enum):
108
113
  STAGE_DEV = "dev"
@@ -111,9 +116,31 @@ class StageEnum(Enum):
111
116
  STAGE_STABLE = "stable"
112
117
 
113
118
 
114
- class ConanUserEnum(Enum):
115
- CONAN_USER_RELEASE = f'{CONAN_USER}.release'
116
- CONAN_USER_DEV = f'{CONAN_USER}.dev'
119
+ class BuildTypeEnum(Enum):
120
+ DEBUG = "debug"
121
+ RELEASE = "release"
122
+
123
+
124
+ def conan_v1():
125
+ return conan_version.major == 1
126
+
127
+
128
+ def conan_v2():
129
+ return conan_version.major == 2
130
+
131
+
132
+ def build_type():
133
+ bt = ["debug", "release"]
134
+ if conan_v1():
135
+ bt.append("dt")
136
+ return bt
137
+
138
+
139
+ def build_type_str():
140
+ bt = "debug, release"
141
+ if conan_v1():
142
+ bt += ", dt"
143
+ return bt
117
144
 
118
145
 
119
146
  class CommandInfo():
@@ -140,11 +167,105 @@ def get_decleared_schema_file(file) -> str:
140
167
  if match is None:
141
168
  continue
142
169
  schema_file = match.group(1).strip()
143
- log.debug("读取行: " + line)
144
170
  if os.path.isfile(schema_file):
145
171
  return str(schema_file)
172
+ if "/bmcgo/" in schema_file and tool_name() == "bingo":
173
+ bing_schema = schema_file.replace("/bmcgo/", "/bingo/")
174
+ if os.path.isfile(bing_schema):
175
+ return str(bing_schema)
146
176
  schema_file = os.path.join(os.path.dirname(file), schema_file)
147
177
  schema_file = os.path.realpath(schema_file)
148
178
  if os.path.isfile(schema_file):
149
179
  return str(schema_file)
150
- return ""
180
+ return ""
181
+
182
+
183
+ def tool_name() -> str:
184
+ return os.path.basename(sys.argv[0])
185
+
186
+
187
+ def community_name() -> str:
188
+ """
189
+ 返回社区名称,默认为openubmc,可以通过环境变量修改
190
+ """
191
+ return os.environ.get("OPENUBMC_COMMUNITY_NAME", "openubmc")
192
+
193
+
194
+ def conan_user() -> str:
195
+ """
196
+ 返回正式conan包的user字段
197
+ """
198
+ if conan_v1():
199
+ return os.environ.get("OPENUBMC_DEFAULT_CONAN_USER", "openUBMC.release")
200
+ else:
201
+ return os.environ.get("OPENUBMC_DEFAULT_CONAN_USER", "openubmc")
202
+
203
+
204
+ def conan_user_dev() -> str:
205
+ """
206
+ 返回调试conan包的user字段
207
+ """
208
+ if conan_v1():
209
+ return os.environ.get("OPENUBMC_DEFAULT_CONAN_USER", "openUBMC.release")
210
+ else:
211
+ return os.environ.get("OPENUBMC_DEFAULT_CONAN_USER_DEV", "openubmc.dev")
212
+
213
+
214
+ def conan_remote() -> str:
215
+ """
216
+ 返回默认远程仓名
217
+ """
218
+ return os.environ.get("OPENUBMC_DEFAULT_CONAN_REMOTE", "openubmc_dev")
219
+
220
+
221
+ def boardname_default() -> str:
222
+ """
223
+ 返回默认单板名
224
+ """
225
+ return os.environ.get("OPENUBMC_DEFAULT_BOARD_NAME", "openUBMC")
226
+
227
+
228
+ def logo() -> str:
229
+ """
230
+ 返回LOGO
231
+ """
232
+ return os.environ.get("OPENUBMC_DEFAULT_LOGO", "openUBMC")
233
+
234
+
235
+ def boardname_default() -> str:
236
+ """
237
+ 返回默认单板名
238
+ """
239
+ return os.environ.get("OPENUBMC_DEFAULT_BOARD_NAME", "openUBMC")
240
+
241
+
242
+ def schema_path() -> str:
243
+ return os.environ.get("OPENUBMC_SCHEMA_PATH", "/usr/share/bingo/schema")
244
+
245
+
246
+ def vendor() -> str:
247
+ """
248
+ 默认厂商名,用于制作HPM包时使用,生效时的优先级:
249
+ 1. 优先manifest/base/vendor配置
250
+ 2. 再次OPENUBMC_DEFAULT_VENDOR环境变量
251
+ 3. 最后使用社区名
252
+ """
253
+ return os.environ.get("OPENUBMC_DEFAULT_VENDOR", "openUBMC")
254
+
255
+
256
+ def need_encrypt_hpm() -> str:
257
+ """
258
+ 是否需要加密固件
259
+ """
260
+ return os.environ.get("OPENUBMC_ENCRYPTO_HPM_PACKAGE", False)
261
+
262
+
263
+ def conan_package_match(name: str, valid_range=True) -> bool:
264
+ restr = CONAN_NAME_RESTR
265
+ if re.match(f"^{restr}/{restr}@{restr}/{restr}$", name):
266
+ return True
267
+ if valid_range:
268
+ match = re.search('\\[.*\\]', name)
269
+ if match:
270
+ return True
271
+ return False
@@ -0,0 +1,10 @@
1
+ # coding: utf-8
2
+ # Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
+ # openUBMC is licensed under Mulan PSL v2.
4
+ # You can use this software according to the terms and conditions of the Mulan PSL v2.
5
+ # You may obtain a copy of Mulan PSL v2 at:
6
+ # http://license.coscl.org.cn/MulanPSL2
7
+ # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
8
+ # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
9
+ # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
10
+ # See the Mulan PSL v2 for more details.
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ # Copyright (c) 2024 Huawei Technologies Co., Ltd.
4
+ # openUBMC is licensed under Mulan PSL v2.
5
+ # You can use this software according to the terms and conditions of the Mulan PSL v2.
6
+ # You may obtain a copy of Mulan PSL v2 at:
7
+ # http://license.coscl.org.cn/MulanPSL2
8
+ # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
9
+ # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
10
+ # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
11
+ # See the Mulan PSL v2 for more details.
12
+ from conan import ConanFile
13
+ import yaml
14
+
15
+
16
+ class OpenubmcConan(ConanFile):
17
+ name = "openubmc"
18
+ url = "https://www.huawei.com"
19
+ settings = "os", "compiler", "build_type", "arch"
20
+ requires = []
21
+ license = "Mulan PSL v2"
22
+ exports_sources = ["manifest.yml"]
23
+ _manifest = None
24
+
25
+ def init(self):
26
+ with open("manifest.yml", "r") as fp:
27
+ self._manifest = yaml.safe_load(fp)
28
+
29
+ def set_version(self):
30
+ self.version = self._manifest["base"]["version"].lower()
31
+
32
+ def requirements(self):
33
+ for dep in self._manifest.get("dependencies", {}):
34
+ require = dep["conan"] + ""
35
+ self.requires(require)
36
+
37
+ def build(self):
38
+ pass
39
+
40
+ def package(self):
41
+ pass
42
+
43
+ def package_info(self):
44
+ pass
45
+
bmcgo/tasks/task.py CHANGED
@@ -20,13 +20,13 @@ import tempfile
20
20
  import filecmp
21
21
  from string import Template
22
22
  from multiprocessing import Process
23
- from collections import OrderedDict
24
23
 
25
24
  import yaml
26
- from conans.model.profile import Profile
27
25
  from bmcgo.utils.config import Config
28
26
  from bmcgo.utils.tools import Tools
29
27
  from bmcgo import errors
28
+ from bmcgo import misc
29
+ from bmcgo.component.deploy import GraphNode
30
30
  from bmcgo.utils.component_post import ComponentPost
31
31
  from bmcgo.functional.simple_sign import BmcgoCommand as SimpleSign
32
32
 
@@ -40,12 +40,21 @@ class Task(Process):
40
40
 
41
41
  def __init__(self, config: Config, work_name=""):
42
42
  super(Task, self).__init__()
43
+ self.community_name = misc.community_name()
43
44
  log_file = os.path.join(config.temp_path, "log", "task.log")
44
45
  self.tools: Tools = Tools(work_name, log_file=log_file)
45
46
  self.log = self.tools.log
46
47
  self.config: Config = config
47
48
  self.built_type_check()
48
49
  self.work_name = work_name
50
+ # 记录每个组件的GraphNode信息
51
+ self.graph_nodes: dict[str, GraphNode] = {}
52
+ # 设置默认的厂商名,产品可以manifest.yml的base/vendor中设置
53
+ # manifest未配置vendor时,使用OPENUBMC_DEFAULT_VENDOR环境变量
54
+ # OPENUBMC_DEFAULT_VENDOR环境变量未设置时,使用openubmc
55
+ self.vendor = self.get_manufacture_config("base/vendor", misc.vendor())
56
+ os.environ["OPENUBMC_PRODUCT_VENDOR"] = self.vendor
57
+ self.customization_dir = os.path.join(self.config.build_path, "customizations")
49
58
 
50
59
  @property
51
60
  def conan_home(self):
@@ -210,7 +219,7 @@ class Task(Process):
210
219
  """
211
220
  return self.config.get_manufacture_config(key, default_val)
212
221
 
213
- def get_profile_config(self) -> (Profile, OrderedDict):
222
+ def get_profile_config(self):
214
223
  return self.tools.get_profile_config(self.config.profile)
215
224
 
216
225
  def prepare_conan(self):
@@ -320,7 +329,15 @@ class Task(Process):
320
329
  raise OSError(f"未知条件: {key}, 请检查此种条件是否在配置内")
321
330
  return True
322
331
 
323
- def _component_cust_action(self, action: str):
332
+ def _component_cust_action_v2(self, action: str):
333
+ profile, _ = self.get_profile_config()
334
+ for name in os.listdir(self.customization_dir):
335
+ path_dir = os.path.join(self.customization_dir, name)
336
+ self.info(f"开始执行组件 {name} 定制化 {action},定制脚本 {path_dir}/include/customization.py")
337
+ post = ComponentPost(self.config, path_dir, profile)
338
+ post.post_work(os.getcwd(), action)
339
+
340
+ def _component_cust_action_v1(self, action: str):
324
341
  conan_install = f"{self.config.build_path}/conan_install"
325
342
 
326
343
  # 优先处理rootfs定制化脚本
@@ -344,6 +361,12 @@ class Task(Process):
344
361
  post = ComponentPost(self.config, os.path.join(conan_install, comp), profile)
345
362
  post.post_work(os.getcwd(), action)
346
363
 
364
+ def _component_cust_action(self, action: str):
365
+ if misc.conan_v2():
366
+ return self._component_cust_action_v2(action)
367
+ else:
368
+ return self._component_cust_action_v1(action)
369
+
347
370
  def _local_signature(self, unsigned_file, cms_output, crl_output, ca_output):
348
371
  """自签名方法"""
349
372
  self_sign_config = self.config.bconfig.hpm_self_sign