新增 ssinstall-local 以准备后续的ACE支持

This commit is contained in:
2025-05-31 00:34:08 +08:00
parent d75c3a6453
commit 963289355c
4 changed files with 142 additions and 0 deletions

129
tool/ssinstall-local Executable file
View 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