Files
PVE-Tools-9/build.sh
Maple 886e82f0cb refactor: 模块化重构 — 拆分 lib/ 基础设施层与 src/modules/ 功能模块
PVE-Tools.sh 从 ~14,700 行单文件重构为 150 行入口点,
所有函数按职责拆分到独立文件,通过 source 机制加载。

lib/ — 基础设施层(零业务逻辑)
  config.sh: 全局变量与常量
  core.sh: 日志、UI、确认、备份、GRUB、进度条
  network.sh: 网络检测、镜像选择
  runtime.sh: 运行时守卫、main() 入口

src/modules/ — 功能模块(10 个目录)
  01-optimization  02-sources  03-boot-kernel
  04-gpu-passthrough  05-vm-container  06-networking
  07-storage-disk  08-tools-about  09-security  10-third-party

新增 build.sh(合并编译)和 dev.sh(开发 source 入口),
release.yml 新增构建步骤,CI 适配模块化结构。
2026-07-08 11:15:59 +08:00

50 lines
1.2 KiB
Bash

#!/bin/bash
# SPDX-License-Identifier: GPL-3.0-only
# Copyright (C) 2026 Ciriu Networks
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OUTPUT="${1:-$ROOT/dist/PVE-Tools.sh}"
VERSION="$(cat "$ROOT/VERSION")"
mkdir -p "$(dirname "$OUTPUT")"
{
echo '#!/bin/bash'
echo
echo "# PVE-Tools Pro v$VERSION"
echo "# Build: $(date -u +%Y-%m-%dT%H:%M:%SZ)"
echo "# SPDX-License-Identifier: GPL-3.0-only"
echo "# Copyright (C) 2026 Ciriu Networks"
echo
for lib_name in config.sh core.sh network.sh runtime.sh; do
lib_file="$ROOT/lib/$lib_name"
if [[ ! -f "$lib_file" ]]; then
echo "Missing lib file: $lib_file" >&2
exit 1
fi
echo "# [lib] $lib_name"
cat "$lib_file"
echo
done
while IFS= read -r -d '' module_file; do
rel="${module_file#$ROOT/src/modules/}"
echo "# [module] $rel"
cat "$module_file"
echo
done < <(find "$ROOT/src/modules" -name '*.sh' -print0 | sort -z)
echo 'main "$@"'
echo
} > "$OUTPUT"
chmod +x "$OUTPUT"
total_lines=$(wc -l < "$OUTPUT")
total_size=$(wc -c < "$OUTPUT")
echo "Built: $OUTPUT"
echo " Lines: $total_lines | Size: $(( total_size / 1024 ))KB"