mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-06-01 22:19:51 +08:00
Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
bbc4d27d7a | |||
dc28c2e9d1 | |||
b4935edf0a | |||
4f294cee8f | |||
45c52d7755 | |||
90ad08a6f9 | |||
819e680222 | |||
6697bd04f1 | |||
2a6e9046e7 | |||
460d965ac1 | |||
2b929f8a06 | |||
f2cafe0567 | |||
564966daef | |||
668e5dc28d | |||
7ae592776d | |||
6f3980e6cb | |||
e2a0079c6e |
README.mdREADME.zh.md
debian
pkg/usr/share/ssinstall-local/transhell
src
tool
@ -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).
|
||||
|
||||
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)
|
||||
|
||||
---
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# 星火应用商店
|
||||
[](https://gitee.com/spark-store-project/spark-store/stargazers) [](https://gitee.com/spark-store-project/spark-store/members)
|
||||
|
||||

|
||||
|
||||
|
||||
## 简介
|
||||
@ -171,9 +171,11 @@ https://github.com/spark-store-project/spark-store
|
||||
|
||||
## 常见问题(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
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
|
||||
|
||||
* 支持安装到 ACE Bookworm
|
||||
|
@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
TRANSHELL_CONTENT_HASH_CHECK_FAILED="Failed in checking package hash! \nPossibly reason can be the package is broken, laggy in sync of Spark Store repository, or, there is a malware attempt to attack. \nIf you don't know what happend, please try install again after execute the command below\n sudo aptss update\n\nIf the problem still happen, please click APP Feedback button in the APP information page to feedback to us.\n\n If you are in the Audition Group,Please use ssaudit instead of ssinstall to audit APPs,for ssinstall is used for password-free install now.\nIf you want to install an app that is removed from Spark Store repository,you can also use ssaudit."
|
||||
TRANSHELL_CONTENT_PLEASE_RUN_AS_ROOT="Please run ssinstall as root"
|
||||
TRANSHELL_CONTENT_FILE_NOT_EXIST="File not exist"
|
||||
TRANSHELL_CONTENT_WILL_NOT_DELETE_DEB="No delete after install option given, will not delete the deb"
|
||||
TRANSHELL_CONTENT_DEB_IS_DELETED="--delete-after-install option is given and the installation is succeeded, delete the deb file."
|
@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
TRANSHELL_CONTENT_HASH_CHECK_FAILED="软件包校验失败!这不应该发生!\n可能是因为软件包已损坏,星火仓库未同步,或者最坏的情况:恶意软件尝试利用自动安装来入侵系统!\n如果你不清楚发生了什么,请执行 sudo aptss update 后再尝试安装。\n如果问题仍然存在,请在应用信息界面点击 应用反馈 来提交反馈给我们!\n\n 如果你是审核人员,请使用 ssaudit来替代ssinstall进行审核工作,因为现在ssinstall已经被用于免密安装。\n如果你正在尝试安装已经下架的星火应用,也可用ssaudit来替代ssinstall"
|
||||
TRANSHELL_CONTENT_PLEASE_RUN_AS_ROOT="请使用root启动ssinstall"
|
||||
TRANSHELL_CONTENT_FILE_NOT_EXIST="文件不存在"
|
||||
TRANSHELL_CONTENT_WILL_NOT_DELETE_DEB="未指定安装后删除或安装出错,不删除deb包"
|
||||
TRANSHELL_CONTENT_DEB_IS_DELETED="使用了--delete-after-install选项且安装未出错,删除deb包"
|
18
src/main.cpp
18
src/main.cpp
@ -142,18 +142,18 @@ int main(int argc, char *argv[])
|
||||
// 龙芯机器配置,使得 DApplication 能正确加载 QtWebEngine
|
||||
qputenv("DTK_FORCE_RASTER_WIDGETS", "FALSE");
|
||||
|
||||
// 设置 QtWebEngine 环境变量
|
||||
QStringList chromium_flags;
|
||||
// 浏览器开启 GPU 支持
|
||||
// qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--disable-features=UseModernMediaControls");
|
||||
// qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--disable-web-security");
|
||||
// chromium_flags.append("--disable-features=UseModernMediaControls");
|
||||
// chromium_flags.append("--disable-web-security");
|
||||
// 全平台软件渲染Webkit
|
||||
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--disable-gpu");
|
||||
#ifdef __sw_64__
|
||||
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--no-sandbox");
|
||||
chromium_flags.append("--disable-gpu");
|
||||
#if defined __sw_64__ || __loongarch__
|
||||
chromium_flags.append("--no-sandbox");
|
||||
#endif
|
||||
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", chromium_flags.join(" ").toUtf8());
|
||||
|
||||
#ifdef __loongarch__
|
||||
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--no-sandbox");
|
||||
#endif
|
||||
/**
|
||||
* NOTE: https://zhuanlan.zhihu.com/p/550285855
|
||||
* 避免 wayland 环境下从 QtWebEngine 后退回到 QWidget 时黑屏闪烁
|
||||
@ -163,8 +163,6 @@ int main(int argc, char *argv[])
|
||||
DApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
||||
// 开启 Hidpi 支持
|
||||
qDebug() << "Enable HiDPI Support.";
|
||||
|
@ -198,7 +198,7 @@ void Utils::setQPAPlatform()
|
||||
// }
|
||||
else
|
||||
{
|
||||
qputenv("QT_QPA_PLATFORM", "dxcb");
|
||||
qputenv("QT_QPA_PLATFORM", "dxcb;xcb");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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=
|
||||
@ -367,15 +376,15 @@ prepare_auth(){
|
||||
AUTH_INFO_PARSED+=("$machine $login $password")
|
||||
done <<< "$auth_info"
|
||||
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
|
||||
# credentials that contain characters that need URL-encoding.
|
||||
get_auth(){
|
||||
if [ "$APT_FAST_APT_AUTH" -eq 0 ]; then
|
||||
echo "$1"
|
||||
return
|
||||
fi
|
||||
for auth_info in "${AUTH_INFO_PARSED[@]}"; do
|
||||
# convert to array, don't escape variable here
|
||||
auth_info_arr=($auth_info)
|
||||
@ -430,44 +439,40 @@ get_uris(){
|
||||
CLEANUP_STATE="$?"
|
||||
if [ "$CLEANUP_STATE" -ne 0 ]
|
||||
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 "${uris_full}"
|
||||
exit "$CLEANUP_STATE"
|
||||
fi
|
||||
prepare_auth
|
||||
local tmpdir=$(mktemp -d) || {
|
||||
local tmpdir
|
||||
tmpdir=$(mktemp -d) || {
|
||||
msg "Failed to create tmp dir" "warning"
|
||||
msg "无法创建临时目录" "warning"
|
||||
exit 1
|
||||
}
|
||||
## --print-uris format is:
|
||||
# 'fileurl' filename filesize checksum_hint:filechecksum
|
||||
# 修改:process_package函数增加第二个参数表示当前线程的临时输出文件
|
||||
process_package() {
|
||||
local pkg_uri_info="$@"
|
||||
|
||||
local display_line="" # 添加局部变量并初始化为空
|
||||
|
||||
local pkg_uri_info="$1"
|
||||
local thread_file="$2"
|
||||
local display_line="" # 初始化显示信息为空
|
||||
IFS=' ' read -r uri filename filesize checksum_string _ <<<"$pkg_uri_info"
|
||||
[ -z "$uri" ] && continue
|
||||
uri="$(get_auth "${uri//"'"/}")"
|
||||
[ -z "$uri" ] && return
|
||||
uri="${uri//"'"/}"
|
||||
[ "$APT_FAST_APT_AUTH" -ne 0 ] && uri="$(get_auth "$uri")"
|
||||
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"
|
||||
|
||||
|
||||
|
||||
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.
|
||||
|
||||
display_line+="$pkg_name_decoded $pkg_version_decoded $filesize\n"
|
||||
if [ -n "$HASH_SUPPORTED" ]; then
|
||||
case "$hash_algo" in
|
||||
SHA512) [ -z "$SHA512_SUPPORTED" ] && hash_algo= || hash_algo=sha-512 ;;
|
||||
@ -522,30 +527,27 @@ get_uris(){
|
||||
hash_algo=
|
||||
fi
|
||||
|
||||
# 原来利用文件锁写入,现在改为写入当前线程的临时文件
|
||||
{
|
||||
get_mirrors "$uri"
|
||||
[ -n "$hash_algo" ] && echo " checksum=$hash_algo=$checksum"
|
||||
echo " out=$filename"
|
||||
} >> "$thread_file"
|
||||
|
||||
# 使用文件锁安全写入下载列表
|
||||
(
|
||||
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 -e "$display_line" >> "$tmpdir/display"
|
||||
echo "$filesize" >> "$tmpdir/sizes"
|
||||
}
|
||||
|
||||
# 主并行处理逻辑(新增线程控制)
|
||||
# 主并行处理逻辑
|
||||
mapfile -t pkg_uri_list < <(echo "$uris_full" | grep -E "^'(http(s|)|(s|)ftp)://")
|
||||
total_pkgs=${#pkg_uri_list[@]}
|
||||
threads=${THREADS:-4} # 默认4线程
|
||||
per_thread=$(( (total_pkgs + threads - 1) / threads )) # 向上取整
|
||||
|
||||
# 分割任务到不同线程
|
||||
# 分配任务到不同线程,每个线程使用自己的临时文件
|
||||
for ((i=0; i<threads; i++)); do
|
||||
thread_file="${DLLIST}.thread.${i}"
|
||||
> "$thread_file" # 清空或创建临时文件
|
||||
start=$((i * per_thread))
|
||||
end=$((start + per_thread -1))
|
||||
[ $end -ge $total_pkgs ] && end=$((total_pkgs -1))
|
||||
@ -554,7 +556,7 @@ get_uris(){
|
||||
(
|
||||
for ((j=start; j<=end; j++)); do
|
||||
[ -z "${pkg_uri_list[j]}" ] && continue
|
||||
process_package "${pkg_uri_list[j]}"
|
||||
process_package "${pkg_uri_list[j]}" "$thread_file"
|
||||
done
|
||||
) &
|
||||
done
|
||||
@ -562,6 +564,15 @@ get_uris(){
|
||||
# 等待所有后台任务完成
|
||||
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
|
||||
DOWNLOAD_DISPLAY+="\n$(cat "$tmpdir/display")"
|
||||
@ -574,12 +585,10 @@ get_uris(){
|
||||
|
||||
# 清理临时目录
|
||||
rm -rf "$tmpdir"
|
||||
|
||||
#cat "$DLLIST"
|
||||
#exit
|
||||
}
|
||||
|
||||
|
||||
|
||||
display_downloadfile(){
|
||||
if [ -n "$VERBOSE_OUTPUT" ]; then
|
||||
cat "$DLLIST"
|
||||
@ -590,7 +599,7 @@ display_downloadfile(){
|
||||
while IFS=' ' read -r pkg ver size _; do
|
||||
[ -z "$pkg" ] && continue
|
||||
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
|
||||
msg "Download size: $(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
|
||||
|
||||
# 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
|
||||
|
||||
case `arch` in
|
||||
x86_64)
|
||||
x86_64 | i686 | i386)
|
||||
STORE_URL="store"
|
||||
STORE_LIST_URL=""
|
||||
;;
|
||||
|
168
tool/ssaudit
168
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,80 +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 command -v bookworm-run ;then
|
||||
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="$?"
|
||||
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
|
||||
|
||||
# 按顺序尝试每个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
|
||||
|
||||
if ! $success; then
|
||||
echo "OMG-IT-GOES-WRONG"
|
||||
echo -e "${try_run_output}"
|
||||
echo -e "所有ACE环境尝试失败,推荐安装以下任一兼容环境:\n${recommendation_msg}"
|
||||
exit "$try_run_ret"
|
||||
fi
|
||||
else
|
||||
|
||||
dpkg -i "$DEBPATH" || aptss install "$DEBPATH" -yf
|
||||
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
|
||||
|
148
tool/ssinstall
148
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"
|
||||
@ -143,6 +144,7 @@ fi
|
||||
|
||||
if [ ! -f "$1" ]; then
|
||||
echo "${TRANSHELL_CONTENT_FILE_NOT_EXIST},Trying to redownload"
|
||||
aptss update
|
||||
FILEPATH=$(dirname "$1")
|
||||
FILENAME=$(basename "$1")
|
||||
PACKAGE_NAME=$(echo "$FILENAME" | sed -r 's/^([^_]+)_.*$/\1/')
|
||||
@ -179,77 +181,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 兼容环境后重试安装"
|
||||
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
|
||||
|
129
tool/ssinstall-local
Executable file
129
tool/ssinstall-local
Executable file
@ -0,0 +1,129 @@
|
||||
#!/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
|
||||
|
||||
help(){
|
||||
echo "Spark Store 安装脚本使用说明:"
|
||||
echo "用法: $0 [选项] <deb文件路径>"
|
||||
echo ""
|
||||
echo "选项:"
|
||||
echo " -h, --help 显示此帮助信息"
|
||||
echo " --delete-after-install 安装完成后删除deb文件"
|
||||
echo ""
|
||||
echo "示例:"
|
||||
echo " $0 /path/to/package.deb"
|
||||
echo " $0 --delete-after-install /path/to/package.deb"
|
||||
}
|
||||
|
||||
parse_args() {
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
-h | --help)
|
||||
help
|
||||
exit 0
|
||||
;;
|
||||
--delete-after-install)
|
||||
DELETE_AFTER_INSTALL="1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
DEBPATH="$1"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
parse_args "$@"
|
||||
|
||||
echo "Spark Store Install script. 星火商店安装脚本"
|
||||
|
||||
function create_desktop_file() {
|
||||
local user=$(who | awk '{print $1}' | head -n 1)
|
||||
if [ -e $(sudo -u "$user" xdg-user-dir)/.config/spark-union/spark-store/ssshell-config-do-not-create-desktop ];then
|
||||
echo "It is configured that do not create desktop file. Give up"
|
||||
else
|
||||
exec_create_desktop_file
|
||||
fi
|
||||
}
|
||||
|
||||
function exec_create_desktop_file() {
|
||||
local user=$(who | awk '{print $1}' | head -n 1)
|
||||
for desktop_file_path in $(dpkg -L "$package_name" |grep /usr/share/applications/ | awk '/\.desktop$/ {print}'); do
|
||||
if [ "$(cat $desktop_file_path | grep NoDisplay=true)" = "" ];then
|
||||
echo "$desktop_file_path is checked and will be installed to desktop"
|
||||
sudo -u "$user" cp "$desktop_file_path" "$(sudo -u "$user" xdg-user-dir DESKTOP)/"
|
||||
fi
|
||||
done
|
||||
for desktop_file_path in $(dpkg -L "$package_name" |grep /opt/apps/$package_name/entries/applications | awk '/\.desktop$/ {print}'); do
|
||||
if [ "$(cat $desktop_file_path | grep NoDisplay=true)" = "" ];then
|
||||
echo "$desktop_file_path is checked and will be installed to desktop"
|
||||
chmod +x "$desktop_file_path"
|
||||
sudo -u "$user" cp "$desktop_file_path" "$(sudo -u "$user" xdg-user-dir DESKTOP)/"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
####################################
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "没有接收到参数,退出"
|
||||
help
|
||||
echo "OMG-IT-GOES-WRONG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "${TRANSHELL_CONTENT_PLEASE_RUN_AS_ROOT}"
|
||||
echo "OMG-IT-GOES-WRONG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
package_name=$(dpkg-deb -f "$DEBPATH" Package)
|
||||
echo "Package name is $package_name"
|
||||
try_run_output=$(aptss --dry-run install "$DEBPATH")
|
||||
try_run_ret="$?"
|
||||
# 安装失败后进行 aptss 刷新,随后尝试安装
|
||||
if [ "$try_run_ret" -ne 0 ]; then
|
||||
aptss update
|
||||
try_run_output=$(aptss --dry-run install "$DEBPATH")
|
||||
try_run_ret="$?"
|
||||
fi
|
||||
|
||||
if [ "$try_run_ret" = "0" ]; then ## 若安装检测成功
|
||||
dpkg -i "$DEBPATH" || aptss install "$DEBPATH" -yfq
|
||||
else
|
||||
echo "Package manager quit with exit code.Here is the log"
|
||||
echo "包管理器以错误代码退出.日志如下"
|
||||
echo
|
||||
echo -e "${try_run_output}"
|
||||
echo "OMG-IT-GOES-WRONG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### 退出阶段
|
||||
if [ "$?" = "0" ]; then
|
||||
if dpkg -s "$package_name" >/dev/null 2>&1; then
|
||||
echo "软件包已安装:$package_name"
|
||||
create_desktop_file
|
||||
if [ "$DELETE_AFTER_INSTALL" = "1" ];then
|
||||
rm "$DEBPATH"
|
||||
echo "${TRANSHELL_CONTENT_DEB_IS_DELETED}"
|
||||
else
|
||||
echo "${TRANSHELL_CONTENT_WILL_NOT_DELETE_DEB}"
|
||||
fi
|
||||
else
|
||||
echo "软件包未安装:$package_name"
|
||||
echo "安装异常!抛出错误"
|
||||
echo "OMG-IT-GOES-WRONG"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "安装异常!抛出错误"
|
||||
echo "OMG-IT-GOES-WRONG"
|
||||
exit 1
|
||||
fi
|
@ -1,10 +1,42 @@
|
||||
#!/bin/bash
|
||||
dpkg -l | grep "^ii $1 " > /dev/null
|
||||
dpkg -s "$1" > /dev/null
|
||||
RET="$?"
|
||||
if [[ "$RET" != "0" ]] && command -v bookworm-run > /dev/null;then
|
||||
echo "Try ACE Bookworm"
|
||||
bookworm-run dpkg -l | grep "^ii $1 " > /dev/null
|
||||
RET="$?"
|
||||
exit "$RET"
|
||||
fi
|
||||
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"
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user