Merge pull request  from shenmo/dev
This commit is contained in:
shenmo 2025-04-14 05:33:26 +00:00 committed by Gitee
commit 3e3cdbc784
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
8 changed files with 248 additions and 165 deletions

@ -152,7 +152,7 @@ You will see an output, and that's your system architecture.
Please refer to the [Spark App Store FAQ and Support Guide](https://gitee.com/spark-store-project/spark-store/blob/dev/FAQ.md). Please refer to the [Spark App Store FAQ and Support Guide](https://gitee.com/spark-store-project/spark-store/blob/dev/FAQ.md).
You can also check the [Chinese version](https://gitee.com/spark-store-project/spark-store/blob/dev/FAQ.zh.md) here. To customly configure aptss, refer to [aptss](https://gitee.com/GXDE-OS/aptss)
--- ---

@ -171,9 +171,11 @@ https://github.com/spark-store-project/spark-store
## 常见问题FAQ ## 常见问题FAQ
请参见[星火应用商店FAQ与支持指南](https://gitee.com/spark-store-project/spark-store/blob/dev/FAQ.md)。 请参见[星火应用商店FAQ与支持指南](https://gitee.com/spark-store-project/spark-store/blob/dev/FAQ.zh.md)。
自定义配置 aptss config 请参阅 [aptss](https://gitee.com/GXDE-OS/aptss)
在这里可以查阅[中文版本](https://gitee.com/spark-store-project/spark-store/blob/dev/FAQ.zh.md)。
--- ---

8
debian/changelog vendored

@ -1,3 +1,11 @@
spark-store (4.7.0) UNRELEASED; urgency=medium
* aptss 第二、三阶段加速
* 修复部分应用无法启动的问题
* 支持使用 ACE deepin23 trixie
-- shenmo <shenmo@spark-app.store> Tue, 24 Sep 2024 11:27:08 +0800
spark-store (4.5.2) UNRELEASED; urgency=medium spark-store (4.5.2) UNRELEASED; urgency=medium
* 支持安装到 ACE Bookworm * 支持安装到 ACE Bookworm

@ -186,12 +186,21 @@ VERBOSE_OUTPUT=
# Download command. # 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' _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" CONFIG_FILES=(
#### Spark Store apt-fast conf is in /tmp "/tmp/aptss-conf/apt-fast.conf" # 原始配置文件位置
if [ -e "$CONFFILE" ]; then "/etc/aptss/apt-fast.conf" # 系统级配置
source "$CONFFILE" )
fi
# 按顺序加载所有配置文件
for conf_file in "${CONFIG_FILES[@]}"; do
if [ -e "$conf_file" ]; then
source "$conf_file"
fi
done
# no proxy as default # no proxy as default
ftp_proxy= ftp_proxy=
@ -367,15 +376,15 @@ prepare_auth(){
AUTH_INFO_PARSED+=("$machine $login $password") AUTH_INFO_PARSED+=("$machine $login $password")
done <<< "$auth_info" done <<< "$auth_info"
done done
if [ "${#AUTH_INFO_PARSED[@]}" -eq 0 ]; then
# acts like auth disabled when no auth info is provided to improve performance
APT_FAST_APT_AUTH=0
fi
} }
# Gets URI as parameter and tries to add basic http credentials. Will fail on # Gets URI as parameter and tries to add basic http credentials. Will fail on
# credentials that contain characters that need URL-encoding. # credentials that contain characters that need URL-encoding.
get_auth(){ get_auth(){
if [ "$APT_FAST_APT_AUTH" -eq 0 ]; then
echo "$1"
return
fi
for auth_info in "${AUTH_INFO_PARSED[@]}"; do for auth_info in "${AUTH_INFO_PARSED[@]}"; do
# convert to array, don't escape variable here # convert to array, don't escape variable here
auth_info_arr=($auth_info) auth_info_arr=($auth_info)
@ -430,44 +439,40 @@ get_uris(){
CLEANUP_STATE="$?" CLEANUP_STATE="$?"
if [ "$CLEANUP_STATE" -ne 0 ] if [ "$CLEANUP_STATE" -ne 0 ]
then then
msg "Package manager quit with exit code.Here is the log" "warning" msg "Package manager quit with exit code. Here is the log" "warning"
msg "包管理器以错误代码退出.日志如下" "warning" msg "包管理器以错误代码退出.日志如下" "warning"
msg "${uris_full}" msg "${uris_full}"
exit "$CLEANUP_STATE" exit "$CLEANUP_STATE"
fi fi
prepare_auth prepare_auth
local tmpdir=$(mktemp -d) || { local tmpdir
tmpdir=$(mktemp -d) || {
msg "Failed to create tmp dir" "warning" msg "Failed to create tmp dir" "warning"
msg "无法创建临时目录" "warning" msg "无法创建临时目录" "warning"
exit 1 exit 1
} }
## --print-uris format is: ## --print-uris format is:
# 'fileurl' filename filesize checksum_hint:filechecksum # 'fileurl' filename filesize checksum_hint:filechecksum
# 修改process_package函数增加第二个参数表示当前线程的临时输出文件
process_package() { process_package() {
local pkg_uri_info="$@" local pkg_uri_info="$1"
local thread_file="$2"
local display_line="" # 添加局部变量并初始化为空 local display_line="" # 初始化显示信息为空
IFS=' ' read -r uri filename filesize checksum_string _ <<<"$pkg_uri_info" IFS=' ' read -r uri filename filesize checksum_string _ <<<"$pkg_uri_info"
[ -z "$uri" ] && continue [ -z "$uri" ] && return
uri="$(get_auth "${uri//"'"/}")" uri="${uri//"'"/}"
[ "$APT_FAST_APT_AUTH" -ne 0 ] && uri="$(get_auth "$uri")"
IFS=':' read -r hash_algo checksum _ <<<"$checksum_string" IFS=':' read -r hash_algo checksum _ <<<"$checksum_string"
filename_decoded="$(urldecode "$filename")" if [[ "$filename" == *%* ]]; then
# decode url string
filename_decoded="$(printf '%b' "${filename//%/\\x}")"
else
filename_decoded="$filename"
fi
IFS='_' read -r pkg_name_decoded pkg_version_decoded _ <<<"$filename_decoded" IFS='_' read -r pkg_name_decoded pkg_version_decoded _ <<<"$filename_decoded"
display_line+="$pkg_name_decoded $pkg_version_decoded $filesize\n"
display_line="${display_line}$pkg_name_decoded $pkg_version_decoded"
display_line="${display_line} $(echo "$filesize" | numfmt --to=iec-i --suffix=B)\n"
## whole uri comes encoded (urlencoded). Filename must NOT be decoded because
# plain aptitude do not decode it when download and install it. Therefore, we
# will have ugly named packages at /var/cache/apt/archives but is the standard
# behavior.
# But package version must be decoded, otherways package=version calls will
# not work.
if [ -n "$HASH_SUPPORTED" ]; then if [ -n "$HASH_SUPPORTED" ]; then
case "$hash_algo" in case "$hash_algo" in
SHA512) [ -z "$SHA512_SUPPORTED" ] && hash_algo= || hash_algo=sha-512 ;; SHA512) [ -z "$SHA512_SUPPORTED" ] && hash_algo= || hash_algo=sha-512 ;;
@ -522,30 +527,27 @@ get_uris(){
hash_algo= hash_algo=
fi fi
# 原来利用文件锁写入,现在改为写入当前线程的临时文件
{
get_mirrors "$uri"
[ -n "$hash_algo" ] && echo " checksum=$hash_algo=$checksum"
echo " out=$filename"
} >> "$thread_file"
# 使用文件锁安全写入下载列表 echo -e "$display_line" >> "$tmpdir/display"
(
flock -x 200 # 获取排他锁
{
get_mirrors "$uri"
[ -n "$hash_algo" ] && echo " checksum=$hash_algo=$checksum"
echo " out=$filename"
} >> "$DLLIST"
) 200>>"$DLLIST" # 使用文件描述符200关联锁文件
# 将显示信息和文件大小存入临时文件
echo "$display_line" >> "$tmpdir/display"
echo "$filesize" >> "$tmpdir/sizes" echo "$filesize" >> "$tmpdir/sizes"
} }
# 主并行处理逻辑(新增线程控制) # 主并行处理逻辑
mapfile -t pkg_uri_list < <(echo "$uris_full" | grep -E "^'(http(s|)|(s|)ftp)://") mapfile -t pkg_uri_list < <(echo "$uris_full" | grep -E "^'(http(s|)|(s|)ftp)://")
total_pkgs=${#pkg_uri_list[@]} total_pkgs=${#pkg_uri_list[@]}
threads=${THREADS:-4} # 默认4线程 threads=${THREADS:-4} # 默认4线程
per_thread=$(( (total_pkgs + threads - 1) / threads )) # 向上取整 per_thread=$(( (total_pkgs + threads - 1) / threads )) # 向上取整
# 分割任务到不同线程 # 分配任务到不同线程,每个线程使用自己的临时文件
for ((i=0; i<threads; i++)); do for ((i=0; i<threads; i++)); do
thread_file="${DLLIST}.thread.${i}"
> "$thread_file" # 清空或创建临时文件
start=$((i * per_thread)) start=$((i * per_thread))
end=$((start + per_thread -1)) end=$((start + per_thread -1))
[ $end -ge $total_pkgs ] && end=$((total_pkgs -1)) [ $end -ge $total_pkgs ] && end=$((total_pkgs -1))
@ -554,7 +556,7 @@ get_uris(){
( (
for ((j=start; j<=end; j++)); do for ((j=start; j<=end; j++)); do
[ -z "${pkg_uri_list[j]}" ] && continue [ -z "${pkg_uri_list[j]}" ] && continue
process_package "${pkg_uri_list[j]}" process_package "${pkg_uri_list[j]}" "$thread_file"
done done
) & ) &
done done
@ -562,6 +564,15 @@ get_uris(){
# 等待所有后台任务完成 # 等待所有后台任务完成
wait wait
# 合并所有线程的临时文件到最终的 $DLLIST 中(保留之前添加的 header
for ((i=0; i<threads; i++)); do
thread_file="${DLLIST}.thread.${i}"
if [ -f "$thread_file" ]; then
cat "$thread_file" >> "$DLLIST"
rm -f "$thread_file"
fi
done
# 合并显示信息 # 合并显示信息
if [ -f "$tmpdir/display" ]; then if [ -f "$tmpdir/display" ]; then
DOWNLOAD_DISPLAY+="\n$(cat "$tmpdir/display")" DOWNLOAD_DISPLAY+="\n$(cat "$tmpdir/display")"
@ -574,12 +585,10 @@ get_uris(){
# 清理临时目录 # 清理临时目录
rm -rf "$tmpdir" rm -rf "$tmpdir"
#cat "$DLLIST"
#exit
} }
display_downloadfile(){ display_downloadfile(){
if [ -n "$VERBOSE_OUTPUT" ]; then if [ -n "$VERBOSE_OUTPUT" ]; then
cat "$DLLIST" cat "$DLLIST"
@ -590,7 +599,7 @@ display_downloadfile(){
while IFS=' ' read -r pkg ver size _; do while IFS=' ' read -r pkg ver size _; do
[ -z "$pkg" ] && continue [ -z "$pkg" ] && continue
printf '%s%-40s %-20s %10s\n' "$aptfast_prefix" "$pkg" "$ver" "$size" printf '%s%-40s %-20s %10s\n' "$aptfast_prefix" "$pkg" "$ver" "$size"
done <<<"$(echo -e "$DOWNLOAD_DISPLAY" | sort "${DISPLAY_SORT_OPTIONS[@]}")" done <<<"$(echo -e "$DOWNLOAD_DISPLAY" | sort "${DISPLAY_SORT_OPTIONS[@]}" | numfmt --to=iec-i --suffix=B --field=3)"
fi fi
msg "Download size: $(echo "$DOWNLOAD_SIZE" | numfmt --to=iec-i --suffix=B)" "normal" msg "Download size: $(echo "$DOWNLOAD_SIZE" | numfmt --to=iec-i --suffix=B)" "normal"
msg "下载大小: $(echo "$DOWNLOAD_SIZE" | numfmt --to=iec-i --suffix=B)" "normal" msg "下载大小: $(echo "$DOWNLOAD_SIZE" | numfmt --to=iec-i --suffix=B)" "normal"
@ -827,3 +836,4 @@ else
fi fi
# After error or all done remove our lockfile (done with EXIT trap) # After error or all done remove our lockfile (done with EXIT trap)

@ -7,7 +7,7 @@ source /opt/durapps/spark-store/bin/bashimport/log.amber
load_transhell load_transhell
case `arch` in case `arch` in
x86_64) x86_64 | i686 | i386)
STORE_URL="store" STORE_URL="store"
STORE_LIST_URL="" STORE_LIST_URL=""
;; ;;

@ -166,75 +166,107 @@ IS_SHA512SUM_CHECKED=skipped
if [ ! -z "$IS_SHA512SUM_CHECKED" ]; then if [ ! -z "$IS_SHA512SUM_CHECKED" ]; then
echo "校验跳过,开始安装" echo "校验跳过,开始安装"
echo "----------------------------------------------------------------------------------" echo "----------------------------------------------------------------------------------"
package_name=$(dpkg-deb -f "$DEBPATH" Package) package_name=$(dpkg-deb -f "$DEBPATH" Package)
echo "Package name is $package_name" 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_output=$(/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh test-install-app "$DEBPATH")
try_run_ret="$?" try_run_ret="$?"
# 安装失败后进行 aptss update 刷新,随后尝试安装 # 安装失败后进行 aptss 刷新,随后尝试在主机安装
if [ "$try_run_ret" -ne 0 ]; then if [ "$try_run_ret" -ne 0 ]; then
aptss update aptss update
try_run_output=$(/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh test-install-app "$DEBPATH") try_run_output=$(/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh test-install-app "$DEBPATH")
try_run_ret="$?" try_run_ret="$?"
fi fi
if [ "$try_run_ret" -ne 0 ]; then
if [[ "$IS_ACE_ENV" == "" ]];then ## 如果已经在ACE里面则不进入分支 if [ "$try_run_ret" -ne 0 ]; then ## 若安装检测仍然失败
if command -v bookworm-run ;then if [[ "$IS_ACE_ENV" == "" ]];then ## 如果未在ACE环境中
echo "----------------------------------------" # 定义按顺序尝试的ACE环境命令:推荐安装包)
echo "Attention: USING ACE BOOKWORM TO INSTALL" declare -a ace_commands_order=(
echo "----------------------------------------" "bookworm-run:amber-ce-bookworm"
bookworm-run ensure_aptss_exist "trixie-run:amber-ce-trixie"
try_run_output=$(bookworm-run aptss install --dry-run "$DEBPATH") "deepin23-run:amber-ce-deepin23"
try_run_ret="$?" )
success=false
recommendation_msg=""
# 收集所有推荐信息
for ace_entry in "${ace_commands_order[@]}"; do
recommendation_msg+="您可安装 ${ace_entry%%:*} 兼容环境后重试: ${ace_entry#*:}\n"
done
# 按顺序尝试每个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 if [ "$try_run_ret" -ne 0 ]; then
bookworm-run aptss update $ace_cmd aptss update
try_run_output=$(bookworm-run aptss install --dry-run "$DEBPATH") try_run_output=$($ace_cmd aptss install --dry-run "$DEBPATH" 2>&1)
try_run_ret="$?" try_run_ret="$?"
fi 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" -yf'
success=true
break # 跳出循环
else
echo "----------------------------------------"
echo "在 $ace_cmd 环境中安装预检失败,错误信息:"
echo -e "${try_run_output}" echo -e "${try_run_output}"
echo "----------------------------------------" echo "----------------------------------------"
echo "Attention: USING ACE BOOKWORM TO INSTALL" fi
echo "----------------------------------------"
exit "$try_run_ret"
fi fi
bookworm-run dpkg -i "$DEBPATH" || aptss install "$DEBPATH" -yf done
fi
else if ! $success; then
echo "OMG-IT-GOES-WRONG" echo "OMG-IT-GOES-WRONG"
echo -e "${try_run_output}" echo -e "${try_run_output}"
echo -e "所有ACE环境尝试失败推荐安装以下任一兼容环境:\n${recommendation_msg}"
exit "$try_run_ret" exit "$try_run_ret"
fi fi
else else # 已经在ACE环境中仍失败直接退出
echo "OMG-IT-GOES-WRONG"
dpkg -i "$DEBPATH" || aptss install "$DEBPATH" -yf echo -e "${try_run_output}"
exit "$try_run_ret"
fi fi
### 退出阶段 else ## 如果主机安装检测成功
dpkg -i "$DEBPATH" || aptss install "$DEBPATH" -yf
fi
if [ "$?" = "0" ] && [ "$2" = "--delete-after-install" ]; then ### 退出阶段保持不变 ###
if dpkg -s "$package_name" >/dev/null 2>&1; then if [ "$?" = "0" ] && [ "$2" = "--delete-after-install" ]; then
echo "软件包已安装:$package_name" if dpkg -s "$package_name" >/dev/null 2>&1; then
create_desktop_file echo "软件包已安装:$package_name"
rm "$DEBPATH" create_desktop_file
echo "${TRANSHELL_CONTENT_DEB_IS_DELETED}" unlock_file $DEBPATH
else rm "$DEBPATH"
echo "软件包未安装:$package_name" echo "${TRANSHELL_CONTENT_DEB_IS_DELETED}"
echo "安装异常!抛出错误"
echo "OMG-IT-GOES-WRONG"
fi
else else
echo "${TRANSHELL_CONTENT_WILL_NOT_DELETE_DEB}" echo "软件包未安装:$package_name"
if dpkg -s "$package_name" >/dev/null 2>&1; then echo "安装异常!抛出错误"
echo "软件包已安装:$package_name" echo "OMG-IT-GOES-WRONG"
create_desktop_file fi
else else
echo "软件包未安装:$package_name" echo "${TRANSHELL_CONTENT_WILL_NOT_DELETE_DEB}"
echo "安装异常!抛出错误" if dpkg -s "$package_name" >/dev/null 2>&1; then
echo "OMG-IT-GOES-WRONG" echo "软件包已安装:$package_name"
fi create_desktop_file
else
echo "软件包未安装:$package_name"
echo "安装异常!抛出错误"
echo "OMG-IT-GOES-WRONG"
fi fi
fi fi
fi

@ -1,5 +1,6 @@
#!/bin/bash #!/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 source /opt/durapps/spark-store/bin/bashimport/transhell.amber
load_transhell_debug load_transhell_debug
@ -61,15 +62,15 @@ function zenity() {
} }
function hash_check() { 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/d.store.deepinos.org.cn_${STORE_URL}_Packages" ] && \
[ ! -e "/var/lib/aptss/lists/mirrors.sdu.edu.cn_spark-store_${STORE_URL}_Packages" ]; then [ ! -e "/var/lib/aptss/lists/mirrors.sdu.edu.cn_spark-store_${STORE_URL}_Packages" ]; then
echo "接收星火仓库软件信息中..." echo "接收星火仓库软件信息中..."
aptss ssupdate aptss ssupdate
fi fi
if [ -e "/var/lib/aptss/lists/d.spark-app.store_${STORE_URL}_Packages" ]; then if [ -e "/var/lib/aptss/lists/${SPARK_DOWNLOAD_SERVER_URL_NO_PROTOCOL}_${STORE_URL}_Packages" ]; then
PACKAGES_DATA_PATH="/var/lib/aptss/lists/d.spark-app.store_${STORE_URL}_Packages" PACKAGES_DATA_PATH="/var/lib/aptss/lists/${SPARK_DOWNLOAD_SERVER_URL_NO_PROTOCOL}_${STORE_URL}_Packages"
echo "星火仓库的Packages位置为 $PACKAGES_DATA_PATH是星火域名仓库配置" echo "星火仓库的Packages位置为 $PACKAGES_DATA_PATH是星火域名仓库配置"
elif [ -e "/var/lib/aptss/lists/d.store.deepinos.org.cn_${STORE_URL}_Packages" ]; then 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" PACKAGES_DATA_PATH="/var/lib/aptss/lists/d.store.deepinos.org.cn_${STORE_URL}_Packages"
@ -179,77 +180,107 @@ fi
if [ ! -z "$IS_SHA512SUM_CHECKED" ]; then if [ ! -z "$IS_SHA512SUM_CHECKED" ]; then
echo "校验成功,开始安装" echo "校验成功,开始安装"
echo "----------------------------------------------------------------------------------" echo "----------------------------------------------------------------------------------"
package_name=$(dpkg-deb -f "$DEBPATH" Package) package_name=$(dpkg-deb -f "$DEBPATH" Package)
echo "Package name is $package_name" 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_output=$(/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh test-install-app "$DEBPATH")
try_run_ret="$?" try_run_ret="$?"
# 安装失败后进行 aptss update 刷新,随后尝试在主机安装 # 安装失败后进行 aptss 刷新,随后尝试在主机安装
if [ "$try_run_ret" -ne 0 ]; then if [ "$try_run_ret" -ne 0 ]; then
aptss update aptss update
try_run_output=$(/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh test-install-app "$DEBPATH") try_run_output=$(/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh test-install-app "$DEBPATH")
try_run_ret="$?" try_run_ret="$?"
fi fi
if [ "$try_run_ret" -ne 0 ]; then ## 若安装检测仍然失败
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 可用则进行安装 # 按顺序尝试每个ACE环境
echo "----------------------------------------" for ace_entry in "${ace_commands_order[@]}"; do
echo "Attention: USING ACE BOOKWORM TO INSTALL" ace_cmd=${ace_entry%%:*}
echo "----------------------------------------" if command -v "$ace_cmd" >/dev/null 2>&1; then
bookworm-run ensure_aptss_exist echo "----------------------------------------"
try_run_output=$(bookworm-run aptss install --dry-run "$DEBPATH") echo "正在尝试使用 $ace_cmd 环境安装..."
try_run_ret="$?" 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 if [ "$try_run_ret" -ne 0 ]; then
bookworm-run aptss update $ace_cmd aptss update
try_run_output=$(bookworm-run aptss install --dry-run "$DEBPATH") try_run_output=$($ace_cmd aptss install --dry-run "$DEBPATH" 2>&1)
try_run_ret="$?" try_run_ret="$?"
fi 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" -yf'
success=true
break # 跳出循环
else
echo "----------------------------------------"
echo "在 $ace_cmd 环境中安装预检失败,错误信息:"
echo -e "${try_run_output}" echo -e "${try_run_output}"
echo "----------------------------------------" echo "----------------------------------------"
echo "Attention: USING ACE BOOKWORM TO INSTALL" fi
echo "----------------------------------------"
exit "$try_run_ret"
fi fi
bookworm-run dpkg -i "$DEBPATH" || aptss install "$DEBPATH" -yf done
fi
else # 如果在主机安装失败且未安装ACE报错退出并推荐安装 ACE if ! $success; then
echo "OMG-IT-GOES-WRONG" echo "OMG-IT-GOES-WRONG"
echo -e "${try_run_output}" echo -e "${try_run_output}"
echo "您可在商店安装 ACE Bookworm 兼容环境后重试安装" echo -e "所有ACE环境尝试失败推荐安装以下任一兼容环境:\n${recommendation_msg}"
exit "$try_run_ret" exit "$try_run_ret"
fi fi
else ## 如果主机安装检测成功了,进入主机安装分支 else # 已经在ACE环境中仍失败直接退出
echo "OMG-IT-GOES-WRONG"
dpkg -i "$DEBPATH" || aptss install "$DEBPATH" -yf echo -e "${try_run_output}"
exit "$try_run_ret"
fi fi
### 退出阶段 else ## 如果主机安装检测成功
dpkg -i "$DEBPATH" || aptss install "$DEBPATH" -yf
fi
if [ "$?" = "0" ] && [ "$2" = "--delete-after-install" ]; then ### 退出阶段保持不变 ###
if dpkg -s "$package_name" >/dev/null 2>&1; then if [ "$?" = "0" ] && [ "$2" = "--delete-after-install" ]; then
echo "软件包已安装:$package_name" if dpkg -s "$package_name" >/dev/null 2>&1; then
create_desktop_file echo "软件包已安装:$package_name"
rm "$DEBPATH" create_desktop_file
echo "${TRANSHELL_CONTENT_DEB_IS_DELETED}" unlock_file $DEBPATH
else rm "$DEBPATH"
echo "软件包未安装:$package_name" echo "${TRANSHELL_CONTENT_DEB_IS_DELETED}"
echo "安装异常!抛出错误"
echo "OMG-IT-GOES-WRONG"
fi
else else
echo "${TRANSHELL_CONTENT_WILL_NOT_DELETE_DEB}" echo "软件包未安装:$package_name"
if dpkg -s "$package_name" >/dev/null 2>&1; then echo "安装异常!抛出错误"
echo "软件包已安装:$package_name" echo "OMG-IT-GOES-WRONG"
create_desktop_file fi
else else
echo "软件包未安装:$package_name" echo "${TRANSHELL_CONTENT_WILL_NOT_DELETE_DEB}"
echo "安装异常!抛出错误" if dpkg -s "$package_name" >/dev/null 2>&1; then
echo "OMG-IT-GOES-WRONG" echo "软件包已安装:$package_name"
fi create_desktop_file
else
echo "软件包未安装:$package_name"
echo "安装异常!抛出错误"
echo "OMG-IT-GOES-WRONG"
fi fi
fi fi
fi

@ -101,7 +101,7 @@ function launch_app(){
log.info "Command is $exec_command" log.info "Command is $exec_command"
# 在默认终端执行命令 # 在默认终端执行命令
bash -c $exec_command bash -c "$exec_command"
} }
if [ "$#" -lt 2 ];then if [ "$#" -lt 2 ];then