openubmc-bingo 0.5.243__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 +81 -1
- 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/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/tasks/task.py +69 -43
- bmcgo/tasks/task_build_conan.py +6 -2
- bmcgo/tasks/task_build_wbd_up.py +4 -4
- 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.243.dist-info → openubmc_bingo-0.5.253.dist-info}/METADATA +2 -1
- {openubmc_bingo-0.5.243.dist-info → openubmc_bingo-0.5.253.dist-info}/RECORD +63 -59
- /bmcgo/codegen/lua/script/{render_utils/base.py → base.py} +0 -0
- {openubmc_bingo-0.5.243.dist-info → openubmc_bingo-0.5.253.dist-info}/WHEEL +0 -0
- {openubmc_bingo-0.5.243.dist-info → openubmc_bingo-0.5.253.dist-info}/entry_points.txt +0 -0
- {openubmc_bingo-0.5.243.dist-info → openubmc_bingo-0.5.253.dist-info}/top_level.txt +0 -0
bmcgo/functional/diff.py
CHANGED
|
@@ -48,7 +48,7 @@ class BmcgoCommand:
|
|
|
48
48
|
self.bconfig = bconfig
|
|
49
49
|
if len(args) != 1 or len(args[0]) != 2:
|
|
50
50
|
log.info("\n".join(command_info.help_info))
|
|
51
|
-
raise errors.
|
|
51
|
+
raise errors.BmcGoException("参数格式错误, 请查看上述提示")
|
|
52
52
|
self.version_before = args[0][0]
|
|
53
53
|
self.version_after = args[0][1]
|
|
54
54
|
|
|
@@ -227,9 +227,9 @@ class BmcgoCommand:
|
|
|
227
227
|
|
|
228
228
|
def run(self):
|
|
229
229
|
if "@" in self.version_before and "@" in self.version_after:
|
|
230
|
-
raise errors.
|
|
230
|
+
raise errors.BmcGoException(f"不支持两个组件版本对比")
|
|
231
231
|
elif "@" not in self.version_before and "@" not in self.version_after:
|
|
232
232
|
self.parse_commit_merge()
|
|
233
233
|
else:
|
|
234
|
-
raise errors.
|
|
234
|
+
raise errors.BmcGoException("输入的版本号无法解析")
|
|
235
235
|
return 0
|
bmcgo/functional/upgrade.py
CHANGED
|
@@ -60,16 +60,46 @@ class BmcgoCommand:
|
|
|
60
60
|
default=install_consts.INSTALL_DEFAULT,
|
|
61
61
|
help="列出所有配置"
|
|
62
62
|
)
|
|
63
|
+
parser.add_argument(
|
|
64
|
+
"-f",
|
|
65
|
+
"--force",
|
|
66
|
+
action=misc.STORE_TRUE,
|
|
67
|
+
help="跳过确认,直接安装"
|
|
68
|
+
)
|
|
69
|
+
parser.add_argument(
|
|
70
|
+
"-l",
|
|
71
|
+
"--list",
|
|
72
|
+
action=misc.STORE_TRUE,
|
|
73
|
+
help="列出可安装版本"
|
|
74
|
+
)
|
|
63
75
|
|
|
64
76
|
args, _ = parser.parse_known_args()
|
|
77
|
+
|
|
65
78
|
self.version = args.version
|
|
79
|
+
self.force = args.force
|
|
80
|
+
self.list = args.list
|
|
81
|
+
|
|
66
82
|
self.installer = InstallManager()
|
|
67
83
|
self.plugin_path = Path(bconfig.bmcgo_config_list.get(misc.CUSTOM_PLUGINS, misc.DEFAULT_PLUGINS_PATH))
|
|
68
84
|
|
|
69
85
|
def run(self):
|
|
70
|
-
self.
|
|
86
|
+
app, opt, ver = self._parse_version()
|
|
87
|
+
self.installer.init(app, opt, ver, self.plugin_path)
|
|
88
|
+
|
|
89
|
+
if self.list:
|
|
90
|
+
self._list_all_versions()
|
|
91
|
+
return 0
|
|
92
|
+
|
|
93
|
+
self.installer.pre_install()
|
|
94
|
+
self.installer.install(self.force)
|
|
95
|
+
self.installer.post_install()
|
|
96
|
+
|
|
97
|
+
log.info(f"安装{self.version}已完成!")
|
|
71
98
|
return 0
|
|
72
99
|
|
|
100
|
+
def _list_all_versions(self):
|
|
101
|
+
self.installer.show_versions()
|
|
102
|
+
|
|
73
103
|
def _parse_version(self):
|
|
74
104
|
match = re.search(self.VERSION_PATTERN, self.version)
|
|
75
105
|
if match:
|
bmcgo/misc.py
CHANGED
|
@@ -17,7 +17,7 @@ from bmcgo.logger import Logger
|
|
|
17
17
|
|
|
18
18
|
log = Logger("work_prepare")
|
|
19
19
|
|
|
20
|
-
CACHE_DIR = "
|
|
20
|
+
CACHE_DIR = f"{os.path.expanduser('~')}/.bmcgo_log"
|
|
21
21
|
CONAN_REPO = "openubmc_dev"
|
|
22
22
|
CONAN_USER = 'openUBMC'
|
|
23
23
|
|
|
@@ -48,7 +48,7 @@ NO_PROXY_CONST = "no_proxy"
|
|
|
48
48
|
TIMESTAMP_SIGN_SERVER = "timestamp_sign_server"
|
|
49
49
|
JARSIGNER_HTTP_PROXY = "jarsigner_http_proxy"
|
|
50
50
|
CUSTOM_PLUGINS = "plugins_path"
|
|
51
|
-
DEFAULT_PLUGINS_PATH = "
|
|
51
|
+
DEFAULT_PLUGINS_PATH = os.path.join(os.environ["HOME"], ".bmcgo", "plugins")
|
|
52
52
|
|
|
53
53
|
DEPLOY_HOST_CONST = "deploy-host"
|
|
54
54
|
PORT_CONST = "port"
|
|
@@ -73,6 +73,35 @@ HELP = "help"
|
|
|
73
73
|
ROOTCA_DER = "rootca.der"
|
|
74
74
|
CMS_CRL = "cms.crl"
|
|
75
75
|
|
|
76
|
+
# hpm签名CA根证书配置
|
|
77
|
+
HPM_SIGN_ROOTCA_DER = "rootca_der"
|
|
78
|
+
|
|
79
|
+
# hpm服务器签名配置
|
|
80
|
+
HPM_SERVER_SIGN = "hpm_server_sign"
|
|
81
|
+
HPM_SERVER_SIGN_CERT_ID = "cert_id"
|
|
82
|
+
HPM_SERVER_SIGN_URL = "url"
|
|
83
|
+
HPM_SERVER_SIGN_SSL_VERYFY = "ssl_verify"
|
|
84
|
+
|
|
85
|
+
# hpm自签名配置
|
|
86
|
+
HPM_SELF_SIGN = "hpm_self_sign"
|
|
87
|
+
HPM_SELF_SIGN_ROOTCA_CRL = "rootca_crl"
|
|
88
|
+
HPM_SELF_SIGN_SIGNER_PEM = "signer_pem"
|
|
89
|
+
HPM_SELF_SIGN_TS_PEM = "ts_signer_pem"
|
|
90
|
+
HPM_SELF_SIGN_TS_CNF = "ts_signer_cnf"
|
|
91
|
+
|
|
92
|
+
# eeprom服务器签名配置
|
|
93
|
+
E2P_SERVER_SIGN = "eeprom_server_sign"
|
|
94
|
+
E2P_SERVER_SIGN_URL = "url"
|
|
95
|
+
|
|
96
|
+
# eeprom自签名配置
|
|
97
|
+
E2P_SELF_SIGN = "eeprom_self_sign"
|
|
98
|
+
E2P_SELF_SIGN_PEM = "priv_pem"
|
|
99
|
+
|
|
100
|
+
# hpm加密配置
|
|
101
|
+
HPM_ENCRYPT = "hpm_encrypt"
|
|
102
|
+
HPM_ENCRYPT_ENABLE = "enable"
|
|
103
|
+
HPM_ENCRYPT_TOOL = "crypto_tool"
|
|
104
|
+
|
|
76
105
|
|
|
77
106
|
class StageEnum(Enum):
|
|
78
107
|
STAGE_DEV = "dev"
|
bmcgo/target/install_sdk.yml
CHANGED
|
@@ -11,5 +11,11 @@ subworks:
|
|
|
11
11
|
- work.prepare_env
|
|
12
12
|
- name: task_download_dependency
|
|
13
13
|
klass: bmcgo.tasks.task_download_dependency
|
|
14
|
+
wait:
|
|
15
|
+
- work.prepare_env
|
|
16
|
+
- name: work.task_prepare_tools
|
|
17
|
+
klass: works.packet.work_prepare_tools.TaskClass
|
|
18
|
+
# 当类不存在时,不执行
|
|
19
|
+
ignore_not_exist: true
|
|
14
20
|
wait:
|
|
15
21
|
- work.prepare_env
|
bmcgo/tasks/task.py
CHANGED
|
@@ -257,50 +257,12 @@ class Task(Process):
|
|
|
257
257
|
return self.tools.pipe_command(commands, out_file, **kwargs)
|
|
258
258
|
|
|
259
259
|
def signature(self, unsigned_file, cms_output, crl_output, ca_output):
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
unsigned_file
|
|
264
|
-
cms_output = os.path.realpath(cms_output)
|
|
265
|
-
tmp_dir = tempfile.TemporaryDirectory()
|
|
266
|
-
cwd = os.getcwd()
|
|
267
|
-
self.chdir(tmp_dir.name)
|
|
268
|
-
rootca_der = self.config.rootca_der
|
|
269
|
-
rootca_crl = self.config.rootca_crl
|
|
270
|
-
signer_pem = self.config.signer_pem
|
|
271
|
-
ts_signer_pem = self.config.ts_signer_pem
|
|
272
|
-
ts_signer_cnf = self.config.ts_signer_cnf
|
|
273
|
-
self.run_command(f"openssl x509 -in {rootca_der} -inform der -outform pem -out rootca.pem")
|
|
274
|
-
self.run_command(f"openssl crl -in {rootca_crl} -inform der -outform pem -out cms.crl.pem")
|
|
275
|
-
cmd = f"hpm_signer -s {signer_pem} -t {ts_signer_pem} -T {ts_signer_cnf} -i {unsigned_file} -o {cms_output}"
|
|
276
|
-
self.run_command(cmd)
|
|
277
|
-
self.run_command(f"hpm_verify -r rootca.pem -C cms.crl.pem -c {unsigned_file} -s {cms_output}")
|
|
278
|
-
self.chdir(cwd)
|
|
279
|
-
self.tools.copy(rootca_crl, crl_output)
|
|
280
|
-
self.tools.copy(rootca_der, ca_output)
|
|
260
|
+
manifest_sign_server = self.get_manufacture_config("base/signature/simple_signer_server")
|
|
261
|
+
hpm_server_sign = self.config.bconfig.hpm_server_sign
|
|
262
|
+
if manifest_sign_server or hpm_server_sign:
|
|
263
|
+
self._server_signature(unsigned_file, cms_output, crl_output, ca_output)
|
|
281
264
|
else:
|
|
282
|
-
|
|
283
|
-
url = sign_server.get("url")
|
|
284
|
-
ssl_verify = sign_server.get("ssl_verify")
|
|
285
|
-
rootca_der = sign_server.get("rootca_der")
|
|
286
|
-
if not os.path.isfile(rootca_der):
|
|
287
|
-
raise FileNotFoundError(f"签名根证书{rootca_der}不存在")
|
|
288
|
-
unsigned_file = os.path.realpath(unsigned_file)
|
|
289
|
-
cms_output = os.path.realpath(cms_output)
|
|
290
|
-
crl_output = os.path.realpath(crl_output)
|
|
291
|
-
ca_output = os.path.realpath(ca_output)
|
|
292
|
-
cwd = os.getcwd()
|
|
293
|
-
tmpdir = tempfile.TemporaryDirectory()
|
|
294
|
-
self.chdir(tmpdir.name)
|
|
295
|
-
args = ["-i", unsigned_file, "-s", cert_id, "-u", url, "-v", ssl_verify]
|
|
296
|
-
cmd = SimpleSign(self.config.bconfig, args)
|
|
297
|
-
cmd.run()
|
|
298
|
-
# 签名工具会输出rootca.crl和signed.cms
|
|
299
|
-
self.tools.copy("signed.cms", cms_output)
|
|
300
|
-
self.tools.copy("rootca.crl", crl_output)
|
|
301
|
-
# 签名根证书在manifest.yml中配置
|
|
302
|
-
self.tools.copy(rootca_der, ca_output)
|
|
303
|
-
os.chdir(cwd)
|
|
265
|
+
self._local_signature(unsigned_file, cms_output, crl_output, ca_output)
|
|
304
266
|
|
|
305
267
|
def error(self, msg, *args, **kwargs):
|
|
306
268
|
uptrace = kwargs.get("uptrace", None)
|
|
@@ -381,3 +343,67 @@ class Task(Process):
|
|
|
381
343
|
self.info(f"执行脚本 {comp}/include/customization.py 开始")
|
|
382
344
|
post = ComponentPost(self.config, os.path.join(conan_install, comp), profile)
|
|
383
345
|
post.post_work(os.getcwd(), action)
|
|
346
|
+
|
|
347
|
+
def _local_signature(self, unsigned_file, cms_output, crl_output, ca_output):
|
|
348
|
+
"""自签名方法"""
|
|
349
|
+
self_sign_config = self.config.bconfig.hpm_self_sign
|
|
350
|
+
unsigned_file = os.path.realpath(unsigned_file)
|
|
351
|
+
cms_output = os.path.realpath(cms_output)
|
|
352
|
+
tmp_dir = tempfile.TemporaryDirectory()
|
|
353
|
+
cwd = os.getcwd()
|
|
354
|
+
self.chdir(tmp_dir.name)
|
|
355
|
+
certificates = self.get_manufacture_config("base/signature/certificates")
|
|
356
|
+
if certificates:
|
|
357
|
+
rootca_der = self.config.rootca_der
|
|
358
|
+
rootca_crl = self.config.rootca_crl
|
|
359
|
+
signer_pem = self.config.signer_pem
|
|
360
|
+
ts_signer_pem = self.config.ts_signer_pem
|
|
361
|
+
ts_signer_cnf = self.config.ts_signer_cnf
|
|
362
|
+
else:
|
|
363
|
+
rootca_der = self_sign_config.rootca_der
|
|
364
|
+
rootca_crl = self_sign_config.rootca_crl
|
|
365
|
+
signer_pem = self_sign_config.signer_pem
|
|
366
|
+
ts_signer_pem = self_sign_config.ts_signer_pem
|
|
367
|
+
ts_signer_cnf = self_sign_config.ts_signer_cnf
|
|
368
|
+
self.run_command(f"openssl x509 -in {rootca_der} -inform der -outform pem -out rootca.pem")
|
|
369
|
+
self.run_command(f"openssl crl -in {rootca_crl} -inform der -outform pem -out cms.crl.pem")
|
|
370
|
+
cmd = f"hpm_signer -s {signer_pem} -t {ts_signer_pem} -T {ts_signer_cnf} -i {unsigned_file} -o {cms_output}"
|
|
371
|
+
self.run_command(cmd)
|
|
372
|
+
self.run_command(f"hpm_verify -r rootca.pem -C cms.crl.pem -c {unsigned_file} -s {cms_output}")
|
|
373
|
+
self.log.info(f"使用 hpm_signer 自签名 {unsigned_file} 成功")
|
|
374
|
+
self.chdir(cwd)
|
|
375
|
+
self.tools.copy(rootca_crl, crl_output)
|
|
376
|
+
self.tools.copy(rootca_der, ca_output)
|
|
377
|
+
|
|
378
|
+
def _server_signature(self, unsigned_file, cms_output, crl_output, ca_output):
|
|
379
|
+
manifest_sign_server = self.get_manufacture_config("base/signature/simple_signer_server")
|
|
380
|
+
hpm_server_sign = self.config.bconfig.hpm_server_sign
|
|
381
|
+
if manifest_sign_server:
|
|
382
|
+
rootca_der = manifest_sign_server.get("rootca_der")
|
|
383
|
+
url = manifest_sign_server.get("url")
|
|
384
|
+
cert_id = manifest_sign_server.get("cert_id")
|
|
385
|
+
ssl_verify = manifest_sign_server.get("ssl_verify")
|
|
386
|
+
else:
|
|
387
|
+
rootca_der = hpm_server_sign.rootca_der
|
|
388
|
+
url = hpm_server_sign.url
|
|
389
|
+
cert_id = hpm_server_sign.cert_id
|
|
390
|
+
ssl_verify = hpm_server_sign.ssl_verify
|
|
391
|
+
|
|
392
|
+
if not os.path.isfile(rootca_der):
|
|
393
|
+
raise FileNotFoundError(f"签名根证书{rootca_der}不存在")
|
|
394
|
+
unsigned_file = os.path.realpath(unsigned_file)
|
|
395
|
+
cms_output = os.path.realpath(cms_output)
|
|
396
|
+
crl_output = os.path.realpath(crl_output)
|
|
397
|
+
ca_output = os.path.realpath(ca_output)
|
|
398
|
+
cwd = os.getcwd()
|
|
399
|
+
tmpdir = tempfile.TemporaryDirectory()
|
|
400
|
+
self.chdir(tmpdir.name)
|
|
401
|
+
args = ["-i", unsigned_file, "-s", cert_id, "-u", url, "-v", ssl_verify]
|
|
402
|
+
cmd = SimpleSign(self.config.bconfig, args)
|
|
403
|
+
cmd.run()
|
|
404
|
+
# 签名工具会输出rootca.crl和signed.cms
|
|
405
|
+
self.tools.copy("signed.cms", cms_output)
|
|
406
|
+
self.tools.copy("rootca.crl", crl_output)
|
|
407
|
+
# 签名根证书在manifest.yml中配置
|
|
408
|
+
self.tools.copy(rootca_der, ca_output)
|
|
409
|
+
os.chdir(cwd)
|
bmcgo/tasks/task_build_conan.py
CHANGED
|
@@ -540,15 +540,19 @@ class TaskClass(Task):
|
|
|
540
540
|
self.run_command(f"rm -rf {self.top_rootfs_dir}")
|
|
541
541
|
self.run_command(f"cp -rf {top_rootfs} {self.top_rootfs_dir}")
|
|
542
542
|
|
|
543
|
+
version_path = self.top_rootfs_dir
|
|
543
544
|
# 复制单板目录下的权限配置和rootfs文件
|
|
544
545
|
rootfs_dir = os.path.join(self.config.board_path, "rootfs")
|
|
545
546
|
if os.path.isdir(rootfs_dir):
|
|
546
547
|
self.run_command(f"rm -rf {self.openubmc_ins_dir}")
|
|
547
548
|
self.run_command(f"cp -rf {rootfs_dir} {self.openubmc_ins_dir}")
|
|
548
|
-
self.config.version_conf(f"{self.openubmc_ins_dir}/etc/version.json")
|
|
549
|
-
self.config.show_version_conf(f"{self.openubmc_ins_dir}/etc/version.json")
|
|
550
549
|
else:
|
|
551
550
|
os.makedirs(self.openubmc_ins_dir)
|
|
551
|
+
|
|
552
|
+
if os.path.isfile(f"{self.openubmc_ins_dir}/etc/version.json"):
|
|
553
|
+
version_path = self.openubmc_ins_dir
|
|
554
|
+
self.config.version_conf(f"{version_path}/etc/version.json")
|
|
555
|
+
self.config.show_version_conf(f"{version_path}/etc/version.json")
|
|
552
556
|
per_file = os.path.join(self.config.board_path, "permissions.ini")
|
|
553
557
|
if os.path.isfile(per_file):
|
|
554
558
|
shutil.copy(per_file, self.openubmc_ins_dir)
|
bmcgo/tasks/task_build_wbd_up.py
CHANGED
|
@@ -22,12 +22,12 @@ class TaskClass(Task):
|
|
|
22
22
|
|
|
23
23
|
def get_wbd_file_config(self):
|
|
24
24
|
wbd_up_file_config = None
|
|
25
|
-
if self.config.
|
|
26
|
-
wbd_config_path = f"tosupporte/{self.config.tosupporte_code}/wbd_up_files"
|
|
27
|
-
wbd_up_file_config = self.get_manufacture_config(wbd_config_path)
|
|
28
|
-
elif self.config.manufacture_code:
|
|
25
|
+
if self.config.manufacture_code:
|
|
29
26
|
wbd_config_path = f"manufacture/{self.config.manufacture_code}/wbd_up_files"
|
|
30
27
|
wbd_up_file_config = self.get_manufacture_config(wbd_config_path)
|
|
28
|
+
elif self.config.tosupporte_code:
|
|
29
|
+
wbd_config_path = f"tosupporte/{self.config.tosupporte_code}/wbd_up_files"
|
|
30
|
+
wbd_up_file_config = self.get_manufacture_config(wbd_config_path)
|
|
31
31
|
else:
|
|
32
32
|
pass
|
|
33
33
|
|
bmcgo/utils/config.py
CHANGED
|
@@ -142,10 +142,15 @@ class Config:
|
|
|
142
142
|
|
|
143
143
|
@property
|
|
144
144
|
def self_sign(self):
|
|
145
|
-
|
|
146
|
-
if not
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
self_sign_config = self.get_manufacture_config("base/signature/simple_signer_server")
|
|
146
|
+
if not self_sign_config:
|
|
147
|
+
self_sign_config = self.get_manufacture_config("base/signature/certificates")
|
|
148
|
+
if not self_sign_config:
|
|
149
|
+
self_sign_config = self.bconfig.hpm_server_sign
|
|
150
|
+
if not self_sign_config:
|
|
151
|
+
self_sign_config = self.bconfig.hpm_self_sign
|
|
152
|
+
|
|
153
|
+
return self_sign_config is not None
|
|
149
154
|
|
|
150
155
|
@property
|
|
151
156
|
def rootca_der(self):
|
|
@@ -1012,8 +1017,12 @@ class Config:
|
|
|
1012
1017
|
def parse_args(self, args=None):
|
|
1013
1018
|
parser = self.argparser(self.code_path)
|
|
1014
1019
|
args, _ = parser.parse_known_args(args)
|
|
1020
|
+
if args.zip_code and args.supporte_code != "default":
|
|
1021
|
+
raise errors.ConfigException("manufacture 编码和 tosupporte 编码不能同时存在")
|
|
1022
|
+
|
|
1015
1023
|
self.set_manufacture_code(args.zip_code)
|
|
1016
|
-
|
|
1024
|
+
if not args.zip_code:
|
|
1025
|
+
self.set_tosupporte_code(args.supporte_code)
|
|
1017
1026
|
self.set_from_source(args.from_source)
|
|
1018
1027
|
self.set_build_type(args.build_type)
|
|
1019
1028
|
self.set_stage(args.stage)
|
|
@@ -1035,14 +1044,17 @@ class Config:
|
|
|
1035
1044
|
self.get_archive()
|
|
1036
1045
|
self.init_conan_profile(args.profile)
|
|
1037
1046
|
|
|
1038
|
-
if self.manufacture_code is not None and self.tosupporte_code != "default":
|
|
1039
|
-
raise errors.ConfigException("manufacture 编码和 tosupport E 编码不能同时存在")
|
|
1040
|
-
|
|
1041
1047
|
# 构建阶段检查
|
|
1042
1048
|
bt = ["dt", "debug", "release"]
|
|
1043
1049
|
if args.build_type not in bt:
|
|
1044
1050
|
raise errors.ConfigException("构建类型 build_type 错误, 可用选项为: [debug, release, dt], 请检查参数")
|
|
1045
1051
|
|
|
1052
|
+
hpm_encrypt = self.bconfig.hpm_encrypt
|
|
1053
|
+
if hpm_encrypt and hpm_encrypt.need_encrypt:
|
|
1054
|
+
if not shutil.which("crypto_tool"):
|
|
1055
|
+
raise errors.BmcGoException(f"开启了hpm加密配置, 在环境中未找到 'crypto_tool', 请确认环境配置是否正确.")
|
|
1056
|
+
os.environ["HPM_ENCRYPT"] = "true"
|
|
1057
|
+
|
|
1046
1058
|
def _load_manifest_with_template(self, filename, template):
|
|
1047
1059
|
try:
|
|
1048
1060
|
real_sha256 = Config._calc_manifest_data_sha256(filename, template)
|
bmcgo/utils/install_manager.py
CHANGED
|
@@ -12,19 +12,23 @@
|
|
|
12
12
|
# See the Mulan PSL v2 for more details.
|
|
13
13
|
|
|
14
14
|
from pathlib import Path
|
|
15
|
-
from
|
|
15
|
+
from typing import Dict, List
|
|
16
|
+
from bmcgo import misc
|
|
17
|
+
from bmcgo.utils.tools import Tools
|
|
16
18
|
from bmcgo.utils.installations import install_consts
|
|
17
19
|
from bmcgo.utils.installations.install_workflow import InstallWorkflow
|
|
18
20
|
from bmcgo.utils.installations.base_installer import BaseInstaller
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
|
|
23
|
+
tools = Tools("install")
|
|
24
|
+
logger = tools.log
|
|
23
25
|
|
|
24
26
|
|
|
25
27
|
class InstallManager:
|
|
26
28
|
def __init__(self):
|
|
27
29
|
self._custom_path = None
|
|
30
|
+
self._workflows = []
|
|
31
|
+
self._installers: Dict[str, List[BaseInstaller]] = {}
|
|
28
32
|
|
|
29
33
|
@property
|
|
30
34
|
def custom_installer_path(self):
|
|
@@ -33,29 +37,80 @@ class InstallManager:
|
|
|
33
37
|
@property
|
|
34
38
|
def custom_install_plan_path(self):
|
|
35
39
|
return self._custom_path / install_consts.PLUGIN_INSTALL_PLAN_PATH
|
|
36
|
-
|
|
37
|
-
def
|
|
40
|
+
|
|
41
|
+
def init(self, app_name, operator, version, custom_path):
|
|
38
42
|
self._set_custom_path(custom_path)
|
|
39
|
-
BaseInstaller.discover_installers()
|
|
40
|
-
InstallWorkflow.discover_workflows()
|
|
41
43
|
|
|
42
|
-
workflows = []
|
|
43
44
|
if app_name == install_consts.INSTALL_ALL:
|
|
44
|
-
|
|
45
|
+
self._workflows = list(InstallWorkflow.get_all_plans())
|
|
45
46
|
else:
|
|
46
|
-
|
|
47
|
+
self._workflows = [app_name]
|
|
48
|
+
|
|
49
|
+
for wname in self._workflows:
|
|
50
|
+
workflow = InstallWorkflow.parse(wname)
|
|
51
|
+
plans = workflow.get(install_consts.PLAN_STEPS, [])
|
|
52
|
+
for plan in plans:
|
|
53
|
+
inst_type = plan.get(install_consts.PLAN_INSTALL_TYPE)
|
|
54
|
+
if not inst_type:
|
|
55
|
+
raise ValueError(f"未配置 {wname}/{install_consts.PLAN_STEPS}/{install_consts.PLAN_INSTALL_TYPE}")
|
|
56
|
+
inst = BaseInstaller.get_installer(inst_type)
|
|
57
|
+
inst.init(plan, operator, version)
|
|
58
|
+
self._installers.setdefault(wname, []).append(inst)
|
|
47
59
|
|
|
48
|
-
|
|
49
|
-
|
|
60
|
+
def show_versions(self):
|
|
61
|
+
for wname in self._workflows:
|
|
62
|
+
if wname not in self._installers:
|
|
63
|
+
raise RuntimeError(f"初始化 {wname} 出现问题,请重试!")
|
|
64
|
+
|
|
65
|
+
for inst in self._installers[wname]:
|
|
66
|
+
logger.info(f"获取 {inst.package_name} {inst.type_name} 版本信息...")
|
|
67
|
+
inst.show_versions()
|
|
68
|
+
|
|
69
|
+
def pre_install(self):
|
|
70
|
+
for wname in self._workflows:
|
|
71
|
+
logger.info(f"安装 {wname} 前检查...")
|
|
50
72
|
plans = InstallWorkflow.parse(wname)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
73
|
+
verisons = {}
|
|
74
|
+
if wname not in self._installers:
|
|
75
|
+
raise RuntimeError(f"初始化 {wname} 出现问题,请重试!")
|
|
76
|
+
for inst in self._installers[wname]:
|
|
77
|
+
inst.pre_install()
|
|
78
|
+
verisons[inst.type_name] = inst.target_version
|
|
79
|
+
|
|
80
|
+
require_version_homogeneous = plans.get(install_consts.PLAN_VERSION_HOMOGENEOUS, False)
|
|
81
|
+
if require_version_homogeneous and len(set(verisons.values())) > 1:
|
|
82
|
+
for t, v in verisons.items():
|
|
83
|
+
logger.error(f"{t}: {v}")
|
|
84
|
+
raise ValueError("版本不一致,终止安装!")
|
|
85
|
+
|
|
86
|
+
def install(self, force):
|
|
87
|
+
logger.info("开始安装...")
|
|
88
|
+
for wname in self._workflows:
|
|
89
|
+
logger.info(f"安装{wname}...")
|
|
90
|
+
try:
|
|
91
|
+
if wname not in self._installers:
|
|
92
|
+
raise RuntimeError(f"初始化 {wname} 出现问题,请重试!")
|
|
93
|
+
for inst in self._installers[wname]:
|
|
94
|
+
inst.install(force)
|
|
95
|
+
except Exception as e:
|
|
96
|
+
logger.info(f"安装失败,回退{wname}...")
|
|
97
|
+
if wname not in self._installers:
|
|
98
|
+
raise RuntimeError(f"初始化 {wname} 出现问题,请重试!") from e
|
|
99
|
+
for inst in self._installers[wname]:
|
|
100
|
+
inst.rollback()
|
|
101
|
+
raise RuntimeError("安装失败") from e
|
|
102
|
+
|
|
103
|
+
def post_install(self):
|
|
104
|
+
for wname in self._workflows:
|
|
105
|
+
logger.info(f"清理安装{wname}的中间文件...")
|
|
106
|
+
if wname not in self._installers:
|
|
107
|
+
raise RuntimeError(f"初始化 {wname} 出现问题,请重试!")
|
|
108
|
+
for inst in self._installers[wname]:
|
|
109
|
+
inst.post_install()
|
|
54
110
|
|
|
55
111
|
def _set_custom_path(self, custom_path: str):
|
|
56
112
|
self._custom_path = Path(custom_path).resolve()
|
|
57
|
-
if not self._custom_path.exists() or not self._custom_path.is_dir():
|
|
58
|
-
logger.warning(f"无效的地址: {self._custom_path}")
|
|
59
|
-
return
|
|
60
113
|
BaseInstaller.add_installer_dir(self.custom_installer_path)
|
|
61
|
-
InstallWorkflow.add_plan_dir(self.custom_install_plan_path)
|
|
114
|
+
InstallWorkflow.add_plan_dir(self.custom_install_plan_path)
|
|
115
|
+
BaseInstaller.discover_installers()
|
|
116
|
+
InstallWorkflow.discover_workflows()
|
|
@@ -15,21 +15,42 @@ import sys
|
|
|
15
15
|
import importlib.util
|
|
16
16
|
from pathlib import Path
|
|
17
17
|
from typing import Dict, List, Type
|
|
18
|
+
from bmcgo.utils.tools import Tools
|
|
18
19
|
from bmcgo.utils.installations import install_consts
|
|
20
|
+
from bmcgo.utils.installations.version_util import PkgVersion
|
|
19
21
|
|
|
20
22
|
|
|
21
23
|
class BaseInstaller(abc.ABC):
|
|
22
|
-
|
|
24
|
+
tools = Tools("install")
|
|
25
|
+
logger = tools.log
|
|
23
26
|
_intallers: Dict[str, Type["BaseInstaller"]] = {}
|
|
24
27
|
search_paths: List[Path] = [Path(__file__).resolve().parent / install_consts.PLUGIN_INSTALLER_PATH]
|
|
28
|
+
type_name = None
|
|
25
29
|
|
|
26
|
-
def
|
|
30
|
+
def __init__(self):
|
|
31
|
+
self._pkg_name = None
|
|
32
|
+
self._target_ver = None
|
|
33
|
+
self._cur_ver = None
|
|
34
|
+
|
|
35
|
+
def __init_subclass__(cls, **kwargs):
|
|
27
36
|
super.__init_subclass__(**kwargs)
|
|
28
37
|
|
|
29
|
-
key =
|
|
38
|
+
key = cls.type_name or cls.__name__.lower()
|
|
30
39
|
if key in cls._intallers:
|
|
31
|
-
cls.logger and cls.logger.warning(f"{
|
|
32
|
-
cls._intallers[
|
|
40
|
+
cls.logger and cls.logger.warning(f"{key}({cls._intallers[key]} 被替换为: {cls})")
|
|
41
|
+
cls._intallers[key] = cls
|
|
42
|
+
|
|
43
|
+
@property
|
|
44
|
+
def target_version(self):
|
|
45
|
+
return self._target_ver
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def current_version(self):
|
|
49
|
+
return self._cur_ver
|
|
50
|
+
|
|
51
|
+
@property
|
|
52
|
+
def package_name(self):
|
|
53
|
+
return self._pkg_name
|
|
33
54
|
|
|
34
55
|
@classmethod
|
|
35
56
|
def add_installer_dir(cls, directory: Path):
|
|
@@ -64,7 +85,93 @@ class BaseInstaller(abc.ABC):
|
|
|
64
85
|
if not installer_cls:
|
|
65
86
|
raise ValueError(f"未定义的安装方法:{installer_type}")
|
|
66
87
|
return installer_cls()
|
|
88
|
+
|
|
89
|
+
def init(self, plan, operator, version):
|
|
90
|
+
self.parse_plan(plan)
|
|
91
|
+
|
|
92
|
+
versions = self.get_versions()
|
|
93
|
+
self.resolve_constraint(versions, operator, version)
|
|
94
|
+
|
|
95
|
+
self.get_current_version()
|
|
96
|
+
|
|
97
|
+
def pre_install(self):
|
|
98
|
+
""" 安装前检查 """
|
|
99
|
+
self.info("安装前检查")
|
|
100
|
+
|
|
101
|
+
def post_install(self):
|
|
102
|
+
""" 安装后清理 """
|
|
103
|
+
self.info("安装后清理")
|
|
104
|
+
|
|
105
|
+
def rollback(self):
|
|
106
|
+
""" 回退 """
|
|
107
|
+
self.info("回退")
|
|
108
|
+
|
|
109
|
+
def parse_plan(self, plan: Dict[str, List[str]]):
|
|
110
|
+
self._pkg_name = plan.get(install_consts.PLAN_PACKAGE_NAME)
|
|
111
|
+
if not self._pkg_name:
|
|
112
|
+
self.error(f"{install_consts.PLAN_PACKAGE_NAME} 未配置!")
|
|
113
|
+
return
|
|
114
|
+
self.parse_custom_plan(plan)
|
|
115
|
+
|
|
116
|
+
def resolve_constraint(self, versions, opt, ver):
|
|
117
|
+
if not versions:
|
|
118
|
+
self.warning("当前没有可下载版本!")
|
|
119
|
+
return
|
|
120
|
+
|
|
121
|
+
if ver == install_consts.INSTALL_LATEST or not opt:
|
|
122
|
+
self._target_ver = versions[0]
|
|
123
|
+
return
|
|
124
|
+
|
|
125
|
+
pkg_ver = PkgVersion(ver)
|
|
126
|
+
for avl_ver in versions:
|
|
127
|
+
v = PkgVersion(avl_ver)
|
|
128
|
+
if opt == ">=" and v >= pkg_ver:
|
|
129
|
+
self._target_ver = v.origin
|
|
130
|
+
break
|
|
131
|
+
elif opt == "<=" and v <= pkg_ver:
|
|
132
|
+
self._target_ver = v.origin
|
|
133
|
+
break
|
|
134
|
+
elif opt == "!=" and v != pkg_ver:
|
|
135
|
+
self._target_ver = v.origin
|
|
136
|
+
break
|
|
137
|
+
elif opt == "<" and v < pkg_ver:
|
|
138
|
+
self._target_ver = v.origin
|
|
139
|
+
break
|
|
140
|
+
elif opt == ">" and v > pkg_ver:
|
|
141
|
+
self._target_ver = v.origin
|
|
142
|
+
break
|
|
143
|
+
elif opt == "=" and v == pkg_ver:
|
|
144
|
+
self._target_ver = v.origin
|
|
145
|
+
break
|
|
146
|
+
else:
|
|
147
|
+
self.warning(f"没有找到匹配的版本:{self._pkg_name}{opt}{ver}")
|
|
148
|
+
return
|
|
149
|
+
|
|
150
|
+
def info(self, msg):
|
|
151
|
+
self.logger and self.logger.info(f"[{self.type_name}] {msg}")
|
|
152
|
+
|
|
153
|
+
def error(self, msg):
|
|
154
|
+
self.logger and self.logger.error(f"[{self.type_name}] {msg}")
|
|
155
|
+
|
|
156
|
+
def warning(self, msg):
|
|
157
|
+
self.logger and self.logger.warning(f"[{self.type_name}] {msg}")
|
|
158
|
+
|
|
159
|
+
@abc.abstractmethod
|
|
160
|
+
def parse_custom_plan(self, plan: Dict[str, List[str]]):
|
|
161
|
+
""" 解析 yml 配置计划 """
|
|
162
|
+
|
|
163
|
+
@abc.abstractmethod
|
|
164
|
+
def install(self, force: bool):
|
|
165
|
+
""" 安装入口 """
|
|
166
|
+
|
|
167
|
+
@abc.abstractmethod
|
|
168
|
+
def get_versions(self):
|
|
169
|
+
""" 可用版本 """
|
|
170
|
+
|
|
171
|
+
@abc.abstractmethod
|
|
172
|
+
def show_versions(self):
|
|
173
|
+
""" 列出可用版本 """
|
|
67
174
|
|
|
68
175
|
@abc.abstractmethod
|
|
69
|
-
def
|
|
70
|
-
"""
|
|
176
|
+
def get_current_version(self):
|
|
177
|
+
""" 获取当前已安装版本 """
|
|
@@ -20,6 +20,7 @@ INSTALL_ALL = "all"
|
|
|
20
20
|
INSTALL_LATEST = "latest"
|
|
21
21
|
INSTALL_DEFAULT = f"{INSTALL_ALL}={INSTALL_LATEST}"
|
|
22
22
|
|
|
23
|
+
PLAN_VERSION_HOMOGENEOUS = "version_homogeneous"
|
|
23
24
|
PLAN_STEPS = "install_steps"
|
|
24
25
|
PLAN_INSTALL_TYPE = "type"
|
|
25
26
|
PLAN_PACKAGE_NAME = "package_name"
|
|
@@ -27,4 +28,5 @@ PLAN_MODULE_NAME = "module_name"
|
|
|
27
28
|
PLAN_REPO_URL = "url"
|
|
28
29
|
PLAN_GPG = "gpg"
|
|
29
30
|
PLAN_CONFIG_FILE = "config_file"
|
|
30
|
-
PLAN_PUBLIC_KEY = "public_key"
|
|
31
|
+
PLAN_PUBLIC_KEY = "public_key"
|
|
32
|
+
PLAN_DOC = "doc"
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
+
version_homogeneous: true
|
|
1
2
|
install_steps:
|
|
2
3
|
- type: pip
|
|
3
4
|
package_name: openubmc-bingo
|
|
4
5
|
module_name: bingo
|
|
5
6
|
- type: apt
|
|
6
7
|
package_name: openubmc-bingo
|
|
7
|
-
|
|
8
|
-
url: https://openubmc-apt-repo.obs.cn-north-4.myhuaweicloud.com/bingo/
|
|
9
|
-
gpg: bingo.gpg
|
|
10
|
-
public_key: gpg_key.public
|
|
8
|
+
doc: https://www.openubmc.cn/marketplace/bingo
|
|
11
9
|
|