Skip to content

Commit 444a34f

Browse files
committed
fix: write vm_config in .build.toml when use --fs
1 parent 6443480 commit 444a34f

1 file changed

Lines changed: 42 additions & 12 deletions

File tree

scripts/tests.sh

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,14 +1380,44 @@ EOF
13801380
fi
13811381

13821382
# 步骤 2: 修改 .build.toml 文件
1383-
if [ "$USE_FS_MODE" == true ]; then
1384-
log " --fs 模式: 跳过 .build.toml 配置文件修改"
1385-
else
1386-
log " 更新 .build.toml 配置..."
1387-
local build_toml=".build.toml"
1383+
log " 更新 .build.toml 配置..."
1384+
local build_toml=".build.toml"
1385+
1386+
if [ -f "$build_toml" ]; then
1387+
if [ "$USE_FS_MODE" == true ]; then
1388+
# --fs 模式: 仅修改 vm_configs 为文件系统路径
1389+
local fs_vm_configs=""
1390+
case "$target_name" in
1391+
axvisor-board-phytiumpi-arceos)
1392+
fs_vm_configs='["/guest/arceos/arceos-aarch64-e2000-smp1.toml"]'
1393+
;;
1394+
axvisor-board-phytiumpi-linux)
1395+
fs_vm_configs='["/guest/linux/linux-aarch64-e2000-smp1.toml"]'
1396+
;;
1397+
axvisor-board-roc-rk3568-pc-arceos)
1398+
fs_vm_configs='["/userdata/rootfs_overlay/guest/arceos/arceos-aarch64-rk3568-smp1.toml"]'
1399+
;;
1400+
axvisor-board-roc-rk3568-pc-linux)
1401+
fs_vm_configs='["/userdata/rootfs_overlay/guest/linux/linux-aarch64-rk3568-smp1.toml"]'
1402+
;;
1403+
*)
1404+
log_warn " 未知目标: $target_name,使用默认 vm_configs"
1405+
fs_vm_configs="$vm_configs_json"
1406+
;;
1407+
esac
13881408

1389-
if [ -f "$build_toml" ]; then
1390-
# 使用 awk 来替换 features 和 vm_configs
1409+
# 仅替换 vm_configs,保留 features
1410+
awk -v vm_configs="$fs_vm_configs" '
1411+
/^vm_configs = \[/ { in_vm=1; next }
1412+
in_vm { if(/^\]/) { in_vm=0 } next }
1413+
/^log = / { print $0 "\nvm_configs = " vm_configs; next }
1414+
{ print }
1415+
' "$build_toml" > "$build_toml.tmp" && mv "$build_toml.tmp" "$build_toml"
1416+
1417+
log_success " .build.toml 更新完成 (--fs 模式)"
1418+
log_debug " - vm_configs: $fs_vm_configs"
1419+
else
1420+
# 非 --fs 模式: 修改 features 和 vm_configs
13911421
awk -v vm_configs="$vm_configs_json" '
13921422
/^features = \[/ { in_features=1; print "features = ["; print " # \"ept-level-4\","; print " \"dyn-plat\","; print " \"axstd/bus-mmio\","; print "]"; next }
13931423
in_features { if(/^\]/) { in_features=0 } next }
@@ -1400,12 +1430,12 @@ EOF
14001430
log_success " .build.toml 更新完成"
14011431
log_debug " - Features 已更新"
14021432
log_debug " - vm_configs: $vm_configs_json"
1403-
else
1404-
log_error " 未找到 .build.toml 文件"
1405-
echo "failed" > "$status_file"
1406-
cd "$COMPONENT_DIR"
1407-
return 1
14081433
fi
1434+
else
1435+
log_error " 未找到 .build.toml 文件"
1436+
echo "failed" > "$status_file"
1437+
cd "$COMPONENT_DIR"
1438+
return 1
14091439
fi
14101440

14111441
# 步骤 3: 检查 .uboot.toml 是否存在,不存在则从配置文件读取或提示用户输入

0 commit comments

Comments
 (0)