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,185 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# encoding=utf-8
|
|
3
|
+
# 描述:BMC Studio语法正确性与模型一致性检查
|
|
4
|
+
# Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
5
|
+
# openUBMC is licensed under Mulan PSL v2.
|
|
6
|
+
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
7
|
+
# You may obtain a copy of Mulan PSL v2 at:
|
|
8
|
+
# http://license.coscl.org.cn/MulanPSL2
|
|
9
|
+
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
10
|
+
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
11
|
+
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
12
|
+
# See the Mulan PSL v2 for more details.
|
|
13
|
+
import argparse
|
|
14
|
+
import json
|
|
15
|
+
import os
|
|
16
|
+
import subprocess
|
|
17
|
+
import tempfile
|
|
18
|
+
from datetime import datetime, timedelta, timezone
|
|
19
|
+
|
|
20
|
+
from git import Repo
|
|
21
|
+
|
|
22
|
+
from bmcgo.codegen.c.helper import Helper
|
|
23
|
+
from bmcgo.utils.tools import Tools
|
|
24
|
+
from bmcgo.bmcgo_config import BmcgoConfig
|
|
25
|
+
from bmcgo.utils.fetch_component_code import FetchComponentCode
|
|
26
|
+
from bmcgo import misc
|
|
27
|
+
from bmcgo.functional.fetch import BmcgoCommand as FetchAgent
|
|
28
|
+
|
|
29
|
+
log = Tools().log
|
|
30
|
+
cwd = os.getcwd()
|
|
31
|
+
command_info: misc.CommandInfo = misc.CommandInfo(
|
|
32
|
+
group=misc.GRP_STUDIO,
|
|
33
|
+
name="check",
|
|
34
|
+
description=["BMC Studio语法正确性与模型一致性检查"],
|
|
35
|
+
hidden=False
|
|
36
|
+
)
|
|
37
|
+
ISSUE_TEMPLATE = '''问题{0}:
|
|
38
|
+
【规则名称】{1}
|
|
39
|
+
【文件路径】{2}
|
|
40
|
+
【错误提示】{3}
|
|
41
|
+
【修复建议】{4}
|
|
42
|
+
'''
|
|
43
|
+
_PACKAGE_INFO_HELP = """
|
|
44
|
+
1. 通过组件包名及版本拉取单个组件代码,格式:package/version@user/channel
|
|
45
|
+
2. 通过配置文件拉取部分指定版本的组件代码。支持一下2种配置文件:
|
|
46
|
+
a. yml格式
|
|
47
|
+
dependencies:
|
|
48
|
+
- conan: "package/version@user/channel"
|
|
49
|
+
b. 文本格式
|
|
50
|
+
package/version@user/channel
|
|
51
|
+
"""
|
|
52
|
+
MODEL_CHOICES = ["all", "mds", "resource_tree", "csr", "interface_mapping"]
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def if_available(bconfig: BmcgoConfig):
|
|
56
|
+
return True
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class BmcgoCommand:
|
|
60
|
+
def __init__(self, bconfig: BmcgoConfig, *args):
|
|
61
|
+
self.bconfig = bconfig
|
|
62
|
+
parser = argparse.ArgumentParser(prog="bmcgo check", description="语法正确性与模型一致性检查", add_help=True,
|
|
63
|
+
formatter_class=argparse.RawTextHelpFormatter)
|
|
64
|
+
parser.add_argument("-b", "--board_name", help="指定单板获取配套全量源码,可选值为build/product目录下的单板名\n默认:openUBMC",
|
|
65
|
+
default="openUBMC")
|
|
66
|
+
parser.add_argument("--stage", help="包类型,可选值为:rc(预发布包), stable(发布包)\n默认: stable", default="stable")
|
|
67
|
+
parser.add_argument("-r", "--remote")
|
|
68
|
+
parser.add_argument("-m", "--model", help=f"检查的模型,可选值为: {', '.join(MODEL_CHOICES)}\n默认: all",
|
|
69
|
+
choices=MODEL_CHOICES, default="all")
|
|
70
|
+
parsed_args, _ = parser.parse_known_args(*args)
|
|
71
|
+
self.board_name = parsed_args.board_name
|
|
72
|
+
self.stage = parsed_args.stage
|
|
73
|
+
self.remote = parsed_args.remote
|
|
74
|
+
self.model = parsed_args.model
|
|
75
|
+
self.community_issues = set()
|
|
76
|
+
self.service_dict = {}
|
|
77
|
+
self.packages = {}
|
|
78
|
+
self.repo_brance = Repo(cwd).active_branch.name
|
|
79
|
+
self.repo_name = "manifest"
|
|
80
|
+
self.disabled = False
|
|
81
|
+
self.studio_dir = "/usr/share/bmc_studio/server"
|
|
82
|
+
self.studio_path = "/usr/share/bmc_studio/server/bmcstudio"
|
|
83
|
+
# 初始化fetch命令对象
|
|
84
|
+
if self.bconfig.manifest:
|
|
85
|
+
self.fetch_agent = FetchAgent(self.bconfig, *args)
|
|
86
|
+
|
|
87
|
+
@staticmethod
|
|
88
|
+
def check_overdue(issue: dict):
|
|
89
|
+
data = issue.get("deadline")
|
|
90
|
+
if date is None:
|
|
91
|
+
return False
|
|
92
|
+
try:
|
|
93
|
+
utc_8 = timezone(timedelta(hours=8))
|
|
94
|
+
deadline = datetime.strptime(data, '%Y/%m/%d').replace(tzinfo=utc_8)
|
|
95
|
+
return datetime.now(tz=utc_8) >= deadline + timedelta(days=1)
|
|
96
|
+
except Exception as e:
|
|
97
|
+
log.warning("日期 %s 解析失败:%s", date, e)
|
|
98
|
+
return False
|
|
99
|
+
|
|
100
|
+
@staticmethod
|
|
101
|
+
def process_issues_group(issues, prefix, add_message=""):
|
|
102
|
+
result = ""
|
|
103
|
+
if issues:
|
|
104
|
+
issues.sort()
|
|
105
|
+
for index, (rule, filepath, error_message, repair_suggestion) in enumerate(issues):
|
|
106
|
+
result += ISSUE_TEMPLATE.format(index + 1, rule, filepath, error_message, repair_suggestion)
|
|
107
|
+
result = result.strip()
|
|
108
|
+
if result and os.getenv("CLOUD_BUILD_RECORD_ID") is not None:
|
|
109
|
+
result = "\n".join(map(lambda s: f'{prefix} {s}', result.split("\n")))
|
|
110
|
+
if add_message:
|
|
111
|
+
result = f"{result}\n{add_message}\n"
|
|
112
|
+
return result
|
|
113
|
+
|
|
114
|
+
@staticmethod
|
|
115
|
+
def filter_output():
|
|
116
|
+
output_path = os.path.join(os.environ["HOME"], "bmc_studio", "var", "data", "cli_data", "issues.json")
|
|
117
|
+
try:
|
|
118
|
+
with open(output_path, "r") as output_fp:
|
|
119
|
+
items = json.load(output_fp)
|
|
120
|
+
except json.decoder.JSONDecoderError as e:
|
|
121
|
+
log.error("检查结果解析失败:%s", e.msg)
|
|
122
|
+
return "", ""
|
|
123
|
+
ci_enabled_issues = []
|
|
124
|
+
disabled_issues = []
|
|
125
|
+
for item in items:
|
|
126
|
+
rule = item.get("rule")
|
|
127
|
+
filepath = item.get("filepath")
|
|
128
|
+
ci_enabled = item.get("ciEnabled")
|
|
129
|
+
if ci_enabled:
|
|
130
|
+
ci_enabled_issues.append(
|
|
131
|
+
(rule, filepath, item.get("errorMessage", ""), item.get("repairSuggestion", ""))
|
|
132
|
+
)
|
|
133
|
+
else:
|
|
134
|
+
disabled_issues.append((rule, filepath, item.get("errorMessage", ""), item.get("repairSuggestion", "")))
|
|
135
|
+
# 门禁环境下需要在每一行前加入ERROR,以红色显示
|
|
136
|
+
error = BmcgoCommand.process_issues_group(ci_enabled_issues, "ERROR")
|
|
137
|
+
warning = BmcgoCommand.process_issues_group(disabled_issues, "WARNING", "!!!!!以上是告警提示,后续门禁会逐步生效!!!!!")
|
|
138
|
+
return error, warning
|
|
139
|
+
|
|
140
|
+
def find_component_packages(self):
|
|
141
|
+
dependencies = self.service_dict.get(misc.CONAN_DEPDENCIES_KEY, {})
|
|
142
|
+
dep_list = dependencies.get("test", [])
|
|
143
|
+
dep_list.extend(dependencies.get("build", []))
|
|
144
|
+
for dep in dep_list:
|
|
145
|
+
package = dep.get(misc.CONAN, "")
|
|
146
|
+
comp_name = package.split("/")[0]
|
|
147
|
+
if "@" not in package:
|
|
148
|
+
package += f"@{misc.ConanUserEnum.CONAN_USER_RELEASE.value}/{misc.StageEnum.STAGE_RC.value}"
|
|
149
|
+
self.packages[comp_name] = package
|
|
150
|
+
|
|
151
|
+
def run(self):
|
|
152
|
+
service_path = os.path.join(cwd, "mds", "service.json")
|
|
153
|
+
if self.bconfig.manifest is None:
|
|
154
|
+
if not os.path.isfile(service_path):
|
|
155
|
+
raise RuntimeError("mds/service.json 文件不存在")
|
|
156
|
+
with open(service_path, "r") as service_fp:
|
|
157
|
+
self.service_dict = json.load(service_fp)
|
|
158
|
+
if "name" not in self.service_dict:
|
|
159
|
+
raise RuntimeError("mds/service.json 文件中缺少 name 配置")
|
|
160
|
+
self.repo_name = self.service_dict.get("name")
|
|
161
|
+
self.find_component_packages()
|
|
162
|
+
if self.disabled:
|
|
163
|
+
log.info("%s 仓库没有开启语法正确性和模型一致性检查", self.repo_name)
|
|
164
|
+
return 0
|
|
165
|
+
with tempfile.TemporaryDirectory(prefix="dependencies_repo_") as tempdir:
|
|
166
|
+
if self.bconfig.manifest:
|
|
167
|
+
self.fetch_agent.code_path = tempdir
|
|
168
|
+
self.fetch_agent.run()
|
|
169
|
+
elif self.packages:
|
|
170
|
+
FetchComponentCode(self.packages, tempdir, self.remote, include_open_source=False).run()
|
|
171
|
+
cmd = [self.studio_path, "check", "--repo", cwd, "--dependencies", tempdir, "--model", self.model]
|
|
172
|
+
if self.bconfig.manifest:
|
|
173
|
+
cmd.append("--manifest")
|
|
174
|
+
cmd.append("true")
|
|
175
|
+
os.chdir(self.studio_dir)
|
|
176
|
+
Helper.run(cmd, stdout=subprocess.DEVNULL)
|
|
177
|
+
os.chdir(cwd)
|
|
178
|
+
error, warning = self.filter_output()
|
|
179
|
+
if error:
|
|
180
|
+
log.warning(warning)
|
|
181
|
+
log.error("语法正确性和模型一致性检查不通过:\n%s\n", error)
|
|
182
|
+
return -1
|
|
183
|
+
log.warning(warning)
|
|
184
|
+
log.success("语法正确性和模型一致性检查通过\n")
|
|
185
|
+
return 0
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# encoding=utf-8
|
|
3
|
+
# 描述:组件维护工具
|
|
4
|
+
# Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
5
|
+
# openUBMC is licensed under Mulan PSL v2.
|
|
6
|
+
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
7
|
+
# You may obtain a copy of Mulan PSL v2 at:
|
|
8
|
+
# http://license.coscl.org.cn/MulanPSL2
|
|
9
|
+
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
10
|
+
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
11
|
+
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
12
|
+
# See the Mulan PSL v2 for more details.
|
|
13
|
+
import os
|
|
14
|
+
import pathlib
|
|
15
|
+
import subprocess
|
|
16
|
+
import shutil
|
|
17
|
+
import stat
|
|
18
|
+
import json
|
|
19
|
+
import yaml
|
|
20
|
+
|
|
21
|
+
from bmcgo import errors
|
|
22
|
+
from bmcgo import misc
|
|
23
|
+
from bmcgo.misc import CommandInfo
|
|
24
|
+
from bmcgo.utils.tools import Tools
|
|
25
|
+
from bmcgo.bmcgo_config import BmcgoConfig
|
|
26
|
+
|
|
27
|
+
tool = Tools("conanIdx")
|
|
28
|
+
log = tool.log
|
|
29
|
+
command_info: CommandInfo = CommandInfo(
|
|
30
|
+
group="Conan Index commmands",
|
|
31
|
+
name="build",
|
|
32
|
+
description=["构建conan index仓下的组件"],
|
|
33
|
+
hidden=False
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def if_available(bconfig: BmcgoConfig):
|
|
38
|
+
return bconfig.conan_index is not None and bconfig.manifest is None
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class Function:
|
|
42
|
+
"""功能类, 用于做一些通用操作
|
|
43
|
+
"""
|
|
44
|
+
@classmethod
|
|
45
|
+
def git_check(cls, tag_list: list):
|
|
46
|
+
"""检查 tag 是否在远端 url 内
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
tag_list (list): 依赖仓列表
|
|
50
|
+
|
|
51
|
+
Raises:
|
|
52
|
+
AttributeError: 如果其中有一个不是 tag, 则报错
|
|
53
|
+
"""
|
|
54
|
+
check = True
|
|
55
|
+
for tag in tag_list:
|
|
56
|
+
cmd = f"git ls-remote {tag['url']} --tags {tag['tag']} | grep tags"
|
|
57
|
+
ret = subprocess.getstatusoutput(cmd)
|
|
58
|
+
if ret[0] != 0:
|
|
59
|
+
log.error("%s not a tag in %s", tag['tag'], tag['url'])
|
|
60
|
+
check = False
|
|
61
|
+
if check is True:
|
|
62
|
+
log.info("tag list check successfully !!!")
|
|
63
|
+
else:
|
|
64
|
+
raise AttributeError("tag list check fail !!!")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class BmcgoCommand:
|
|
68
|
+
def __init__(self, bconfig: BmcgoConfig, *args):
|
|
69
|
+
self.bconfig = bconfig
|
|
70
|
+
parser = tool.create_common_parser("Conan Index Build")
|
|
71
|
+
self.args, _ = parser.parse_known_args(*args)
|
|
72
|
+
self.path = ""
|
|
73
|
+
self.version = ""
|
|
74
|
+
self.conan_package = ""
|
|
75
|
+
self.upload = False
|
|
76
|
+
self.remote = None
|
|
77
|
+
self.options = []
|
|
78
|
+
self.stage = misc.StageEnum.STAGE_DEV.value
|
|
79
|
+
self.enable_luajit = False
|
|
80
|
+
self.from_source = False
|
|
81
|
+
self.build_type = 'debug'
|
|
82
|
+
self.asan = False
|
|
83
|
+
self.profile = ''
|
|
84
|
+
self.initialize()
|
|
85
|
+
self.channel = f"@{misc.ConanUserEnum.CONAN_USER_DEV.value}/{self.stage}"
|
|
86
|
+
|
|
87
|
+
@staticmethod
|
|
88
|
+
def run_command(command, ignore_error=False, sudo=False, **kwargs):
|
|
89
|
+
"""
|
|
90
|
+
如果ignore_error为False,命令返回码非0时则打印堆栈和日志并触发异常,中断构建
|
|
91
|
+
"""
|
|
92
|
+
uptrace = kwargs.get("uptrace", 1)
|
|
93
|
+
kwargs["uptrace"] = uptrace
|
|
94
|
+
return tool.run_command(command, ignore_error, sudo, **kwargs)
|
|
95
|
+
|
|
96
|
+
def initialize(self):
|
|
97
|
+
self.set_package(self.args.conan_package)
|
|
98
|
+
self.upload = self.args.upload_package
|
|
99
|
+
if self.args.remote:
|
|
100
|
+
self.remote = self.args.remote
|
|
101
|
+
if self.args.options:
|
|
102
|
+
self.options = self.args.options
|
|
103
|
+
self.stage = self.args.stage
|
|
104
|
+
self.enable_luajit = self.args.enable_luajit
|
|
105
|
+
self.from_source = self.args.from_source
|
|
106
|
+
self.build_type = self.args.build_type
|
|
107
|
+
self.asan = self.args.asan
|
|
108
|
+
self.profile = Tools.get_conan_profile(None, self.build_type, self.enable_luajit)
|
|
109
|
+
if self.args.profile:
|
|
110
|
+
self.profile = self.args.profile
|
|
111
|
+
|
|
112
|
+
# 入参可以是huawei_secure_c/1.0.0样式
|
|
113
|
+
def set_package(self, path: str):
|
|
114
|
+
os.chdir(self.bconfig.conan_index.folder)
|
|
115
|
+
split = path.split("/")
|
|
116
|
+
if len(split) != 2:
|
|
117
|
+
raise errors.BmcGoException(f"包名称({path})错误,例:kmc/1.0.1")
|
|
118
|
+
|
|
119
|
+
if not os.path.isdir(split[0]):
|
|
120
|
+
raise errors.BmcGoException(f"包路径({split[0]})不存在,或不是文件夹")
|
|
121
|
+
|
|
122
|
+
config_yaml = os.path.join(self.bconfig.conan_index.folder, split[0], "config.yml")
|
|
123
|
+
with open(config_yaml) as f:
|
|
124
|
+
config_data = yaml.safe_load(f)
|
|
125
|
+
config_data = config_data.get('versions', None)
|
|
126
|
+
if config_data is None:
|
|
127
|
+
raise errors.BmcGoException(f"Config format error, config.yml path: {config_yaml}")
|
|
128
|
+
config_data = config_data.get(split[1], None)
|
|
129
|
+
if config_data is None:
|
|
130
|
+
raise errors.BmcGoException(f"Unkown version, config.yml path: {config_yaml}, version: {split[1]}")
|
|
131
|
+
folder = config_data.get('folder', None)
|
|
132
|
+
if config_data is None:
|
|
133
|
+
raise errors.BmcGoException(f"Unkown folder, config.yml path: {config_yaml}, version: {split[1]}")
|
|
134
|
+
self.path = "{}/{}".format(split[0], folder)
|
|
135
|
+
self.version = split[1]
|
|
136
|
+
if self.stage != "dev":
|
|
137
|
+
self.tag_check()
|
|
138
|
+
|
|
139
|
+
def install_luac(self):
|
|
140
|
+
conan_bin = os.path.join(os.path.expanduser('~'), ".conan", "bin")
|
|
141
|
+
# 设置PLD_LIBRARY_PATH环境变量,luajit运行时需要加载so动态库
|
|
142
|
+
ld_library_path = conan_bin + ":" + os.environ.get("LD_LIBRARY_PATH", "")
|
|
143
|
+
os.environ["LD_LIBRARY_PATH"] = ld_library_path
|
|
144
|
+
# 设置PATH环境变量,luajit无需指定全路径
|
|
145
|
+
path = conan_bin + ":" + os.environ.get("PATH", "")
|
|
146
|
+
os.environ["PATH"] = path
|
|
147
|
+
os.environ["LUA_PATH"] = f"{conan_bin}/?.lua"
|
|
148
|
+
|
|
149
|
+
# 待安装的luajit版本
|
|
150
|
+
luajit_pkg = f"luajit/2.1.0.B012@{tool.conan_user}/{misc.StageEnum.STAGE_STABLE.value}"
|
|
151
|
+
luajit_flag = luajit_pkg.split("@")[0].replace("/", "_")
|
|
152
|
+
luajit_flag = os.path.join(conan_bin, luajit_flag)
|
|
153
|
+
|
|
154
|
+
# 使能luajit时需要安装luajit
|
|
155
|
+
luac_path = os.path.join(conan_bin, "luajit")
|
|
156
|
+
# luajit版本一致且luac/luajit存在时赋权即可
|
|
157
|
+
if os.path.isfile(luajit_flag) and os.path.exists(luac_path):
|
|
158
|
+
os.chmod(luac_path, stat.S_IRWXU)
|
|
159
|
+
return
|
|
160
|
+
Tools.clean_conan_bin(conan_bin)
|
|
161
|
+
# 其它情况都尝试安装luajit
|
|
162
|
+
cmd = ["conan", "install", luajit_pkg]
|
|
163
|
+
cmd += ("-pr profile.dt.ini -if=temp/.deploy -g deploy").split()
|
|
164
|
+
if self.remote:
|
|
165
|
+
cmd += ["-r", self.remote]
|
|
166
|
+
self.run_command(cmd)
|
|
167
|
+
cmd = ["cp", "temp/.deploy/luajit/usr/bin/luajit", f"{conan_bin}"]
|
|
168
|
+
self.run_command(cmd)
|
|
169
|
+
cmd = ["cp", "temp/.deploy/luajit/usr/lib64/liblua.so", f"{conan_bin}"]
|
|
170
|
+
self.run_command(cmd)
|
|
171
|
+
cmd = ["cp", "-r", "temp/.deploy/luajit/usr/bin/jit", f"{conan_bin}"]
|
|
172
|
+
self.run_command(cmd)
|
|
173
|
+
os.chmod(luac_path, stat.S_IRWXU)
|
|
174
|
+
luajit2luac = shutil.which("luajit2luac.sh")
|
|
175
|
+
cmd = ["cp", luajit2luac, f"{conan_bin}/luac"]
|
|
176
|
+
self.run_command(cmd)
|
|
177
|
+
pathlib.Path(luajit_flag).touch(exist_ok=True)
|
|
178
|
+
|
|
179
|
+
def run(self):
|
|
180
|
+
self.install_luac()
|
|
181
|
+
if self.path == "" or self.version == "":
|
|
182
|
+
raise errors.BmcGoException(f"Path({self.path}) or version({self.version}) error")
|
|
183
|
+
os.chdir(self.bconfig.conan_index.folder)
|
|
184
|
+
os.chdir(self.path)
|
|
185
|
+
if self.stage != misc.StageEnum.STAGE_DEV.value:
|
|
186
|
+
# rc和stable模式
|
|
187
|
+
self.channel = f"@{tool.conan_user}/{self.stage}"
|
|
188
|
+
log.info("Start build package")
|
|
189
|
+
if self.build_type == "dt":
|
|
190
|
+
setting = "-s build_type=Dt"
|
|
191
|
+
else:
|
|
192
|
+
if self.build_type == "debug":
|
|
193
|
+
setting = "-s build_type=Debug"
|
|
194
|
+
else:
|
|
195
|
+
setting = "-s build_type=Release"
|
|
196
|
+
options = " "
|
|
197
|
+
packake_name = self.path.split("/")[0]
|
|
198
|
+
if self.asan:
|
|
199
|
+
options += f"-o {packake_name}:asan=True"
|
|
200
|
+
for option in self.options:
|
|
201
|
+
options += f" -o {option}"
|
|
202
|
+
|
|
203
|
+
dt_stat = os.environ.get("BMCGO_DT_RUN", "off")
|
|
204
|
+
show_log = True if dt_stat == "off" else False
|
|
205
|
+
pkg = packake_name + "/" + self.version + self.channel
|
|
206
|
+
append_cmd = f"-r {self.remote}" if self.remote else ""
|
|
207
|
+
cmd = "conan create . {} -pr={} -pr:b profile.dt.ini {} {} -tf None {}".format(
|
|
208
|
+
pkg, self.profile, setting, append_cmd, options
|
|
209
|
+
)
|
|
210
|
+
cmd += f" --build={packake_name}"
|
|
211
|
+
if self.from_source:
|
|
212
|
+
cmd += " --build=*"
|
|
213
|
+
else:
|
|
214
|
+
cmd += " --build=missing"
|
|
215
|
+
self.run_command(cmd, show_log=show_log)
|
|
216
|
+
|
|
217
|
+
if not self.upload:
|
|
218
|
+
return
|
|
219
|
+
|
|
220
|
+
cmd = "conan info {} -pr={} -j".format(pkg, self.profile)
|
|
221
|
+
info_json = self.run_command(cmd, shell=True, capture_output=True).stdout
|
|
222
|
+
for line in info_json.split("\n"):
|
|
223
|
+
if line.startswith("[{"):
|
|
224
|
+
info_json = line
|
|
225
|
+
break
|
|
226
|
+
info = json.loads(info_json)
|
|
227
|
+
for i in info:
|
|
228
|
+
if i["reference"] != pkg:
|
|
229
|
+
continue
|
|
230
|
+
cmd = "conan upload {}:{} -r {} -c --retry=3 --retry-wait 10 --all".format(pkg, i["id"], self.remote)
|
|
231
|
+
self.run_command(cmd)
|
|
232
|
+
log.info("===>>>Upload package successfully, pkg: {}:{}".format(pkg, i["id"]))
|
|
233
|
+
|
|
234
|
+
def tag_check(self):
|
|
235
|
+
yaml_file = f"{self.path}/conandata.yml"
|
|
236
|
+
if os.path.exists(yaml_file) is False:
|
|
237
|
+
log.warning("%s config not exists or does not need config file")
|
|
238
|
+
with open(yaml_file, mode="r") as fp:
|
|
239
|
+
config_data = yaml.safe_load(fp)
|
|
240
|
+
# 这个值是必定存在的
|
|
241
|
+
version_config = config_data['sources'][self.version]
|
|
242
|
+
tag_list = []
|
|
243
|
+
# 单个仓的处理
|
|
244
|
+
if version_config.get('url', None) is not None:
|
|
245
|
+
tag_list.append({"tag": version_config['branch'], "url": version_config['url']})
|
|
246
|
+
# 多个仓的处理
|
|
247
|
+
else:
|
|
248
|
+
for value in version_config.values():
|
|
249
|
+
tag_list.append({"tag": value['branch'], "url": value['url']})
|
|
250
|
+
# 这里的 git 命令的意思是检查远端是否有此 tag, 如果不加 grep, 可能导致分支被认为是 tag
|
|
251
|
+
Function.git_check(tag_list)
|