在主机或者 ACE 安装之前,使用 aptss install --dry-run 方式测试能否安装成功来替代直接尝试安装,如果测试失败了,…

This commit is contained in:
shenmo 2025-06-05 17:08:03 +08:00
parent 73af595774
commit c9f0ac7c5e
2 changed files with 48 additions and 36 deletions

@ -266,36 +266,43 @@ function install_in_ace_env() {
echo "正在尝试使用 $ace_cmd 环境安装..."
echo "----------------------------------------"
# 在ACE环境中执行安装
if $ace_cmd "ensure_aptss_exist && { dpkg -i '$deb_path' || aptss install '$deb_path' -yfq; }"; then
return 0
else
# 如果第一次安装失败执行aptss update后再试一次
echo "第一次安装失败,正在更新仓库信息后重试..."
# 首先尝试dry-run测试
if ! $ace_cmd "ensure_aptss_exist && aptss install --dry-run '$deb_path'"; then
echo "初始dry-run测试失败尝试更新后重试..."
$ace_cmd "aptss update"
if $ace_cmd "dpkg -i '$deb_path' || aptss install '$deb_path' -yfq"; then
return 0
else
if ! $ace_cmd "aptss install --dry-run '$deb_path'"; then
echo "dry-run测试仍然失败放弃安装"
return 1
fi
fi
# dry-run成功后执行实际安装
if $ace_cmd "dpkg -i '$deb_path' || aptss install '$deb_path' -yfq"; then
return 0
else
return 1
fi
}
# 在主机安装
function install_in_host() {
local deb_path="$1"
# 首先尝试dry-run测试
if ! aptss install --dry-run "$deb_path"; then
echo "初始dry-run测试失败尝试更新后重试..."
aptss update
if ! aptss install --dry-run "$deb_path"; then
echo "dry-run测试仍然失败放弃安装"
return 1
fi
fi
# dry-run成功后执行实际安装
if dpkg -i "$deb_path" || aptss install "$deb_path" -yfq; then
return 0
else
# 如果第一次安装失败执行aptss update后再试一次
echo "第一次安装失败,正在更新仓库信息后重试..."
aptss update
if dpkg -i "$deb_path" || aptss install "$deb_path" -yfq; then
return 0
else
return 1
fi
return 1
fi
}
@ -327,7 +334,6 @@ function auto_try_install() {
return 1
}
# 清理安装后的文件
function post_install_cleanup() {
local success=$1

@ -266,36 +266,43 @@ function install_in_ace_env() {
echo "正在尝试使用 $ace_cmd 环境安装..."
echo "----------------------------------------"
# 在ACE环境中执行安装
if $ace_cmd "ensure_aptss_exist && { dpkg -i '$deb_path' || aptss install '$deb_path' -yfq; }"; then
return 0
else
# 如果第一次安装失败执行aptss update后再试一次
echo "第一次安装失败,正在更新仓库信息后重试..."
# 首先尝试dry-run测试
if ! $ace_cmd "ensure_aptss_exist && aptss install --dry-run '$deb_path'"; then
echo "初始dry-run测试失败尝试更新后重试..."
$ace_cmd "aptss update"
if $ace_cmd "dpkg -i '$deb_path' || aptss install '$deb_path' -yfq"; then
return 0
else
if ! $ace_cmd "aptss install --dry-run '$deb_path'"; then
echo "dry-run测试仍然失败放弃安装"
return 1
fi
fi
# dry-run成功后执行实际安装
if $ace_cmd "dpkg -i '$deb_path' || aptss install '$deb_path' -yfq"; then
return 0
else
return 1
fi
}
# 在主机安装
function install_in_host() {
local deb_path="$1"
# 首先尝试dry-run测试
if ! aptss install --dry-run "$deb_path"; then
echo "初始dry-run测试失败尝试更新后重试..."
aptss update
if ! aptss install --dry-run "$deb_path"; then
echo "dry-run测试仍然失败放弃安装"
return 1
fi
fi
# dry-run成功后执行实际安装
if dpkg -i "$deb_path" || aptss install "$deb_path" -yfq; then
return 0
else
# 如果第一次安装失败执行aptss update后再试一次
echo "第一次安装失败,正在更新仓库信息后重试..."
aptss update
if dpkg -i "$deb_path" || aptss install "$deb_path" -yfq; then
return 0
else
return 1
fi
return 1
fi
}
@ -327,7 +334,6 @@ function auto_try_install() {
return 1
}
# 清理安装后的文件
function post_install_cleanup() {
local success=$1