mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-09-23 11:32:21 +08:00
在主机或者 ACE 安装之前,使用 aptss install --dry-run 方式测试能否安装成功来替代直接尝试安装,如果测试失败了,…
This commit is contained in:
parent
73af595774
commit
c9f0ac7c5e
42
tool/ssaudit
42
tool/ssaudit
@ -266,36 +266,43 @@ function install_in_ace_env() {
|
|||||||
echo "正在尝试使用 $ace_cmd 环境安装..."
|
echo "正在尝试使用 $ace_cmd 环境安装..."
|
||||||
echo "----------------------------------------"
|
echo "----------------------------------------"
|
||||||
|
|
||||||
# 在ACE环境中执行安装
|
# 首先尝试dry-run测试
|
||||||
if $ace_cmd "ensure_aptss_exist && { dpkg -i '$deb_path' || aptss install '$deb_path' -yfq; }"; then
|
if ! $ace_cmd "ensure_aptss_exist && aptss install --dry-run '$deb_path'"; then
|
||||||
return 0
|
echo "初始dry-run测试失败,尝试更新后重试..."
|
||||||
else
|
|
||||||
# 如果第一次安装失败,执行aptss update后再试一次
|
|
||||||
echo "第一次安装失败,正在更新仓库信息后重试..."
|
|
||||||
$ace_cmd "aptss update"
|
$ace_cmd "aptss update"
|
||||||
if $ace_cmd "dpkg -i '$deb_path' || aptss install '$deb_path' -yfq"; then
|
if ! $ace_cmd "aptss install --dry-run '$deb_path'"; then
|
||||||
return 0
|
echo "dry-run测试仍然失败,放弃安装"
|
||||||
else
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
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() {
|
function install_in_host() {
|
||||||
local deb_path="$1"
|
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
|
if dpkg -i "$deb_path" || aptss install "$deb_path" -yfq; then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
# 如果第一次安装失败,执行aptss update后再试一次
|
return 1
|
||||||
echo "第一次安装失败,正在更新仓库信息后重试..."
|
|
||||||
aptss update
|
|
||||||
if dpkg -i "$deb_path" || aptss install "$deb_path" -yfq; then
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,7 +334,6 @@ function auto_try_install() {
|
|||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# 清理安装后的文件
|
# 清理安装后的文件
|
||||||
function post_install_cleanup() {
|
function post_install_cleanup() {
|
||||||
local success=$1
|
local success=$1
|
||||||
|
@ -266,36 +266,43 @@ function install_in_ace_env() {
|
|||||||
echo "正在尝试使用 $ace_cmd 环境安装..."
|
echo "正在尝试使用 $ace_cmd 环境安装..."
|
||||||
echo "----------------------------------------"
|
echo "----------------------------------------"
|
||||||
|
|
||||||
# 在ACE环境中执行安装
|
# 首先尝试dry-run测试
|
||||||
if $ace_cmd "ensure_aptss_exist && { dpkg -i '$deb_path' || aptss install '$deb_path' -yfq; }"; then
|
if ! $ace_cmd "ensure_aptss_exist && aptss install --dry-run '$deb_path'"; then
|
||||||
return 0
|
echo "初始dry-run测试失败,尝试更新后重试..."
|
||||||
else
|
|
||||||
# 如果第一次安装失败,执行aptss update后再试一次
|
|
||||||
echo "第一次安装失败,正在更新仓库信息后重试..."
|
|
||||||
$ace_cmd "aptss update"
|
$ace_cmd "aptss update"
|
||||||
if $ace_cmd "dpkg -i '$deb_path' || aptss install '$deb_path' -yfq"; then
|
if ! $ace_cmd "aptss install --dry-run '$deb_path'"; then
|
||||||
return 0
|
echo "dry-run测试仍然失败,放弃安装"
|
||||||
else
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
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() {
|
function install_in_host() {
|
||||||
local deb_path="$1"
|
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
|
if dpkg -i "$deb_path" || aptss install "$deb_path" -yfq; then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
# 如果第一次安装失败,执行aptss update后再试一次
|
return 1
|
||||||
echo "第一次安装失败,正在更新仓库信息后重试..."
|
|
||||||
aptss update
|
|
||||||
if dpkg -i "$deb_path" || aptss install "$deb_path" -yfq; then
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,7 +334,6 @@ function auto_try_install() {
|
|||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# 清理安装后的文件
|
# 清理安装后的文件
|
||||||
function post_install_cleanup() {
|
function post_install_cleanup() {
|
||||||
local success=$1
|
local success=$1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user