chore: 能够通过比较文件内容,处理包

This commit is contained in:
2025-11-17 09:39:11 +08:00
parent 84c4933ece
commit 27f10afd78
3 changed files with 73 additions and 20 deletions

View File

@@ -67,16 +67,43 @@ install_dependencies() {
local sudo_prefix
sudo_prefix=$(get_cmd_prefix)
local will_install_dependencies=false
local dependencies=(
"tar"
"gzip"
"jq"
"gpg"
"bc"
)
for dep in "${dependencies[@]}"; do
if command -v "$dep" >/dev/null 2>&1; then
info "系统依赖 $dep 已安装"
else
warn "系统依赖 $dep 未安装"
will_install_dependencies=true
fi
done
if ! $will_install_dependencies; then
info "系统依赖已安装"
return 0
fi
# 关键依赖
local keys_deps = " coreutils findutils util-linux "
if command -v apt-get >/dev/null 2>&1; then
# Debian/Ubuntu
$sudo_prefix apt-get update
$sudo_prefix apt-get install -y tar gzip jq coreutils findutils util-linux bc
$sudo_prefix apt-get install -y $keys_deps $(printf "%s " "${dependencies[@]}")
elif command -v yum >/dev/null 2>&1; then
# CentOS/RHEL
$sudo_prefix yum install -y tar gzip jq coreutils findutils util-linux bc
$sudo_prefix yum install -y $keys_deps $(printf "%s " "${dependencies[@]}")
else
warn "无法自动安装依赖,请手动安装: tar, gzip, jq, coreutils, findutils, util-linux, bc"
warn "无法自动安装依赖,请手动安装: $keys_deps $(printf "%s " "${dependencies[@]}")"
fi
# 安装GPG用于签名验证