Compare commits

...

5 Commits

Author SHA1 Message Date
b6f57c727b update debian/changelog.
Signed-off-by: shenmo <jifengshenmo@outlook.com>
2024-12-16 15:45:41 +00:00
d0dec1b3b0 update debian/spark-store.prerm.
Signed-off-by: shenmo <jifengshenmo@outlook.com>
2024-12-11 04:52:01 +00:00
b125993336 update tool/update-upgrade/ss-update-notifier.sh.
Signed-off-by: shenmo <jifengshenmo@outlook.com>
2024-12-02 14:38:44 +00:00
5a37f24145 try fix always retry 2024-12-01 23:22:14 +08:00
a7b32db9b5 update tool/bashimport/log.amber.
Signed-off-by: shenmo <jifengshenmo@outlook.com>
2024-11-30 11:02:58 +00:00
5 changed files with 53 additions and 45 deletions

3
debian/changelog vendored
View File

@@ -1,7 +1,8 @@
spark-store (4.3.3.1-fix2) UNRELEASED; urgency=medium spark-store (4.3.3.2) UNRELEASED; urgency=medium
* 提升升级工具体验,不再反复弹窗 * 提升升级工具体验,不再反复弹窗
* 提升aptss使用体验汇报目前所在阶段而不是卡住不动 * 提升aptss使用体验汇报目前所在阶段而不是卡住不动
* 修复debian sid 无法卸载
-- shenmo <shenmo@spark-app.store> Tue, 24 Sep 2024 11:27:08 +0800 -- shenmo <shenmo@spark-app.store> Tue, 24 Sep 2024 11:27:08 +0800

View File

@@ -51,7 +51,7 @@ for username in `ls /home`
# Remove gpg key file # Remove gpg key file
rm -f /etc/apt/trusted.gpg.d/spark-store.gpg rm -f /etc/apt/trusted.gpg.d/spark-store.gpg
apt-key del '9D9A A859 F750 24B1 A1EC E16E 0E41 D354 A29A 440C' apt-key del '9D9A A859 F750 24B1 A1EC E16E 0E41 D354 A29A 440C' || true
else else
if [ ! -z "`pidof spark-store`" ] ; then if [ ! -z "`pidof spark-store`" ] ; then

View File

@@ -2,13 +2,14 @@
Description=Spark Store update notifier Description=Spark Store update notifier
After=apt-daily.service network.target network-online.target systemd-networkd.service NetworkManager.service connman.service After=apt-daily.service network.target network-online.target systemd-networkd.service NetworkManager.service connman.service
[Service] [Service]
Type=simple Type=simple
RemainAfterExit=yes RemainAfterExit=yes
ExecStart=/opt/durapps/spark-store/bin/update-upgrade/ss-update-notifier.sh ExecStart=/opt/durapps/spark-store/bin/update-upgrade/ss-update-notifier.sh
Restart=on-failure Restart=on-failure
RestartSec=10 RestartSec=15 # 可以设置为更长的重试间隔,比如 15 秒或 30 秒
StartLimitIntervalSec=1h # 设置为 1 小时的时间窗口
StartLimitBurst=3 # 最大允许失败次数为 3 次
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
log.warn() { echo -e "[\e[33mWARN\e[0m]: \e[1m$*\e[0m"; } log.warn() { echo -e "[\e[33mWARN\e[0m]: \e[1m$*\e[0m"; }
log.error() { echo -e "[\e[31mERROR\e[0m]: \e[1m$*\e[0m"; exit 1; } log.error() { echo -e "[\e[31mERROR\e[0m]: \e[1m$*\e[0m"; }
log.info() { echo -e "[\e[96mINFO\e[0m]: \e[1m$*\e[0m"; } log.info() { echo -e "[\e[96mINFO\e[0m]: \e[1m$*\e[0m"; }
log.debug() { echo -e "[\e[32mDEBUG\e[0m]: \e[1m$*\e[0m"; } log.debug() { echo -e "[\e[32mDEBUG\e[0m]: \e[1m$*\e[0m"; }

View File

@@ -1,16 +1,12 @@
#!/bin/bash #!/bin/bash
source /opt/durapps/spark-store/bin/bashimport/transhell.amber source /opt/durapps/spark-store/bin/bashimport/transhell.amber
load_transhell_debug load_transhell_debug
############################################################# #############################################################
# 发送通知 # 发送通知
function notify-send() { function notify-send() {
# Detect user using the display # Detect user using the display
local user=$(who | awk '{print $1}' | head -n 1) local user=$(who | awk '{print $1}' | head -n 1)
@@ -20,11 +16,8 @@ function notify-send() {
sudo -u $user DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${uid}/bus notify-send "$@" sudo -u $user DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${uid}/bus notify-send "$@"
} }
# 检测网络链接畅通 # 检测网络链接畅通
function network-check() function network-check() {
{
# 超时时间 # 超时时间
local timeout=15 local timeout=15
@@ -32,9 +25,9 @@ function network-check()
local target=www.baidu.com local target=www.baidu.com
# 获取响应状态码 # 获取响应状态码
local ret_code=`curl -I -s --connect-timeout ${timeout} ${target} -w %{http_code} | tail -n1` local ret_code=$(curl -I -s --connect-timeout ${timeout} ${target} -w %{http_code} | tail -n1)
if [ "x$ret_code" = "x200" ] ; then if [ "$ret_code" = "200" ]; then
# 网络畅通 # 网络畅通
return 0 return 0
else else
@@ -43,32 +36,47 @@ function network-check()
fi fi
} }
network-check # 初始化等待时间和最大等待时间
if [ $? -ne 0 ] ; then initial_wait_time=15 # 初始等待时间 15 秒
echo "$TRANSHELL_CONTENT_NETWORK_FAIL" max_wait_time=$((12 * 3600)) # 最大等待时间 12 小时
exit -1
fi
# The code above is modified from https://blog.csdn.net/yaxuan88521/article/details/120516298 # 检测网络,若不通则进行重试,采用指数退避算法
wait_time=$initial_wait_time
while ! network-check; do
echo "$TRANSHELL_CONTENT_NETWORK_FAIL"
echo "Waiting for network to recover... Retrying in ${wait_time} seconds."
sleep $wait_time
wait_time=$((wait_time * 2)) # 等待时间翻倍
if [ $wait_time -gt $max_wait_time ]; then
wait_time=$max_wait_time # 最大等待时间限制为12小时
fi
done
# 每日更新星火源文件 # 每日更新星火源文件
aptss update aptss update
updatetext=`LANGUAGE=en_US aptss ssupdate 2>&1` updatetext=`LANGUAGE=en_US aptss ssupdate 2>&1`
until [ "`echo $updatetext | grep E: `" = "" ];do # 在网络恢复后,继续更新操作
echo "${TRANSHELL_CONTENT_UPDATE_ERROR_AND_WAIT_15_SEC}" retry_count=0
sleep 15 max_retries=12 # 最大重试次数,防止死循环
updatetext=`LANGUAGE=en_US aptss ssupdate 2>&1`
until ! echo $updatetext | grep -q "E:"; do
if [ $retry_count -ge $max_retries ]; then
echo "Reached maximum retry limit for aptss ssupdate."
exit 1
fi
echo "${TRANSHELL_CONTENT_UPDATE_ERROR_AND_WAIT_15_SEC}"
sleep 15
updatetext=`LANGUAGE=en_US aptss ssupdate 2>&1`
retry_count=$((retry_count + 1))
done done
update_app_number=$(env LANGUAGE=en_US /usr/bin/apt -c /opt/durapps/spark-store/bin/apt-fast-conf/aptss-apt.conf list --upgradable -o Dir::Etc::sourcelist="/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list" -o Dir::Etc::sourceparts="/dev/null" -o APT::Get::List-Cleanup="0" 2>/dev/null | grep -c upgradable) update_app_number=$(env LANGUAGE=en_US /usr/bin/apt -c /opt/durapps/spark-store/bin/apt-fast-conf/aptss-apt.conf list --upgradable -o Dir::Etc::sourcelist="/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list" -o Dir::Etc::sourceparts="/dev/null" -o APT::Get::List-Cleanup="0" 2>/dev/null | grep -c upgradable)
if [ "$update_app_number" -le 0 ] ; then if [ "$update_app_number" -le 0 ]; then
exit 0 exit 0
fi fi
@@ -78,43 +86,41 @@ PKG_LIST="$(/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh
IFS_OLD="$IFS" IFS_OLD="$IFS"
IFS=$'\n' IFS=$'\n'
for line in $PKG_LIST ; do for line in $PKG_LIST; do
PKG_NAME=$(echo $line | awk -F ' ' '{print $1}') PKG_NAME=$(echo $line | awk -F ' ' '{print $1}')
PKG_NEW_VER=$(echo $line | awk -F ' ' '{print $2}') PKG_NEW_VER=$(echo $line | awk -F ' ' '{print $2}')
PKG_CUR_VER=$(echo $line | awk -F ' ' '{print $3}') PKG_CUR_VER=$(echo $line | awk -F ' ' '{print $3}')
dpkg --compare-versions $PKG_NEW_VER le $PKG_CUR_VER dpkg --compare-versions $PKG_NEW_VER le $PKG_CUR_VER
if [ $? -eq 0 ] ; then if [ $? -eq 0 ]; then
let update_app_number=$update_app_number-1 let update_app_number=$update_app_number-1
continue continue
fi fi
## 检测是否是 hold 状态 # 检测是否是 hold 状态
PKG_STA=$(dpkg-query -W -f='${db:Status-Want}' $PKG_NAME) PKG_STA=$(dpkg-query -W -f='${db:Status-Want}' $PKG_NAME)
if [ "$PKG_STA" = "hold" ] ; then if [ "$PKG_STA" = "hold" ]; then
let update_app_number=$update_app_number-1 let update_app_number=$update_app_number-1
fi fi
done done
# 还原分隔符 # 还原分隔符
IFS="$IFS_OLD" IFS="$IFS_OLD"
if [ $update_app_number -le 0 ] ; then if [ $update_app_number -le 0 ]; then
exit 0 exit 0
fi fi
update_transhell update_transhell
## 如果都是hold或者版本一致的那就直接退出否则把剩余的给提醒了 # 如果都是hold或者版本一致的那就直接退出否则把剩余的给提醒了
# TODO: 除了apt-mark hold之外额外有一个禁止检查列表
##TODO:除了apt-mark hold之外额外有一个禁止检查列表 # 如果不想提示就不提示
## 如果不想提示就不提示
user=$(who | awk '{print $1}' | head -n 1) user=$(who | awk '{print $1}' | head -n 1)
if [ -e "/home/$user/.config/spark-union/spark-store/ssshell-config-do-not-show-upgrade-notify" ];then if [ -e "/home/$user/.config/spark-union/spark-store/ssshell-config-do-not-show-upgrade-notify" ]; then
echo "他不想站在世界之巅,好吧" echo "他不想站在世界之巅,好吧"
echo "Okay he don't want to be at the top of the world, okay" echo "Okay he don't want to be at the top of the world, okay"
exit exit
else else
notify-send -a spark-store "${TRANSHELL_CONTENT_SPARK_STORE_UPGRADE_NOTIFY}" "${TRANSHELL_CONTENT_THERE_ARE_APPS_TO_UPGRADE}" notify-send -a spark-store "${TRANSHELL_CONTENT_SPARK_STORE_UPGRADE_NOTIFY}" "${TRANSHELL_CONTENT_THERE_ARE_APPS_TO_UPGRADE}" || true # Some machine don't have bus, or who command just print nothing.
fi fi