已合并
解决qemu镜像拉起失败问题 #1985
xuhaijun创建于 9月11日
解决qemu镜像拉起失败问题 #1985
已合并
共 3 个文件变更+45-198
| @@ -153,20 +153,10 @@ tosupporte: | |||
| 153 | qemu_image: inner/${board_name}_${tosupporte_code}_default.cpio | 153 | qemu_image: inner/${board_name}_${tosupporte_code}_default.cpio |
| 154 | files: | 154 | files: |
| 155 | - file: ${board_path}/version.xml | 155 | - file: ${board_path}/version.xml |
| 156 | + default_options: | ||
| 157 | + qemu: true | ||
| 156 | dependencies: | 158 | dependencies: |
| 157 | - conan: qemu_drivers | 159 | - conan: qemu_drivers |
| 158 | - - conan: fructrl | ||
| 159 | - options: | ||
| 160 | - qemu: true | ||
| 161 | - - conan: general_hardware | ||
| 162 | - options: | ||
| 163 | - qemu: true | ||
| 164 | - - conan: nsm | ||
| 165 | - options: | ||
| 166 | - qemu: true | ||
| 167 | - - conan: bmc_network | ||
| 168 | - options: | ||
| 169 | - qemu: true | ||
| 170 | - conan: bmc_soc | 160 | - conan: bmc_soc |
| 171 | action: delete | 161 | action: delete |
| 172 | - conan: soctrl | 162 | - conan: soctrl |
| @@ -11,4 +11,4 @@ dependencies: | |||
| 11 | - conan: "manufacture/1.70.19@openubmc/stable" | 11 | - conan: "manufacture/1.70.19@openubmc/stable" |
| 12 | - conan: "bios/1.81.4@openubmc/stable" | 12 | - conan: "bios/1.81.4@openubmc/stable" |
| 13 | - conan: "general_hardware/1.91.29@openubmc/stable" | 13 | - conan: "general_hardware/1.91.29@openubmc/stable" |
| 14 | - - conan: "qemu_mockup/0.0.50@openubmc/stable" | 14 | + - conan: "qemu_mockup/0.0.88@openubmc/stable" |
| @@ -17,6 +17,7 @@ import os | |||
| 17 | import subprocess | 17 | import subprocess |
| 18 | import logging | 18 | import logging |
| 19 | import json | 19 | import json |
| 20 | +import shutil | ||
| 20 | 21 | ||
| 21 | from functools import wraps | 22 | from functools import wraps |
| 22 | 23 | ||
| @@ -319,10 +320,16 @@ class QemuCi(object): | |||
| 319 | for line in lines_to_add: | 320 | for line in lines_to_add: |
| 320 | escaped_line = line.replace('/', '\\/').replace('&', '\\&') | 321 | escaped_line = line.replace('/', '\\/').replace('&', '\\&') |
| 321 | self.tool.run_command(f"sed -i '$a\\{escaped_line}' {des}", sudo=True) | 322 | self.tool.run_command(f"sed -i '$a\\{escaped_line}' {des}", sudo=True) |
| 322 | - | 323 | + |
| 323 | - # 在指定位置插入 9p.sh 的调用 | 324 | + # 检查 exec_main 调用行是否存在(绝对匹配,避免匹配 exec_main() {) |
| 324 | - self.tool.run_command("sed -i '/rm -rf \/var\/lib/i sh \/opt\/bmc\/insmod_9p_vfs.sh' {}".format(des), sudo=True) | 325 | + check_cmd = "grep -q '^mount -t tmpfs -o nodev tmpfs /dev/shm$' {} || (echo 'ERROR: `mount -t tmpfs -o nodev tmpfs /dev/shm` not found' && exit 1)".format(des) |
| 325 | - | 326 | + self.tool.run_command(check_cmd, sudo=True) |
| 327 | + | ||
| 328 | + # 在 exec_main 调用前插入 insmod_9p_vfs.sh | ||
| 329 | + # 使用 ^exec_main$ 确保绝对匹配,避免匹配 exec_main() { 函数定义 | ||
| 330 | + # 确保在主启动流程执行前先加载 9p vfs 模块 | ||
| 331 | + self.tool.run_command(f"sed -i '\\@^mount -t tmpfs -o nodev tmpfs /dev/shm$@i\\sh /opt/bmc/insmod_9p_vfs.sh' {des}", sudo=True) | ||
| 332 | + | ||
| 326 | @log("chown -R 96:96 /opt/bmc/apps/rmcpd") | 333 | @log("chown -R 96:96 /opt/bmc/apps/rmcpd") |
| 327 | def __chown_rmcpd(self): | 334 | def __chown_rmcpd(self): |
| 328 | des = "{}/opt/bmc/apps/rmcpd".format(self.des) | 335 | des = "{}/opt/bmc/apps/rmcpd".format(self.des) |
| @@ -394,25 +401,7 @@ class QemuCi(object): | |||
| 394 | self.__sed_mc_config() | 401 | self.__sed_mc_config() |
| 395 | self.__sed_service_config() | 402 | self.__sed_service_config() |
| 396 | self.__sed_etc_systemd_journald_conf() | 403 | self.__sed_etc_systemd_journald_conf() |
| 397 | - self.__sed_S11Eventinit_sh() | 404 | + self.__sed_rc_local_service() |
| 398 | - self.__sed_S11FrudataInit_sh() | ||
| 399 | - self.__sed_S11SensorInit_sh() | ||
| 400 | - self.__sed_S12BiosInit_sh() | ||
| 401 | - self.__sed_S12ComputeInit_sh() | ||
| 402 | - self.__sed_S12GeneralHardwareInit_sh() | ||
| 403 | - self.__sed_S12ManufactureInit_sh() | ||
| 404 | - self.__sed_S12NetworkAdapterInit_sh() | ||
| 405 | - self.__sed_S12PcieDeviceInit_sh() | ||
| 406 | - self.__sed_S12StorageInit_sh() | ||
| 407 | - self.__sed_S16FileTransferInit_sh() | ||
| 408 | - self.__sed_S16SsdpInit_sh() | ||
| 409 | - self.__sed_ipmi_core_start() | ||
| 410 | - self.__sed_S16UmsInit_sh() | ||
| 411 | - self.__sed_data_fs_check_sh() | ||
| 412 | - self.__sed_log_partition_check_sh() | ||
| 413 | - self.__sed_partition_migrate_sh() | ||
| 414 | - self.__sed_trust_partition_check_sh() | ||
| 415 | - self.__sed_ensure_exist_sh() | ||
| 416 | 405 | ||
| 417 | def check_path_is_existed(self, path): | 406 | def check_path_is_existed(self, path): |
| 418 | if os.path.exists(path): | 407 | if os.path.exists(path): |
| @@ -427,7 +416,7 @@ class QemuCi(object): | |||
| 427 | scripts_des = "{}/scripts/".format(self.des) | 416 | scripts_des = "{}/scripts/".format(self.des) |
| 428 | qemu_des = "{}/qemu/".format(self.des) | 417 | qemu_des = "{}/qemu/".format(self.des) |
| 429 | qemu_luas_des = "{}/qemu_luas/".format(self.des) | 418 | qemu_luas_des = "{}/qemu_luas/".format(self.des) |
| 430 | - sr_des = "{}/sr/".format(self.des) | 419 | + sr_des = "{}/sr/".format(self.des) |
| 431 | 420 | ||
| 432 | if self.check_path_is_existed(virtio_des): | 421 | if self.check_path_is_existed(virtio_des): |
| 433 | self.tool.run_command("\\rm -rf {}".format(virtio_des), sudo=True) | 422 | self.tool.run_command("\\rm -rf {}".format(virtio_des), sudo=True) |
| @@ -495,158 +484,27 @@ class QemuCi(object): | |||
| 495 | system_files = "{}/etc/systemd/system.conf".format(self.des) | 484 | system_files = "{}/etc/systemd/system.conf".format(self.des) |
| 496 | self.tool.run_command('sed -i "s/#LogLevel=info/LogLevel=debug/g" {}'.format(system_files), sudo=True) | 485 | self.tool.run_command('sed -i "s/#LogLevel=info/LogLevel=debug/g" {}'.format(system_files), sudo=True) |
| 497 | self.tool.run_command('sed -i "s/#LogTarget=journal-or-kmsg/LogTarget=journalctl/g" {}'.format(system_files), sudo=True) | 486 | self.tool.run_command('sed -i "s/#LogTarget=journal-or-kmsg/LogTarget=journalctl/g" {}'.format(system_files), sudo=True) |
| 498 | - | 487 | + |
| 499 | - @log("sed /etc/systemd/rc.d/rc.sysint") | ||
| 500 | - def __sed_etc_system_rc_sysint(self): | ||
| 501 | - rc_sysinit = "{}/etc/rc.d/rc.sysinit".format(self.des) | ||
| 502 | - self.tool.run_command('sed -i "558,563d" {}'.format(rc_sysinit), sudo=True) | ||
| 503 | - self.tool.run_command('sed -i "s/logpart_mount_time=0/logpart_mount_time=4/g" {}'.format(rc_sysinit), sudo=True) | ||
| 504 | - self.tool.run_command('sed -i "522,523d" {}'.format(rc_sysinit), sudo=True) | ||
| 505 | - self.tool.run_command('sed -i "522i\dev_files=\\"/dev/sys_info /dev/trng /dev/mem /dev/dfx /dev/uart_connect /dev/mdio /dev/mctp\\"" {}'.format(rc_sysinit), sudo=True) | ||
| 506 | - self.tool.run_command('sed -i "394d" {}'.format(rc_sysinit), sudo=True) | ||
| 507 | - self.tool.run_command('sed -i "391d" {}'.format(rc_sysinit), sudo=True) | ||
| 508 | - self.tool.run_command('sed -i "384d" {}'.format(rc_sysinit), sudo=True) | ||
| 509 | - self.tool.run_command('sed -i "349,351d" {}'.format(rc_sysinit), sudo=True) | ||
| 510 | - self.tool.run_command('sed -i "311,316d" {}'.format(rc_sysinit), sudo=True) | ||
| 511 | - self.tool.run_command('sed -i "307d" {}'.format(rc_sysinit), sudo=True) | ||
| 512 | - self.tool.run_command('sed -i "146d" {}'.format(rc_sysinit), sudo=True) | ||
| 513 | - self.tool.run_command('sed -i "144d" {}'.format(rc_sysinit), sudo=True) | ||
| 514 | - self.tool.run_command('sed -i "133d" {}'.format(rc_sysinit), sudo=True) | ||
| 515 | - self.tool.run_command('sed -i "336d" {}'.format(rc_sysinit), sudo=True) | ||
| 516 | - self.tool.run_command('sed -i "326,328d" {}'.format(rc_sysinit), sudo=True) | ||
| 517 | - self.tool.run_command('sed -i "244d" {}'.format(rc_sysinit), sudo=True) | ||
| 518 | - self.tool.run_command('sed -i "197d" {}'.format(rc_sysinit), sudo=True) | ||
| 519 | - self.tool.run_command('sed -i "154d" {}'.format(rc_sysinit), sudo=True) | ||
| 520 | - self.tool.run_command('sed -i "84,85d" {}'.format(rc_sysinit), sudo=True) | ||
| 521 | - | ||
| 522 | @log("sed /etc/systemd/journald_conf") | 488 | @log("sed /etc/systemd/journald_conf") |
| 523 | def __sed_etc_systemd_journald_conf(self): | 489 | def __sed_etc_systemd_journald_conf(self): |
| 524 | journald_conf = "{}/etc/systemd/journald.conf".format(self.des) | 490 | journald_conf = "{}/etc/systemd/journald.conf".format(self.des) |
| 525 | self.tool.run_command('sed -i "s/SystemMaxUse=8M/SystemMaxUse=25M/g" {}'.format(journald_conf), sudo=True) | 491 | self.tool.run_command('sed -i "s/SystemMaxUse=8M/SystemMaxUse=25M/g" {}'.format(journald_conf), sudo=True) |
| 526 | self.tool.run_command('sed -i "s/RuntimeMaxUse=8M/RuntimeMaxUse=25M/g" {}'.format(journald_conf), sudo=True) | 492 | self.tool.run_command('sed -i "s/RuntimeMaxUse=8M/RuntimeMaxUse=25M/g" {}'.format(journald_conf), sudo=True) |
| 527 | self.tool.run_command('sed -i "s/ sleep 1/ sleep 0.1/g" {}'.format(journald_conf), sudo=True) | 493 | self.tool.run_command('sed -i "s/ sleep 1/ sleep 0.1/g" {}'.format(journald_conf), sudo=True) |
| 528 | - | 494 | + |
| 529 | - @log("sed /etc/rc.d/rc.start/S11EventInit.sh") | 495 | + @log("sed /lib/systemd/system/rc-local.service") |
| 530 | - def __sed_S11Eventinit_sh(self): | 496 | + def __sed_rc_local_service(self): |
| 531 | - S11EventInit_file = "{}/etc/rc.d/rc.start/S11EventInit.sh".format(self.des) | 497 | + # rc.local为前台脚本,将Type=forking改为Type=oneshot,避免systemd等待不存在的fork子进程导致启动阻塞 |
| 532 | - self.tool.run_command('sed -i "5,7d" {}'.format(S11EventInit_file), sudo=True) | 498 | + des = "{}/lib/systemd/system/rc-local.service".format(self.des) |
| 533 | - | 499 | + if not self.check_path_is_existed(des): |
| 534 | - @log("sed /etc/rc.d/rc.start/S11FrudataInit.sh") | 500 | + return |
| 535 | - def __sed_S11FrudataInit_sh(self): | 501 | + self.tool.run_command('sed -i "s/Type=forking/Type=oneshot/g" {}'.format(des), sudo=True) |
| 536 | - S11FrudataInit_file = "{}/etc/rc.d/rc.start/S11FrudataInit.sh".format(self.des) | 502 | + # 将日志打印到串口,解决rc-local.service启动时缺少可定位性问题 |
| 537 | - self.tool.run_command('sed -i "5d" {}'.format(S11FrudataInit_file), sudo=True) | 503 | + self.tool.run_command('sed -i "/^\[Service\]/a StandardOutput=tty" {}'.format(des, des), sudo=True) |
| 538 | - | 504 | + self.tool.run_command('sed -i "/^\[Service\]/a StandardError=tty" {}'.format(des, des), sudo=True) |
| 539 | - @log("sed /etc/rc.d/rc.start/S11SensorInit.sh") | 505 | + self.tool.run_command('sed -i "/^\[Service\]/a TTYPath=/dev/ttyS0" {}'.format(des, des), sudo=True) |
| 540 | - def __sed_S11SensorInit_sh(self): | ||
| 541 | - S11SensorInit_file = "{}/etc/rc.d/rc.start/S11SensorInit.sh".format(self.des) | ||
| 542 | - self.tool.run_command('sed -i "14,17d" {}'.format(S11SensorInit_file), sudo=True) | ||
| 543 | - | ||
| 544 | - @log("sed /etc/rc.d/rc.start/S12BiosInit.sh") | ||
| 545 | - def __sed_S12BiosInit_sh(self): | ||
| 546 | - S12BiosInit_file = "{}/etc/rc.d/rc.start/S12BiosInit.sh".format(self.des) | ||
| 547 | - self.tool.run_command('sed -i "4,12d" {}'.format(S12BiosInit_file), sudo=True) | ||
| 548 | - | ||
| 549 | - @log("sed /etc/rc.d/rc.start/S12ComputeInit.sh") | ||
| 550 | - def __sed_S12ComputeInit_sh(self): | ||
| 551 | - S12ComputeInit_file = "{}/etc/rc.d/rc.start/S12ComputeInit.sh".format(self.des) | ||
| 552 | - self.tool.run_command('sed -i "5,6d" {}'.format(S12ComputeInit_file), sudo=True) | ||
| 553 | - | ||
| 554 | - @log("sed /etc/rc.d/rc.start/S12GeneralHardwareInit.sh") | ||
| 555 | - def __sed_S12GeneralHardwareInit_sh(self): | ||
| 556 | - S12GeneralHardwareInit_file = "{}/etc/rc.d/rc.start/S12GeneralHardwareInit.sh".format(self.des) | ||
| 557 | - self.tool.run_command('sed -i "14,21d" {}'.format(S12GeneralHardwareInit_file), sudo=True) | ||
| 558 | - | ||
| 559 | - @log("sed /etc/rc.d/rc.start/S12ManufactureInit.sh") | ||
| 560 | - def __sed_S12ManufactureInit_sh(self): | ||
| 561 | - S12ManufactureInit_file = "{}/etc/rc.d/rc.start/S12ManufactureInit.sh".format(self.des) | ||
| 562 | - self.tool.run_command('sed -i "14,15d" {}'.format(S12ManufactureInit_file), sudo=True) | ||
| 563 | - | ||
| 564 | - @log("sed /etc/rc.d/rc.start/S12NetworkAdapterInit.sh") | ||
| 565 | - def __sed_S12NetworkAdapterInit_sh(self): | ||
| 566 | - S12NetworkAdapterInit_file = "{}/etc/rc.d/rc.start/S12NetworkAdapterInit.sh".format(self.des) | ||
| 567 | - self.tool.run_command('sed -i "13,16d" {}'.format(S12NetworkAdapterInit_file), sudo=True) | ||
| 568 | - | ||
| 569 | - @log("sed /etc/rc.d/rc.start/S12PcieDeviceInit.sh") | ||
| 570 | - def __sed_S12PcieDeviceInit_sh(self): | ||
| 571 | - S12PcieDeviceInit_file = "{}/etc/rc.d/rc.start/S12PcieDeviceInit.sh".format(self.des) | ||
| 572 | - self.tool.run_command('sed -i "5d" {}'.format(S12PcieDeviceInit_file), sudo=True) | ||
| 573 | - | ||
| 574 | - @log("sed /etc/rc.d/rc.start/S12StorageInit.sh") | ||
| 575 | - def __sed_S12StorageInit_sh(self): | ||
| 576 | - S12StorageInit_file = "{}/etc/rc.d/rc.start/S12StorageInit.sh".format(self.des) | ||
| 577 | - self.tool.run_command('sed -i "14,19d" {}'.format(S12StorageInit_file), sudo=True) | ||
| 578 | - | ||
| 579 | - @log("sed /etc/rc.d/rc.start/S16FileTransferInit.sh") | ||
| 580 | - def __sed_S16FileTransferInit_sh(self): | ||
| 581 | - S16FileTransferInit_file = "{}/etc/rc.d/rc.start/S16FileTransferInit.sh".format(self.des) | ||
| 582 | - self.tool.run_command('sed -i "5d" {}'.format(S16FileTransferInit_file), sudo=True) | ||
| 583 | - self.tool.run_command('sed -i "1,3d" {}'.format(S16FileTransferInit_file), sudo=True) | ||
| 584 | - | ||
| 585 | - @log("sed /etc/rc.d/rc.start/S16SsdpInit.sh") | ||
| 586 | - def __sed_S16SsdpInit_sh(self): | ||
| 587 | - S16SsdpInit_file = "{}/etc/rc.d/rc.start/S16SsdpInit.sh".format(self.des) | ||
| 588 | - self.tool.run_command('sed -i "1d" {}'.format(S16SsdpInit_file), sudo=True) | ||
| 589 | - | ||
| 590 | - @log("sed /etc/rc.d/rc.start/ipmi_core.start") | ||
| 591 | - def __sed_ipmi_core_start(self): | ||
| 592 | - ipmi_core_start_file = "{}/etc/rc.d/rc.start/ipmi_core.start".format(self.des) | ||
| 593 | - self.tool.run_command('sed -i "2,4d" {}'.format(ipmi_core_start_file), sudo=True) | ||
| 594 | - | ||
| 595 | - @log("sed /etc/rc.d/rc.start/S16UmsInit.sh") | ||
| 596 | - def __sed_S16UmsInit_sh(self): | ||
| 597 | - S16UmsInit_file = "{}/etc/rc.d/rc.start/S16UmsInit.sh".format(self.des) | ||
| 598 | - self.tool.run_command('sed -i "2,4d" {}'.format(S16UmsInit_file), sudo=True) | ||
| 599 | - self.tool.run_command('sed -i "6,7d" {}'.format(S16UmsInit_file), sudo=True) | ||
| 600 | - | ||
| 601 | - @log("sed /opt/bmc/script/data_fs_check.sh") | ||
| 602 | - def __sed_data_fs_check_sh(self): | ||
| 603 | - data_fs_check_file = "{}/opt/bmc/script/data_fs_check.sh".format(self.des) | ||
| 604 | - self.tool.run_command('sed -i "49d" {}'.format(data_fs_check_file), sudo=True) | ||
| 605 | - | ||
| 606 | - @log("sed /opt/bmc/script/log_partition_check.sh") | ||
| 607 | - def __sed_log_partition_check_sh(self): | ||
| 608 | - log_partition_check_file = "{}/opt/bmc/script/log_partition_check.sh".format(self.des) | ||
| 609 | - self.tool.run_command('sed -i "17d" {}'.format(log_partition_check_file), sudo=True) | ||
| 610 | - self.tool.run_command('sed -i "17i\logpart_sectors_num=0" {}'.format(log_partition_check_file), sudo=True) | ||
| 611 | - | ||
| 612 | - @log("sed /opt/bmc/script/partition_migrate.sh") | ||
| 613 | - def __sed_partition_migrate_sh(self): | ||
| 614 | - partition_migrate_file = "{}/opt/bmc/script/partition_migrate.sh".format(self.des) | ||
| 615 | - self.tool.run_command('sed -i "18,20d" {}'.format(partition_migrate_file), sudo=True) | ||
| 616 | - self.tool.run_command('sed -i "18i\logpart_sectors_num=0" {}'.format(partition_migrate_file), sudo=True) | ||
| 617 | - self.tool.run_command('sed -i "18i\permanent_sectors_num=0" {}'.format(partition_migrate_file), sudo=True) | ||
| 618 | - self.tool.run_command('sed -i "18i\ reserved_sectors_num=0" {}'.format(partition_migrate_file), sudo=True) | ||
| 619 | - | ||
| 620 | - @log("sed /opt/bmc/script/trust_partition_check.sh") | ||
| 621 | - def __sed_trust_partition_check_sh(self): | ||
| 622 | - trust_partition_check_file = "{}/opt/bmc/script/trust_partition_check.sh".format(self.des) | ||
| 623 | - self.tool.run_command('sed -i "17d" {}'.format(trust_partition_check_file), sudo=True) | ||
| 624 | - self.tool.run_command('sed -i "17i\ trustpart_sectors_num=0" {}'.format(trust_partition_check_file), sudo=True) | ||
| 625 | - | ||
| 626 | - @log("sed /etc/rc.d/rc.start/ensure_exist.sh") | ||
| 627 | - def __sed_ensure_exist_sh(self): | ||
| 628 | - ensure_exist_file = "{}/etc/rc.d/rc.start/ensure_exist.sh".format(self.des) | ||
| 629 | - self.tool.run_command('sed -i "153d" {}'.format(ensure_exist_file), sudo=True) | ||
| 630 | - self.tool.run_command('sed -i "143d" {}'.format(ensure_exist_file), sudo=True) | ||
| 631 | - self.tool.run_command('sed -i "133d" {}'.format(ensure_exist_file), sudo=True) | ||
| 632 | - self.tool.run_command('sed -i "122d" {}'.format(ensure_exist_file), sudo=True) | ||
| 633 | 506 | ||
| 634 | class TaskClass(Task): | 507 | class TaskClass(Task): |
| 635 | - @staticmethod | ||
| 636 | - def copy_folder(self,source_path, target_path): | ||
| 637 | - # 确保目标路径存在 | ||
| 638 | - os.makedirs(target_path, exist_ok=True) | ||
| 639 | - # 遍历源文件夹 | ||
| 640 | - for item in os.listdir(source_path): | ||
| 641 | - source_item = os.path.join(source_path, item) | ||
| 642 | - target_item = os.path.join(target_path, item) | ||
| 643 | - # 如果是文件,直接复制 | ||
| 644 | - if os.path.isfile(source_item): | ||
| 645 | - self.run_command(f"cp -r {source_item} {target_item}", sudo=True) | ||
| 646 | - # 如果是文件夹,递归复制 | ||
| 647 | - elif os.path.isdir(source_item): | ||
| 648 | - self.run_command(f"cp -r {source_item} {target_item}") | ||
| 649 | - | ||
| 650 | def mv_web_backend(self, qemu_rootfs_path): | 508 | def mv_web_backend(self, qemu_rootfs_path): |
| 651 | """ | 509 | """ |
| 652 | 将源文件夹中的文件复制到目标文件夹中 | 510 | 将源文件夹中的文件复制到目标文件夹中 |
| @@ -709,33 +567,32 @@ class TaskClass(Task): | |||
| 709 | 567 | ||
| 710 | self.chdir(f"{self.config.temp_path}/qemu") | 568 | self.chdir(f"{self.config.temp_path}/qemu") |
| 711 | 569 | ||
| 712 | - self.run_command(f"rm -rf {qemu_name}", sudo=True) | 570 | + self.run_command(f"rm -rf {qemu_name}") |
| 713 | qemu_path = f"../{qemu_name}" | 571 | qemu_path = f"../{qemu_name}" |
| 714 | - self.chdir(f"{qemu_rootfs_path}") | 572 | + self.chdir(qemu_rootfs_path) |
| 715 | 573 | ||
| 716 | # 将仿真镜像、zImage和dtb压缩为总包 | 574 | # 将仿真镜像、zImage和dtb压缩为总包 |
| 717 | data_name = qemu_name.split('.')[0] | 575 | data_name = qemu_name.split('.')[0] |
| 718 | - self.run_command(f"rm -rf {self.config.temp_path}/{data_name}/", sudo=True) | 576 | + qemu_output = os.path.join(self.config.output_path, data_name) |
| 719 | - | 577 | + os.makedirs(qemu_output, exist_ok=True) |
| 720 | - # 创建新目录 | ||
| 721 | - os.makedirs(f"{self.config.temp_path}/{data_name}/") | ||
| 722 | # 复制dtb文件到其他地方 | 578 | # 复制dtb文件到其他地方 |
| 723 | - self.run_command(f"cp -dfr {qemu_mockup_dir}/data/dtb/hi1711_9p8c.dtb {self.config.temp_path}/{data_name}", sudo=True) | 579 | + self.run_command(f"cp -dfr {qemu_mockup_dir}/data/dtb/hi1711_9p8c.dtb {qemu_output}/hi1711_9p8c.dtb", sudo=True) |
| 724 | - self.run_command(f"rm -rf {qemu_rootfs_path}/opt/bmc/apps/qemu_mockup", sudo=True) | ||
| 725 | # 使用相对目录压缩 | 580 | # 使用相对目录压缩 |
| 726 | self.pipe_command([f"sudo find .", " sudo cpio -H newc --quiet -o"], qemu_path) | 581 | self.pipe_command([f"sudo find .", " sudo cpio -H newc --quiet -o"], qemu_path) |
| 727 | - self.run_command(f"pwd", sudo=True) | 582 | + self.run_command(f"pwd") |
| 728 | - self.run_command(f"gzip -k {qemu_path}", sudo=True) | 583 | + self.run_command(f"gzip -k {qemu_path}") |
| 729 | - self.run_command(f"cp -dfr {qemu_path}.gz {inner_path}", sudo=True) | 584 | + self.run_command(f"cp -dfr {qemu_path}.gz {qemu_output}") |
| 585 | + self.run_command(f"cp -dfr {qemu_path}.gz {inner_path}") | ||
| 730 | # 移动zImage | 586 | # 移动zImage |
| 731 | - self.run_command(f"dd if={src_rootfs_path}/boot/uImage of={inner_path}/zImage_openUBMC bs=1 skip=64", sudo=True) | 587 | + self.run_command(f"dd if={src_rootfs_path}/boot/uImage of={qemu_output}/zImage_openUBMC bs=64 skip=1", sudo=True) |
| 588 | + self.run_command(f"dd if={src_rootfs_path}/boot/uImage of={inner_path}/zImage_openUBMC bs=64 skip=1", sudo=True) | ||
| 589 | + self.run_command(f"chown {os.getuid()}:{os.getgid()} {qemu_output} -R", sudo=True) | ||
| 590 | + qemu_dir = os.path.join(self.config.output_path, "qemu") | ||
| 591 | + shutil.rmtree(qemu_dir, ignore_errors=True) | ||
| 732 | 592 | ||
| 733 | - # 复制文件 | ||
| 734 | - self.run_command(f"cp -dfr {qemu_path}.gz {self.config.temp_path}/{data_name}", sudo=True) | ||
| 735 | - self.run_command(f"cp -dfr {inner_path}/zImage_openUBMC {self.config.temp_path}/{data_name}", sudo=True) | ||
| 736 | # 打包压缩 | 593 | # 打包压缩 |
| 737 | - self.run_command(f"tar -czf {self.config.temp_path}/{data_name}.data.gz -C {self.config.temp_path} {data_name}", sudo=True) | 594 | + self.run_command(f"tar -czf {self.config.output_path}/{data_name}.data.gz -C {os.path.dirname(qemu_output)} {os.path.basename(qemu_output)}") |
| 738 | - self.run_command(f"cp -dfr {self.config.temp_path}/{data_name}.data.gz {self.config.output_path}", sudo=True) | 595 | + self.run_command(f'mv {qemu_output} {qemu_dir}/') |
| 739 | 596 | ||
| 740 | def run(self): | 597 | def run(self): |
| 741 | qemu_dir = os.path.join(self.config.output_path, "packet/inner") | 598 | qemu_dir = os.path.join(self.config.output_path, "packet/inner") |