openubmc-bingo 0.6.73__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 +145 -30
- {openubmc_bingo-0.6.73.dist-info → openubmc_bingo-0.6.75.dist-info}/METADATA +1 -1
- {openubmc_bingo-0.6.73.dist-info → openubmc_bingo-0.6.75.dist-info}/RECORD +7 -7
- {openubmc_bingo-0.6.73.dist-info → openubmc_bingo-0.6.75.dist-info}/WHEEL +0 -0
- {openubmc_bingo-0.6.73.dist-info → openubmc_bingo-0.6.75.dist-info}/entry_points.txt +0 -0
- {openubmc_bingo-0.6.73.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
|
|
18
|
+
from multiprocessing import Pool, Manager
|
|
19
19
|
import patch_ng
|
|
20
20
|
import yaml
|
|
21
21
|
from git import Repo, exc
|
|
@@ -48,6 +48,7 @@ class FetchComponentCode:
|
|
|
48
48
|
f" -r {misc.conan_remote()} --only None 2>/dev/null"
|
|
49
49
|
if misc.conan_v2():
|
|
50
50
|
cmd = f"conan graph info --requires='{version_range}' --filter {component_name}"
|
|
51
|
+
|
|
51
52
|
ret, output = subprocess.getstatusoutput(cmd)
|
|
52
53
|
output = output.strip()
|
|
53
54
|
if ret != 0 or not output:
|
|
@@ -114,15 +115,17 @@ class FetchComponentCode:
|
|
|
114
115
|
log.info(f"{code_dir} 开始应用源码补丁{patch_file}")
|
|
115
116
|
try:
|
|
116
117
|
FetchComponentCode._apply_patches_direct(real_patch, patch_file, changed_files)
|
|
117
|
-
except errors.BmcGoException:
|
|
118
|
-
# 尝试还原文件修改
|
|
118
|
+
except errors.BmcGoException as e:
|
|
119
119
|
for a_file, b_file in changed_files.items():
|
|
120
120
|
cmd = f"git checkout -- {a_file}"
|
|
121
121
|
tools.run_command(cmd, ignore_error=True)
|
|
122
122
|
cmd = f"git checkout -- {b_file}"
|
|
123
123
|
tools.run_command(cmd, ignore_error=True)
|
|
124
|
-
|
|
125
|
-
|
|
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
|
|
126
129
|
log.info(f"{code_dir} 应用源码补丁{patch_file}")
|
|
127
130
|
os.chdir(cwd)
|
|
128
131
|
|
|
@@ -185,6 +188,88 @@ class FetchComponentCode:
|
|
|
185
188
|
|
|
186
189
|
return revision, url
|
|
187
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
|
+
|
|
188
273
|
def run(self):
|
|
189
274
|
packages_to_fetch = dict()
|
|
190
275
|
for component_name, package in self.packages.items():
|
|
@@ -202,14 +287,19 @@ class FetchComponentCode:
|
|
|
202
287
|
|
|
203
288
|
process_count = min(len(packages_to_fetch), os.cpu_count())
|
|
204
289
|
log.info("创建 %u 个进程拉取代码", process_count)
|
|
290
|
+
|
|
291
|
+
manager = Manager()
|
|
292
|
+
conan_lock = manager.Lock()
|
|
293
|
+
|
|
205
294
|
pool = Pool(processes=process_count)
|
|
206
295
|
for component_name, conan_version in packages_to_fetch.items():
|
|
207
|
-
pool.apply_async(func=self.update_component_code,
|
|
296
|
+
pool.apply_async(func=self.update_component_code,
|
|
297
|
+
args=(component_name, conan_version, conan_lock),
|
|
208
298
|
error_callback=process_err_cb)
|
|
209
299
|
pool.close()
|
|
210
300
|
pool.join()
|
|
211
301
|
|
|
212
|
-
def update_component_code(self, component_name, conan_version):
|
|
302
|
+
def update_component_code(self, component_name, conan_version, conan_lock):
|
|
213
303
|
"""
|
|
214
304
|
update component code by conan version
|
|
215
305
|
"""
|
|
@@ -220,9 +310,12 @@ class FetchComponentCode:
|
|
|
220
310
|
version_split = re.split(r'[/, @]', conan_version)
|
|
221
311
|
conan_dir = os.path.join(os.path.expanduser('~'), '.conan/data/', *version_split, 'export')
|
|
222
312
|
conandata = os.path.join(conan_dir, 'conandata.yml')
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
313
|
+
|
|
314
|
+
with conan_lock:
|
|
315
|
+
if not os.path.exists(conan_dir):
|
|
316
|
+
conan_remote_list = tools.get_conan_remote_list(self.remote)
|
|
317
|
+
tools.download_conan_recipes(conan_version, conan_remote_list)
|
|
318
|
+
|
|
226
319
|
if os.path.exists(conandata):
|
|
227
320
|
self.__update_component_code_by_conandata(version_split[0], version_split[1], conandata)
|
|
228
321
|
return
|
|
@@ -234,10 +327,12 @@ class FetchComponentCode:
|
|
|
234
327
|
return
|
|
235
328
|
log.error("conandata(%s) 和 conanfile(%s) 都没有找到", conandata, conanfile)
|
|
236
329
|
else:
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
330
|
+
path_cmd_info = None
|
|
331
|
+
with conan_lock:
|
|
332
|
+
conan_remote_list = tools.get_conan_remote_list(self.remote)
|
|
333
|
+
tools.download_conan_recipes(conan_version, conan_remote_list)
|
|
334
|
+
path_cmd = f"conan cache path {conan_version}"
|
|
335
|
+
path_cmd_info = Tools().run_command(path_cmd, capture_output=True)
|
|
241
336
|
|
|
242
337
|
version_split = re.split(r'[/, @]', conan_version)
|
|
243
338
|
conan_dir = path_cmd_info.stdout.strip()
|
|
@@ -249,21 +344,41 @@ class FetchComponentCode:
|
|
|
249
344
|
log.error("conandata(%s) 没有找到", conandata)
|
|
250
345
|
log.info("更新组件 %s 代码到 %s 失败, 无法获取到 conan 信息", component_name,
|
|
251
346
|
conan_version)
|
|
252
|
-
except exc.
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
347
|
+
except exc.GitError as exp:
|
|
348
|
+
log.warning("Git 操作失败 (组件: %s): %s。 尝试MDS修补...", component_name, exp)
|
|
349
|
+
package_folder = None
|
|
350
|
+
|
|
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
|
|
363
|
+
|
|
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
|
|
378
|
+
|
|
379
|
+
# 清理 'install' 方案(如果成功)创建的 'tmp' 目录
|
|
266
380
|
shutil.rmtree(f"{self.target_dir}/tmp", ignore_errors=True)
|
|
381
|
+
|
|
267
382
|
except Exception as exp:
|
|
268
|
-
log.error("
|
|
269
|
-
log.error("
|
|
383
|
+
log.error("工作状态错误 (组件: %s): %s", component_name, exp)
|
|
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
|