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,595 @@
|
|
|
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
|
+
功 能:buildimg_ext4脚本,该脚本 make ext4 image
|
|
14
|
+
版权信息:华为技术有限公司,版本所有(C) 2019-2020
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
import os
|
|
18
|
+
import shutil
|
|
19
|
+
import json
|
|
20
|
+
import stat
|
|
21
|
+
import time
|
|
22
|
+
import subprocess
|
|
23
|
+
import tempfile
|
|
24
|
+
from multiprocessing import Process
|
|
25
|
+
|
|
26
|
+
from git import Repo
|
|
27
|
+
|
|
28
|
+
from bmcgo.tasks.task import Task
|
|
29
|
+
from bmcgo.utils.config import Config
|
|
30
|
+
from bmcgo.utils.combine_json_schemas import CombineJsonSchemas
|
|
31
|
+
from bmcgo.utils.mapping_config_patch import MappingConfigPatch
|
|
32
|
+
from bmcgo import errors, misc
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class MakeZeroImageProcess(Process):
|
|
36
|
+
def __init__(self, work, bs_count, img_path):
|
|
37
|
+
super().__init__()
|
|
38
|
+
self.work = work
|
|
39
|
+
self.bs_count = bs_count
|
|
40
|
+
self.img_path = img_path
|
|
41
|
+
|
|
42
|
+
def run(self):
|
|
43
|
+
self.work.work_name = os.path.basename(self.img_path)
|
|
44
|
+
cmd = f"dd if=/dev/zero of={self.img_path} bs=4096 count={self.bs_count}"
|
|
45
|
+
self.work.run_command(cmd)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class TaskClass(Task):
|
|
49
|
+
def __init__(self, config: Config, work_name=""):
|
|
50
|
+
super(TaskClass, self).__init__(config, work_name)
|
|
51
|
+
self.rootfs_img_process = None
|
|
52
|
+
self.datafs_img_process = None
|
|
53
|
+
self.buildimg_dir = None
|
|
54
|
+
self.rtos_rootfs = None
|
|
55
|
+
self.rtos_datafs = None
|
|
56
|
+
self.mnt_datafs = None
|
|
57
|
+
self.rootfs_img_path = f"{self.config.work_out}/rootfs_BMC.img"
|
|
58
|
+
self.datafs_img_path = f"{self.config.hpm_build_dir}/datafs_{self.config.board_name}.img"
|
|
59
|
+
|
|
60
|
+
def set_evn(self):
|
|
61
|
+
self.buildimg_dir = self.config.buildimg_dir
|
|
62
|
+
self.tools.check_path(self.buildimg_dir)
|
|
63
|
+
shutil.rmtree(f"{self.buildimg_dir}/rtos_with_driver", ignore_errors=True)
|
|
64
|
+
# rootfs解压目录
|
|
65
|
+
self.rtos_rootfs = f"{self.buildimg_dir}/rtos_with_driver/rootfs"
|
|
66
|
+
self.rtos_datafs = f"{self.rtos_rootfs}/data"
|
|
67
|
+
# 镜像挂载点
|
|
68
|
+
self.mnt_datafs = f"{self.buildimg_dir}/mnt_datafs"
|
|
69
|
+
self.tools.check_path(self.mnt_datafs)
|
|
70
|
+
self.tools.check_path(self.rtos_rootfs)
|
|
71
|
+
|
|
72
|
+
def component_cust_conf(self):
|
|
73
|
+
self.chdir(self.rtos_rootfs)
|
|
74
|
+
self._component_cust_action("post_rootfs")
|
|
75
|
+
self.run_command(f"rm -rf {self.rtos_rootfs}/include", sudo=True, command_echo=False)
|
|
76
|
+
self.run_command(f"rm -rf {self.rtos_rootfs}/usr/include", sudo=True, command_echo=False)
|
|
77
|
+
|
|
78
|
+
def component_swbom(self):
|
|
79
|
+
os.chdir(self.rtos_rootfs)
|
|
80
|
+
swbom = f"{self.buildimg_dir}/swbom"
|
|
81
|
+
with os.fdopen(os.open(swbom, os.O_WRONLY | os.O_CREAT | os.O_TRUNC,
|
|
82
|
+
stat.S_IWUSR | stat.S_IRUSR), 'w') as fp:
|
|
83
|
+
if self.config.build_type == "debug":
|
|
84
|
+
fp.write("rootfs_rw\n")
|
|
85
|
+
elif self.config.build_type == "release":
|
|
86
|
+
fp.write("rootfs_ro\n")
|
|
87
|
+
fp.close()
|
|
88
|
+
self.run_command(f"cp -df {swbom} etc/swbom", sudo=True)
|
|
89
|
+
self.run_command(f"rm -rf {swbom}", sudo=True)
|
|
90
|
+
|
|
91
|
+
def prepare_config_for_luacov(self):
|
|
92
|
+
"""
|
|
93
|
+
整包覆盖率统计: 将luacov路径增加到config.cfg, 同时将preload指定为打桩的app_preloader_luacov.lua
|
|
94
|
+
"""
|
|
95
|
+
self.info("准备 config.cfg 配置文件, 配置 luacov 路径")
|
|
96
|
+
test_config = os.path.join(self.rtos_rootfs, "opt/bmc/libmc/config.cfg")
|
|
97
|
+
|
|
98
|
+
with open(test_config, "r") as f:
|
|
99
|
+
# 插入luacov搜索路径
|
|
100
|
+
search_str = ' self:add_lua_path(self.apps_root .. "?/init.lua")\n'
|
|
101
|
+
insert_str = ' self:add_lua_path(self.bmc_root .. "lualib/luacov/?.lua")\n'
|
|
102
|
+
lines = f.readlines()
|
|
103
|
+
if insert_str in lines:
|
|
104
|
+
return
|
|
105
|
+
insert_index = lines.index(search_str)
|
|
106
|
+
lines.insert(insert_index + 1, insert_str)
|
|
107
|
+
# 让preload引用打桩的app_preloader_luacov.lua
|
|
108
|
+
search_str = ' preload = self.preload or (self.libmc_root .. "lualib/mc/app_preloader.lua")\n'
|
|
109
|
+
replace_str = ' preload = self.preload or (self.libmc_root .. "lualib/mc/app_preloader_luacov.lua")\n'
|
|
110
|
+
lines = [replace_str if line == search_str else line for line in lines]
|
|
111
|
+
write_str = "".join(lines)
|
|
112
|
+
with os.fdopen(os.open(test_config, os.O_WRONLY | os.O_CREAT | os.O_TRUNC,
|
|
113
|
+
stat.S_IWUSR | stat.S_IRUSR), 'w') as f:
|
|
114
|
+
f.write(write_str)
|
|
115
|
+
|
|
116
|
+
def prepare_preloader_for_luacov(self):
|
|
117
|
+
"""
|
|
118
|
+
整包覆盖率统计: 通过app_preloader使得所有组件引用luacov
|
|
119
|
+
"""
|
|
120
|
+
self.info("预加载 luacov")
|
|
121
|
+
app_preloader_luacov = os.path.join(self.rtos_rootfs, "opt/bmc/libmc/lualib/mc/app_preloader_luacov.lua")
|
|
122
|
+
|
|
123
|
+
with os.fdopen(os.open(app_preloader_luacov, os.O_WRONLY | os.O_CREAT | os.O_TRUNC,
|
|
124
|
+
stat.S_IWUSR | stat.S_IRUSR), 'w') as fp:
|
|
125
|
+
write_str = "require 'mc.app_preloader'\nrequire 'luacov'\n "
|
|
126
|
+
fp.write(write_str)
|
|
127
|
+
|
|
128
|
+
def prepare_coverage_config(self):
|
|
129
|
+
"""
|
|
130
|
+
整包覆盖率统计: 修改luacov覆盖率配置文件
|
|
131
|
+
"""
|
|
132
|
+
self.info("准备覆盖率配置")
|
|
133
|
+
coverage_config = os.path.join(self.rtos_rootfs, "opt/bmc/lualib/luacov/luacov/defaults.lua")
|
|
134
|
+
coverage_path = os.path.join("/", "data/")
|
|
135
|
+
with open(coverage_config, "r") as f:
|
|
136
|
+
lines = f.readlines()
|
|
137
|
+
# 修改输出数据路径
|
|
138
|
+
search_str = ' statsfile = "luacov.stats.out",\n'
|
|
139
|
+
replace_str = f' statsfile = "{coverage_path}luacov.stats.out",\n'
|
|
140
|
+
lines = [replace_str if line == search_str else line for line in lines]
|
|
141
|
+
# 使能HTML形式报告
|
|
142
|
+
search_str = ' reportfile = "luacov.report.out",\n'
|
|
143
|
+
replace_str = f' reportfile = "{coverage_path}luacov.report.html",\n'
|
|
144
|
+
insert_str = ' reporter = "html",\n'
|
|
145
|
+
lines = [replace_str if line == search_str else line for line in lines]
|
|
146
|
+
insert_index = lines.index(replace_str)
|
|
147
|
+
lines.insert(insert_index + 1, insert_str)
|
|
148
|
+
# 使能统计未运行到的代码
|
|
149
|
+
search_str = ' includeuntestedfiles = false,\n'
|
|
150
|
+
replace_str = ' includeuntestedfiles = true,\n'
|
|
151
|
+
lines = [replace_str if line == search_str else line for line in lines]
|
|
152
|
+
write_str = "".join(lines)
|
|
153
|
+
with os.fdopen(os.open(coverage_config, os.O_WRONLY | os.O_CREAT | os.O_TRUNC,
|
|
154
|
+
stat.S_IWUSR | stat.S_IRUSR), 'w') as fp:
|
|
155
|
+
fp.write(write_str)
|
|
156
|
+
|
|
157
|
+
def modify_maca_check_for_luacov(self):
|
|
158
|
+
"""
|
|
159
|
+
保证服务正常:luacov工具会降低各组件服务运行速度,需要修改maca启动检查和健康检查避免服务重启
|
|
160
|
+
"""
|
|
161
|
+
self.info("修改 maca 检查配置文件")
|
|
162
|
+
maca_startup_path = os.path.join(self.rtos_rootfs, "opt/bmc/apps/maca/lualib/app_mgmt/monitor/startup/init.lua")
|
|
163
|
+
with open(maca_startup_path, "r") as f:
|
|
164
|
+
lines = f.readlines()
|
|
165
|
+
# 延长maca启动检查事件
|
|
166
|
+
search_str1 = 'local STARTUP_CHECK_TIMEOUT<const> = 2\n'
|
|
167
|
+
replace_str1 = 'local STARTUP_CHECK_TIMEOUT<const> = 30\n'
|
|
168
|
+
lines = [replace_str1 if line == search_str1 else line for line in lines]
|
|
169
|
+
search_str2 = 'local MAX_STARTUP_CHECK_TIMES<const> = 6\n'
|
|
170
|
+
replace_str2 = 'local MAX_STARTUP_CHECK_TIMES<const> = 200\n'
|
|
171
|
+
lines = [replace_str2 if line == search_str2 else line for line in lines]
|
|
172
|
+
search_str3 = 'local MAX_ABNORMAL_RESET_TIMES<const> = 10\n'
|
|
173
|
+
replace_str3 = 'local MAX_ABNORMAL_RESET_TIMES<const> = 200\n'
|
|
174
|
+
lines = [replace_str3 if line == search_str3 else line for line in lines]
|
|
175
|
+
write_str = "".join(lines)
|
|
176
|
+
with os.fdopen(os.open(maca_startup_path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC,
|
|
177
|
+
stat.S_IWUSR | stat.S_IRUSR), 'w') as fp:
|
|
178
|
+
fp.write(write_str)
|
|
179
|
+
|
|
180
|
+
maca_health_path = os.path.join(self.rtos_rootfs, "opt/bmc/apps/maca/lualib/app_mgmt/monitor/health/init.lua")
|
|
181
|
+
with open(maca_health_path, "r") as f:
|
|
182
|
+
lines = f.readlines()
|
|
183
|
+
# 取消maca健康检查
|
|
184
|
+
search_str = ' self:check_components_health()\n'
|
|
185
|
+
replace_str = ' -- self:check_components_health()\n'
|
|
186
|
+
lines = [replace_str if line == search_str else line for line in lines]
|
|
187
|
+
write_str = "".join(lines)
|
|
188
|
+
with os.fdopen(os.open(maca_health_path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC,
|
|
189
|
+
stat.S_IWUSR | stat.S_IRUSR), 'w') as fp:
|
|
190
|
+
fp.write(write_str)
|
|
191
|
+
|
|
192
|
+
# 支持配置导入导出schema文件根据产品不同配置进行定制化
|
|
193
|
+
def schema_custom(self):
|
|
194
|
+
self.info("开始自定义模式")
|
|
195
|
+
schema_path = os.path.join(self.rtos_rootfs, "opt/bmc/profile_schema")
|
|
196
|
+
# 产品差异化shcema路径,由vpd仓打包到指定路径下
|
|
197
|
+
product_schema_path = os.path.join(self.rtos_rootfs, "opt/bmc/profile_schema/product")
|
|
198
|
+
# 整合schema, 生成默认配置
|
|
199
|
+
combine_schemas = CombineJsonSchemas(self.config, schema_path)
|
|
200
|
+
combine_schemas.gen_default_settings()
|
|
201
|
+
# 差异化处理完schema文件之后已完成schema整合,不在需要产品schema目录(强制删除时即使不存在也不会出错)
|
|
202
|
+
self.run_command(f"rm -rf {product_schema_path}", sudo=True)
|
|
203
|
+
|
|
204
|
+
# 支持映射配置文件根据产品差异进行打补丁
|
|
205
|
+
def mapping_config_patch(self):
|
|
206
|
+
self.info("开始根据配置映射打补丁")
|
|
207
|
+
for item in ["redfish", "web_backend", misc.CLI, "snmp"]:
|
|
208
|
+
config_path = os.path.join(self.rtos_rootfs, "opt/bmc/apps", item, "interface_config")
|
|
209
|
+
if not os.path.isdir(config_path):
|
|
210
|
+
continue
|
|
211
|
+
patch_work = MappingConfigPatch(self.config, config_path=config_path)
|
|
212
|
+
patch_work.run()
|
|
213
|
+
|
|
214
|
+
def scan_mds_dir(self, mds_dir):
|
|
215
|
+
for mds_file in os.scandir(mds_dir):
|
|
216
|
+
if not mds_file.is_file() or not mds_file.name.endswith(".json"):
|
|
217
|
+
continue
|
|
218
|
+
mds_file_permission = self.tools.get_file_permission(mds_file.path)
|
|
219
|
+
self.run_command(f"chmod 777 {mds_file.path}", sudo=True, command_echo=False)
|
|
220
|
+
self.remove_space_in_json_file(mds_file.path)
|
|
221
|
+
self.run_command(f"chmod {mds_file_permission} {mds_file.path}", sudo=True, command_echo=False)
|
|
222
|
+
|
|
223
|
+
def remove_space_in_json_file(self, file_path):
|
|
224
|
+
try:
|
|
225
|
+
with open(file_path, "r") as fp:
|
|
226
|
+
content = json.load(fp)
|
|
227
|
+
with os.fdopen(os.open(file_path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC,
|
|
228
|
+
stat.S_IWUSR | stat.S_IRUSR), 'w') as fp:
|
|
229
|
+
json.dump(content, fp, separators=(',', ':'))
|
|
230
|
+
except Exception as e:
|
|
231
|
+
raise Exception(f"{file_path} 文件解析失败: {e}") from e
|
|
232
|
+
|
|
233
|
+
def trim_mds_and_sr_json(self):
|
|
234
|
+
self.info("移除 mds 文件和 sr 文件中的空格")
|
|
235
|
+
apps_dir = os.path.join(self.rtos_rootfs, "opt/bmc/apps")
|
|
236
|
+
if os.path.isdir(apps_dir):
|
|
237
|
+
apps_dir_permission = self.tools.get_file_permission(apps_dir)
|
|
238
|
+
self.run_command(f"chmod 777 {apps_dir}", sudo=True, command_echo=False)
|
|
239
|
+
for app_dir in os.scandir(apps_dir):
|
|
240
|
+
mds_dir = os.path.join(app_dir.path, "mds")
|
|
241
|
+
if not app_dir.is_dir() or not os.path.isdir(mds_dir):
|
|
242
|
+
continue
|
|
243
|
+
mds_dir_permission = self.tools.get_file_permission(mds_dir)
|
|
244
|
+
self.run_command(f"chmod 777 {mds_dir}", sudo=True, command_echo=False)
|
|
245
|
+
self.scan_mds_dir(mds_dir)
|
|
246
|
+
self.run_command(f"chmod {mds_dir_permission} {mds_dir}", sudo=True, command_echo=False)
|
|
247
|
+
self.run_command(f"chmod {apps_dir_permission} {apps_dir}", sudo=True, command_echo=False)
|
|
248
|
+
|
|
249
|
+
sr_dir = os.path.join(self.rtos_rootfs, "opt/bmc/sr")
|
|
250
|
+
if not os.path.isdir(sr_dir):
|
|
251
|
+
return
|
|
252
|
+
sr_dir_permission = self.tools.get_file_permission(sr_dir)
|
|
253
|
+
self.run_command(f"chmod 777 {sr_dir}", sudo=True, command_echo=False)
|
|
254
|
+
for sr_file in os.scandir(sr_dir):
|
|
255
|
+
if not sr_file.is_file() or not sr_file.name.endswith(".sr"):
|
|
256
|
+
continue
|
|
257
|
+
sr_file_permission = self.tools.get_file_permission(sr_file.path)
|
|
258
|
+
self.run_command(f"chmod 777 {sr_file.path}", sudo=True, command_echo=False)
|
|
259
|
+
self.remove_space_in_json_file(sr_file.path)
|
|
260
|
+
self.run_command(f"chmod {sr_file_permission} {sr_file.path}", sudo=True, command_echo=False)
|
|
261
|
+
self.run_command(f"chmod {sr_dir_permission} {sr_dir}", sudo=True, command_echo=False)
|
|
262
|
+
|
|
263
|
+
def merge_and_converge_process(self, sr_dir, sr_file, csr_version):
|
|
264
|
+
try:
|
|
265
|
+
sr_file_base_name, _ = os.path.splitext(sr_file.name)
|
|
266
|
+
with open(sr_file.path, "r") as fp:
|
|
267
|
+
sr_data = json.load(fp)
|
|
268
|
+
csr_version[sr_file_base_name] = {
|
|
269
|
+
"FormatVersion": str(sr_data["FormatVersion"]),
|
|
270
|
+
"DataVersion": str(sr_data["DataVersion"]),
|
|
271
|
+
"Merged": True
|
|
272
|
+
}
|
|
273
|
+
except Exception as e:
|
|
274
|
+
raise Exception(f"{sr_file.path} 获取sr文件版本号失败: {e}") from e
|
|
275
|
+
try:
|
|
276
|
+
soft_sr_file_name = sr_file_base_name + '_soft.sr'
|
|
277
|
+
soft_sr_file_path = os.path.join(sr_dir, soft_sr_file_name)
|
|
278
|
+
if not os.path.exists(soft_sr_file_path):
|
|
279
|
+
return
|
|
280
|
+
soft_sr_dir_permission = self.tools.get_file_permission(sr_dir)
|
|
281
|
+
self.run_command(f"chmod 777 {soft_sr_file_path}", sudo=True, command_echo=False)
|
|
282
|
+
with open(soft_sr_file_path, "r") as fp:
|
|
283
|
+
soft_sr_data = json.load(fp)
|
|
284
|
+
except Exception as e:
|
|
285
|
+
raise Exception(f"{soft_sr_file_path} soft sr文件解析失败: {e}") from e
|
|
286
|
+
try:
|
|
287
|
+
for key, value in sr_data['Objects'].items():
|
|
288
|
+
if key in soft_sr_data['Objects']:
|
|
289
|
+
sr_data['Objects'][key] = {**value, **soft_sr_data['Objects'][key]}
|
|
290
|
+
sr_data['Objects'] = {**soft_sr_data['Objects'], **sr_data['Objects']}
|
|
291
|
+
self.run_command(f"chmod {soft_sr_dir_permission} {soft_sr_file_path}", sudo=True, command_echo=False)
|
|
292
|
+
except Exception as e:
|
|
293
|
+
raise Exception(f"{sr_file.path} 文件合并失败: {e}") from e
|
|
294
|
+
try:
|
|
295
|
+
with os.fdopen(os.open(sr_file.path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC,
|
|
296
|
+
stat.S_IWUSR | stat.S_IRUSR), 'w') as fp:
|
|
297
|
+
json.dump(sr_data, fp, separators=(',', ':'))
|
|
298
|
+
except Exception as e:
|
|
299
|
+
raise Exception(f"{sr_file.path} 文件覆盖失败: {e}") from e
|
|
300
|
+
|
|
301
|
+
def merge_sr_and_converge_version(self, csr_version):
|
|
302
|
+
self.info("合并 sr 和 soft sr, 汇聚 sr 文件中的版本号")
|
|
303
|
+
sr_dir = os.path.join(self.rtos_rootfs, "opt/bmc/sr")
|
|
304
|
+
if not os.path.isdir(sr_dir):
|
|
305
|
+
return
|
|
306
|
+
sr_dir_permission = self.tools.get_file_permission(sr_dir)
|
|
307
|
+
self.run_command(f"chmod 777 {sr_dir}", sudo=True, command_echo=False)
|
|
308
|
+
for sr_file in os.scandir(sr_dir):
|
|
309
|
+
if not sr_file.is_file() or not sr_file.name.endswith(".sr") or sr_file.name.endswith("_soft.sr"):
|
|
310
|
+
continue
|
|
311
|
+
sr_file_permission = self.tools.get_file_permission(sr_file.path)
|
|
312
|
+
self.run_command(f"chmod 777 {sr_file.path}", sudo=True, command_echo=False)
|
|
313
|
+
self.merge_and_converge_process(sr_dir, sr_file, csr_version)
|
|
314
|
+
self.run_command(f"chmod {sr_file_permission} {sr_file.path}", sudo=True, command_echo=False)
|
|
315
|
+
self.run_command(f"chmod {sr_dir_permission} {sr_dir}", sudo=True, command_echo=False)
|
|
316
|
+
|
|
317
|
+
def create_csr_version_file(self, csr_version):
|
|
318
|
+
self.info("生成 csr_version.json 文件")
|
|
319
|
+
csr_version = sorted(csr_version.items(), key=lambda item: item[0])
|
|
320
|
+
csr_version = dict(csr_version)
|
|
321
|
+
sr_dir = os.path.join(self.rtos_rootfs, "opt/bmc/sr")
|
|
322
|
+
if not os.path.isdir(sr_dir):
|
|
323
|
+
return
|
|
324
|
+
sr_dir_permission = self.tools.get_file_permission(sr_dir)
|
|
325
|
+
self.run_command(f"chmod 777 {sr_dir}", sudo=True, command_echo=False)
|
|
326
|
+
csr_version_file_path = os.path.join(sr_dir, "csr_version.json")
|
|
327
|
+
try:
|
|
328
|
+
with os.fdopen(os.open(csr_version_file_path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC,
|
|
329
|
+
stat.S_IWUSR | stat.S_IRUSR), 'w') as fp:
|
|
330
|
+
json.dump(csr_version, fp, separators=(',', ':'))
|
|
331
|
+
except Exception as e:
|
|
332
|
+
raise Exception(f"{csr_version_file_path} 文件生成失败: {e}") from e
|
|
333
|
+
self.run_command(f"chmod {sr_dir_permission} {sr_dir}", sudo=True, command_echo=False)
|
|
334
|
+
self.run_command(f"chmod 440 {csr_version_file_path}", sudo=True, command_echo=False)
|
|
335
|
+
|
|
336
|
+
def make_strip_cmd(self, file_list):
|
|
337
|
+
work_path = os.getcwd()
|
|
338
|
+
relative_path = os.path.relpath(work_path, self.rtos_rootfs)
|
|
339
|
+
base = ["sudo find {} -type f ".format(relative_path)]
|
|
340
|
+
base.append("grep -v \"/share/\"")
|
|
341
|
+
base.append("grep -v \".json$\"")
|
|
342
|
+
base.append("grep -v \"\.lua$\"")
|
|
343
|
+
base.append("grep -v \".sh$\"")
|
|
344
|
+
base.append("grep -v \".png$\"")
|
|
345
|
+
base.append("grep -v \".jpg$\"")
|
|
346
|
+
base.append("grep -v \".jpeg$\"")
|
|
347
|
+
base.append("grep -v \".html$\"")
|
|
348
|
+
base.append("grep -v \".js$\"")
|
|
349
|
+
base.append("grep -v \".css$\"")
|
|
350
|
+
base.append("grep -v \".svg$\"")
|
|
351
|
+
base.append("grep -v \".sr$\"")
|
|
352
|
+
base.append("grep -v \".conf$\"")
|
|
353
|
+
base.append("grep -v \".service$\"")
|
|
354
|
+
base.append("grep -v \".cfg$\"")
|
|
355
|
+
base.append("grep -v \".gif$\"")
|
|
356
|
+
base.append("grep -v \".ttf$\"")
|
|
357
|
+
base.append("grep -v \".target$\"")
|
|
358
|
+
if self.config.build_type == "debug":
|
|
359
|
+
# so库一般带有版本号,此处不能注明具体的版本号,否则可能导致版本变更时不能正确strip
|
|
360
|
+
not_striped_list = ["rootfs/opt/bmc", "libclp_common.so", "libclp_private_cmd.so", "libcutils.so"]
|
|
361
|
+
not_striped_list += ["libfilehook.so", "liblogging.so", "liblua.so", "libmctp.so", "libnsm_kmc.so"]
|
|
362
|
+
not_striped_list += ["libplatform.so", "libsnmp.so", "libsoc_adapter.so", "libuip.so"]
|
|
363
|
+
for file in not_striped_list:
|
|
364
|
+
base.append("grep -v \"{}\"".format(file))
|
|
365
|
+
base.append("sudo xargs -P 0 -I {{}} file {{}}".format(file_list))
|
|
366
|
+
base.append("grep 'not stripped'")
|
|
367
|
+
base.append("awk -F: '{{print $1}}'")
|
|
368
|
+
base.append("grep -v '.ko$'")
|
|
369
|
+
return base
|
|
370
|
+
|
|
371
|
+
def build_common_fs(self):
|
|
372
|
+
"""
|
|
373
|
+
构建rootfs根文件系统,文件存在self.buildimg_dir目录下
|
|
374
|
+
"""
|
|
375
|
+
self.chdir(self.buildimg_dir)
|
|
376
|
+
self.info("开始构建 rootfs ...")
|
|
377
|
+
|
|
378
|
+
rtos_tar = os.path.join(self.config.sdk_path, "rtos.tar.gz")
|
|
379
|
+
sdk_tar = os.path.join(self.config.sdk_path, "hi1711sdk.tar.gz")
|
|
380
|
+
# 解压SDK
|
|
381
|
+
self.run_command(f"rm -rf {self.rtos_rootfs}", sudo=True)
|
|
382
|
+
self.run_command(f"tar --xattrs --xattrs-include=* -xf {rtos_tar}", sudo=True)
|
|
383
|
+
self.run_command(f"sudo chown -R 0:0 {self.rtos_rootfs}", sudo=True)
|
|
384
|
+
self.info("拷贝RTOS提供的mke2fs.conf配置文件覆盖本地环境中的/etc/mke2fs.conf文件, 确保mkfs.ext4使用该配置文件")
|
|
385
|
+
self.run_command(f"cp -f {self.rtos_rootfs}/etc/mke2fs.conf /etc/mke2fs.conf", sudo=True)
|
|
386
|
+
self.run_command(f"rm -rf {self.rtos_rootfs}/etc/ssh", sudo=True)
|
|
387
|
+
self.run_command(f"rm -rf {self.rtos_rootfs}/usr/share/doc/openubmc", sudo=True)
|
|
388
|
+
|
|
389
|
+
# 记录代码分支和提交节点
|
|
390
|
+
self.create_bmc_release()
|
|
391
|
+
|
|
392
|
+
# 解压SDK并复制到指定位置
|
|
393
|
+
sdk_path = os.path.join(self.buildimg_dir, "sdk")
|
|
394
|
+
self.run_command(f"rm -rf {sdk_path}", sudo=True)
|
|
395
|
+
self.run_command(f"mkdir -p {sdk_path}", sudo=True)
|
|
396
|
+
self.run_command("tar -xf {} -C {}".format(sdk_tar, sdk_path), sudo=True)
|
|
397
|
+
ko_path = f"{self.rtos_rootfs}/lib/modules/"
|
|
398
|
+
self.run_command("cp -dfr {}/. {}".format(sdk_path, ko_path), sudo=True)
|
|
399
|
+
|
|
400
|
+
self.chdir(self.config.work_out)
|
|
401
|
+
self.copy_rtos_modules()
|
|
402
|
+
|
|
403
|
+
for cus in self.customization:
|
|
404
|
+
cus.rootfs_cust(self.rtos_rootfs)
|
|
405
|
+
# strip非ko文件
|
|
406
|
+
file_list = os.path.join(self.buildimg_dir, "no_striped.filelist")
|
|
407
|
+
base = self.make_strip_cmd(file_list)
|
|
408
|
+
strip = os.path.join(self.config.cross_compile_install_path, "bin", self.config.strip)
|
|
409
|
+
self.pipe_command(base, file_list)
|
|
410
|
+
if os.path.isfile(file_list) and not self.config.enable_arm_gcov:
|
|
411
|
+
cmd = ["cat {}".format(file_list), "sudo xargs -P 0 -I {{}} {} -R .comment {{}}".format(strip)]
|
|
412
|
+
self.pipe_command(cmd)
|
|
413
|
+
cmd = ["cat {}".format(file_list), "sudo xargs -P 0 -I {{}} {} {{}}".format(strip)]
|
|
414
|
+
self.pipe_command(cmd)
|
|
415
|
+
# 删除.a文件
|
|
416
|
+
cmd = ["sudo find {} -type f -name *.a".format(self.rtos_rootfs), "sudo xargs -P 0 -i{{}} rm {{}}"]
|
|
417
|
+
self.pipe_command(cmd)
|
|
418
|
+
self.build_cfg_fs()
|
|
419
|
+
# 使能覆盖率统计
|
|
420
|
+
if self.config.enable_arm_gcov:
|
|
421
|
+
self.modify_maca_check_for_luacov()
|
|
422
|
+
self.prepare_config_for_luacov()
|
|
423
|
+
self.prepare_preloader_for_luacov()
|
|
424
|
+
self.prepare_coverage_config()
|
|
425
|
+
|
|
426
|
+
def create_bmc_release(self):
|
|
427
|
+
bmc_release_path = f"{self.rtos_rootfs}/etc/bmc-release"
|
|
428
|
+
temp_bmc_release_file = tempfile.NamedTemporaryFile()
|
|
429
|
+
repo = Repo(self.config.code_root)
|
|
430
|
+
current_commit = repo.head.commit
|
|
431
|
+
commit_content_item = f"COMMIT={current_commit.hexsha}\nCOMMIT_DATE={current_commit.committed_datetime}\n"
|
|
432
|
+
try:
|
|
433
|
+
commit_head = f'BRANCH={repo.active_branch.name}'
|
|
434
|
+
except Exception as e:
|
|
435
|
+
# 获取当前提交的所有标签
|
|
436
|
+
tags = repo.tags
|
|
437
|
+
# 查找与当前提交匹配的标签
|
|
438
|
+
current_commit_tag = ""
|
|
439
|
+
for tag in tags:
|
|
440
|
+
if tag.commit == current_commit:
|
|
441
|
+
current_commit_tag = tag
|
|
442
|
+
break
|
|
443
|
+
commit_head = f'TAG={current_commit_tag}'
|
|
444
|
+
commit_content = f"{commit_head}\n{commit_content_item}"
|
|
445
|
+
with os.fdopen(os.open(temp_bmc_release_file.name, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, stat.S_IWUSR |
|
|
446
|
+
stat.S_IRUSR | stat.S_IWGRP | stat.S_IRGRP | stat.S_IWOTH | stat.S_IROTH),
|
|
447
|
+
'w') as file:
|
|
448
|
+
file.write(commit_content)
|
|
449
|
+
self.run_command(f"cp {temp_bmc_release_file.name} {bmc_release_path}", sudo=True, command_echo=False)
|
|
450
|
+
self.run_command(f"chmod 644 {bmc_release_path}", sudo=True)
|
|
451
|
+
|
|
452
|
+
def copy_rtos_modules(self):
|
|
453
|
+
self.run_command("cp -af {}/. {}".format(self.config.rootfs_path, self.rtos_rootfs), sudo=True)
|
|
454
|
+
cp_cmd = "cp -df {} {}"
|
|
455
|
+
self.run_command(cp_cmd.format("/opt/hcc_arm64le/aarch64-target-linux-gnu/lib64/libgcc_s.so.1",
|
|
456
|
+
f"{self.rtos_rootfs}/lib64/libgcc_s.so.1"), sudo=True)
|
|
457
|
+
self.run_command(cp_cmd.format("/opt/hcc_arm64le/aarch64-target-linux-gnu/lib64/libstdc++.so.6",
|
|
458
|
+
f"{self.rtos_rootfs}/lib64/libstdc++.so.6"), sudo=True)
|
|
459
|
+
self.run_command("mkdir -p {}".format(f"{self.rtos_rootfs}/opt/pme/upgrade"), sudo=True)
|
|
460
|
+
self.run_command(cp_cmd.format(f"{self.config.code_path}/manufacture/misc/pme_profile_en.dat",
|
|
461
|
+
f"{self.rtos_rootfs}/opt/pme/upgrade/pme_profile_en"), sudo=True)
|
|
462
|
+
self.run_command(cp_cmd.format(f"{self.config.code_path}/manufacture/misc/datatocheck_upgrade.dat",
|
|
463
|
+
f"{self.rtos_rootfs}/opt/pme/upgrade/datatocheck_upgrade.dat"),
|
|
464
|
+
sudo=True)
|
|
465
|
+
self.run_command("chmod 755 {}".format(f"{self.rtos_rootfs}/lib64/libgcc_s.so.1"), sudo=True)
|
|
466
|
+
self.run_command("chmod 755 {}".format(f"{self.rtos_rootfs}/lib64/libstdc++.so.6"), sudo=True)
|
|
467
|
+
self.run_command("chmod 400 {}".format(f"{self.rtos_rootfs}/opt/pme/upgrade/pme_profile_en"), sudo=True)
|
|
468
|
+
self.run_command("chmod 400 {}".format(f"{self.rtos_rootfs}/opt/pme/upgrade/datatocheck_upgrade.dat"),
|
|
469
|
+
sudo=True)
|
|
470
|
+
|
|
471
|
+
def make_datafs_img(self):
|
|
472
|
+
tar_path = f"{self.rtos_rootfs}/usr/upgrade/datafs.tar.gz"
|
|
473
|
+
self.run_command(f"mkdir -p {self.rtos_datafs}", sudo=True)
|
|
474
|
+
self.run_command(f"mkdir -p {os.path.dirname(tar_path)}", sudo=True)
|
|
475
|
+
|
|
476
|
+
# 自定义配置
|
|
477
|
+
for cus in self.customization:
|
|
478
|
+
cus.datafs_cust(self.rtos_datafs)
|
|
479
|
+
|
|
480
|
+
# 打包datafs.tar.gz
|
|
481
|
+
self.chdir(self.rtos_rootfs)
|
|
482
|
+
|
|
483
|
+
# ! 制作datafs img镜像,供work_buildpkg_ext4.py使用
|
|
484
|
+
datafs_mount_path = f"{self.config.build_path}/mnt_datafs/"
|
|
485
|
+
self.run_command(f"mkdir -p {datafs_mount_path}", sudo=True)
|
|
486
|
+
|
|
487
|
+
# 等待dd任务创建self.datafs_img_path完成
|
|
488
|
+
while True:
|
|
489
|
+
if not self.datafs_img_process.is_alive():
|
|
490
|
+
if self.datafs_img_process.exitcode is not None and self.datafs_img_process.exitcode != 0:
|
|
491
|
+
raise errors.BmcGoException(f"创建镜像文件 {self.datafs_img_process.img_path} 失败")
|
|
492
|
+
break
|
|
493
|
+
time.sleep(0.1)
|
|
494
|
+
self.tools.create_image_and_mount_datafs(self.datafs_img_path, datafs_mount_path)
|
|
495
|
+
|
|
496
|
+
# 复制所有文件到挂载目录
|
|
497
|
+
self.run_command(f"cp -a {self.rtos_datafs}/. {datafs_mount_path}", ignore_error=True, sudo=True)
|
|
498
|
+
self.run_command(f"chown 0:0 {datafs_mount_path}", sudo=True)
|
|
499
|
+
self.tools.umount_datafs(datafs_mount_path)
|
|
500
|
+
self.run_command(f"rm -rf {datafs_mount_path}", sudo=True)
|
|
501
|
+
|
|
502
|
+
subprocess.run(f"LD_PRELOAD= sudo LD_PRELOAD=${{LD_PRELOAD}} -E\
|
|
503
|
+
/usr/bin/tar --format=gnu -czvf {tar_path} ./data/", shell=True, check=True)
|
|
504
|
+
self.run_command(f"chmod 440 {tar_path}", sudo=True)
|
|
505
|
+
self.run_command(f"chown 0:0 {tar_path}", sudo=True)
|
|
506
|
+
return
|
|
507
|
+
|
|
508
|
+
def make_rootfs_img(self):
|
|
509
|
+
self.make_datafs_img()
|
|
510
|
+
|
|
511
|
+
# 等待dd任务创建self.rootfs_img_path完成
|
|
512
|
+
while True:
|
|
513
|
+
if not self.rootfs_img_process.is_alive():
|
|
514
|
+
if self.rootfs_img_process.exitcode is not None and self.rootfs_img_process.exitcode != 0:
|
|
515
|
+
raise errors.BmcGoException(f"创建镜像文件 {self.rootfs_img_process.img_path} 失败")
|
|
516
|
+
break
|
|
517
|
+
time.sleep(0.1)
|
|
518
|
+
self.tools.create_image_and_mount_datafs(self.rootfs_img_path, self.mnt_datafs)
|
|
519
|
+
self.component_cust_conf()
|
|
520
|
+
|
|
521
|
+
# 差异化处理装备定制化schema文件
|
|
522
|
+
self.schema_custom()
|
|
523
|
+
|
|
524
|
+
# 映射配置机型差异补丁
|
|
525
|
+
self.mapping_config_patch()
|
|
526
|
+
|
|
527
|
+
# 合并sr和soft sr,汇聚csr version
|
|
528
|
+
csr_version = {}
|
|
529
|
+
self.merge_sr_and_converge_version(csr_version)
|
|
530
|
+
|
|
531
|
+
# 生成csr_version文件
|
|
532
|
+
self.create_csr_version_file(csr_version)
|
|
533
|
+
|
|
534
|
+
# 去除mds和sr文件中的空格和换行,节省空间和内存
|
|
535
|
+
self.trim_mds_and_sr_json()
|
|
536
|
+
|
|
537
|
+
self.component_swbom()
|
|
538
|
+
self.run_command(f"sudo cp -a {self.rtos_rootfs}/. {self.mnt_datafs}/")
|
|
539
|
+
if self.config.build_type == 'debug':
|
|
540
|
+
for cus in self.customization:
|
|
541
|
+
cus.rootfs_debug_cust(self.mnt_datafs)
|
|
542
|
+
elif self.config.build_type == 'release':
|
|
543
|
+
for cus in self.customization:
|
|
544
|
+
cus.rootfs_release_cust(self.mnt_datafs)
|
|
545
|
+
|
|
546
|
+
for cus in self.customization:
|
|
547
|
+
cus.rootfs_common(self.mnt_datafs)
|
|
548
|
+
self.chdir(self.config.work_out)
|
|
549
|
+
self.tools.umount_datafs(self.mnt_datafs)
|
|
550
|
+
|
|
551
|
+
self.run_command(f"zerofree -v {self.rootfs_img_path}")
|
|
552
|
+
self.run_command(f"get_img_parma_area.sh {self.rootfs_img_path}")
|
|
553
|
+
|
|
554
|
+
def build_cfg_fs(self):
|
|
555
|
+
self.chdir(self.rtos_rootfs)
|
|
556
|
+
self.info(f"开始制作 {self.config.board_name} cfgfs ...")
|
|
557
|
+
|
|
558
|
+
self.run_command(f"chmod o+w {self.rtos_rootfs}/etc/profile", sudo=True)
|
|
559
|
+
ps1_replace = 'PS1="\\\\\[\\\\033[32m\\\\\]~ \\\\w\\\[\\\\033[m\\\\\] \\\\\\\\\$ "'
|
|
560
|
+
self.run_command(f"sed -i 's/^PS1=.*$/{ps1_replace}/' {self.rtos_rootfs}/etc/profile", sudo=True)
|
|
561
|
+
|
|
562
|
+
f = open(f"{self.rtos_rootfs}/etc/profile", mode='a+')
|
|
563
|
+
f.write((
|
|
564
|
+
'LD_LIBRARY_PATH=/opt/bmc/lib:/usr/local/lib:/lib:/opt/pme/lib:/opt/pme/plugins/chip:'
|
|
565
|
+
'/opt/bmc/lib:/lib/systemd\n'
|
|
566
|
+
'if [ ! -d /dev/shm/dbus ]; then\n'
|
|
567
|
+
' mkdir -p /dev/shm/dbus\n'
|
|
568
|
+
'fi\n'
|
|
569
|
+
'if [ ! -f /dev/shm/dbus/.dbus ]; then\n'
|
|
570
|
+
' dbus-launch >/dev/shm/dbus/.dbus\n'
|
|
571
|
+
'fi\n'
|
|
572
|
+
'sleep 1\n'
|
|
573
|
+
'export $(cat /dev/shm/dbus/.dbus)\n'
|
|
574
|
+
))
|
|
575
|
+
f.close()
|
|
576
|
+
self.run_command(f"chmod o-w {self.rtos_rootfs}/etc/profile", sudo=True)
|
|
577
|
+
|
|
578
|
+
def change_own(self):
|
|
579
|
+
user_group = f"{os.getuid()}:{os.getgid()}"
|
|
580
|
+
self.run_command(f"chown -R {user_group} {self.buildimg_dir}")
|
|
581
|
+
self.run_command(f"chown -R {user_group} {self.buildimg_dir}")
|
|
582
|
+
return
|
|
583
|
+
|
|
584
|
+
def run(self):
|
|
585
|
+
# 性能调优,异步进程dd创建image文件
|
|
586
|
+
self.rootfs_img_process = MakeZeroImageProcess(self, 96256, self.rootfs_img_path)
|
|
587
|
+
self.rootfs_img_process.start()
|
|
588
|
+
|
|
589
|
+
# 性能调优,异步进程dd创建image文件。262144*4096/1024/1024 = 1024MB等于data对应磁盘分区的大小(见config.cfg)
|
|
590
|
+
self.datafs_img_process = MakeZeroImageProcess(self, 262144, self.datafs_img_path)
|
|
591
|
+
self.datafs_img_process.start()
|
|
592
|
+
|
|
593
|
+
self.set_evn()
|
|
594
|
+
self.build_common_fs()
|
|
595
|
+
self.make_rootfs_img()
|