diff --git a/tool/ssaudit b/tool/ssaudit index 5a25c57..e6cced1 100755 --- a/tool/ssaudit +++ b/tool/ssaudit @@ -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 diff --git a/tool/ssinstall b/tool/ssinstall index e9b53fa..3ec57c1 100755 --- a/tool/ssinstall +++ b/tool/ssinstall @@ -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