diff --git a/tool/apt-fast/ss-apt-fast b/tool/apt-fast/ss-apt-fast index 17abb7b..dea3648 100755 --- a/tool/apt-fast/ss-apt-fast +++ b/tool/apt-fast/ss-apt-fast @@ -186,12 +186,21 @@ VERBOSE_OUTPUT= # Download command. _DOWNLOADER='aria2c --no-conf -c -j ${_MAXNUM} -x ${_MAXCONPERSRV} -s ${_SPLITCON} -i ${DLLIST} --min-split-size=${_MINSPLITSZ} --stream-piece-selector=${_PIECEALGO} --connect-timeout=60 --timeout=600 -m0' -# Load config file. -CONFFILE="/tmp/aptss-conf/apt-fast.conf" -#### Spark Store apt-fast conf is in /tmp -if [ -e "$CONFFILE" ]; then - source "$CONFFILE" -fi +# 定义默认的配置文件列表(按加载顺序排列) +CONFIG_FILES=( + "/tmp/aptss-conf/apt-fast.conf" # 原始配置文件位置 + "/etc/aptss/apt-fast.conf" # 系统级配置 +) + + +# 按顺序加载所有配置文件 +for conf_file in "${CONFIG_FILES[@]}"; do + if [ -e "$conf_file" ]; then + source "$conf_file" + fi +done + + # no proxy as default ftp_proxy= diff --git a/tool/aptss b/tool/aptss index bdb8beb..228f0fc 100755 --- a/tool/aptss +++ b/tool/aptss @@ -7,7 +7,7 @@ source /opt/durapps/spark-store/bin/bashimport/log.amber load_transhell case `arch` in - x86_64) + x86_64 | i686 | i386) STORE_URL="store" STORE_LIST_URL="" ;; diff --git a/tool/ssaudit b/tool/ssaudit index 2520efe..013a0e4 100755 --- a/tool/ssaudit +++ b/tool/ssaudit @@ -1,6 +1,8 @@ #!/bin/bash - +SPARK_DOWNLOAD_SERVER_URL="https://d.spark-app.store/" +SPARK_DOWNLOAD_SERVER_URL_NO_PROTOCOL="d.spark-app.store" source /opt/durapps/spark-store/bin/bashimport/transhell.amber + load_transhell_debug export DEBIAN_FRONTEND=noninteractive @@ -60,30 +62,8 @@ function zenity() { } function hash_check() { - if [ ! -e "/var/lib/aptss/lists/d.spark-app.store_${STORE_URL}_Packages" ] && \ - [ ! -e "/var/lib/aptss/lists/d.store.deepinos.org.cn_${STORE_URL}_Packages" ] && \ - [ ! -e "/var/lib/aptss/lists/mirrors.sdu.edu.cn_spark-store_${STORE_URL}_Packages" ]; then - echo "接收星火仓库软件信息中..." - aptss ssupdate - fi - if [ -e "/var/lib/aptss/lists/d.spark-app.store_${STORE_URL}_Packages" ]; then - PACKAGES_DATA_PATH="/var/lib/aptss/lists/d.spark-app.store_${STORE_URL}_Packages" - echo "星火仓库的Packages位置为 $PACKAGES_DATA_PATH,是星火域名仓库配置" - elif [ -e "/var/lib/aptss/lists/d.store.deepinos.org.cn_${STORE_URL}_Packages" ]; then - PACKAGES_DATA_PATH="/var/lib/aptss/lists/d.store.deepinos.org.cn_${STORE_URL}_Packages" - echo "星火仓库的Packages位置为 $PACKAGES_DATA_PATH,是d域名单目录仓库配置" - else - PACKAGES_DATA_PATH="/var/lib/aptss/lists/mirrors.sdu.edu.cn_spark-store-repository_${STORE_URL}_Packages" - echo "星火仓库的Packages位置为 $PACKAGES_DATA_PATH,是SDU镜像仓库配置" - fi - - echo "正在运行包验证..." - echo "Running Spark Package Verify..." - - DEB_SHA512SUM=$(sha512sum "$1" | cut -d ' ' -f 1) - unset IS_SHA512SUM_CHECKED - IS_SHA512SUM_CHECKED=$(cat "$PACKAGES_DATA_PATH" | grep "$DEB_SHA512SUM") + IS_SHA512SUM_CHECKED=skipped } function lock_file(){ @@ -161,82 +141,114 @@ fi lock_file "$DEBPATH" -IS_SHA512SUM_CHECKED=skipped +hash_check "$DEBPATH" + + if [ ! -z "$IS_SHA512SUM_CHECKED" ]; then echo "校验跳过,开始安装" echo "----------------------------------------------------------------------------------" - package_name=$(dpkg-deb -f "$DEBPATH" Package) - echo "Package name is $package_name" - try_run_output=$(/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh test-install-app "$DEBPATH") - try_run_ret="$?" -# 安装失败后进行 aptss update 刷新,随后尝试在主机安装 - if [ "$try_run_ret" -ne 0 ]; then +package_name=$(dpkg-deb -f "$DEBPATH" Package) +echo "Package name is $package_name" +try_run_output=$(/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh test-install-app "$DEBPATH") +try_run_ret="$?" +# 安装失败后进行 aptss 刷新,随后尝试在主机安装 +if [ "$try_run_ret" -ne 0 ]; then aptss update try_run_output=$(/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh test-install-app "$DEBPATH") try_run_ret="$?" - fi - - if [ "$try_run_ret" -ne 0 ]; then ## 若安装检测仍然失败 +fi - if [[ "$IS_ACE_ENV" == "" ]];then ## 如果已经在ACE里面则不进入分支 +if [ "$try_run_ret" -ne 0 ]; then ## 若安装检测仍然失败 + if [[ "$IS_ACE_ENV" == "" ]];then ## 如果未在ACE环境中 + # 定义按顺序尝试的ACE环境(命令:推荐安装包) + declare -a ace_commands_order=( + "bookworm-run:amber-ce-bookworm" + "trixie-run:amber-ce-trixie" + "deepin23-run:amber-ce-deepin23" + ) + + success=false + recommendation_msg="" + # 收集所有推荐信息 + for ace_entry in "${ace_commands_order[@]}"; do + recommendation_msg+="您可安装 ${ace_entry%%:*} 兼容环境后重试: ${ace_entry#*:}\n" + done - if command -v bookworm-run ;then ## 如果 bookworm-run 可用则进行安装 - echo "----------------------------------------" - echo "Attention: USING ACE BOOKWORM TO INSTALL" - echo "----------------------------------------" - bookworm-run ensure_aptss_exist - try_run_output=$(bookworm-run aptss install --dry-run "$DEBPATH") - try_run_ret="$?" + # 按顺序尝试每个ACE环境 + for ace_entry in "${ace_commands_order[@]}"; do + ace_cmd=${ace_entry%%:*} + if command -v "$ace_cmd" >/dev/null 2>&1; then + echo "----------------------------------------" + echo "正在尝试使用 $ace_cmd 环境安装..." + echo "----------------------------------------" + + # 在ACE环境中执行安装检测 + $ace_cmd ensure_aptss_exist + try_run_output=$($ace_cmd aptss install --dry-run "$DEBPATH" 2>&1) + try_run_ret="$?" + + # 如果首次检测失败则更新后重试 if [ "$try_run_ret" -ne 0 ]; then - bookworm-run aptss update - try_run_output=$(bookworm-run aptss install --dry-run "$DEBPATH") + $ace_cmd aptss update + try_run_output=$($ace_cmd aptss install --dry-run "$DEBPATH" 2>&1) try_run_ret="$?" fi - if [ "$try_run_ret" -ne 0 ]; then - echo "OMG-IT-GOES-WRONG" + + # 最终检测结果处理 + if [ "$try_run_ret" -eq 0 ]; then + echo "----------------------------------------" + echo "在 $ace_cmd 环境中预检成功,开始安装..." + echo "----------------------------------------" + $ace_cmd 'dpkg -i "$DEBPATH" || aptss install "$DEBPATH" -yfq' + success=true + break # 跳出循环 + else + echo "----------------------------------------" + echo "在 $ace_cmd 环境中安装预检失败,错误信息:" echo -e "${try_run_output}" echo "----------------------------------------" - echo "Attention: USING ACE BOOKWORM TO INSTALL" - echo "----------------------------------------" - exit "$try_run_ret" + fi fi - bookworm-run dpkg -i "$DEBPATH" || aptss install "$DEBPATH" -yf - fi + done - else # 如果在主机安装失败且未安装ACE,报错退出并推荐安装 ACE - + if ! $success; then echo "OMG-IT-GOES-WRONG" echo -e "${try_run_output}" - echo "您可在商店安装 ACE Bookworm 兼容环境后重试安装 https://bbs.deepin.org.cn/post/285056 " + echo -e "所有ACE环境尝试失败,推荐安装以下任一兼容环境:\n${recommendation_msg}" exit "$try_run_ret" - fi - else ## 如果主机安装检测成功了,进入主机安装分支 - - dpkg -i "$DEBPATH" || aptss install "$DEBPATH" -yf + fi + else # 已经在ACE环境中仍失败直接退出 + echo "OMG-IT-GOES-WRONG" + echo -e "${try_run_output}" + exit "$try_run_ret" fi -### 退出阶段 +else ## 如果主机安装检测成功 + dpkg -i "$DEBPATH" || aptss install "$DEBPATH" -yfq +fi - if [ "$?" = "0" ] && [ "$2" = "--delete-after-install" ]; then - if dpkg -s "$package_name" >/dev/null 2>&1; then - echo "软件包已安装:$package_name" - create_desktop_file - rm "$DEBPATH" - echo "${TRANSHELL_CONTENT_DEB_IS_DELETED}" - else - echo "软件包未安装:$package_name" - echo "安装异常!抛出错误" - echo "OMG-IT-GOES-WRONG" - fi +### 退出阶段保持不变 ### +if [ "$?" = "0" ] && [ "$2" = "--delete-after-install" ]; then + if dpkg -s "$package_name" >/dev/null 2>&1; then + echo "软件包已安装:$package_name" + create_desktop_file + unlock_file $DEBPATH + rm "$DEBPATH" + echo "${TRANSHELL_CONTENT_DEB_IS_DELETED}" else - echo "${TRANSHELL_CONTENT_WILL_NOT_DELETE_DEB}" - if dpkg -s "$package_name" >/dev/null 2>&1; then - echo "软件包已安装:$package_name" - create_desktop_file - else - echo "软件包未安装:$package_name" - echo "安装异常!抛出错误" - echo "OMG-IT-GOES-WRONG" - fi + echo "软件包未安装:$package_name" + echo "安装异常!抛出错误" + echo "OMG-IT-GOES-WRONG" + fi +else + echo "${TRANSHELL_CONTENT_WILL_NOT_DELETE_DEB}" + if dpkg -s "$package_name" >/dev/null 2>&1; then + echo "软件包已安装:$package_name" + create_desktop_file + else + echo "软件包未安装:$package_name" + echo "安装异常!抛出错误" + echo "OMG-IT-GOES-WRONG" fi fi +fi diff --git a/tool/ssinstall b/tool/ssinstall index 8e5d87b..25fa3ae 100755 --- a/tool/ssinstall +++ b/tool/ssinstall @@ -1,5 +1,6 @@ #!/bin/bash - +SPARK_DOWNLOAD_SERVER_URL="https://d.spark-app.store/" +SPARK_DOWNLOAD_SERVER_URL_NO_PROTOCOL="d.spark-app.store" source /opt/durapps/spark-store/bin/bashimport/transhell.amber load_transhell_debug @@ -61,15 +62,15 @@ function zenity() { } function hash_check() { - if [ ! -e "/var/lib/aptss/lists/d.spark-app.store_${STORE_URL}_Packages" ] && \ + if [ ! -e "/var/lib/aptss/lists/${SPARK_DOWNLOAD_SERVER_URL_NO_PROTOCOL}_${STORE_URL}_Packages" ] && \ [ ! -e "/var/lib/aptss/lists/d.store.deepinos.org.cn_${STORE_URL}_Packages" ] && \ [ ! -e "/var/lib/aptss/lists/mirrors.sdu.edu.cn_spark-store_${STORE_URL}_Packages" ]; then echo "接收星火仓库软件信息中..." aptss ssupdate fi - if [ -e "/var/lib/aptss/lists/d.spark-app.store_${STORE_URL}_Packages" ]; then - PACKAGES_DATA_PATH="/var/lib/aptss/lists/d.spark-app.store_${STORE_URL}_Packages" + if [ -e "/var/lib/aptss/lists/${SPARK_DOWNLOAD_SERVER_URL_NO_PROTOCOL}_${STORE_URL}_Packages" ]; then + PACKAGES_DATA_PATH="/var/lib/aptss/lists/${SPARK_DOWNLOAD_SERVER_URL_NO_PROTOCOL}_${STORE_URL}_Packages" echo "星火仓库的Packages位置为 $PACKAGES_DATA_PATH,是星火域名仓库配置" elif [ -e "/var/lib/aptss/lists/d.store.deepinos.org.cn_${STORE_URL}_Packages" ]; then PACKAGES_DATA_PATH="/var/lib/aptss/lists/d.store.deepinos.org.cn_${STORE_URL}_Packages" @@ -179,78 +180,107 @@ fi if [ ! -z "$IS_SHA512SUM_CHECKED" ]; then echo "校验成功,开始安装" echo "----------------------------------------------------------------------------------" - package_name=$(dpkg-deb -f "$DEBPATH" Package) - echo "Package name is $package_name" - try_run_output=$(/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh test-install-app "$DEBPATH") - try_run_ret="$?" -# 安装失败后进行 aptss update 刷新,随后尝试在主机安装 - if [ "$try_run_ret" -ne 0 ]; then +package_name=$(dpkg-deb -f "$DEBPATH" Package) +echo "Package name is $package_name" +try_run_output=$(/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh test-install-app "$DEBPATH") +try_run_ret="$?" +# 安装失败后进行 aptss 刷新,随后尝试在主机安装 +if [ "$try_run_ret" -ne 0 ]; then aptss update try_run_output=$(/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh test-install-app "$DEBPATH") try_run_ret="$?" - fi - - if [ "$try_run_ret" -ne 0 ]; then ## 若安装检测仍然失败 +fi - if [[ "$IS_ACE_ENV" == "" ]];then ## 如果已经在ACE里面则不进入分支 +if [ "$try_run_ret" -ne 0 ]; then ## 若安装检测仍然失败 + if [[ "$IS_ACE_ENV" == "" ]];then ## 如果未在ACE环境中 + # 定义按顺序尝试的ACE环境(命令:推荐安装包) + declare -a ace_commands_order=( + "bookworm-run:amber-ce-bookworm" + "trixie-run:amber-ce-trixie" + "deepin23-run:amber-ce-deepin23" + ) + + success=false + recommendation_msg="" + # 收集所有推荐信息 + for ace_entry in "${ace_commands_order[@]}"; do + recommendation_msg+="您可安装 ${ace_entry%%:*} 兼容环境后重试: ${ace_entry#*:}\n" + done - if command -v bookworm-run ;then ## 如果 bookworm-run 可用则进行安装 - echo "----------------------------------------" - echo "Attention: USING ACE BOOKWORM TO INSTALL" - echo "----------------------------------------" - bookworm-run ensure_aptss_exist - try_run_output=$(bookworm-run aptss install --dry-run "$DEBPATH") - try_run_ret="$?" + # 按顺序尝试每个ACE环境 + for ace_entry in "${ace_commands_order[@]}"; do + ace_cmd=${ace_entry%%:*} + if command -v "$ace_cmd" >/dev/null 2>&1; then + echo "----------------------------------------" + echo "正在尝试使用 $ace_cmd 环境安装..." + echo "----------------------------------------" + + # 在ACE环境中执行安装检测 + $ace_cmd ensure_aptss_exist + try_run_output=$($ace_cmd aptss install --dry-run "$DEBPATH" 2>&1) + try_run_ret="$?" + + # 如果首次检测失败则更新后重试 if [ "$try_run_ret" -ne 0 ]; then - bookworm-run aptss update - try_run_output=$(bookworm-run aptss install --dry-run "$DEBPATH") + $ace_cmd aptss update + try_run_output=$($ace_cmd aptss install --dry-run "$DEBPATH" 2>&1) try_run_ret="$?" fi - if [ "$try_run_ret" -ne 0 ]; then - echo "OMG-IT-GOES-WRONG" + + # 最终检测结果处理 + if [ "$try_run_ret" -eq 0 ]; then + echo "----------------------------------------" + echo "在 $ace_cmd 环境中预检成功,开始安装..." + echo "----------------------------------------" + $ace_cmd 'dpkg -i "$DEBPATH" || aptss install "$DEBPATH" -yfq' + success=true + break # 跳出循环 + else + echo "----------------------------------------" + echo "在 $ace_cmd 环境中安装预检失败,错误信息:" echo -e "${try_run_output}" echo "----------------------------------------" - echo "Attention: USING ACE BOOKWORM TO INSTALL" - echo "----------------------------------------" - exit "$try_run_ret" + fi fi - bookworm-run 'dpkg -i "$DEBPATH" || aptss install "$DEBPATH" -yf ' - fi + done - else # 如果在主机安装失败且未安装ACE,报错退出并推荐安装 ACE - + if ! $success; then echo "OMG-IT-GOES-WRONG" echo -e "${try_run_output}" - echo "您可在商店安装 ACE Bookworm 兼容环境后重试安装 https://bbs.deepin.org.cn/post/285056 " + echo -e "所有ACE环境尝试失败,推荐安装以下任一兼容环境:\n${recommendation_msg}" exit "$try_run_ret" - fi - else ## 如果主机安装检测成功了,进入主机安装分支 - - dpkg -i "$DEBPATH" || aptss install "$DEBPATH" -yf + fi + else # 已经在ACE环境中仍失败直接退出 + echo "OMG-IT-GOES-WRONG" + echo -e "${try_run_output}" + exit "$try_run_ret" fi -### 退出阶段 +else ## 如果主机安装检测成功 + dpkg -i "$DEBPATH" || aptss install "$DEBPATH" -yfq +fi - if [ "$?" = "0" ] && [ "$2" = "--delete-after-install" ]; then - if dpkg -s "$package_name" >/dev/null 2>&1; then - echo "软件包已安装:$package_name" - create_desktop_file - unlock_file $DEBPATH - rm "$DEBPATH" - echo "${TRANSHELL_CONTENT_DEB_IS_DELETED}" - else - echo "软件包未安装:$package_name" - echo "安装异常!抛出错误" - echo "OMG-IT-GOES-WRONG" - fi +### 退出阶段保持不变 ### +if [ "$?" = "0" ] && [ "$2" = "--delete-after-install" ]; then + if dpkg -s "$package_name" >/dev/null 2>&1; then + echo "软件包已安装:$package_name" + create_desktop_file + unlock_file $DEBPATH + rm "$DEBPATH" + echo "${TRANSHELL_CONTENT_DEB_IS_DELETED}" else - echo "${TRANSHELL_CONTENT_WILL_NOT_DELETE_DEB}" - if dpkg -s "$package_name" >/dev/null 2>&1; then - echo "软件包已安装:$package_name" - create_desktop_file - else - echo "软件包未安装:$package_name" - echo "安装异常!抛出错误" - echo "OMG-IT-GOES-WRONG" - fi + echo "软件包未安装:$package_name" + echo "安装异常!抛出错误" + echo "OMG-IT-GOES-WRONG" + fi +else + echo "${TRANSHELL_CONTENT_WILL_NOT_DELETE_DEB}" + if dpkg -s "$package_name" >/dev/null 2>&1; then + echo "软件包已安装:$package_name" + create_desktop_file + else + echo "软件包未安装:$package_name" + echo "安装异常!抛出错误" + echo "OMG-IT-GOES-WRONG" fi fi +fi diff --git a/tool/store-helper/check-is-installed b/tool/store-helper/check-is-installed index febb4ce..97b0201 100755 --- a/tool/store-helper/check-is-installed +++ b/tool/store-helper/check-is-installed @@ -1,2 +1,42 @@ #!/bin/bash -dpkg -l | grep "^ii $1 " > /dev/null +dpkg -s "$1" > /dev/null +RET="$?" + if [[ "$RET" != "0" ]] &&[[ "$IS_ACE_ENV" == "" ]];then ## 如果未在ACE环境中 + # 定义按顺序尝试的ACE环境(命令:推荐安装包) + declare -a ace_commands_order=( + "bookworm-run:amber-ce-bookworm" + "trixie-run:amber-ce-trixie" + "deepin23-run:amber-ce-deepin23" + ) +for ace_entry in "${ace_commands_order[@]}"; do + ace_cmd=${ace_entry%%:*} + if command -v "$ace_cmd" >/dev/null 2>&1; then + echo "----------------------------------------" + echo "正在检查 $ace_cmd 环境的安装..." + echo "----------------------------------------" + + # 在ACE环境中执行安装检测 + $ace_cmd dpkg -l | grep "^ii $1 " > /dev/null + try_run_ret="$?" + + + # 最终检测结果处理 + if [ "$try_run_ret" -eq 0 ]; then + echo "----------------------------------------" + echo "在 $ace_cmd 环境中找到了安装" + echo "----------------------------------------" + exit $try_run_ret + else + echo "----------------------------------------" + echo "在 $ace_cmd 环境中未能找到安装,继续查找" + echo "----------------------------------------" + fi + fi + done + echo "----------------------------------------" + echo "所有已安装的 ACE 环境中未能找到安装,退出" + echo "----------------------------------------" + exit "$RET" + fi +## 如果在ACE环境中或者未出错 +exit "$RET" diff --git a/tool/store-helper/ss-launcher b/tool/store-helper/ss-launcher index a635ff8..a7730dc 100755 --- a/tool/store-helper/ss-launcher +++ b/tool/store-helper/ss-launcher @@ -1,142 +1,132 @@ #!/bin/bash -# ===== Log ===== -# log.info xxx -# log.warn xxx -# log.info xxx -# log.debug xxx -# 带颜色的echo -function log.color_output() { - local color=$1 - shift 1 - echo >&2 -e "\033[${color}m$@\033[0m" - return 0 +# ===== ACE环境配置 ===== +declare -a ace_commands_order=( + "bookworm-run:amber-ce-bookworm" + "trixie-run:amber-ce-trixie" + "deepin23-run:amber-ce-deepin23" +) + +# ===== 日志和函数 ===== +[ -f /opt/durapps/spark-store/bin/bashimport/log.amber ] && \ + source /opt/durapps/spark-store/bin/bashimport/log.amber || { + log.info() { echo "INFO: $*"; } + log.warn() { echo "WARN: $*"; } + log.error() { echo "ERROR: $*"; } + log.debug() { echo "DEBUG: $*"; } } -# Log is named without prefix "utils." for convenience -# Usage: log.log <level> ...content -function log.log() { - if [[ $# < 2 ]]; then - return -1 - fi - - local level=$1 - shift 1 - - case $level in - error) log.color_output "0;31" "[ERROR] $@" ;; - warn) log.color_output "1;33" "[WARN] $@" ;; - info) log.color_output "1;37" "[INFO] $@" ;; - debug) log.color_output "1;30" "[DEBUG] $@" ;; - esac - - return 0 -} - -function log.error() { log.log "error" "$@"; } -function log.warn() { log.log "warn" $@; } -function log.info() { log.log "info" $@; } -function log.debug() { log.log "debug" $@; } - - -function scan_desktop_file_log(){ -unset desktop_file_path -package_name=$1 - for desktop_file_path in $(dpkg -L "$1" |grep /usr/share/applications/ | awk '/\.desktop$/ {print}'); do - if [ "$(cat $desktop_file_path | grep NoDisplay=true)" = "" ];then - log.info "$desktop_file_path is found." - fi - done - for desktop_file_path in $(dpkg -L "$1" |grep /opt/apps/$package_name/entries/applications/ | awk '/\.desktop$/ {print}'); do - if [ "$(cat $desktop_file_path | grep NoDisplay=true)" = "" ];then - log.info "$desktop_file_path is found." - fi - done - - -} - -function scan_desktop_file(){ +# ===== 功能函数 ===== +function scan_desktop_file_log() { unset desktop_file_path - local result="" - for desktop_file_path in $(dpkg -L "$1" | grep /usr/share/applications/ | awk '/\.desktop$/ {print}'); do - if [ "$(grep NoDisplay=true $desktop_file_path)" = "" ]; then - result+="$desktop_file_path," - fi - done - for desktop_file_path in $(dpkg -L "$1" | grep /opt/apps/$package_name/entries/applications | awk '/\.desktop$/ {print}'); do - if [ "$(grep NoDisplay=true $desktop_file_path)" = "" ]; then - result+="$desktop_file_path," - fi - done - # 去掉最后一个逗号 - if [ -n "$result" ]; then - result=${result%,} - fi - echo "$result" + local package_name=$1 + # 标准desktop文件检测 + while IFS= read -r path; do + [ -z "$(grep 'NoDisplay=true' "$path")" ] && { + log.info "Found valid desktop file: $path" + desktop_file_path="$path" + return 0 + } + done < <(dpkg -L "$package_name" 2>/dev/null | grep -E '/usr/share/applications/.*\.desktop$|/opt/apps/.*/entries/applications/.*\.desktop$') + + # 深度环境特殊处理 + while IFS= read -r path; do + [ -z "$(grep 'NoDisplay=true' "$path")" ] && { + log.info "Found deepin desktop file: $path" + desktop_file_path="$path" + return 0 + } + done < <(find /opt/apps/$package_name -path '*/entries/applications/*.desktop' 2>/dev/null) + return 1 } -function launch_app(){ +function scan_desktop_file() { + local package_name=$1 result="" + # 标准结果收集 + while IFS= read -r path; do + [ -z "$(grep 'NoDisplay=true' "$path")" ] && result+="$path," + done < <(dpkg -L "$package_name" 2>/dev/null | grep -E '/usr/share/applications/.*\.desktop$|/opt/apps/.*/entries/applications/.*\.desktop$') + + # 深度环境补充扫描 + while IFS= read -r path; do + [ -z "$(grep 'NoDisplay=true' "$path")" ] && result+="$path," + done < <(find /opt/apps/$package_name -path '*/entries/applications/*.desktop' 2>/dev/null) + + echo "${result%,}" +} - # 检查是否传入了路径参数 - if [ -z "$1" ]; then - log.error "请传入文件路径作为参数" +function launch_app() { + local DESKTOP_FILE_PATH="${1#file://}" + # 提取并净化Exec命令 + exec_command=$(grep -m1 '^Exec=' "$DESKTOP_FILE_PATH" | cut -d= -f2- | sed 's/%.//g') + [ -z "$exec_command" ] && return 1 + log.info "Launching: $exec_command" + # 图形环境启动优化 + if [ -n "$DISPLAY" ]; then + nohup env DISPLAY=$DISPLAY XAUTHORITY=${XAUTHORITY:-~/.Xauthority} ${SHELL:-bash} -c "$exec_command" >/dev/null 2>&1 & + else + nohup ${SHELL:-bash} -c "$exec_command" >/dev/null 2>&1 & + fi +} + +# ===== ACE环境执行器 ===== +function ace_runner() { + local command_type=$1 package_name=$2 + for ace_entry in "${ace_commands_order[@]}"; do + local ace_cmd=${ace_entry%%:*} + command -v "$ace_cmd" >/dev/null || continue + + log.info "Checking in $ace_cmd environment..." + if output=$($ace_cmd "$0" "$command_type" "$package_name" 2>/dev/null); then + [ "$command_type" = "list" ] && echo "$output" + exit 0 + fi + done + return 1 +} + +# ===== 主逻辑 ===== +[ $# -lt 2 ] && { + log.error "Usage: $0 {check|launch|list|start} package_name/desktop_file" + exit 1 +} + +case $1 in +check) + # 当前环境检查 + if scan_desktop_file_log "$2"; then + exit 0 + else + # 非ACE环境下执行ACE环境扫描 + [ -z "$IS_ACE_ENV" ] && ace_runner check "$2" exit 1 fi + ;; - DESKTOP_FILE_PATH=$1 - - if [[ $DESKTOP_FILE_PATH == file://* ]]; then - # 如果是,移除 'file://' 部分并输出结果 - DESKTOP_FILE_PATH="${DESKTOP_FILE_PATH#file://}" +list) + # 当前环境列表 + if result=$(scan_desktop_file "$2"); then + echo "$result" + exit 0 + else + # 非ACE环境下执行ACE环境扫描 + [ -z "$IS_ACE_ENV" ] && ace_runner list "$2" + exit 1 fi + ;; - # 获取文件内容中第一个 Exec= 后的命令 - exec_command=$(grep -m 1 -oP "(?<=Exec=).*" "$DESKTOP_FILE_PATH") - - # 删除 exec_command 中最后的 % 及其后面的内容 - exec_command="${exec_command%\%*}" - - # 打印提取的命令 - log.info "Command is $exec_command" - - # 在默认终端执行命令 - bash -c "$exec_command" -} - -if [ "$#" -lt 2 ];then -log.info "Usage: $0 check/launch/list/start packagename/desktop-file" -exit -1 -fi - - -if [ "$1" = "check" ];then - -scan_desktop_file_log "$2" - if [ "$desktop_file_path" = "" ];then - log.error "No desktop file found. exit -1" - exit -1 - else - exit 0 - fi - -elif [ "$1" = "list" ];then -scan_desktop_file "$2" - if [ "$desktop_file_path" = "" ];then - exit -1 - else - exit 0 - fi -elif [ "$1" = "launch" ];then -scan_desktop_file_log "$2" - if [ "$desktop_file_path" = "" ];then - log.error "No desktop file found. exit -1" - exit -1 - fi - - -launch_app "${desktop_file_path}" - -elif [ "$1" = "start" ];then -launch_app "${desktop_file_path}" -fi +launch|start) + # 当前环境启动 + if scan_desktop_file_log "$2" && launch_app "$desktop_file_path"; then + exit 0 + else + # 非ACE环境下通过ACE环境启动 + [ -z "$IS_ACE_ENV" ] && ace_runner launch "$2" + exit 1 + fi + ;; +*) + log.error "Invalid command: $1" + exit 2 + ;; +esac diff --git a/tool/store-helper/uninstaller b/tool/store-helper/uninstaller index 86cee57..eaad4c0 100755 --- a/tool/store-helper/uninstaller +++ b/tool/store-helper/uninstaller @@ -1,14 +1,54 @@ #!/bin/bash -dpkg -l | grep "^ii $1 " > /dev/null +# ===== ACE环境配置 ===== +declare -a ace_commands_order=( + "bookworm-run:amber-ce-bookworm" + "trixie-run:amber-ce-trixie" + "deepin23-run:amber-ce-deepin23" +) + +# ===== 日志和函数 ===== +[ -f /opt/durapps/spark-store/bin/bashimport/log.amber ] && \ + source /opt/durapps/spark-store/bin/bashimport/log.amber || { + log.info() { echo "INFO: $*"; } + log.warn() { echo "WARN: $*"; } + log.error() { echo "ERROR: $*"; } + log.debug() { echo "DEBUG: $*"; } +} + +dpkg -s "$1" > /dev/null RET="$?" if [[ "$RET" == "0" ]] ;then apt autopurge $1 -y else -if command -v bookworm-run > /dev/null;then - echo "Try ACE Bookworm" - bookworm-run apt autopurge $1 -y +for ace_entry in "${ace_commands_order[@]}"; do + ace_cmd=${ace_entry%%:*} + if command -v "$ace_cmd" >/dev/null 2>&1; then + echo "----------------------------------------" + echo "正在检查 $ace_cmd 环境的安装..." + echo "----------------------------------------" + + # 在ACE环境中执行安装检测 + $ace_cmd dpkg -l | grep "^ii $1 " > /dev/null + try_run_ret="$?" + -fi -fi + # 最终检测结果处理 + if [ "$try_run_ret" -eq 0 ]; then + echo "----------------------------------------" + echo "在 $ace_cmd 环境中找到了安装" + echo "----------------------------------------" + $ace_cmd apt autopurge $1 -y + else + echo "----------------------------------------" + echo "在 $ace_cmd 环境中未能找到安装,继续查找" + echo "----------------------------------------" + fi + fi + done + echo "----------------------------------------" + echo "所有已安装的 ACE 环境中未能找到安装,退出" + echo "----------------------------------------" + exit "$RET" + fi exit "$RET" diff --git a/tool/update-upgrade/ss-do-upgrade.sh b/tool/update-upgrade/ss-do-upgrade.sh index 474a777..dee6321 100755 --- a/tool/update-upgrade/ss-do-upgrade.sh +++ b/tool/update-upgrade/ss-do-upgrade.sh @@ -146,7 +146,7 @@ for PKG_UPGRADE in $PKG_UPGRADE_LIST; do update_transhell # 启动升级任务 - (yes | pkexec ${HERE}/ss-do-upgrade-worker.sh upgrade-app $PKG_UPGRADE -y 2>&1 > /dev/null ) & + (yes n | pkexec ${HERE}/ss-do-upgrade-worker.sh upgrade-app $PKG_UPGRADE -yfq 2>&1 > /dev/null ) & # 计算进度百分比 progress=$(( count * 100 / total - 1))