openubmc-bingo 0.5.242__py3-none-any.whl → 0.5.253__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 +1 -1
- bmcgo/bmcgo_config.py +82 -1
- bmcgo/cli/cli.py +0 -2
- bmcgo/cli/config.yaml +9 -0
- bmcgo/codegen/lua/Makefile +13 -0
- bmcgo/codegen/lua/codegen.py +6 -3
- bmcgo/codegen/lua/script/dto/options.py +1 -0
- bmcgo/codegen/lua/script/{render_utils/factory.py → factory.py} +1 -1
- bmcgo/codegen/lua/script/gen_entry.py +6 -3
- bmcgo/codegen/lua/script/gen_intf_rpc_json.py +12 -0
- bmcgo/codegen/lua/script/gen_schema.py +2 -0
- bmcgo/codegen/lua/script/merge_model.py +10 -3
- bmcgo/codegen/lua/script/render_utils/__init__.py +5 -4
- bmcgo/codegen/lua/script/render_utils/client_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/controller_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/db_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/error_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/ipmi_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/ipmi_message_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/mdb_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/message_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/messages_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/model_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/old_model_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/plugin_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/redfish_proto.py +2 -2
- bmcgo/codegen/lua/script/render_utils/request_lua.py +2 -2
- bmcgo/codegen/lua/script/render_utils/service_lua.py +3 -2
- bmcgo/codegen/lua/script/template.py +5 -1
- bmcgo/codegen/lua/script/utils.py +9 -2
- bmcgo/codegen/lua/templates/Makefile +8 -0
- bmcgo/codegen/lua/templates/apps/Makefile +27 -1
- bmcgo/codegen/lua/templates/apps/controller.lua.mako +20 -4
- bmcgo/codegen/lua/v1/script/gen_schema.py +328 -0
- bmcgo/codegen/lua/v1/script/render_utils/model_lua.py +458 -0
- bmcgo/codegen/lua/v1/templates/apps/model.lua.mako +62 -0
- bmcgo/codegen/lua/v1/templates/apps/service.lua.mako +193 -0
- bmcgo/component/build.py +16 -42
- bmcgo/component/component_helper.py +54 -0
- bmcgo/component/coverage/incremental_cov.py +25 -33
- bmcgo/component/deploy.py +7 -9
- bmcgo/frame.py +9 -6
- bmcgo/functional/conan_index_build.py +16 -41
- bmcgo/functional/csr_build.py +313 -88
- bmcgo/functional/diff.py +3 -3
- bmcgo/functional/upgrade.py +31 -1
- bmcgo/misc.py +31 -2
- bmcgo/target/install_sdk.yml +6 -0
- bmcgo/target/personal.yml +5 -0
- bmcgo/target/publish.yml +5 -0
- bmcgo/tasks/task.py +69 -43
- bmcgo/tasks/task_build_conan.py +6 -2
- bmcgo/tasks/task_build_wbd_up.py +69 -0
- bmcgo/utils/config.py +20 -8
- bmcgo/utils/install_manager.py +75 -20
- bmcgo/utils/installations/base_installer.py +114 -7
- bmcgo/utils/installations/install_consts.py +3 -1
- bmcgo/utils/installations/install_plans/bingo.yml +2 -4
- bmcgo/utils/installations/install_workflow.py +6 -2
- bmcgo/utils/installations/installers/apt_installer.py +58 -136
- bmcgo/utils/installations/installers/pip_installer.py +52 -18
- bmcgo/utils/installations/version_util.py +1 -1
- {openubmc_bingo-0.5.242.dist-info → openubmc_bingo-0.5.253.dist-info}/METADATA +2 -1
- {openubmc_bingo-0.5.242.dist-info → openubmc_bingo-0.5.253.dist-info}/RECORD +68 -62
- /bmcgo/codegen/lua/script/{render_utils/base.py → base.py} +0 -0
- {openubmc_bingo-0.5.242.dist-info → openubmc_bingo-0.5.253.dist-info}/WHEEL +0 -0
- {openubmc_bingo-0.5.242.dist-info → openubmc_bingo-0.5.253.dist-info}/entry_points.txt +0 -0
- {openubmc_bingo-0.5.242.dist-info → openubmc_bingo-0.5.253.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
${make_header('lua')}
|
|
2
|
+
<%namespace name="imports" file="../../../templates/apps/utils/imports.mako"/>
|
|
3
|
+
<%namespace name="default_intf" file="../../../templates/apps/utils/default_intf.lua.mako"/>
|
|
4
|
+
<%namespace name="mdb_obj" file= "../../../templates/apps/utils/mdb_obj.lua.mako"/>
|
|
5
|
+
<% has_signal = root['signals']%>
|
|
6
|
+
<% has_mdb = any('path' in cls_data for cls, cls_data in root['class_require'].items())%>
|
|
7
|
+
<% has_default = any((rpc['default'] != '' and not rpc['override']) for rpc in root['methods'])%>
|
|
8
|
+
<% ClassName = root['package'] + '_service' %>
|
|
9
|
+
|
|
10
|
+
% if root['has_ipmi_cmd']:
|
|
11
|
+
local ipmi = require 'ipmi'
|
|
12
|
+
% endif
|
|
13
|
+
% if has_default or has_mdb:
|
|
14
|
+
local mdb = require 'mc.mdb'
|
|
15
|
+
% endif
|
|
16
|
+
% if utils_py.check_local_reset_db(root) or utils_py.check_local_temporary_db(root):
|
|
17
|
+
local skynet = require 'skynet'
|
|
18
|
+
% endif
|
|
19
|
+
local class = require 'mc.class'
|
|
20
|
+
% if has_signal:
|
|
21
|
+
local context = require 'mc.context'
|
|
22
|
+
% endif
|
|
23
|
+
local c = require 'mc.class_mgnt'
|
|
24
|
+
% if utils_py.check_need_mem_db(root):
|
|
25
|
+
local open_db = require '${project_name}.db'
|
|
26
|
+
% endif
|
|
27
|
+
local bootstrap = require 'mc.bootstrap'
|
|
28
|
+
% if utils_py.check_local_poweroff_db(root) or utils_py.check_local_reset_db(root) or utils_py.check_local_temporary_db(root):
|
|
29
|
+
local open_local_db = require '${project_name}.local_db'
|
|
30
|
+
% endif
|
|
31
|
+
% if (root['path_level'] == 2 and utils_py.check_db_open(root['package']) and utils_py.check_remote_per(root)) or root['class_require']:
|
|
32
|
+
local object_manage = require 'mc.mdb.object_manage'
|
|
33
|
+
% endif
|
|
34
|
+
% if root['path_level'] == 2 and utils_py.check_db_open(root['package']) and utils_py.check_remote_per(root):
|
|
35
|
+
local persist_client = require 'persistence.persist_client_lib'
|
|
36
|
+
% endif
|
|
37
|
+
% if utils_py.check_need_mem_db(root) or utils_py.check_need_local_db(root):
|
|
38
|
+
local ok, datas = pcall(require, '${project_name}.datas')
|
|
39
|
+
if not ok then
|
|
40
|
+
datas = nil -- 如果没有datas配置,证明当前组件不需要datas,仅打开数据库
|
|
41
|
+
end
|
|
42
|
+
% endif
|
|
43
|
+
|
|
44
|
+
% for intf, intf_data in root['intf_imports'].items():
|
|
45
|
+
local ${intf}Types = require '${project_name}.json_types.${intf}'
|
|
46
|
+
% endfor
|
|
47
|
+
|
|
48
|
+
% for cls, cls_data in root['class_require'].items():
|
|
49
|
+
${mdb_obj.render(cls, cls_data['data'], root['class_require'])}
|
|
50
|
+
% endfor
|
|
51
|
+
|
|
52
|
+
% if root['path_level'] == 2:
|
|
53
|
+
local ${ClassName} = class(bootstrap.Service)
|
|
54
|
+
% else:
|
|
55
|
+
local ${ClassName} = class(bootstrap.Attach)
|
|
56
|
+
% endif
|
|
57
|
+
|
|
58
|
+
% if has_default:
|
|
59
|
+
${default_intf.add_subs(ClassName)}
|
|
60
|
+
% endif
|
|
61
|
+
${ClassName}.package = '${root['package']}'
|
|
62
|
+
|
|
63
|
+
% for rpc in root['methods']:
|
|
64
|
+
%if rpc['default'] != '' and not rpc['override']:
|
|
65
|
+
<% default_path = ClassName +'.'+ rpc['intf_class'] + 'Default' %>
|
|
66
|
+
require '${project_name}.json_types.${rpc['intf_class']}Default'
|
|
67
|
+
${default_intf.render(default_path, ClassName, rpc['intf_class'] + "Default", rpc['interface'] + ".Default")}
|
|
68
|
+
%endif
|
|
69
|
+
% endfor
|
|
70
|
+
## 动态对象生成创建接口,以便非CSR场景创建对象时使用
|
|
71
|
+
% for cls, cls_data in root['class_require'].items():
|
|
72
|
+
% if render_utils.is_dynamic_obj(cls_data['path']):
|
|
73
|
+
|
|
74
|
+
function ${ClassName}:Create${cls}(${", ".join(render_utils.get_path_params(render_utils.get_path(cls, root['class_require'])))}, prop_setting_cb)
|
|
75
|
+
local path = ${render_utils.make_path(render_utils.get_path(cls, root['class_require']))}
|
|
76
|
+
return object_manage.create_object("${cls}", path, path, prop_setting_cb)
|
|
77
|
+
end
|
|
78
|
+
% else:
|
|
79
|
+
|
|
80
|
+
function ${ClassName}:Create${cls}(prop_setting_cb)
|
|
81
|
+
return object_manage.create_object("${cls}", '${cls}_0', ${render_utils.make_path(render_utils.get_path(cls, root['class_require']))}, prop_setting_cb)
|
|
82
|
+
end
|
|
83
|
+
% endif
|
|
84
|
+
%endfor
|
|
85
|
+
|
|
86
|
+
## 生成注册回调的接口,增加参数校验
|
|
87
|
+
% for rpc in root['methods']:
|
|
88
|
+
<% class_intf = rpc['class'] + '_' + rpc['intf_class'] %>
|
|
89
|
+
% if rpc['interface'] != "bmc.kepler.Object.Properties":
|
|
90
|
+
function ${ClassName}:Impl${rpc['name']}(cb)
|
|
91
|
+
c("${rpc['class']}"):_implement("${rpc['name']}", "${rpc['interface']}", "${rpc['func_name']}", cb)
|
|
92
|
+
end
|
|
93
|
+
% endif
|
|
94
|
+
% endfor
|
|
95
|
+
|
|
96
|
+
% for method, _ in root.get('private_class_require', {}).get('private', {}).get('data', {}).get('methods', {}).items():
|
|
97
|
+
function ${ClassName}:Impl${method}(cb)
|
|
98
|
+
c('private'):_implement("${method}", nil, "${method}", cb)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
function ${ClassName}:${method}(...)
|
|
102
|
+
return c('private'):_call("${method}", ...)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
% endfor
|
|
106
|
+
## 生成发送信号的接口
|
|
107
|
+
% for signal in root['signals']:
|
|
108
|
+
<% params = render_utils.params(signal['signature'])%>
|
|
109
|
+
% if ':' in signal['path']:
|
|
110
|
+
---@param mdb_object object
|
|
111
|
+
% endif
|
|
112
|
+
% for p in render_utils.props(signal['signature']): ## 生成参数注释
|
|
113
|
+
---@param ${p['name']} ${utils_py.do_type_to_lua(p['type'], p['repeated'])}
|
|
114
|
+
% endfor
|
|
115
|
+
function ${ClassName}:${signal['name']}(${'mdb_object,' if (':' in signal['path']) else ''}${params})
|
|
116
|
+
self.bus:signal(${'mdb_object.path' if (':' in signal['path']) else ('"'+signal['path']+'"')}, '${signal['interface']}', '${signal['signal_name']}', 'a{ss}${utils_py.do_service_types_to_dbus(root, signal['signature'][1:])}', context.get_context() or {}${"" if params == '' else ", "}${params})
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
% endfor
|
|
120
|
+
|
|
121
|
+
% if root['has_ipmi_cmd']:
|
|
122
|
+
function ${ClassName}:register_ipmi_cmd(ipmi_cmd, cb)
|
|
123
|
+
self.ipmi_cmds[ipmi_cmd.name] = ipmi.register_ipmi_cmd(self.bus, self.service_name, ipmi_cmd, cb or self[ipmi_cmd.name])
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
function ${ClassName}:unregister_ipmi_cmd(ipmi_cmd)
|
|
127
|
+
local cmd_obj = self.ipmi_cmds[ipmi_cmd.name]
|
|
128
|
+
if not cmd_obj then
|
|
129
|
+
return
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
cmd_obj:unregister()
|
|
133
|
+
self.ipmi_cmds[ipmi_cmd.name] = nil
|
|
134
|
+
end
|
|
135
|
+
% endif
|
|
136
|
+
|
|
137
|
+
function ${ClassName}:ctor(${"" if root['path_level'] == 2 else "bus"})
|
|
138
|
+
self.name = '${project_name}'
|
|
139
|
+
% if utils_py.check_need_mem_db(root):
|
|
140
|
+
self.db = open_db(':memory:', datas)
|
|
141
|
+
% endif
|
|
142
|
+
% if root['path_level'] == 2:
|
|
143
|
+
% if utils_py.check_local_poweroff_db(root):
|
|
144
|
+
self.local_db = open_local_db(bootstrap.Service:get_local_db_path(self.name) .. '/${project_name}.db', datas, 'poweroff')
|
|
145
|
+
% endif
|
|
146
|
+
% endif
|
|
147
|
+
% if utils_py.check_local_reset_db(root) or utils_py.check_local_temporary_db(root):
|
|
148
|
+
if skynet.getenv('TEST_DATA_DIR') then
|
|
149
|
+
% if utils_py.check_local_reset_db(root):
|
|
150
|
+
self.reset_local_db = open_local_db(skynet.getenv('TEST_DATA_DIR')..'/${project_name}_reset.db', datas, "reset")
|
|
151
|
+
% endif
|
|
152
|
+
% if utils_py.check_local_temporary_db(root):
|
|
153
|
+
self.temporary_local_db = open_local_db(skynet.getenv('TEST_DATA_DIR')..'/${project_name}_temp.db', datas, "temporary")
|
|
154
|
+
% endif
|
|
155
|
+
else
|
|
156
|
+
% if utils_py.check_local_reset_db(root):
|
|
157
|
+
self.reset_local_db = open_local_db('/opt/bmc/pram/persistence.local/${project_name}.db', datas, "reset")
|
|
158
|
+
% endif
|
|
159
|
+
% if utils_py.check_local_temporary_db(root):
|
|
160
|
+
self.temporary_local_db = open_local_db('/dev/shm/persistence.local/${project_name}.db', datas, "temporary")
|
|
161
|
+
% endif
|
|
162
|
+
end
|
|
163
|
+
% endif
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
% if root['path_level'] == 2:
|
|
167
|
+
function ${ClassName}:pre_init()
|
|
168
|
+
${ClassName}.super.pre_init(self)
|
|
169
|
+
% if utils_py.check_remote_per(root):
|
|
170
|
+
self.persist = persist_client.new(self.bus, self.db, self, ${render_utils.get_not_recover_tables(root)})
|
|
171
|
+
object_manage.set_persist_client(self.persist)
|
|
172
|
+
% endif
|
|
173
|
+
end
|
|
174
|
+
% endif
|
|
175
|
+
|
|
176
|
+
## service初始化
|
|
177
|
+
function ${ClassName}:init()
|
|
178
|
+
% if root['path_level'] == 2:
|
|
179
|
+
${ClassName}.super.init(self)
|
|
180
|
+
%endif
|
|
181
|
+
% if has_default:
|
|
182
|
+
self:SubscribeAll()
|
|
183
|
+
%endif
|
|
184
|
+
% for rpc in root['methods']:
|
|
185
|
+
%if not rpc['override'] :
|
|
186
|
+
self:Impl${rpc['name']}(function(obj, ctx, ...)
|
|
187
|
+
return self:Get${rpc['default']}Object():${rpc['func_name']}_PACKED(ctx, obj.path,...):unpack()
|
|
188
|
+
end)
|
|
189
|
+
%endif
|
|
190
|
+
% endfor
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
return ${ClassName}
|
bmcgo/component/build.py
CHANGED
|
@@ -49,6 +49,21 @@ class BuildComp():
|
|
|
49
49
|
process = subprocess.run(cmd, check=True, capture_output=True)
|
|
50
50
|
return process.stdout.decode("UTF-8").strip().split("\n")
|
|
51
51
|
|
|
52
|
+
@staticmethod
|
|
53
|
+
def check_luac():
|
|
54
|
+
luac_path = os.path.join(os.path.expanduser('~'), ".conan", "bin", "luac")
|
|
55
|
+
if not os.path.isfile(luac_path):
|
|
56
|
+
raise BmcGoException(f"当前环境中未安装luac!请更新manifest仓代码,执行环境初始化脚本init.py重新部署环境!")
|
|
57
|
+
|
|
58
|
+
conan_bin = os.path.join(os.path.expanduser('~'), ".conan", "bin")
|
|
59
|
+
# 设置PLD_LIBRARY_PATH环境变量,luajit运行时需要加载so动态库
|
|
60
|
+
ld_library_path = conan_bin + ":" + os.environ.get("LD_LIBRARY_PATH", "")
|
|
61
|
+
os.environ["LD_LIBRARY_PATH"] = ld_library_path
|
|
62
|
+
# 设置PATH环境变量,luajit无需指定全路径
|
|
63
|
+
path = conan_bin + ":" + os.environ.get("PATH", "")
|
|
64
|
+
os.environ["PATH"] = path
|
|
65
|
+
os.environ["LUA_PATH"] = f"{conan_bin}/?.lua"
|
|
66
|
+
|
|
52
67
|
def gen_conanbase(self, gen_conanbase, service_json):
|
|
53
68
|
lookup = TemplateLookup(directories=os.path.join(cwd_script, "template"))
|
|
54
69
|
if gen_conanbase:
|
|
@@ -123,47 +138,6 @@ class BuildComp():
|
|
|
123
138
|
return http_proto + chunk[0] + chunk[1]
|
|
124
139
|
return http_proto + chunk[0] + "/" + chunk[1]
|
|
125
140
|
|
|
126
|
-
def install_luac(self):
|
|
127
|
-
conan_bin = os.path.join(os.path.expanduser('~'), ".conan", "bin")
|
|
128
|
-
# 设置PLD_LIBRARY_PATH环境变量,luajit运行时需要加载so动态库
|
|
129
|
-
ld_library_path = conan_bin + ":" + os.environ.get("LD_LIBRARY_PATH", "")
|
|
130
|
-
os.environ["LD_LIBRARY_PATH"] = ld_library_path
|
|
131
|
-
# 设置PATH环境变量,luajit无需指定全路径
|
|
132
|
-
path = conan_bin + ":" + os.environ.get("PATH", "")
|
|
133
|
-
os.environ["PATH"] = path
|
|
134
|
-
os.environ["LUA_PATH"] = f"{conan_bin}/?.lua"
|
|
135
|
-
|
|
136
|
-
# 待安装的luajit版本
|
|
137
|
-
channel = f"@{Tools().conan_user}/{misc.StageEnum.STAGE_STABLE.value}"
|
|
138
|
-
luajit_pkg = f"luajit/2.1.0.B012{channel}"
|
|
139
|
-
luajit_flag = luajit_pkg.split("@")[0].replace("/", "_")
|
|
140
|
-
luajit_flag = os.path.join(conan_bin, luajit_flag)
|
|
141
|
-
|
|
142
|
-
# 使能luajit时需要安装luajit
|
|
143
|
-
luac_path = os.path.join(conan_bin, "luajit")
|
|
144
|
-
# luajit版本一致且luac/luajit存在时赋权即可
|
|
145
|
-
if os.path.isfile(luajit_flag) and os.path.exists(luac_path):
|
|
146
|
-
os.chmod(luac_path, stat.S_IRWXU)
|
|
147
|
-
return
|
|
148
|
-
Tools.clean_conan_bin(conan_bin)
|
|
149
|
-
# 其它情况都尝试安装luajit
|
|
150
|
-
cmd = [misc.CONAN, "install", luajit_pkg]
|
|
151
|
-
cmd += ("-pr profile.dt.ini -if=temp/.deploy -g deploy").split()
|
|
152
|
-
if self.info.remote:
|
|
153
|
-
cmd += ["-r", self.info.remote]
|
|
154
|
-
Helper.run(cmd)
|
|
155
|
-
cmd = ["cp", "temp/.deploy/luajit/usr/bin/luajit", f"{conan_bin}"]
|
|
156
|
-
Helper.run(cmd)
|
|
157
|
-
cmd = ["cp", "temp/.deploy/luajit/usr/lib64/liblua.so", f"{conan_bin}"]
|
|
158
|
-
Helper.run(cmd)
|
|
159
|
-
cmd = ["cp", "-r", "temp/.deploy/luajit/usr/bin/jit", f"{conan_bin}"]
|
|
160
|
-
Helper.run(cmd)
|
|
161
|
-
os.chmod(luac_path, stat.S_IRWXU)
|
|
162
|
-
luajit2luac = shutil.which("luajit2luac.sh")
|
|
163
|
-
cmd = ["cp", luajit2luac, f"{conan_bin}/luac"]
|
|
164
|
-
Helper.run(cmd)
|
|
165
|
-
pathlib.Path(luajit_flag).touch(exist_ok=True)
|
|
166
|
-
|
|
167
141
|
def check_conan_profile(self):
|
|
168
142
|
profile = os.path.join(tool.conan_profiles_dir, self.info.profile)
|
|
169
143
|
luajit_profile = os.path.join(tool.conan_profiles_dir, "profile.luajit.ini")
|
|
@@ -199,7 +173,7 @@ class BuildComp():
|
|
|
199
173
|
|
|
200
174
|
def run(self):
|
|
201
175
|
self.check_conan_profile()
|
|
202
|
-
self.
|
|
176
|
+
self.check_luac()
|
|
203
177
|
tool.clean_locks()
|
|
204
178
|
from_source = "--build=missing"
|
|
205
179
|
if self.info.from_source:
|
|
@@ -16,6 +16,7 @@ import re
|
|
|
16
16
|
from typing import List
|
|
17
17
|
from multiprocessing import Process
|
|
18
18
|
from tempfile import NamedTemporaryFile
|
|
19
|
+
from packaging import version
|
|
19
20
|
|
|
20
21
|
from bmcgo.utils.tools import Tools
|
|
21
22
|
from bmcgo.bmcgo_config import misc
|
|
@@ -58,6 +59,59 @@ class ComponentHelper:
|
|
|
58
59
|
content = json.load(service_fp)
|
|
59
60
|
return content.get("language", "lua")
|
|
60
61
|
|
|
62
|
+
@staticmethod
|
|
63
|
+
def compare_versions(version_str, target_version="1.80.35"):
|
|
64
|
+
# 处理简单版本号格式 a/1.1xxx
|
|
65
|
+
simple_match = re.match(r'[^/]+/(\d+\.\d+(?:\.\d+)?)', version_str)
|
|
66
|
+
if simple_match:
|
|
67
|
+
return version.parse(simple_match.group(1)) >= version.parse(target_version)
|
|
68
|
+
|
|
69
|
+
# 处理待条件的版本号
|
|
70
|
+
condition_match = re.findall(r'\[([^]]+)\]', version_str)
|
|
71
|
+
if condition_match:
|
|
72
|
+
conditions = condition_match[0].split()
|
|
73
|
+
|
|
74
|
+
# 只有>或>=
|
|
75
|
+
if len(conditions) == 1 and any(op in conditions[0] for op in [">", ">="]):
|
|
76
|
+
return True
|
|
77
|
+
|
|
78
|
+
# 包含<或<=
|
|
79
|
+
for cond in conditions:
|
|
80
|
+
if "<=" in cond:
|
|
81
|
+
ver = cond.lstrip("<=>")
|
|
82
|
+
return version.parse(ver) >= version.parse(target_version)
|
|
83
|
+
elif "<" in cond:
|
|
84
|
+
ver = cond.lstrip("<=>")
|
|
85
|
+
return version.parse(ver) > version.parse(target_version)
|
|
86
|
+
|
|
87
|
+
ver = conditions[0].lstrip("<=>")
|
|
88
|
+
return version.parse(ver) >= version.parse(target_version)
|
|
89
|
+
|
|
90
|
+
return False
|
|
91
|
+
|
|
92
|
+
@staticmethod
|
|
93
|
+
def enable_new_major_version(dependencies):
|
|
94
|
+
if not dependencies:
|
|
95
|
+
return False
|
|
96
|
+
|
|
97
|
+
for dependency in dependencies:
|
|
98
|
+
version_str = dependency.get("conan", "")
|
|
99
|
+
if not version_str.startswith("libmc4lua"):
|
|
100
|
+
continue
|
|
101
|
+
return ComponentHelper.compare_versions(version_str)
|
|
102
|
+
|
|
103
|
+
return False
|
|
104
|
+
|
|
105
|
+
@staticmethod
|
|
106
|
+
def get_major_version(service_json="mds/service.json"):
|
|
107
|
+
if not os.path.isfile(service_json):
|
|
108
|
+
raise RuntimeError(f"{service_json}文件不存在")
|
|
109
|
+
with open(service_json, "r", encoding="UTF-8") as service_fp:
|
|
110
|
+
content = json.load(service_fp)
|
|
111
|
+
|
|
112
|
+
return 1 if (ComponentHelper.enable_new_major_version(content.get("dependencies", {}).get("build", {})) or \
|
|
113
|
+
ComponentHelper.enable_new_major_version(content.get("dependencies", {}).get("test", {}))) else 0
|
|
114
|
+
|
|
61
115
|
@staticmethod
|
|
62
116
|
def get_config_value(json_data, key: str, default=None):
|
|
63
117
|
for sub_key in key.split("/"):
|
|
@@ -127,30 +127,34 @@ class IncrementalCov(object):
|
|
|
127
127
|
return True
|
|
128
128
|
return False
|
|
129
129
|
|
|
130
|
-
def get_lua_cov_map(self, path_list):
|
|
130
|
+
def get_lua_cov_map(self, changes, path_list):
|
|
131
131
|
# 获取lua代码的校验字典
|
|
132
|
-
|
|
132
|
+
lua_changes = {}
|
|
133
133
|
uncovers = {}
|
|
134
134
|
# 如果未覆盖到lua文件则返回空字典,path_list[1]为.out文件路径
|
|
135
135
|
if not os.path.exists(path_list[1]):
|
|
136
|
-
return
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
for
|
|
140
|
-
value_check_list = check_list[key]
|
|
136
|
+
return lua_changes, uncovers
|
|
137
|
+
cov_lines = self.parse_data(path_list[0])
|
|
138
|
+
filter_lines = self.parse_check_data(path_list[1])
|
|
139
|
+
for file, change_lines in changes.items():
|
|
141
140
|
temp_uncovers = []
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
141
|
+
temp_changes = []
|
|
142
|
+
filters = filter_lines[file]
|
|
143
|
+
if file not in cov_lines:
|
|
144
|
+
cov = []
|
|
145
|
+
else:
|
|
146
|
+
cov = cov_lines[file]
|
|
147
|
+
|
|
148
|
+
for change in change_lines:
|
|
149
|
+
if filters[change] == 0:
|
|
150
|
+
continue
|
|
151
|
+
temp_changes.append(change)
|
|
152
|
+
if not cov or not cov[change]:
|
|
153
|
+
temp_uncovers.append(change)
|
|
154
|
+
lua_changes[file] = temp_changes
|
|
155
|
+
uncovers[file] = temp_uncovers
|
|
156
|
+
|
|
157
|
+
return lua_changes, uncovers
|
|
154
158
|
|
|
155
159
|
def parse_data(self, file_path):
|
|
156
160
|
# 解析lua覆盖率的统计文件
|
|
@@ -302,19 +306,7 @@ class IncrementalCov(object):
|
|
|
302
306
|
os.path.join(path, "luacov.stats.out"),
|
|
303
307
|
os.path.join(path, "luacov.stats.filter"),
|
|
304
308
|
]
|
|
305
|
-
|
|
306
|
-
uncovers = {}
|
|
307
|
-
lua_changes = {}
|
|
308
|
-
for f, lines in changes.items():
|
|
309
|
-
if f not in lua_covers_map and f not in lua_uncovers_map:
|
|
310
|
-
lua_changes[f] = lines
|
|
311
|
-
uncovers[f] = lines
|
|
312
|
-
continue
|
|
313
|
-
lua_changes[f] = sorted(list(set(lua_uncovers_map[f] + lua_covers_map[f]) & set(lines)))
|
|
314
|
-
uncov_lines = list(set(lua_uncovers_map[f]) & set(lines))
|
|
315
|
-
if len(uncov_lines) != 0:
|
|
316
|
-
uncovers[f] = sorted(uncov_lines)
|
|
317
|
-
return lua_changes, uncovers
|
|
309
|
+
return self.get_lua_cov_map(changes, path_list)
|
|
318
310
|
|
|
319
311
|
def find_and_return_file_path(self, filename):
|
|
320
312
|
for root, _, files in os.walk(self.lcov_dir, topdown=True):
|
|
@@ -374,7 +366,7 @@ class IncrementalCov(object):
|
|
|
374
366
|
uncov_linenum += len(v)
|
|
375
367
|
|
|
376
368
|
cov_linenum = change_linenum - uncov_linenum
|
|
377
|
-
coverage = round(cov_linenum * 1.0 / change_linenum if change_linenum > 0 else 1, 4)
|
|
369
|
+
coverage = round((cov_linenum * 1.0 / change_linenum) if change_linenum > 0 else 1, 4)
|
|
378
370
|
script_dir = os.path.split(os.path.realpath(__file__))[0]
|
|
379
371
|
if type_name == "c":
|
|
380
372
|
template = open(os.path.join(script_dir, "c_incremental_cov_report.template"), "r").read()
|
bmcgo/component/deploy.py
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import os
|
|
13
13
|
import shutil
|
|
14
14
|
import stat
|
|
15
|
+
import yaml
|
|
15
16
|
|
|
16
17
|
from mako.lookup import TemplateLookup
|
|
17
18
|
|
|
@@ -25,12 +26,6 @@ from bmcgo import misc
|
|
|
25
26
|
log = Logger("deploy")
|
|
26
27
|
|
|
27
28
|
cwd_script = os.path.split(os.path.realpath(__file__))[0]
|
|
28
|
-
DT_DEPENDENCIES = {
|
|
29
|
-
"dtframeforlua": "dtframeforlua", # 目前定义在部分组件的service.json
|
|
30
|
-
"luaunit": "luaunit/3.2",
|
|
31
|
-
"luacov": "luacov/[>=0.16.2]",
|
|
32
|
-
"luafilesystem": "luafilesystem/1.8.0.B022",
|
|
33
|
-
}
|
|
34
29
|
|
|
35
30
|
|
|
36
31
|
class DeployComp():
|
|
@@ -45,11 +40,14 @@ class DeployComp():
|
|
|
45
40
|
user_channel = ComponentHelper.get_user_channel(self.info.stage)
|
|
46
41
|
# DT专用的依赖,只在部署时添加
|
|
47
42
|
dependencies = []
|
|
48
|
-
|
|
43
|
+
with open(self.bconfig.conf_path, "r") as fp:
|
|
44
|
+
config = yaml.safe_load(fp)
|
|
45
|
+
dt_dependencies = config.get("dt_dependencies", {})
|
|
46
|
+
lua_run_deps = [dt_dependencies.get("luaunit")]
|
|
49
47
|
# 只有lua需要添加依赖
|
|
50
48
|
if not os.path.isdir("test_package") and self.info.coverage:
|
|
51
|
-
lua_run_deps.append(
|
|
52
|
-
lua_run_deps.append(
|
|
49
|
+
lua_run_deps.append(dt_dependencies.get("luacov"))
|
|
50
|
+
lua_run_deps.append(dt_dependencies.get("luafilesystem"))
|
|
53
51
|
for dep in lua_run_deps:
|
|
54
52
|
for build_dep in self.info.build_dependencies:
|
|
55
53
|
if build_dep.startswith(dep.split("/", -1)[0]):
|
bmcgo/frame.py
CHANGED
|
@@ -168,12 +168,7 @@ class Frame(object):
|
|
|
168
168
|
signal.raise_signal(signal.SIGINT)
|
|
169
169
|
|
|
170
170
|
def run(self):
|
|
171
|
-
|
|
172
|
-
shutil.rmtree(misc.CACHE_DIR)
|
|
173
|
-
os.makedirs(misc.CACHE_DIR)
|
|
174
|
-
os.chmod(misc.CACHE_DIR, 0o777)
|
|
175
|
-
if shutil.which(misc.CONAN) is not None:
|
|
176
|
-
tool.run_command("conan remove --locks")
|
|
171
|
+
self._prepare()
|
|
177
172
|
# 启动全局状态服务
|
|
178
173
|
signal.signal(signal.SIGINT, self.sigint_handler)
|
|
179
174
|
signal.signal(signal.SIGTERM, self.sigterm_handler)
|
|
@@ -215,3 +210,11 @@ class Frame(object):
|
|
|
215
210
|
time.sleep(2)
|
|
216
211
|
raise errors.BmcGoException(f"任务 {args.target} 执行失败")
|
|
217
212
|
return 0
|
|
213
|
+
|
|
214
|
+
def _prepare(self):
|
|
215
|
+
tool.sudo_passwd_check()
|
|
216
|
+
shutil.rmtree(misc.CACHE_DIR)
|
|
217
|
+
os.makedirs(misc.CACHE_DIR)
|
|
218
|
+
os.chmod(misc.CACHE_DIR, 0o777)
|
|
219
|
+
if shutil.which(misc.CONAN) is not None:
|
|
220
|
+
tool.run_command("conan remove --locks")
|
|
@@ -92,6 +92,21 @@ class BmcgoCommand:
|
|
|
92
92
|
uptrace = kwargs.get("uptrace", 1)
|
|
93
93
|
kwargs["uptrace"] = uptrace
|
|
94
94
|
return tool.run_command(command, ignore_error, sudo, **kwargs)
|
|
95
|
+
|
|
96
|
+
@staticmethod
|
|
97
|
+
def check_luac():
|
|
98
|
+
luac_path = os.path.join(os.path.expanduser('~'), ".conan", "bin", "luac")
|
|
99
|
+
if not os.path.isfile(luac_path):
|
|
100
|
+
raise errors.BmcGoException(f"当前环境中未安装luac!请更新manifest仓代码,执行环境初始化脚本init.py重新部署环境!")
|
|
101
|
+
|
|
102
|
+
conan_bin = os.path.join(os.path.expanduser('~'), ".conan", "bin")
|
|
103
|
+
# 设置PLD_LIBRARY_PATH环境变量,luajit运行时需要加载so动态库
|
|
104
|
+
ld_library_path = conan_bin + ":" + os.environ.get("LD_LIBRARY_PATH", "")
|
|
105
|
+
os.environ["LD_LIBRARY_PATH"] = ld_library_path
|
|
106
|
+
# 设置PATH环境变量,luajit无需指定全路径
|
|
107
|
+
path = conan_bin + ":" + os.environ.get("PATH", "")
|
|
108
|
+
os.environ["PATH"] = path
|
|
109
|
+
os.environ["LUA_PATH"] = f"{conan_bin}/?.lua"
|
|
95
110
|
|
|
96
111
|
def initialize(self):
|
|
97
112
|
self.set_package(self.args.conan_package)
|
|
@@ -136,48 +151,8 @@ class BmcgoCommand:
|
|
|
136
151
|
if self.stage != "dev":
|
|
137
152
|
self.tag_check()
|
|
138
153
|
|
|
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
154
|
def run(self):
|
|
180
|
-
self.
|
|
155
|
+
self.check_luac()
|
|
181
156
|
if self.path == "" or self.version == "":
|
|
182
157
|
raise errors.BmcGoException(f"Path({self.path}) or version({self.version}) error")
|
|
183
158
|
os.chdir(self.bconfig.conan_index.folder)
|