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
bmcgo/tasks/task.py
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
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
|
+
import os
|
|
13
|
+
import json
|
|
14
|
+
import stat
|
|
15
|
+
import traceback
|
|
16
|
+
import importlib
|
|
17
|
+
import shutil
|
|
18
|
+
import time
|
|
19
|
+
import tempfile
|
|
20
|
+
import filecmp
|
|
21
|
+
from string import Template
|
|
22
|
+
from multiprocessing import Process
|
|
23
|
+
from collections import OrderedDict
|
|
24
|
+
|
|
25
|
+
import yaml
|
|
26
|
+
from conans.model.profile import Profile
|
|
27
|
+
from bmcgo.utils.config import Config
|
|
28
|
+
from bmcgo.utils.tools import Tools
|
|
29
|
+
from bmcgo import errors
|
|
30
|
+
from bmcgo.utils.component_post import ComponentPost
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class Task(Process):
|
|
34
|
+
name = "WorkBase"
|
|
35
|
+
timeout = 1200
|
|
36
|
+
description = "基础类"
|
|
37
|
+
work_name = ""
|
|
38
|
+
manifest_obj = None
|
|
39
|
+
|
|
40
|
+
def __init__(self, config: Config, work_name=""):
|
|
41
|
+
super(Task, self).__init__()
|
|
42
|
+
log_file = os.path.join(config.temp_path, "log", "task.log")
|
|
43
|
+
self.tools: Tools = Tools(work_name, log_file=log_file)
|
|
44
|
+
self.log = self.tools.log
|
|
45
|
+
self.config: Config = config
|
|
46
|
+
self.work_name = work_name
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def conan_home(self):
|
|
50
|
+
return self.tools.conan_home
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def conan_profiles_dir(self):
|
|
54
|
+
return self.tools.conan_profiles_dir
|
|
55
|
+
|
|
56
|
+
@property
|
|
57
|
+
def conan_data(self):
|
|
58
|
+
return self.tools.conan_data
|
|
59
|
+
|
|
60
|
+
# rootfs定制化,参考application/build/customization
|
|
61
|
+
@property
|
|
62
|
+
def customization(self):
|
|
63
|
+
config = self.get_manufacture_config("base/customization")
|
|
64
|
+
if config is None:
|
|
65
|
+
return []
|
|
66
|
+
# 类名
|
|
67
|
+
config_file = []
|
|
68
|
+
if isinstance(config, str):
|
|
69
|
+
config_file = [config]
|
|
70
|
+
elif isinstance(config, list):
|
|
71
|
+
config_file = config
|
|
72
|
+
obj = []
|
|
73
|
+
for config in config_file:
|
|
74
|
+
path = config.replace("/", ".")[0:-3]
|
|
75
|
+
work_py_file = importlib.import_module(path, "works.work")
|
|
76
|
+
work_class = getattr(work_py_file, "Customization", None)
|
|
77
|
+
if not work_class:
|
|
78
|
+
work_class = getattr(work_py_file, "BaseCustomization", None)
|
|
79
|
+
if not work_class:
|
|
80
|
+
raise errors.BmcGoException(f"定制化脚本 {config} 未找到Customization或BaseCustomization类,定制化失败")
|
|
81
|
+
obj.append(work_class(self, self.config))
|
|
82
|
+
return obj
|
|
83
|
+
|
|
84
|
+
def built_type_check(self):
|
|
85
|
+
if self.config.manufacture_code is None:
|
|
86
|
+
return
|
|
87
|
+
manufacture_build_type = self.get_manufacture_config(f"manufacture/{self.config.manufacture_code}/build_type")
|
|
88
|
+
if manufacture_build_type is not None and self.config.build_type != manufacture_build_type:
|
|
89
|
+
self.error("构建类型和包编码中配置的构建类型不匹配, 参数配置为: {}, 而对应包编码配置为: {}".format(\
|
|
90
|
+
self.config.build_type, manufacture_build_type))
|
|
91
|
+
raise Exception
|
|
92
|
+
|
|
93
|
+
def read_json(self, json_path):
|
|
94
|
+
if not os.path.exists(json_path):
|
|
95
|
+
raise Exception
|
|
96
|
+
with open(json_path, "r") as json_file:
|
|
97
|
+
return json.load(json_file)
|
|
98
|
+
raise Exception
|
|
99
|
+
|
|
100
|
+
# 子类必须实现run方法,未实现时异常
|
|
101
|
+
def run(self):
|
|
102
|
+
self.info(f"{__file__} error")
|
|
103
|
+
raise Exception
|
|
104
|
+
|
|
105
|
+
# 安装函数,将各work的产出安装到config.rootfs目录中
|
|
106
|
+
def install(self):
|
|
107
|
+
pass
|
|
108
|
+
|
|
109
|
+
def deal_conf(self, config_dict):
|
|
110
|
+
"""
|
|
111
|
+
处理每个work的私有配置"work_config",只有work类有set_xxx类方法的属性可以设置
|
|
112
|
+
"""
|
|
113
|
+
if not config_dict:
|
|
114
|
+
return
|
|
115
|
+
for conf in config_dict:
|
|
116
|
+
try:
|
|
117
|
+
exist = getattr(self, f"set_{conf}")
|
|
118
|
+
val = config_dict.get(conf)
|
|
119
|
+
exist(val)
|
|
120
|
+
except Exception as e:
|
|
121
|
+
raise Exception(f"无效配置: {conf}, {e}, {traceback.print_exc()}") from e
|
|
122
|
+
|
|
123
|
+
def link(self, src, dst, uptrade=1):
|
|
124
|
+
if os.path.isfile(dst):
|
|
125
|
+
os.unlink(dst)
|
|
126
|
+
if os.path.dirname(dst) != "":
|
|
127
|
+
os.makedirs(os.path.dirname(dst), exist_ok=True)
|
|
128
|
+
# 直接复制文件
|
|
129
|
+
self.info(f"复制 {src} 到 {dst} 并保留权限", uptrace=uptrade)
|
|
130
|
+
shutil.copyfile(src, dst)
|
|
131
|
+
|
|
132
|
+
def manufacture_version_check(self, filename) -> bool:
|
|
133
|
+
""" 当某些包打出来的包的版本号是当前版本加1的,使用此接口来进行确认是否加1
|
|
134
|
+
返回值:
|
|
135
|
+
bool: 是否需要加1
|
|
136
|
+
"""
|
|
137
|
+
with open(filename, mode="r") as fp:
|
|
138
|
+
origin_config = yaml.safe_load(fp)
|
|
139
|
+
# 这两个code是冲突的,只取其一,默认情况下会取第二个
|
|
140
|
+
if self.config.manufacture_code is not None:
|
|
141
|
+
package_name = origin_config.get("manufacture").get(self.config.manufacture_code).get("package_name")
|
|
142
|
+
else:
|
|
143
|
+
package_name = origin_config.get("tosupporte").get(self.config.tosupporte_code).get("package_name")
|
|
144
|
+
|
|
145
|
+
if "manufacture_version" in package_name:
|
|
146
|
+
return True
|
|
147
|
+
else:
|
|
148
|
+
return False
|
|
149
|
+
|
|
150
|
+
# 依赖manifest的files复制文件
|
|
151
|
+
def copy_manifest_files(self, files, exclude_files=None):
|
|
152
|
+
if files is None:
|
|
153
|
+
return
|
|
154
|
+
exclude_files = exclude_files or []
|
|
155
|
+
file_list = []
|
|
156
|
+
if isinstance(files, dict):
|
|
157
|
+
for _, val in files.items():
|
|
158
|
+
file_list.append(val)
|
|
159
|
+
else:
|
|
160
|
+
file_list = files
|
|
161
|
+
for file in file_list:
|
|
162
|
+
condition = file.get("condition")
|
|
163
|
+
match = self._if_match(condition)
|
|
164
|
+
if not match:
|
|
165
|
+
continue
|
|
166
|
+
filename = file.get("file")
|
|
167
|
+
if filename is None:
|
|
168
|
+
continue
|
|
169
|
+
filename = time.strftime(filename, self.config.date)
|
|
170
|
+
dst = file.get("dst")
|
|
171
|
+
if dst is None:
|
|
172
|
+
dst = os.path.basename(filename)
|
|
173
|
+
if dst in exclude_files:
|
|
174
|
+
self.debug(f"Skip copy {filename} because in exclude list")
|
|
175
|
+
continue
|
|
176
|
+
if not os.path.isfile(filename):
|
|
177
|
+
self.error("{} 不是一个文件或者不存在".format(filename))
|
|
178
|
+
dst = time.strftime(dst, self.config.date)
|
|
179
|
+
if "/" in dst:
|
|
180
|
+
dst = str(Template(dst).safe_substitute(self.config.get_template()))
|
|
181
|
+
dirname = os.path.dirname(dst)
|
|
182
|
+
os.makedirs(dirname, exist_ok=True)
|
|
183
|
+
self.info("复制文件 {} 到 {}".format(filename, dst))
|
|
184
|
+
if file.get("template"):
|
|
185
|
+
# 模板文件替换内容后复制
|
|
186
|
+
with open(filename, "r") as fp:
|
|
187
|
+
content = fp.read()
|
|
188
|
+
fp.close()
|
|
189
|
+
self.info(f"模板替换后复制{filename}到{dst}")
|
|
190
|
+
content = Template(content)
|
|
191
|
+
content = content.safe_substitute(self.config.get_template())
|
|
192
|
+
with os.fdopen(os.open(dst, os.O_WRONLY | os.O_CREAT | os.O_TRUNC,
|
|
193
|
+
stat.S_IWUSR | stat.S_IRUSR), 'w') as file_handler:
|
|
194
|
+
file_handler.write(content)
|
|
195
|
+
file_handler.close()
|
|
196
|
+
else:
|
|
197
|
+
# 非模板文件直接复制
|
|
198
|
+
self.link(filename, dst)
|
|
199
|
+
|
|
200
|
+
# 从manifest中获取属性值
|
|
201
|
+
def get_manufacture_config(self, key: str, default_val=None):
|
|
202
|
+
"""获取manifest.yml当中的配置
|
|
203
|
+
参数:
|
|
204
|
+
key (str): 要获取的配置,采用路径类似格式,比如'manufacture/05023VAY'
|
|
205
|
+
返回值:
|
|
206
|
+
None: 未找到配置
|
|
207
|
+
str: 配置的值
|
|
208
|
+
"""
|
|
209
|
+
return self.config.get_manufacture_config(key, default_val)
|
|
210
|
+
|
|
211
|
+
def get_profile_config(self) -> (Profile, OrderedDict):
|
|
212
|
+
return self.tools.get_profile_config(self.config.profile)
|
|
213
|
+
|
|
214
|
+
def prepare_conan(self):
|
|
215
|
+
#先删除profiles
|
|
216
|
+
self.run_command(f"rm -rf {self.conan_profiles_dir}/profile.dt.ini", ignore_error=True)
|
|
217
|
+
self.run_command(f"rm -rf {self.conan_profiles_dir}/profile.ini", ignore_error=True)
|
|
218
|
+
self.run_command(f"rm -rf {self.conan_profiles_dir}/profile.luajit.ini", ignore_error=True)
|
|
219
|
+
profile_dt = f"{self.config.code_path}/profile.dt.ini"
|
|
220
|
+
if os.path.isfile(profile_dt):
|
|
221
|
+
shutil.copy2(profile_dt, f"{self.conan_profiles_dir}/profile.dt.ini")
|
|
222
|
+
profile = f"{self.config.code_path}/profile.ini"
|
|
223
|
+
if os.path.isfile(profile):
|
|
224
|
+
shutil.copy2(profile, f"{self.conan_profiles_dir}/profile.ini")
|
|
225
|
+
# 新增profile文件需要存在在manifest/build/profiles目录
|
|
226
|
+
profiles = os.path.join(self.config.code_path, "profiles")
|
|
227
|
+
if os.path.isdir(profiles):
|
|
228
|
+
shutil.copytree(profiles, self.conan_profiles_dir, dirs_exist_ok=True)
|
|
229
|
+
platform_profiles = os.path.join(self.config.temp_platform_build_dir, "profiles")
|
|
230
|
+
if os.path.isdir(platform_profiles):
|
|
231
|
+
shutil.copytree(platform_profiles, self.conan_profiles_dir, dirs_exist_ok=True)
|
|
232
|
+
self.run_command("conan remote remove conancenter", ignore_error=True)
|
|
233
|
+
|
|
234
|
+
def check_need_install(self, download_dir_path, old_sha, new_sha):
|
|
235
|
+
need_install_flag = True
|
|
236
|
+
# 计算sha256
|
|
237
|
+
self.pipe_command([f"find {download_dir_path} -type f", "xargs sha256sum", "awk '{print $1}'", "sort"], new_sha)
|
|
238
|
+
if os.path.isfile(old_sha) and filecmp.cmp(old_sha, new_sha):
|
|
239
|
+
need_install_flag = False
|
|
240
|
+
return need_install_flag
|
|
241
|
+
|
|
242
|
+
def chdir(self, path):
|
|
243
|
+
self.info(f"切换工作目录到: {path}", uptrace=1)
|
|
244
|
+
os.chdir(path)
|
|
245
|
+
|
|
246
|
+
def run_command(self, command, ignore_error=False, sudo=False, **kwargs):
|
|
247
|
+
"""
|
|
248
|
+
如果ignore_error为False,命令返回码非0时则打印堆栈和日志并触发异常,中断构建
|
|
249
|
+
"""
|
|
250
|
+
uptrace = kwargs.get("uptrace", 1)
|
|
251
|
+
kwargs["uptrace"] = uptrace
|
|
252
|
+
return self.tools.run_command(command, ignore_error, sudo, **kwargs)
|
|
253
|
+
|
|
254
|
+
def pipe_command(self, commands, out_file=None, **kwargs):
|
|
255
|
+
return self.tools.pipe_command(commands, out_file, **kwargs)
|
|
256
|
+
|
|
257
|
+
def signature(self, unsigned_file, output_file):
|
|
258
|
+
"""自签名方法"""
|
|
259
|
+
unsigned_file = os.path.realpath(unsigned_file)
|
|
260
|
+
output_file = os.path.realpath(output_file)
|
|
261
|
+
tmp_dir = tempfile.TemporaryDirectory()
|
|
262
|
+
cwd = os.getcwd()
|
|
263
|
+
self.chdir(tmp_dir.name)
|
|
264
|
+
rootca_der = self.config.rootca_der
|
|
265
|
+
rootca_crl = self.config.rootca_crl
|
|
266
|
+
signer_pem = self.config.signer_pem
|
|
267
|
+
ts_signer_pem = self.config.ts_signer_pem
|
|
268
|
+
ts_signer_cnf = self.config.ts_signer_cnf
|
|
269
|
+
self.run_command(f"openssl x509 -in {rootca_der} -inform der -outform pem -out rootca.pem")
|
|
270
|
+
self.run_command(f"openssl crl -in {rootca_crl} -inform der -outform pem -out cms.crl.pem")
|
|
271
|
+
cmd = f"hpm_signer -s {signer_pem} -t {ts_signer_pem} -T {ts_signer_cnf} -i {unsigned_file} -o {output_file}"
|
|
272
|
+
self.run_command(cmd)
|
|
273
|
+
self.run_command(f"hpm_verify -r rootca.pem -C cms.crl.pem -c {unsigned_file} -s {output_file}")
|
|
274
|
+
self.chdir(cwd)
|
|
275
|
+
|
|
276
|
+
def error(self, msg, *args, **kwargs):
|
|
277
|
+
uptrace = kwargs.get("uptrace", None)
|
|
278
|
+
if uptrace is None:
|
|
279
|
+
uptrace = 1
|
|
280
|
+
else:
|
|
281
|
+
uptrace += 1
|
|
282
|
+
kwargs["uptrace"] = uptrace
|
|
283
|
+
self.tools.log.error(msg, *args, **kwargs)
|
|
284
|
+
|
|
285
|
+
def info(self, msg, *args, **kwargs):
|
|
286
|
+
uptrace = kwargs.get("uptrace", None)
|
|
287
|
+
if uptrace is None:
|
|
288
|
+
uptrace = 1
|
|
289
|
+
else:
|
|
290
|
+
uptrace += 1
|
|
291
|
+
kwargs["uptrace"] = uptrace
|
|
292
|
+
self.tools.log.info(msg, *args, **kwargs)
|
|
293
|
+
|
|
294
|
+
def debug(self, msg, *args, **kwargs):
|
|
295
|
+
uptrace = kwargs.get("uptrace", None)
|
|
296
|
+
if uptrace is None:
|
|
297
|
+
uptrace = 1
|
|
298
|
+
else:
|
|
299
|
+
uptrace += 1
|
|
300
|
+
kwargs["uptrace"] = uptrace
|
|
301
|
+
self.tools.log.debug(msg, *args, **kwargs)
|
|
302
|
+
|
|
303
|
+
def warning(self, msg, *args, **kwargs):
|
|
304
|
+
uptrace = kwargs.get("uptrace", None)
|
|
305
|
+
if uptrace is None:
|
|
306
|
+
uptrace = 1
|
|
307
|
+
else:
|
|
308
|
+
uptrace += 1
|
|
309
|
+
kwargs["uptrace"] = uptrace
|
|
310
|
+
self.tools.log.warning(msg, *args, **kwargs)
|
|
311
|
+
|
|
312
|
+
def success(self, msg, *args, **kwargs):
|
|
313
|
+
uptrace = kwargs.get("uptrace", None)
|
|
314
|
+
if uptrace is None:
|
|
315
|
+
uptrace = 1
|
|
316
|
+
else:
|
|
317
|
+
uptrace += 1
|
|
318
|
+
kwargs["uptrace"] = uptrace
|
|
319
|
+
self.tools.log.success(msg, *args, **kwargs)
|
|
320
|
+
|
|
321
|
+
def _if_match(self, condition):
|
|
322
|
+
if condition is None:
|
|
323
|
+
return True
|
|
324
|
+
for key, val in condition.items():
|
|
325
|
+
if key == "build_type":
|
|
326
|
+
if self.config.build_type != val:
|
|
327
|
+
return False
|
|
328
|
+
else:
|
|
329
|
+
raise OSError(f"未知条件: {key}, 请检查此种条件是否在配置内")
|
|
330
|
+
return True
|
|
331
|
+
|
|
332
|
+
def _component_cust_action(self, action: str):
|
|
333
|
+
conan_install = f"{self.config.build_path}/conan_install"
|
|
334
|
+
|
|
335
|
+
# 优先处理rootfs定制化脚本
|
|
336
|
+
comps = ["rootfs"]
|
|
337
|
+
for dirname in os.listdir(conan_install):
|
|
338
|
+
if not os.path.isdir(f"{conan_install}/{dirname}"):
|
|
339
|
+
continue
|
|
340
|
+
if dirname != "rootfs" and dirname != "openubmc":
|
|
341
|
+
comps.append(dirname)
|
|
342
|
+
# 最后处理openubmc
|
|
343
|
+
comps.append("openubmc")
|
|
344
|
+
self.info(f"所有组件为: {comps}")
|
|
345
|
+
|
|
346
|
+
profile, _ = self.get_profile_config()
|
|
347
|
+
for comp in comps:
|
|
348
|
+
cust = os.path.join(conan_install, comp, "include", "customization.py")
|
|
349
|
+
if not os.path.isfile(cust):
|
|
350
|
+
continue
|
|
351
|
+
self.info(f">>>>>>>>>> 开始执行 {cust} post_rootfs 定制化")
|
|
352
|
+
self.info(f"执行脚本 {comp}/include/customization.py 开始")
|
|
353
|
+
post = ComponentPost(self.config, os.path.join(conan_install, comp), profile)
|
|
354
|
+
post.post_work(os.getcwd(), action)
|