diff --git a/debian/changelog b/debian/changelog index 6f05fb4..db1084a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +spark-store (3.0.3-11) stable; urgency=medium + + * Now support autoupdate + + -- shenmo <shenmo@spark-app.store> Mon, 17 Jan 2022 00:00:00 +0800 + + + + spark-store (3.0.3-10) stable; urgency=medium * Now also compile dstore patch diff --git a/pkg/usr/lib/systemd/system/spark-update-notifier.service b/pkg/usr/lib/systemd/system/spark-update-notifier.service new file mode 100644 index 0000000..83b73ac --- /dev/null +++ b/pkg/usr/lib/systemd/system/spark-update-notifier.service @@ -0,0 +1,15 @@ +[Unit] +Description:Spark Store update notifier +After=apt-daily.service network.target network-online.target systemd-networkd.service NetworkManager.service connman.service + + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/opt/durapps/spark-store/bin/update-upgrade/ss-update-notify-placer +Restart=on-failure +RestartSec=10 + +[Install] +Alias=spark-update-notifier +WantedBy=multi-user.target \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 377330e..fcb8eaa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -50,7 +50,7 @@ int main(int argc, char *argv[]) a.setOrganizationName("spark-union"); a.setOrganizationDomain("https://www.deepinos.org/"); a.setApplicationName("Spark Store"); //不需要翻译,否则 ~/.local/share/ 下文件夹名称也被翻译为中文 - a.setApplicationVersion(DApplication::buildVersion("3.0.3-10")); + a.setApplicationVersion(DApplication::buildVersion("3.0.3-11")); a.setApplicationAcknowledgementPage("https://gitee.com/deepin-community-store/spark-store"); a.setApplicationDescription( QObject::tr( diff --git a/src/widget.cpp b/src/widget.cpp index 7232bee..e61332b 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -192,14 +192,18 @@ void Widget::initUI() // 添加菜单项 QAction *actionSubmission = new QAction(tr("Submit App"), this); QAction *setting = new QAction(tr("Settings")); + QAction *upgrade = new QAction(tr("App Upgrade")); QMenu *menu = new QMenu; menu->addAction(setting); + menu->addAction(upgrade); menu->addAction(actionSubmission); + titlebar->setMenu(menu); connect(actionSubmission, &QAction::triggered, this, [=]{QDesktopServices::openUrl(QUrl("https://upload.deepinos.org/"));}); connect(setting, &QAction::triggered, this, &Widget::opensetting); + connect(upgrade, &QAction::triggered, this, [=]{QProcess::startDetached("x-terminal-emulator -e /opt/durapps/spark-store/bin/update-upgrade/ss-update-controler.sh");}); // 载入自定义字体 int loadedFontID = QFontDatabase::addApplicationFont(":/fonts/fonts/hksnzt.ttf"); diff --git a/tool/update-upgrade/autostart/spark-update-notifier.desktop b/tool/update-upgrade/autostart/spark-update-notifier.desktop new file mode 100644 index 0000000..d458c3b --- /dev/null +++ b/tool/update-upgrade/autostart/spark-update-notifier.desktop @@ -0,0 +1,5 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=Application +Exec=/opt/durapps/spark-store/bin/update-upgrade/ss-update-notify.sh +Name=spark-update-notifier diff --git a/tool/update-upgrade/ss-do-upgrade.sh b/tool/update-upgrade/ss-do-upgrade.sh new file mode 100755 index 0000000..4e0976c --- /dev/null +++ b/tool/update-upgrade/ss-do-upgrade.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -e +sudo apt upgrade -o Dir::Etc::sourcelist="sources.list.d/sparkstore.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0" + diff --git a/tool/update-upgrade/ss-update-controler.sh b/tool/update-upgrade/ss-update-controler.sh new file mode 100755 index 0000000..b787498 --- /dev/null +++ b/tool/update-upgrade/ss-update-controler.sh @@ -0,0 +1,62 @@ +#!/bin/bash +set -e +echo "因为目前没有有时间的Qt程序员志愿者所以现在加功能只有让shenmo写脚本了..." +echo "下面一段是shenmo想了半天写出来的(为了让用户认真读操碎了心~" +echo "请务必认真阅读(" +echo +echo "此功能被添加的原因是:为了防止影响系统更新,星火源默认的优先级是400,低于默认的500。这导致了与系统仓库相同包名的软件包无法正常更新到比系统仓库更高的版本。例如:hugo,系统仓库中的低版本会被优先安装,而且默认不会更新到星火的更新的版本" +echo "此脚本可以检测星火源中是否有比当前系统更高版本的软件包,由您决定是否安装" +echo "此脚本使用apt update/apt list --upgrade/apt upgrade来更新软件源、列出更新列表和操作更新" +echo +echo "该脚本不对其使用效果有任何明示或暗示的担保,在使用前请您确保您清楚地知道您在干什么。您应当清楚,星火商店的软件包并不是适配所有发行版的;尽管绝大多数的软件更新是无害的,您仍然应该仔细检查显示出来的更新内容,以确保不会对您的依赖环境造成破坏,尤其是那些看起来和系统依赖相关的软件包。在查看过更新列表之后,确认更新之前,您仍有一次取消更新的机会。" +echo "本脚本的开发者不对使用该脚本可能造成的后果负责" +echo +echo +echo +echo "请按任意键继续..." +read + +reset + +endloop=0 +while [ $endloop -eq 0 ] ;do +echo "欢迎使用星火更新工具 脚本版 " +echo "请在以下操作中选择一个进行~" +echo "输入1 开启或关闭星火更新检测工具(如果开启则会在系统启动后自动检测更新。如有更新则会弹出通知)" +echo "输入2 查看可更新软件包列表并决定是否更新" +echo "输入3 退出脚本" +read option + +case $option in + 1) + echo "执行以下操作需要授权..." + + if [ -f $XDG_CONFIG_HOME/autostart/spark-update-notifier.desktop ];then + echo "检测到已经启动了自动更新检测,关闭中" + sudo systemctl disable spark-update-notifier + rm $XDG_CONFIG_HOME/autostart/spark-update-notifier.desktop + + else + echo "未检测到自动更新检测,启动中" + sudo systemctl enable spark-update-notifier + sudo service spark-update-notifier start + ln -s /opt/durapps/spark-store/bin/update-upgrade/autostart/spark-update-notifier.desktop $XDG_CONFIG_HOME/autostart + /opt/durapps/spark-store/bin/update-upgrade/ss-update-notify.sh + fi + ;; + + 2) + /opt/durapps/spark-store/bin/update-upgrade/ss-upgrade-list.sh + /opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade.sh + + ;; + 3) + echo "按回车退出" + exit 0 + ;; + *) + echo "无法识别的输入!请重新输入" + reset +esac + +done \ No newline at end of file diff --git a/tool/update-upgrade/ss-update-notify-placer.sh b/tool/update-upgrade/ss-update-notify-placer.sh new file mode 100755 index 0000000..41196cc --- /dev/null +++ b/tool/update-upgrade/ss-update-notify-placer.sh @@ -0,0 +1,48 @@ +#!/bin/bash +set -e +LANG=en.US + +#!/bin/bash + +#检测网络链接畅通 +function network() +{ + #超时时间 + local timeout=1 + + #目标网站 + local target=www.baidu.com + + #获取响应状态码 + local ret_code=`curl -I -s --connect-timeout ${timeout} ${target} -w %{http_code} | tail -n1` + + if [ "x$ret_code" = "x200" ]; then + #网络畅通 + return 0 + else + #网络不畅通 + return 1 + fi + + return 0 +} + +network +if [ $? -eq 1 ];then + echo "Network fail. Stop to avoid bother dpkg" + exit -1 +fi + +#The code above is modified from https://blog.csdn.net/yaxuan88521/article/details/120516298 + + +updatetext=`sudo apt update -o Dir::Etc::sourcelist="sources.list.d/sparkstore.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"` +isupdate=`echo $updatetext | grep "can be upgraded"` +#echo $isupdate + +if [ "$isupdate" ];then + update_app_number=`echo ${updatetext%package*} #从右向左截取第一个 src 后的字符串` + update_app_number=`echo ${update_app_number: -1}` + mkdir -p /tmp/spark-store-updatenum + sudo echo "$update_app_number" > /tmp/spark-store-updatenum/number +fi diff --git a/tool/update-upgrade/ss-update-notify.sh b/tool/update-upgrade/ss-update-notify.sh new file mode 100755 index 0000000..98fc91a --- /dev/null +++ b/tool/update-upgrade/ss-update-notify.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +if [ -f /tmp/spark-store-updatenum/number ];then + update_app_number=`cat /tmp/spark-store-updatenum/number` + echo "$update_app_number" + notify-send -i spark-store "星火更新提醒" "星火商店仓库中有$update_app_number个软件包可以更新啦!请及时处理" +fi diff --git a/tool/update-upgrade/ss-upgrade-list.sh b/tool/update-upgrade/ss-upgrade-list.sh new file mode 100755 index 0000000..6077a56 --- /dev/null +++ b/tool/update-upgrade/ss-upgrade-list.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e + + +echo "可更新的应用有:" +sudo apt list --upgradable -o Dir::Etc::sourcelist="sources.list.d/sparkstore.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"