openubmc-bingo 0.5.240__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.
- bmcgo/__init__.py +12 -0
- bmcgo/bmcgo.py +22 -0
- bmcgo/bmcgo_config.py +176 -0
- bmcgo/cli/__init__.py +10 -0
- bmcgo/cli/cli.py +584 -0
- bmcgo/codegen/__init__.py +14 -0
- bmcgo/codegen/c/__init__.py +9 -0
- bmcgo/codegen/c/annotation.py +52 -0
- bmcgo/codegen/c/argument.py +42 -0
- bmcgo/codegen/c/codegen.py +153 -0
- bmcgo/codegen/c/comment.py +22 -0
- bmcgo/codegen/c/ctype_defination.py +353 -0
- bmcgo/codegen/c/helper.py +87 -0
- bmcgo/codegen/c/interface.py +63 -0
- bmcgo/codegen/c/method.py +82 -0
- bmcgo/codegen/c/property.py +180 -0
- bmcgo/codegen/c/renderer.py +21 -0
- bmcgo/codegen/c/signal.py +64 -0
- bmcgo/codegen/c/template/client.c.mako +145 -0
- bmcgo/codegen/c/template/client.h.mako +36 -0
- bmcgo/codegen/c/template/interface.c.mako +0 -0
- bmcgo/codegen/c/template/interface.introspect.xml.mako +99 -0
- bmcgo/codegen/c/template/micro_component.c.mako +32 -0
- bmcgo/codegen/c/template/public.c.mako +228 -0
- bmcgo/codegen/c/template/public.h.mako +128 -0
- bmcgo/codegen/c/template/server.c.mako +104 -0
- bmcgo/codegen/c/template/server.h.mako +36 -0
- bmcgo/codegen/lua/.lua-format +7 -0
- bmcgo/codegen/lua/Makefile +101 -0
- bmcgo/codegen/lua/__init__.py +9 -0
- bmcgo/codegen/lua/codegen.py +171 -0
- bmcgo/codegen/lua/proto/Makefile +87 -0
- bmcgo/codegen/lua/proto/ipmi_types.proto +17 -0
- bmcgo/codegen/lua/proto/types.proto +52 -0
- bmcgo/codegen/lua/script/check_intfs.py +161 -0
- bmcgo/codegen/lua/script/dto/__init__.py +11 -0
- bmcgo/codegen/lua/script/dto/exception.py +53 -0
- bmcgo/codegen/lua/script/dto/kepler_abstract.py +47 -0
- bmcgo/codegen/lua/script/dto/options.py +33 -0
- bmcgo/codegen/lua/script/dto/print_simple.py +19 -0
- bmcgo/codegen/lua/script/dto/redfish_api.py +241 -0
- bmcgo/codegen/lua/script/dto/url_route.py +195 -0
- bmcgo/codegen/lua/script/gen_db_json.py +444 -0
- bmcgo/codegen/lua/script/gen_depends.py +89 -0
- bmcgo/codegen/lua/script/gen_entry.py +263 -0
- bmcgo/codegen/lua/script/gen_feature_json.py +156 -0
- bmcgo/codegen/lua/script/gen_historical_local_db_json.py +88 -0
- bmcgo/codegen/lua/script/gen_intf_json.py +261 -0
- bmcgo/codegen/lua/script/gen_intf_rpc_json.py +575 -0
- bmcgo/codegen/lua/script/gen_ipmi_json.py +485 -0
- bmcgo/codegen/lua/script/gen_mdb_json.py +117 -0
- bmcgo/codegen/lua/script/gen_rpc_msg_json.py +487 -0
- bmcgo/codegen/lua/script/gen_schema.py +302 -0
- bmcgo/codegen/lua/script/ipmi_types_pb2.py +135 -0
- bmcgo/codegen/lua/script/loader/__init__.py +11 -0
- bmcgo/codegen/lua/script/loader/file_utils.py +33 -0
- bmcgo/codegen/lua/script/loader/kepler_abstract_collect.py +79 -0
- bmcgo/codegen/lua/script/loader/kepler_abstract_loader.py +47 -0
- bmcgo/codegen/lua/script/loader/redfish_loader.py +127 -0
- bmcgo/codegen/lua/script/lua_format.py +62 -0
- bmcgo/codegen/lua/script/mds_util.py +385 -0
- bmcgo/codegen/lua/script/merge_model.py +330 -0
- bmcgo/codegen/lua/script/merge_proto_algo.py +85 -0
- bmcgo/codegen/lua/script/proto_loader.py +47 -0
- bmcgo/codegen/lua/script/proto_plugin.py +140 -0
- bmcgo/codegen/lua/script/redfish_source_tree.py +118 -0
- bmcgo/codegen/lua/script/render_utils/__init__.py +38 -0
- bmcgo/codegen/lua/script/render_utils/base.py +25 -0
- bmcgo/codegen/lua/script/render_utils/client_lua.py +98 -0
- bmcgo/codegen/lua/script/render_utils/controller_lua.py +71 -0
- bmcgo/codegen/lua/script/render_utils/db_lua.py +224 -0
- bmcgo/codegen/lua/script/render_utils/error_lua.py +185 -0
- bmcgo/codegen/lua/script/render_utils/factory.py +52 -0
- bmcgo/codegen/lua/script/render_utils/ipmi_lua.py +159 -0
- bmcgo/codegen/lua/script/render_utils/ipmi_message_lua.py +24 -0
- bmcgo/codegen/lua/script/render_utils/mdb_lua.py +177 -0
- bmcgo/codegen/lua/script/render_utils/mdb_register.py +215 -0
- bmcgo/codegen/lua/script/render_utils/message_lua.py +26 -0
- bmcgo/codegen/lua/script/render_utils/messages_lua.py +156 -0
- bmcgo/codegen/lua/script/render_utils/model_lua.py +485 -0
- bmcgo/codegen/lua/script/render_utils/old_model_lua.py +429 -0
- bmcgo/codegen/lua/script/render_utils/plugin_lua.py +38 -0
- bmcgo/codegen/lua/script/render_utils/redfish_proto.py +86 -0
- bmcgo/codegen/lua/script/render_utils/request_lua.py +76 -0
- bmcgo/codegen/lua/script/render_utils/service_lua.py +130 -0
- bmcgo/codegen/lua/script/render_utils/utils_message_lua.py +125 -0
- bmcgo/codegen/lua/script/render_utils/validate_lua.py +221 -0
- bmcgo/codegen/lua/script/sep_ipmi_message_cmds.py +217 -0
- bmcgo/codegen/lua/script/template.py +166 -0
- bmcgo/codegen/lua/script/types_pb2.py +516 -0
- bmcgo/codegen/lua/script/utils.py +663 -0
- bmcgo/codegen/lua/script/validate.py +80 -0
- bmcgo/codegen/lua/script/yaml_to_json.py +73 -0
- bmcgo/codegen/lua/templates/Makefile +114 -0
- bmcgo/codegen/lua/templates/apps/Makefile +261 -0
- bmcgo/codegen/lua/templates/apps/Makefile.mdb.mk +64 -0
- bmcgo/codegen/lua/templates/apps/app.lua.mako +19 -0
- bmcgo/codegen/lua/templates/apps/class.lua.mako +35 -0
- bmcgo/codegen/lua/templates/apps/client.lua.mako +429 -0
- bmcgo/codegen/lua/templates/apps/controller.lua.mako +276 -0
- bmcgo/codegen/lua/templates/apps/datas.lua.mako +8 -0
- bmcgo/codegen/lua/templates/apps/db.lua.mako +89 -0
- bmcgo/codegen/lua/templates/apps/entry.lua.mako +128 -0
- bmcgo/codegen/lua/templates/apps/feature.lua.mako +37 -0
- bmcgo/codegen/lua/templates/apps/generate_route.mako +25 -0
- bmcgo/codegen/lua/templates/apps/impl_feature.lua.mako +72 -0
- bmcgo/codegen/lua/templates/apps/ipmi.lua.mako +97 -0
- bmcgo/codegen/lua/templates/apps/ipmi_cmd.lua.mako +18 -0
- bmcgo/codegen/lua/templates/apps/ipmi_message.lua.mako +36 -0
- bmcgo/codegen/lua/templates/apps/local_db.lua.mako +263 -0
- bmcgo/codegen/lua/templates/apps/main.lua.mako +25 -0
- bmcgo/codegen/lua/templates/apps/mc.lua.mako +77 -0
- bmcgo/codegen/lua/templates/apps/mdb.lua.mako +45 -0
- bmcgo/codegen/lua/templates/apps/mdb_interface.lua.mako +73 -0
- bmcgo/codegen/lua/templates/apps/message.lua.mako +38 -0
- bmcgo/codegen/lua/templates/apps/model.lua.mako +239 -0
- bmcgo/codegen/lua/templates/apps/orm_classes.lua.mako +16 -0
- bmcgo/codegen/lua/templates/apps/plugin.lua.mako +8 -0
- bmcgo/codegen/lua/templates/apps/redfish.proto.mako +47 -0
- bmcgo/codegen/lua/templates/apps/service.lua.mako +440 -0
- bmcgo/codegen/lua/templates/apps/signal_listen.lua.mako +19 -0
- bmcgo/codegen/lua/templates/apps/utils/default_intf.lua.mako +41 -0
- bmcgo/codegen/lua/templates/apps/utils/enum.mako +10 -0
- bmcgo/codegen/lua/templates/apps/utils/imports.mako +13 -0
- bmcgo/codegen/lua/templates/apps/utils/mdb_intf.lua.mako +25 -0
- bmcgo/codegen/lua/templates/apps/utils/mdb_obj.lua.mako +23 -0
- bmcgo/codegen/lua/templates/apps/utils/message.mako +160 -0
- bmcgo/codegen/lua/templates/apps/utils/request.lua.mako +59 -0
- bmcgo/codegen/lua/templates/apps/utils/validate.mako +83 -0
- bmcgo/codegen/lua/templates/errors.lua.mako +36 -0
- bmcgo/codegen/lua/templates/messages.lua.mako +32 -0
- bmcgo/codegen/lua/templates/new_app/.clang-format.mako +170 -0
- bmcgo/codegen/lua/templates/new_app/.gitignore.mako +26 -0
- bmcgo/codegen/lua/templates/new_app/CHANGELOG.md.mako +0 -0
- bmcgo/codegen/lua/templates/new_app/CMakeLists.txt.mako +29 -0
- bmcgo/codegen/lua/templates/new_app/Makefile.mako +25 -0
- bmcgo/codegen/lua/templates/new_app/README.md.mako +0 -0
- bmcgo/codegen/lua/templates/new_app/conanfile.py.mako +7 -0
- bmcgo/codegen/lua/templates/new_app/config.cfg.mako +6 -0
- bmcgo/codegen/lua/templates/new_app/mds/model.json.mako +3 -0
- bmcgo/codegen/lua/templates/new_app/mds/service.json.mako +21 -0
- bmcgo/codegen/lua/templates/new_app/permissions.ini.mako +16 -0
- bmcgo/codegen/lua/templates/new_app/src/lualib/${project_name}_app.lua.mako +16 -0
- bmcgo/codegen/lua/templates/new_app/src/service/main.lua.mako +25 -0
- bmcgo/codegen/lua/templates/new_app/test/integration/test_${project_name}.conf.mako +9 -0
- bmcgo/codegen/lua/templates/new_app/test/integration/test_${project_name}.lua.mako +47 -0
- bmcgo/codegen/lua/templates/new_app/test/unit/test.lua.mako +23 -0
- bmcgo/codegen/lua/templates/new_app/user_conf/rootfs/etc/systemd/system/${project_name}.service.mako +18 -0
- bmcgo/codegen/lua/templates/new_app/user_conf/rootfs/etc/systemd/system/multi-user.target.wants/${project_name}.service.link +1 -0
- bmcgo/component/__init__.py +10 -0
- bmcgo/component/analysis/analysis.py +183 -0
- bmcgo/component/analysis/build_deps.py +165 -0
- bmcgo/component/analysis/data_deps.py +333 -0
- bmcgo/component/analysis/dep-rules.json +912 -0
- bmcgo/component/analysis/dep_node.py +110 -0
- bmcgo/component/analysis/intf_deps.py +163 -0
- bmcgo/component/analysis/intf_validation.py +254 -0
- bmcgo/component/analysis/rule.py +211 -0
- bmcgo/component/analysis/smc_dfx_whitelist.json +11 -0
- bmcgo/component/analysis/sr_validation.py +391 -0
- bmcgo/component/build.py +222 -0
- bmcgo/component/component_dt_version_parse.py +348 -0
- bmcgo/component/component_helper.py +114 -0
- bmcgo/component/coverage/__init__.py +11 -0
- bmcgo/component/coverage/c_incremental_cov_report.template +53 -0
- bmcgo/component/coverage/incremental_cov.py +464 -0
- bmcgo/component/deploy.py +110 -0
- bmcgo/component/gen.py +169 -0
- bmcgo/component/package_info.py +236 -0
- bmcgo/component/template/conanbase.py.mako +278 -0
- bmcgo/component/template/conanfile.deploy.py.mako +40 -0
- bmcgo/component/test.py +947 -0
- bmcgo/errors.py +119 -0
- bmcgo/frame.py +217 -0
- bmcgo/functional/__init__.py +10 -0
- bmcgo/functional/analysis.py +96 -0
- bmcgo/functional/bmc_studio_action.py +98 -0
- bmcgo/functional/check.py +185 -0
- bmcgo/functional/conan_index_build.py +251 -0
- bmcgo/functional/config.py +332 -0
- bmcgo/functional/csr_build.py +724 -0
- bmcgo/functional/deploy.py +263 -0
- bmcgo/functional/diff.py +235 -0
- bmcgo/functional/fetch.py +235 -0
- bmcgo/functional/full_component.py +391 -0
- bmcgo/functional/maintain.py +381 -0
- bmcgo/functional/new.py +166 -0
- bmcgo/functional/schema_valid.py +111 -0
- bmcgo/functional/simple_sign.py +104 -0
- bmcgo/functional/upgrade.py +78 -0
- bmcgo/ipmigen/__init__.py +13 -0
- bmcgo/ipmigen/ctype_defination.py +82 -0
- bmcgo/ipmigen/ipmigen.py +309 -0
- bmcgo/ipmigen/template/cmd.c.mako +366 -0
- bmcgo/ipmigen/template/ipmi.c.mako +25 -0
- bmcgo/ipmigen/template/ipmi.h.mako +51 -0
- bmcgo/logger.py +176 -0
- bmcgo/misc.py +117 -0
- bmcgo/target/app.yml +17 -0
- bmcgo/target/install_sdk.yml +15 -0
- bmcgo/target/personal.yml +53 -0
- bmcgo/target/publish.yml +45 -0
- bmcgo/tasks/__init__.py +11 -0
- bmcgo/tasks/download_buildtools_hm.py +124 -0
- bmcgo/tasks/misc.py +15 -0
- bmcgo/tasks/task.py +354 -0
- bmcgo/tasks/task_build_conan.py +714 -0
- bmcgo/tasks/task_build_rootfs_img.py +595 -0
- bmcgo/tasks/task_buildgppbin.py +88 -0
- bmcgo/tasks/task_buildhpm_ext4.py +82 -0
- bmcgo/tasks/task_create_interface_config.py +122 -0
- bmcgo/tasks/task_download_buildtools.py +99 -0
- bmcgo/tasks/task_download_dependency.py +72 -0
- bmcgo/tasks/task_hpm_envir_prepare.py +112 -0
- bmcgo/tasks/task_packet_to_supporte.py +87 -0
- bmcgo/tasks/task_prepare.py +105 -0
- bmcgo/tasks/task_sign_and_pack_hpm.py +42 -0
- bmcgo/utils/__init__.py +10 -0
- bmcgo/utils/buffer.py +128 -0
- bmcgo/utils/combine_json_schemas.py +170 -0
- bmcgo/utils/component_post.py +54 -0
- bmcgo/utils/component_version_check.py +86 -0
- bmcgo/utils/config.py +1067 -0
- bmcgo/utils/fetch_component_code.py +232 -0
- bmcgo/utils/install_manager.py +61 -0
- bmcgo/utils/installations/__init__.py +10 -0
- bmcgo/utils/installations/base_installer.py +70 -0
- bmcgo/utils/installations/install_consts.py +30 -0
- bmcgo/utils/installations/install_plans/bingo.yml +11 -0
- bmcgo/utils/installations/install_workflow.py +50 -0
- bmcgo/utils/installations/installers/apt_installer.py +177 -0
- bmcgo/utils/installations/installers/pip_installer.py +46 -0
- bmcgo/utils/installations/version_util.py +100 -0
- bmcgo/utils/mapping_config_patch.py +443 -0
- bmcgo/utils/perf_analysis.py +114 -0
- bmcgo/utils/tools.py +704 -0
- bmcgo/worker.py +417 -0
- openubmc_bingo-0.5.240.dist-info/METADATA +30 -0
- openubmc_bingo-0.5.240.dist-info/RECORD +242 -0
- openubmc_bingo-0.5.240.dist-info/WHEEL +5 -0
- openubmc_bingo-0.5.240.dist-info/entry_points.txt +2 -0
- openubmc_bingo-0.5.240.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#!/usr/bin/env 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
|
+
|
|
13
|
+
"""
|
|
14
|
+
文件名:envir_prepare.py
|
|
15
|
+
功能:打包目录形成
|
|
16
|
+
版权信息:华为技术有限公司,版本所有(C) 2020-2021
|
|
17
|
+
"""
|
|
18
|
+
import os
|
|
19
|
+
import json
|
|
20
|
+
import shutil
|
|
21
|
+
import jsonschema
|
|
22
|
+
import yaml
|
|
23
|
+
from bmcgo.tasks.task import Task
|
|
24
|
+
from bmcgo import misc
|
|
25
|
+
from bmcgo import errors
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class TaskClass(Task):
|
|
29
|
+
# 构建AdaptiveLM依赖xmllint
|
|
30
|
+
def check_xmllint(self):
|
|
31
|
+
ret = self.run_command("xmllint --version", ignore_error=True)
|
|
32
|
+
if ret.returncode != 0:
|
|
33
|
+
self.run_command("apt install -y libxml2-utils", sudo=True)
|
|
34
|
+
ret = self.run_command("ls /usr/bin/tclsh", ignore_error=True)
|
|
35
|
+
if ret.returncode != 0:
|
|
36
|
+
self.run_command("apt install -y tclsh", sudo=True)
|
|
37
|
+
ret = self.run_command("ls /usr/bin/w3m", ignore_error=True)
|
|
38
|
+
if ret.returncode != 0:
|
|
39
|
+
self.run_command("apt install -y w3m", sudo=True)
|
|
40
|
+
|
|
41
|
+
def build_config_check(self):
|
|
42
|
+
# 不支持生产装备出包
|
|
43
|
+
if self.config.manufacture_code is None:
|
|
44
|
+
key = f"tosupporte/{self.config.tosupporte_code}"
|
|
45
|
+
supporte_cfg = self.get_manufacture_config(key)
|
|
46
|
+
if supporte_cfg is None:
|
|
47
|
+
raise errors.ConfigException(f"参数 -sc 错误, 配置 (manifest.yml: {key}) 错误 !!!!")
|
|
48
|
+
key += "/package_name"
|
|
49
|
+
package_name = self.get_manufacture_config(key)
|
|
50
|
+
if package_name is None:
|
|
51
|
+
raise errors.ConfigException(f"获取包名错误, 配置 (manifest.yml: {key}) 错误 !!!!")
|
|
52
|
+
return
|
|
53
|
+
manufacture = self.get_manufacture_config("manufacture")
|
|
54
|
+
if manufacture is None:
|
|
55
|
+
raise errors.ConfigException("manufacture 编码(-z 编码) 无法被设置")
|
|
56
|
+
|
|
57
|
+
codes = list(manufacture.keys())
|
|
58
|
+
if self.config.manufacture_code not in codes:
|
|
59
|
+
raise errors.ConfigException("manifest.yml 中 manufacture 错误, 可以被设置为: {}".format(codes))
|
|
60
|
+
|
|
61
|
+
pkg_name_key = f"manufacture/{self.config.manufacture_code}/package_name"
|
|
62
|
+
package_name = self.get_manufacture_config(pkg_name_key)
|
|
63
|
+
if package_name is None:
|
|
64
|
+
raise errors.ConfigException("manifest.yml 中 package_name 属性丢失, manufacture: {}".format(package_name))
|
|
65
|
+
|
|
66
|
+
def run_signature_prepare(self):
|
|
67
|
+
self.chdir(self.config.board_path)
|
|
68
|
+
if self.config.sign_certificates is None:
|
|
69
|
+
# 复制签名需要使用的文件
|
|
70
|
+
files = self.get_manufacture_config(f"base/signature/files")
|
|
71
|
+
if files is None:
|
|
72
|
+
raise errors.ConfigException("获取manifest.yml中base/signature/files失败, 请检查相关配置或生成是否正确")
|
|
73
|
+
self.copy_manifest_files(files)
|
|
74
|
+
|
|
75
|
+
def schema_subsys_valid(self, stage):
|
|
76
|
+
for subsys_file in os.listdir(os.path.join(self.config.code_path, "subsys", stage)):
|
|
77
|
+
file = os.path.join(self.config.code_path, "subsys", stage, subsys_file)
|
|
78
|
+
self.debug("开始校验 %s", file)
|
|
79
|
+
if not os.path.isfile(file):
|
|
80
|
+
continue
|
|
81
|
+
schema_file = misc.get_decleared_schema_file(file)
|
|
82
|
+
if schema_file == "":
|
|
83
|
+
raise errors.BmcGoException(f"schema校验文件{schema_file}未找到,本机绝对路径存储的schema文件且保证文件已存在")
|
|
84
|
+
with open(schema_file, "rb") as fp:
|
|
85
|
+
schema = json.load(fp)
|
|
86
|
+
fp = open(file, "rb")
|
|
87
|
+
subsys = yaml.safe_load(fp)
|
|
88
|
+
fp.close()
|
|
89
|
+
self.debug("开始校验 %s", file)
|
|
90
|
+
jsonschema.validate(subsys, schema)
|
|
91
|
+
|
|
92
|
+
def schema_valid(self):
|
|
93
|
+
if self.config.target != "publish":
|
|
94
|
+
return
|
|
95
|
+
self.schema_subsys_valid("rc")
|
|
96
|
+
self.schema_subsys_valid("stable")
|
|
97
|
+
|
|
98
|
+
def run(self):
|
|
99
|
+
self.built_type_check()
|
|
100
|
+
self.prepare_conan()
|
|
101
|
+
self.check_xmllint()
|
|
102
|
+
self.build_config_check()
|
|
103
|
+
self.run_signature_prepare()
|
|
104
|
+
self.schema_valid()
|
|
105
|
+
self.config.dump_manifest()
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env 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
|
+
|
|
13
|
+
import os
|
|
14
|
+
from bmcgo.tasks.task import Task
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class TaskClass(Task):
|
|
18
|
+
def sign_hpms(self):
|
|
19
|
+
self.chdir(self.config.work_out)
|
|
20
|
+
if self.config.sign_certificates is not None:
|
|
21
|
+
self.chdir(self.config.work_out)
|
|
22
|
+
# 复制预置的ca, crl作为签名文件,并复制cms
|
|
23
|
+
self.signature(f"rootfs_{self.config.board_name}.filelist",
|
|
24
|
+
f"rootfs_{self.config.board_name}.filelist.cms",
|
|
25
|
+
"cms.crl", "rootca.der")
|
|
26
|
+
else:
|
|
27
|
+
self.run_command(f"touch {self.config.work_out}/rootfs_{self.config.board_name}.filelist.cms")
|
|
28
|
+
self.run_command(f"cp {self.config.board_path}/cms.crl {self.config.work_out}/cms.crl")
|
|
29
|
+
self.chdir(self.config.work_out)
|
|
30
|
+
|
|
31
|
+
# 生成的文件为rootfs_{board_name}.hpm.signed
|
|
32
|
+
self.info(f"给 hpm 包 rootfs_{self.config.board_name}.hpm 签名")
|
|
33
|
+
self.run_command(f"cms_sign_hpm.sh 2 rootfs_{self.config.board_name}.hpm")
|
|
34
|
+
if self.config.enable_arm_gcov:
|
|
35
|
+
self.link(f"rootfs_{self.config.board_name}.hpm.signed", os.path.join(
|
|
36
|
+
self.config.inner_path, f"{self.config.board_name}_gcov.hpm"))
|
|
37
|
+
else:
|
|
38
|
+
self.link(f"rootfs_{self.config.board_name}.hpm.signed", os.path.join(
|
|
39
|
+
self.config.output_path, f"rootfs_{self.config.board_name}.hpm"))
|
|
40
|
+
|
|
41
|
+
def run(self):
|
|
42
|
+
self.sign_hpms()
|
bmcgo/utils/__init__.py
ADDED
|
@@ -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.
|
bmcgo/utils/buffer.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# Copyright © Huawei Technologies Co., Ltd. 2025. All rights reserved.
|
|
4
|
+
|
|
5
|
+
MAX_BUFFER_LENGTH = 4 * 1024 * 1024 * 1024
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class BufferOverflowException(Exception):
|
|
9
|
+
def __init__(self, message="The data to be input to buffer is out of range."):
|
|
10
|
+
super().__init__(message)
|
|
11
|
+
|
|
12
|
+
def get_class_name(self):
|
|
13
|
+
return "BufferOverflowException"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Buffer:
|
|
17
|
+
def __init__(self, buf_len: int, little_endian: bool = True):
|
|
18
|
+
if buf_len > MAX_BUFFER_LENGTH:
|
|
19
|
+
self.buf = bytearray(MAX_BUFFER_LENGTH)
|
|
20
|
+
elif buf_len > 0:
|
|
21
|
+
self.buf = bytearray(buf_len)
|
|
22
|
+
else:
|
|
23
|
+
raise ValueError(f"Invalid buffer length: buf_len={buf_len}")
|
|
24
|
+
self.size = len(self.buf)
|
|
25
|
+
self.pos = 0
|
|
26
|
+
self.marker = -1
|
|
27
|
+
self.bo = little_endian
|
|
28
|
+
|
|
29
|
+
def capacity(self):
|
|
30
|
+
# 字节缓冲区容量
|
|
31
|
+
return self.size
|
|
32
|
+
|
|
33
|
+
def position(self):
|
|
34
|
+
# 此缓冲区当前输入位置
|
|
35
|
+
return self.pos
|
|
36
|
+
|
|
37
|
+
def set_position(self, new_pos: int):
|
|
38
|
+
# 设置此缓冲区输入位置
|
|
39
|
+
if new_pos > self.size or new_pos < 0:
|
|
40
|
+
raise ValueError("Position out of range")
|
|
41
|
+
self.pos = new_pos
|
|
42
|
+
|
|
43
|
+
def put(self, b: bytearray):
|
|
44
|
+
# 将字节数组写入当前位置的缓冲区并递增位置
|
|
45
|
+
if len(b) > self.size - self.pos:
|
|
46
|
+
raise BufferOverflowException()
|
|
47
|
+
if self.bo:
|
|
48
|
+
self.buf[self.pos:self.pos + len(b)] = b
|
|
49
|
+
else:
|
|
50
|
+
self.buf[self.pos:self.pos + len(b)] = b[::-1]
|
|
51
|
+
self.pos += len(b)
|
|
52
|
+
|
|
53
|
+
def put_uint8(self, v: int):
|
|
54
|
+
# 按当前字节顺序将1字节无符号整数写入此缓冲区,位置递增1
|
|
55
|
+
if self.size - self.pos < 1:
|
|
56
|
+
raise BufferOverflowException()
|
|
57
|
+
self.buf[self.pos] = v
|
|
58
|
+
self.pos += 1
|
|
59
|
+
|
|
60
|
+
def put_uint16(self, v: int):
|
|
61
|
+
# 按当前字节顺序将一个2字节无符号整数写入此缓冲区,位置递增2
|
|
62
|
+
if self.size - self.pos < 2:
|
|
63
|
+
raise BufferOverflowException()
|
|
64
|
+
n = v
|
|
65
|
+
start = self.pos
|
|
66
|
+
for i in range(2):
|
|
67
|
+
if self.bo:
|
|
68
|
+
self.buf[self.pos] = n & 0xFF
|
|
69
|
+
else:
|
|
70
|
+
self.buf[start + 1 - i] = n & 0xFF
|
|
71
|
+
n >>= 8
|
|
72
|
+
self.pos += 1
|
|
73
|
+
|
|
74
|
+
def put_uint32(self, v: int):
|
|
75
|
+
#按当前字节顺序将一个4字节无符号整数写入此缓冲区,位置递增4
|
|
76
|
+
if self.size - self.pos < 4:
|
|
77
|
+
raise BufferOverflowException()
|
|
78
|
+
n = v
|
|
79
|
+
start = self.pos
|
|
80
|
+
for i in range(4):
|
|
81
|
+
if self.bo:
|
|
82
|
+
self.buf[self.pos] = n & 0xFF
|
|
83
|
+
else:
|
|
84
|
+
self.buf[start + 3 - i] = n & 0xFF
|
|
85
|
+
n >>= 8
|
|
86
|
+
self.pos += 1
|
|
87
|
+
|
|
88
|
+
def put_uint64(self, v: int):
|
|
89
|
+
# 按当前字节顺序将一个8字节无符号整数写入此缓冲区,位置递增8
|
|
90
|
+
if self.size - self.pos < 8:
|
|
91
|
+
raise BufferOverflowException()
|
|
92
|
+
n = v
|
|
93
|
+
if self.bo:
|
|
94
|
+
self.put_uint32(n & 0xFFFFFFFF)
|
|
95
|
+
self.put_uint32(n >> 32)
|
|
96
|
+
else:
|
|
97
|
+
start = self.pos
|
|
98
|
+
for i in range(8):
|
|
99
|
+
self.buf[start + 7 - i] = n & 0xFF
|
|
100
|
+
n >>= 8
|
|
101
|
+
self.pos += 1
|
|
102
|
+
|
|
103
|
+
def mark(self):
|
|
104
|
+
# 将此缓冲区的标记设置在其位置
|
|
105
|
+
self.marker = self.pos
|
|
106
|
+
return self
|
|
107
|
+
|
|
108
|
+
def reset(self):
|
|
109
|
+
# 将此缓冲区的位置重置为先前标记的位置
|
|
110
|
+
if self.marker < 0:
|
|
111
|
+
raise BufferOverflowException("The marker of buffer is invalid.")
|
|
112
|
+
self.pos = self.marker
|
|
113
|
+
return self
|
|
114
|
+
|
|
115
|
+
def clean(self):
|
|
116
|
+
# 重置此缓冲区位置及标志位
|
|
117
|
+
self.pos = 0
|
|
118
|
+
self.marker = -1
|
|
119
|
+
return self
|
|
120
|
+
|
|
121
|
+
def array(self):
|
|
122
|
+
# 返回缓冲区的字节数组
|
|
123
|
+
return self.buf
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def round_up_data_size(data_size: int) -> int:
|
|
127
|
+
# 对齐数据字节量为8的倍数
|
|
128
|
+
return ((data_size + 7) // 8) * 8
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
#!/usr/bin/env 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
|
+
|
|
13
|
+
import os
|
|
14
|
+
import json
|
|
15
|
+
import stat
|
|
16
|
+
from collections import OrderedDict
|
|
17
|
+
from bmcgo.tasks.task import Task
|
|
18
|
+
from bmcgo.logger import Logger
|
|
19
|
+
|
|
20
|
+
log = Logger("combine_json_schemas")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class CombineJsonSchemas(Task):
|
|
24
|
+
'''
|
|
25
|
+
用途: 支持产品定制差异化json schema文件, 用于产品扩展装备定制化的默认值和属性
|
|
26
|
+
说明:
|
|
27
|
+
1、该脚本在构建阶段整合组件原始schema和产品差异化schema文件, 同时生成装备定制化默认配置default_settings.json
|
|
28
|
+
2、json schema文件来自装备定制化定义的schema文件(复用配置导入导出schema文件)
|
|
29
|
+
3、该脚本属于装备定制化处理产品差异的通用机制, 虽然与产品有关, 但是脚本本身不处理产品差异(由一级流水线完成产品差异处理)
|
|
30
|
+
'''
|
|
31
|
+
def __init__(self, config, schema_path, work_name=""):
|
|
32
|
+
super(CombineJsonSchemas, self).__init__(config, work_name)
|
|
33
|
+
self.schema_path = schema_path
|
|
34
|
+
self.custom_path_name = "custom"
|
|
35
|
+
self.default_settings = "default_settings.json"
|
|
36
|
+
self.config = config
|
|
37
|
+
self.schema_tmp = os.path.join(config.build_path, "profile_schema")
|
|
38
|
+
|
|
39
|
+
def handle_type_change(self, dict1, dict2):
|
|
40
|
+
# 键值相同,但是类型由object变化为array
|
|
41
|
+
if "type" in dict1 and dict1["type"] == "object" and dict2["type"] == "array":
|
|
42
|
+
dict1.pop("properties")
|
|
43
|
+
# 键值相同,但是类型由array变化为object
|
|
44
|
+
if "type" in dict1 and dict1["type"] == "array" and dict2["type"] == "object":
|
|
45
|
+
dict1.pop("items")
|
|
46
|
+
|
|
47
|
+
# 将dict2合并到dict1
|
|
48
|
+
def merge_dicts(self, dict1, dict2):
|
|
49
|
+
for key, value in dict2.items():
|
|
50
|
+
if key in dict1 and isinstance(dict1[key], dict) and isinstance(value, dict):
|
|
51
|
+
# 处理键值相同,但是类型发生变化的情况
|
|
52
|
+
self.handle_type_change(dict1[key], value)
|
|
53
|
+
self.merge_dicts(dict1[key], value)
|
|
54
|
+
else:
|
|
55
|
+
dict1[key] = value
|
|
56
|
+
|
|
57
|
+
def has_key(self, dict_ins, key_str):
|
|
58
|
+
if not dict_ins:
|
|
59
|
+
return False
|
|
60
|
+
|
|
61
|
+
if not isinstance(dict_ins, dict):
|
|
62
|
+
return False
|
|
63
|
+
|
|
64
|
+
return key_str in dict_ins.keys()
|
|
65
|
+
|
|
66
|
+
# 递归解析schema内部结构
|
|
67
|
+
def rec_parse(self, data):
|
|
68
|
+
if data['type'] == 'array': # 定制数据是明确的条目,配置不存在于数组中
|
|
69
|
+
return {}
|
|
70
|
+
|
|
71
|
+
if data['type'] == 'object':
|
|
72
|
+
sub_objs = data['properties']
|
|
73
|
+
ret_data = OrderedDict()
|
|
74
|
+
for key in sub_objs:
|
|
75
|
+
tmp = self.rec_parse(sub_objs[key])
|
|
76
|
+
if tmp != {}:
|
|
77
|
+
ret_data[key] = tmp
|
|
78
|
+
|
|
79
|
+
return ret_data
|
|
80
|
+
|
|
81
|
+
if self.has_key(data, 'CustomDefault'):
|
|
82
|
+
return {'AttributeType':'ImportAndExport', 'Import': True, 'Value': data['CustomDefault']}
|
|
83
|
+
|
|
84
|
+
return {}
|
|
85
|
+
|
|
86
|
+
def load_schema(self, path, product_schema_path, com_obj):
|
|
87
|
+
# 临时的产品schema路径下无需求处理
|
|
88
|
+
if product_schema_path == os.path.dirname(path):
|
|
89
|
+
return
|
|
90
|
+
with open(path, 'r') as handle:
|
|
91
|
+
data = json.load(handle, object_pairs_hook=OrderedDict)
|
|
92
|
+
tmp = self.rec_parse(data['properties']['ConfigData'])
|
|
93
|
+
if tmp != {}:
|
|
94
|
+
com_obj['ConfigData'] = tmp
|
|
95
|
+
|
|
96
|
+
def load_json_file(self, json_file):
|
|
97
|
+
with open(json_file) as f:
|
|
98
|
+
return json.load(f, object_pairs_hook=OrderedDict)
|
|
99
|
+
|
|
100
|
+
def save_json_file(self, json_file, mode, json_dict):
|
|
101
|
+
log.info(f"保存 json 文件: {json_file}")
|
|
102
|
+
with os.fdopen(os.open(json_file, os.O_WRONLY | os.O_CREAT | os.O_TRUNC,
|
|
103
|
+
stat.S_IWUSR | stat.S_IRUSR), 'w') as fp:
|
|
104
|
+
json.dump(json_dict, fp, indent=4)
|
|
105
|
+
self.run_command(f"chmod {mode} {json_file}")
|
|
106
|
+
|
|
107
|
+
# 将原始schema文件和产品差异化schema文件结合后生成组件新的schema文件
|
|
108
|
+
def regenerate_schema(self, path, product_schema_path, origin_schema):
|
|
109
|
+
# 不存在产品差异化schema时则无需处理; 临时的产品schema路径下无需求处理
|
|
110
|
+
if not os.path.exists(product_schema_path) or product_schema_path == os.path.dirname(path):
|
|
111
|
+
return
|
|
112
|
+
product_schemas = sorted(os.listdir(product_schema_path))
|
|
113
|
+
# 存在与原始schema名称一致的产品差异化schema文件时,合并schema文件
|
|
114
|
+
if origin_schema in product_schemas:
|
|
115
|
+
origin_dict = self.load_json_file(os.path.join(path, origin_schema))
|
|
116
|
+
product_dict = self.load_json_file(os.path.join(product_schema_path, origin_schema))
|
|
117
|
+
self.merge_dicts(origin_dict, product_dict)
|
|
118
|
+
self.save_json_file(os.path.join(path, origin_schema), 440, origin_dict)
|
|
119
|
+
|
|
120
|
+
# 遍历所有schema文件
|
|
121
|
+
def walk_schema(self, path, product_schema_path, com_objs):
|
|
122
|
+
files = sorted(os.listdir(path))
|
|
123
|
+
for file in files:
|
|
124
|
+
sub_path = os.path.join(path, file)
|
|
125
|
+
if os.path.isdir(sub_path):
|
|
126
|
+
self.walk_schema(sub_path, product_schema_path, com_objs)
|
|
127
|
+
else:
|
|
128
|
+
seps = file.split('.')
|
|
129
|
+
if seps[1] != 'json':
|
|
130
|
+
continue
|
|
131
|
+
self.regenerate_schema(path, product_schema_path, file)
|
|
132
|
+
app_name = seps[0]
|
|
133
|
+
if not self.has_key(com_objs, app_name):
|
|
134
|
+
com_objs[app_name] = {}
|
|
135
|
+
|
|
136
|
+
self.load_schema(sub_path, product_schema_path, com_objs[app_name])
|
|
137
|
+
|
|
138
|
+
def gen_default_settings(self):
|
|
139
|
+
log.info(f"开始生成配置: {self.default_settings}")
|
|
140
|
+
if not os.path.isdir(self.schema_path):
|
|
141
|
+
raise Exception('schema 文件的目标必须为文件夹')
|
|
142
|
+
|
|
143
|
+
# 1.准备临时目录,支持非root构建
|
|
144
|
+
# 清理临时schema路径, 防止上次构建失败导致路径残留
|
|
145
|
+
if os.path.exists(self.schema_tmp):
|
|
146
|
+
self.run_command(f"rm -rf {self.schema_tmp}", sudo=True)
|
|
147
|
+
# 拷贝schema路径到构建临时路径
|
|
148
|
+
self.run_command(f"cp -r {self.schema_path} {self.config.build_path}", sudo=True)
|
|
149
|
+
# 修改权限为当前用户
|
|
150
|
+
user_group = f"{os.getuid()}:{os.getgid()}"
|
|
151
|
+
self.run_command(f"chown -R {user_group} {self.schema_tmp}", sudo=True)
|
|
152
|
+
self.run_command(f"chmod -R 750 {self.schema_tmp}", sudo=True) # 增加写权限, 防止创建子目录失败
|
|
153
|
+
# 创建custom路径存放默认配置
|
|
154
|
+
custom_tmp = os.path.join(self.schema_tmp, self.custom_path_name)
|
|
155
|
+
if not os.path.exists(custom_tmp):
|
|
156
|
+
self.run_command(f"mkdir {custom_tmp}")
|
|
157
|
+
self.run_command(f"chmod +w {custom_tmp}") # 增加写权限, 保存default_settings.json
|
|
158
|
+
|
|
159
|
+
# 2.整合schema文件
|
|
160
|
+
product_schema_tmp = os.path.join(self.schema_tmp, "product")
|
|
161
|
+
com_objs = OrderedDict()
|
|
162
|
+
ret_data = {'Components': com_objs}
|
|
163
|
+
self.walk_schema(self.schema_tmp, product_schema_tmp, com_objs)
|
|
164
|
+
self.save_json_file(os.path.join(custom_tmp, self.default_settings), 440, ret_data)
|
|
165
|
+
|
|
166
|
+
# 3.拷贝整合后的schema文件到源目录
|
|
167
|
+
self.run_command(f"cp -rf {self.schema_tmp}/. {self.schema_path}", sudo=True)
|
|
168
|
+
self.run_command(f"chmod 550 {os.path.join(self.schema_path, self.custom_path_name)}", sudo=True)
|
|
169
|
+
# 4.清理临时目录
|
|
170
|
+
self.run_command(f"rm -rf {self.schema_tmp}", sudo=True)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env 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
|
+
|
|
13
|
+
"""
|
|
14
|
+
文件名:component_post.py
|
|
15
|
+
功能:获取对应路径下的python脚本,并执行其中的方法
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
import os
|
|
19
|
+
import importlib
|
|
20
|
+
import sys
|
|
21
|
+
from inspect import getmembers, isfunction
|
|
22
|
+
|
|
23
|
+
from conans.model.profile import Profile
|
|
24
|
+
from bmcgo.utils.config import Config
|
|
25
|
+
from bmcgo.utils.tools import Tools
|
|
26
|
+
from bmcgo.logger import Logger
|
|
27
|
+
|
|
28
|
+
log = Logger("component_post")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ComponentPost():
|
|
32
|
+
def __init__(self, config: Config, component_path, profile: Profile):
|
|
33
|
+
sys.path.insert(0, os.path.dirname(component_path))
|
|
34
|
+
cust_py = importlib.import_module(f"{os.path.basename(component_path)}.include.customization", "customization")
|
|
35
|
+
self.cust_cls = getattr(cust_py, "Customization")
|
|
36
|
+
self.config = config
|
|
37
|
+
self.component_path = component_path
|
|
38
|
+
self.profile = profile
|
|
39
|
+
|
|
40
|
+
def post_work(self, work_path, func_name):
|
|
41
|
+
if Tools.has_kwargs(self.cust_cls.__init__):
|
|
42
|
+
# 支持组件新的Customization的__init__(board_name, rootfs_path, **kwargs)
|
|
43
|
+
real_post = self.cust_cls(self.config.board_name, work_path, profile=self.profile)
|
|
44
|
+
else:
|
|
45
|
+
# 兼容之前组件Customization的__init__(board_name, rootfs_path)
|
|
46
|
+
real_post = self.cust_cls(self.config.board_name, work_path)
|
|
47
|
+
func_tuple_list = getmembers(self.cust_cls, isfunction)
|
|
48
|
+
func_list = [func_tuple_list[i][0] for i in range(len(func_tuple_list))]
|
|
49
|
+
if func_name not in func_list:
|
|
50
|
+
log.info(f"组件 {os.path.basename(self.component_path)} 中没有 {func_name} 方法")
|
|
51
|
+
else:
|
|
52
|
+
getattr(real_post, func_name)()
|
|
53
|
+
log.info(f"组件 {os.path.basename(self.component_path)} {func_name} 执行完成")
|
|
54
|
+
sys.path.pop(0)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env 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
|
+
|
|
13
|
+
"""
|
|
14
|
+
文件名: work_component_version_check.py
|
|
15
|
+
功能: 对比manifest.yml生成的组件清单和自动生成的清单是否一致
|
|
16
|
+
注意: 这个文件名为work, 但不继承 Task 类 !!!!!!
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
import json
|
|
20
|
+
|
|
21
|
+
import yaml
|
|
22
|
+
|
|
23
|
+
from bmcgo.logger import Logger
|
|
24
|
+
from bmcgo import misc
|
|
25
|
+
|
|
26
|
+
log = Logger("component_version_check")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class ComponentVersionCheck:
|
|
30
|
+
"""类方法中的 manifest.yml 是有两个含义, conan 目录和单板目录, 均已注明
|
|
31
|
+
conan 目录的 manifest.yml 文件是由单板目录下的 manifest.yml 自动生成的
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
def __init__(self, manifest_yml: str, ibmc_lock: str):
|
|
35
|
+
"""读取 manifest.yml(conan目录) 文件与 openubmc.lock 文件
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
manifest_yml (str): manifest.yml文件路径
|
|
39
|
+
ibmc_lock (str): openubmc.lock文件路径
|
|
40
|
+
"""
|
|
41
|
+
with open(manifest_yml, "r") as manifest_fp:
|
|
42
|
+
self.manifest = yaml.safe_load(manifest_fp)
|
|
43
|
+
with open(ibmc_lock, "r") as ibmc_lock_fp:
|
|
44
|
+
self.ibmc_lock = json.load(ibmc_lock_fp)
|
|
45
|
+
|
|
46
|
+
def generate_manifest_dict(self) -> dict:
|
|
47
|
+
"""根据 manifest.yml(conan目录) 配置生成 组件名: 组件配置 的字典
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
dict: 返回 组件名: 组件配置 的字典
|
|
51
|
+
"""
|
|
52
|
+
dependency_list = self.manifest[misc.CONAN_DEPDENCIES_KEY]
|
|
53
|
+
manifest_dict = {x[misc.CONAN].split('/')[0]: x[misc.CONAN].split('@')[0] for x in dependency_list}
|
|
54
|
+
return manifest_dict
|
|
55
|
+
|
|
56
|
+
def generate_ibmc_lock_dict(self) -> dict:
|
|
57
|
+
"""根据 ibmc.lock 配置生成 组件名: 组件配置 的字典
|
|
58
|
+
|
|
59
|
+
Returns:
|
|
60
|
+
dict: 返回 组件名: 组件配置 的字典
|
|
61
|
+
"""
|
|
62
|
+
component_list = self.ibmc_lock["graph_lock"]["nodes"]
|
|
63
|
+
ibmc_lock_dict = {x["ref"].split('/')[0]: x["ref"].split('@')[0]
|
|
64
|
+
for x in [component_conf for _, component_conf in component_list.items()]}
|
|
65
|
+
ibmc_lock_dict.pop("openubmc")
|
|
66
|
+
return ibmc_lock_dict
|
|
67
|
+
|
|
68
|
+
def run(self):
|
|
69
|
+
"""检查所有组件是否都在 manifest.yml(单板目录下) 中配置了
|
|
70
|
+
"""
|
|
71
|
+
manifest_dict = self.generate_manifest_dict()
|
|
72
|
+
ibmc_lock_dict = self.generate_ibmc_lock_dict()
|
|
73
|
+
# 这里使用报错退出, 为防止有多个组件未配置, 报错在方法结束后触发
|
|
74
|
+
report_error = False
|
|
75
|
+
for key, version in ibmc_lock_dict.items():
|
|
76
|
+
if key not in manifest_dict.keys():
|
|
77
|
+
log.error(f"{version} 组件没有在manifest中配置!!!!!!")
|
|
78
|
+
report_error = True
|
|
79
|
+
elif version != manifest_dict[key]:
|
|
80
|
+
log.error(f"{version} 组件版本与manifest中配置{manifest_dict[key]}不匹配!!!!!!")
|
|
81
|
+
report_error = True
|
|
82
|
+
|
|
83
|
+
if report_error is True:
|
|
84
|
+
raise AttributeError
|
|
85
|
+
else:
|
|
86
|
+
log.info("所有组件均已在manifest中配置")
|