openubmc-bingo 0.6.74__py3-none-any.whl → 0.6.75__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/utils/fetch_component_code.py +124 -52
- {openubmc_bingo-0.6.74.dist-info → openubmc_bingo-0.6.75.dist-info}/METADATA +1 -1
- {openubmc_bingo-0.6.74.dist-info → openubmc_bingo-0.6.75.dist-info}/RECORD +7 -7
- {openubmc_bingo-0.6.74.dist-info → openubmc_bingo-0.6.75.dist-info}/WHEEL +0 -0
- {openubmc_bingo-0.6.74.dist-info → openubmc_bingo-0.6.75.dist-info}/entry_points.txt +0 -0
- {openubmc_bingo-0.6.74.dist-info → openubmc_bingo-0.6.75.dist-info}/top_level.txt +0 -0
bmcgo/__init__.py
CHANGED
|
@@ -15,7 +15,7 @@ import os
|
|
|
15
15
|
import re
|
|
16
16
|
import shutil
|
|
17
17
|
import subprocess
|
|
18
|
-
from multiprocessing import Pool, Manager
|
|
18
|
+
from multiprocessing import Pool, Manager
|
|
19
19
|
import patch_ng
|
|
20
20
|
import yaml
|
|
21
21
|
from git import Repo, exc
|
|
@@ -49,9 +49,6 @@ class FetchComponentCode:
|
|
|
49
49
|
if misc.conan_v2():
|
|
50
50
|
cmd = f"conan graph info --requires='{version_range}' --filter {component_name}"
|
|
51
51
|
|
|
52
|
-
# !! 注意:resolve_version_range 也需要加锁,因为它会访问 conan 缓存
|
|
53
|
-
# 但由于它在 run() 的主进程中串行调用,所以暂时安全。
|
|
54
|
-
# 如果未来您也想并发化这一步,也必须加锁。
|
|
55
52
|
ret, output = subprocess.getstatusoutput(cmd)
|
|
56
53
|
output = output.strip()
|
|
57
54
|
if ret != 0 or not output:
|
|
@@ -118,15 +115,17 @@ class FetchComponentCode:
|
|
|
118
115
|
log.info(f"{code_dir} 开始应用源码补丁{patch_file}")
|
|
119
116
|
try:
|
|
120
117
|
FetchComponentCode._apply_patches_direct(real_patch, patch_file, changed_files)
|
|
121
|
-
except errors.BmcGoException:
|
|
122
|
-
# 尝试还原文件修改
|
|
118
|
+
except errors.BmcGoException as e:
|
|
123
119
|
for a_file, b_file in changed_files.items():
|
|
124
120
|
cmd = f"git checkout -- {a_file}"
|
|
125
121
|
tools.run_command(cmd, ignore_error=True)
|
|
126
122
|
cmd = f"git checkout -- {b_file}"
|
|
127
123
|
tools.run_command(cmd, ignore_error=True)
|
|
128
|
-
|
|
129
|
-
|
|
124
|
+
try:
|
|
125
|
+
cmd = "git am " + real_patch
|
|
126
|
+
tools.run_command(cmd)
|
|
127
|
+
except Exception as am_e:
|
|
128
|
+
raise RuntimeError(f"git am 恢复补丁 {patch_file} 失败") from am_e
|
|
130
129
|
log.info(f"{code_dir} 应用源码补丁{patch_file}")
|
|
131
130
|
os.chdir(cwd)
|
|
132
131
|
|
|
@@ -189,6 +188,88 @@ class FetchComponentCode:
|
|
|
189
188
|
|
|
190
189
|
return revision, url
|
|
191
190
|
|
|
191
|
+
# --- 新增:MDS修补方案 1 (Install) ---
|
|
192
|
+
@staticmethod
|
|
193
|
+
def _try_mds_install_plan(conan_version, component_name):
|
|
194
|
+
"""
|
|
195
|
+
尝试使用 'conan install' 来获取 package_folder
|
|
196
|
+
"""
|
|
197
|
+
log.info(f"MDS修补 (方案1: install): 正在尝试 {conan_version}...")
|
|
198
|
+
cmd_install = f"conan install --requires={conan_version} -r openubmc_dev\
|
|
199
|
+
--build=missing -pr profile.ini --format=json --output-folder=tmp"
|
|
200
|
+
|
|
201
|
+
command_result = tools.run_command(cmd_install, capture_output=True, ignore_error=True)
|
|
202
|
+
stdout = command_result.stdout.strip()
|
|
203
|
+
stderr = command_result.stderr.strip()
|
|
204
|
+
|
|
205
|
+
if command_result.returncode != 0 or not stdout:
|
|
206
|
+
log.warning(f"MDS修补 (方案1: install) 失败: 命令执行失败。 STDERR: {stderr}")
|
|
207
|
+
raise RuntimeError(f"Install plan failed (command error). stderr: {stderr}")
|
|
208
|
+
|
|
209
|
+
try:
|
|
210
|
+
result = json.loads(stdout)
|
|
211
|
+
nodes = result.get("graph", {}).get("nodes", {})
|
|
212
|
+
package_folder = None
|
|
213
|
+
for node in nodes.values():
|
|
214
|
+
if node.get("ref") and node.get("ref").startswith(conan_version):
|
|
215
|
+
package_folder = node.get("package_folder")
|
|
216
|
+
if package_folder:
|
|
217
|
+
break
|
|
218
|
+
|
|
219
|
+
if not package_folder:
|
|
220
|
+
log.warning(f"MDS修补 (方案1: install) 失败: 未在JSON中找到 package_folder。")
|
|
221
|
+
raise RuntimeError("Install plan failed (JSON parse).")
|
|
222
|
+
|
|
223
|
+
log.info(f"MDS修补 (方案1: install) 成功。 找到 package_folder: {package_folder}")
|
|
224
|
+
return package_folder # 成功
|
|
225
|
+
except Exception as json_err:
|
|
226
|
+
log.warning(f"MDS修补 (方案1: install) 失败: JSON解析错误。 {json_err}")
|
|
227
|
+
raise RuntimeError(f"Install plan failed (JSON parse).") from json_err
|
|
228
|
+
|
|
229
|
+
# --- 新增:MDS修补方案 2 (Download) ---
|
|
230
|
+
@staticmethod
|
|
231
|
+
def _try_mds_download_plan(conan_version, component_name):
|
|
232
|
+
"""
|
|
233
|
+
尝试使用 'conan download' (不带profile) 来获取 package_folder
|
|
234
|
+
"""
|
|
235
|
+
log.warning(f"MDS修补 (方案1: install) 失败。 切换到 (方案2: download)...")
|
|
236
|
+
try:
|
|
237
|
+
cmd_download = f"conan download {conan_version} -r openubmc_dev --format=json"
|
|
238
|
+
log.info(f"MDS修补 (方案2: download): 执行: {cmd_download}")
|
|
239
|
+
command_result = tools.run_command(cmd_download, capture_output=True, ignore_error=True)
|
|
240
|
+
stdout = command_result.stdout.strip()
|
|
241
|
+
stderr = command_result.stderr.strip()
|
|
242
|
+
|
|
243
|
+
if command_result.returncode != 0 or not stdout:
|
|
244
|
+
log.error(f"MDS修补 (方案2: download) 失败: 命令执行失败。 STDERR: {stderr}")
|
|
245
|
+
raise RuntimeError(f"Download command failed. STDERR: {stderr}")
|
|
246
|
+
|
|
247
|
+
result = json.loads(stdout)
|
|
248
|
+
local_cache = result.get("Local Cache")
|
|
249
|
+
component_info = local_cache.get(conan_version)
|
|
250
|
+
revisions = component_info.get("revisions")
|
|
251
|
+
first_revision_id = next(iter(revisions))
|
|
252
|
+
first_revision_data = revisions[first_revision_id]
|
|
253
|
+
packages = first_revision_data.get("packages")
|
|
254
|
+
first_package_id = next(iter(packages))
|
|
255
|
+
full_pref = f"{conan_version}#{first_revision_id}:{first_package_id}"
|
|
256
|
+
|
|
257
|
+
cmd_cache_path = f"conan cache path {full_pref}"
|
|
258
|
+
log.info(f"MDS修补 (方案2: download): 执行: {cmd_cache_path}")
|
|
259
|
+
path_cmd_info = tools.run_command(cmd_cache_path, capture_output=True, ignore_error=True)
|
|
260
|
+
|
|
261
|
+
if path_cmd_info.returncode != 0 or not path_cmd_info.stdout:
|
|
262
|
+
log.error(f"MDS修补 (方案2: download) 失败: 'conan cache path' 失败。 STDERR: {path_cmd_info.stderr.strip()}")
|
|
263
|
+
raise RuntimeError(f"'conan cache path' 失败. STDERR: {path_cmd_info.stderr.strip()}")
|
|
264
|
+
|
|
265
|
+
package_folder = path_cmd_info.stdout.strip()
|
|
266
|
+
log.info(f"MDS修补 (方案2: download) 成功。 找到 package_folder: {package_folder}")
|
|
267
|
+
return package_folder # 成功
|
|
268
|
+
|
|
269
|
+
except Exception as download_e:
|
|
270
|
+
log.error(f"MDS修补 (方案2: download) 失败: {download_e}")
|
|
271
|
+
raise RuntimeError("Download plan failed.") from download_e
|
|
272
|
+
|
|
192
273
|
def run(self):
|
|
193
274
|
packages_to_fetch = dict()
|
|
194
275
|
for component_name, package in self.packages.items():
|
|
@@ -207,18 +288,18 @@ class FetchComponentCode:
|
|
|
207
288
|
process_count = min(len(packages_to_fetch), os.cpu_count())
|
|
208
289
|
log.info("创建 %u 个进程拉取代码", process_count)
|
|
209
290
|
|
|
210
|
-
# --- 修改:创建并传递锁 ---
|
|
211
291
|
manager = Manager()
|
|
212
292
|
conan_lock = manager.Lock()
|
|
293
|
+
|
|
213
294
|
pool = Pool(processes=process_count)
|
|
214
295
|
for component_name, conan_version in packages_to_fetch.items():
|
|
215
296
|
pool.apply_async(func=self.update_component_code,
|
|
216
|
-
args=(component_name, conan_version, conan_lock),
|
|
297
|
+
args=(component_name, conan_version, conan_lock),
|
|
217
298
|
error_callback=process_err_cb)
|
|
218
299
|
pool.close()
|
|
219
300
|
pool.join()
|
|
220
301
|
|
|
221
|
-
def update_component_code(self, component_name, conan_version, conan_lock):
|
|
302
|
+
def update_component_code(self, component_name, conan_version, conan_lock):
|
|
222
303
|
"""
|
|
223
304
|
update component code by conan version
|
|
224
305
|
"""
|
|
@@ -230,7 +311,7 @@ class FetchComponentCode:
|
|
|
230
311
|
conan_dir = os.path.join(os.path.expanduser('~'), '.conan/data/', *version_split, 'export')
|
|
231
312
|
conandata = os.path.join(conan_dir, 'conandata.yml')
|
|
232
313
|
|
|
233
|
-
with conan_lock:
|
|
314
|
+
with conan_lock:
|
|
234
315
|
if not os.path.exists(conan_dir):
|
|
235
316
|
conan_remote_list = tools.get_conan_remote_list(self.remote)
|
|
236
317
|
tools.download_conan_recipes(conan_version, conan_remote_list)
|
|
@@ -247,7 +328,7 @@ class FetchComponentCode:
|
|
|
247
328
|
log.error("conandata(%s) 和 conanfile(%s) 都没有找到", conandata, conanfile)
|
|
248
329
|
else:
|
|
249
330
|
path_cmd_info = None
|
|
250
|
-
with conan_lock:
|
|
331
|
+
with conan_lock:
|
|
251
332
|
conan_remote_list = tools.get_conan_remote_list(self.remote)
|
|
252
333
|
tools.download_conan_recipes(conan_version, conan_remote_list)
|
|
253
334
|
path_cmd = f"conan cache path {conan_version}"
|
|
@@ -265,48 +346,39 @@ class FetchComponentCode:
|
|
|
265
346
|
conan_version)
|
|
266
347
|
except exc.GitError as exp:
|
|
267
348
|
log.warning("Git 操作失败 (组件: %s): %s。 尝试MDS修补...", component_name, exp)
|
|
268
|
-
|
|
269
|
-
stdout = ""
|
|
270
|
-
stderr = ""
|
|
349
|
+
package_folder = None
|
|
271
350
|
|
|
272
|
-
with conan_lock:
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
351
|
+
with conan_lock:
|
|
352
|
+
try:
|
|
353
|
+
# --- 方案 1: install (优先) ---
|
|
354
|
+
package_folder = FetchComponentCode._try_mds_install_plan(conan_version, component_name)
|
|
355
|
+
except Exception as install_e:
|
|
356
|
+
# --- 方案 2: download (后备) ---
|
|
357
|
+
try:
|
|
358
|
+
package_folder = FetchComponentCode._try_mds_download_plan(conan_version, component_name)
|
|
359
|
+
except Exception as download_e:
|
|
360
|
+
# --- 两个方案都失败了 ---
|
|
361
|
+
log.error(f"MDS修补: 方案1 和 方案2 均失败 (组件: {component_name})。")
|
|
362
|
+
raise RuntimeError(f"MDS修补方案 'install' 和 'download' 均失败 (组件: {component_name})") from exp
|
|
278
363
|
|
|
279
|
-
# ---
|
|
280
|
-
if
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
log.error("
|
|
292
|
-
raise
|
|
364
|
+
# --- 复制步骤 (锁外) ---
|
|
365
|
+
if package_folder:
|
|
366
|
+
mds_src_path = f"{package_folder}/include"
|
|
367
|
+
if os.path.exists(mds_src_path):
|
|
368
|
+
src = mds_src_path
|
|
369
|
+
dest = os.path.abspath(f"{component_name}")
|
|
370
|
+
shutil.copytree(src, dest, dirs_exist_ok=True)
|
|
371
|
+
log.info(f"将组件 {component_name} 复制到 {dest}.")
|
|
372
|
+
else:
|
|
373
|
+
log.warning(f"MDS修补: 在 {package_folder} 中未找到 'include/mds'。")
|
|
374
|
+
else:
|
|
375
|
+
# 这种情况不应该发生,因为如果两个方案都失败了,上面会抛出异常
|
|
376
|
+
log.error(f"MDS修补失败 (组件: {component_name}): 未能获取 package_folder。")
|
|
377
|
+
raise exp # 重新抛出原始 GitError
|
|
293
378
|
|
|
294
|
-
|
|
295
|
-
# --- 检查结束 ---
|
|
296
|
-
|
|
297
|
-
for node in nodes.values():
|
|
298
|
-
if node.get("ref") and node.get("ref").startswith(conan_version):
|
|
299
|
-
package_folder = node.get("package_folder")
|
|
300
|
-
if package_folder:
|
|
301
|
-
if os.path.exists(f"{package_folder}/include/mds"):
|
|
302
|
-
src = f"{package_folder}/include/mds"
|
|
303
|
-
dest = os.path.abspath(f"{component_name}/mds")
|
|
304
|
-
shutil.copytree(src, dest, dirs_exist_ok=True)
|
|
305
|
-
log.info("将组件 %s 复制到 %s.", component_name, f"{component_name}/mds")
|
|
306
|
-
else:
|
|
307
|
-
log.warning("MDS修补: 节点 %s 没有 'package_folder'。", node.get("ref"))
|
|
308
|
-
|
|
379
|
+
# 清理 'install' 方案(如果成功)创建的 'tmp' 目录
|
|
309
380
|
shutil.rmtree(f"{self.target_dir}/tmp", ignore_errors=True)
|
|
381
|
+
|
|
310
382
|
except Exception as exp:
|
|
311
|
-
log.error("工作状态错误 (组件: %s): %s", component_name, exp)
|
|
383
|
+
log.error("工作状态错误 (组件: %s): %s", component_name, exp)
|
|
312
384
|
log.error("更新组件 %s 代码到 %s 失败", component_name, conan_version)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
bmcgo/__init__.py,sha256=
|
|
1
|
+
bmcgo/__init__.py,sha256=xYnz0SHAzra5qQuSJQxD6TGJB7iJ727cnjIs0dP1hto,562
|
|
2
2
|
bmcgo/bmcgo.py,sha256=uD4TsfjrFB5aQPIS6WRUVc9ShXX-dSImY9ezkB13g1w,685
|
|
3
3
|
bmcgo/bmcgo_config.py,sha256=-KYhC3jNqWkCWu6YkyxDZlyC3floXIHaibGpmyB6YWQ,11873
|
|
4
4
|
bmcgo/errors.py,sha256=QW1ndrJcJ2Ws7riOznPKVvZsNlrYk73eZol7w8gJTPU,3076
|
|
@@ -245,7 +245,7 @@ bmcgo/utils/combine_json_schemas.py,sha256=08JrAlLeo_JgUqzYcZNgSwJZPLfjbWVJ4esPP
|
|
|
245
245
|
bmcgo/utils/component_post.py,sha256=rTSMv36geI6rbm6ZFQenZfG0mn1nVPpdJqn7g8bYtKA,2330
|
|
246
246
|
bmcgo/utils/component_version_check.py,sha256=ukc-H-A4ljkOShzVtkYWL0oTIYwxgDIZtP-fPqqHnRY,6274
|
|
247
247
|
bmcgo/utils/config.py,sha256=BoNx8U8VjnHrC-lFXIhp6Ex8f02kZgUS-mTkRxi_SYM,51141
|
|
248
|
-
bmcgo/utils/fetch_component_code.py,sha256=
|
|
248
|
+
bmcgo/utils/fetch_component_code.py,sha256=ZB-BO88W3di8YDzOB27V7OBgROUOPDgdwn_wlYwZbAg,18195
|
|
249
249
|
bmcgo/utils/install_manager.py,sha256=Ag7tcTbhBfc6aTe5FOiET-8koq8_iY38Sozmi3dquio,4919
|
|
250
250
|
bmcgo/utils/json_validator.py,sha256=_k5wU78wfYGrzvSDaqOEtT4otgKUjquVhZNpVf2PW_c,7524
|
|
251
251
|
bmcgo/utils/mapping_config_patch.py,sha256=ersqH5AmDvSfrOLbsNs3mfBxLQ3AUbJlCAjjtO6dMDk,16909
|
|
@@ -263,8 +263,8 @@ bmcgo/utils/installations/install_plans/qemu.yml,sha256=lT7aKag60QUH6hTGFKa3hGRq
|
|
|
263
263
|
bmcgo/utils/installations/install_plans/studio.yml,sha256=AEspVgsVAnmUdvqZYNCb7SPoUEq_0i61dfpauyguLa4,229
|
|
264
264
|
bmcgo/utils/installations/installers/apt_installer.py,sha256=nPaCb4cobSi9InN_aHsEPtQ0k4FgsCUWE5_VgBPvcRE,3769
|
|
265
265
|
bmcgo/utils/installations/installers/pip_installer.py,sha256=dDdios1EQ7fzt90r02pZeoM3jCmjslLzkSvzd2hgRVM,3241
|
|
266
|
-
openubmc_bingo-0.6.
|
|
267
|
-
openubmc_bingo-0.6.
|
|
268
|
-
openubmc_bingo-0.6.
|
|
269
|
-
openubmc_bingo-0.6.
|
|
270
|
-
openubmc_bingo-0.6.
|
|
266
|
+
openubmc_bingo-0.6.75.dist-info/METADATA,sha256=TB-LiWbqElLEcOZMHZZCkLCLKGGaScvq35nbXkJAGwg,1010
|
|
267
|
+
openubmc_bingo-0.6.75.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
268
|
+
openubmc_bingo-0.6.75.dist-info/entry_points.txt,sha256=UUoUP-vAWTgg9vEYbRwYqOBHgpRtkngdzMPb-ocz90g,42
|
|
269
|
+
openubmc_bingo-0.6.75.dist-info/top_level.txt,sha256=9AcvCAt1nZcOgMsGt6T07mg2Bgtdet-3mHTwg91axgI,6
|
|
270
|
+
openubmc_bingo-0.6.75.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|