From c4f4465e87cddbec53724d379e8b6c8f22aa8804 Mon Sep 17 00:00:00 2001
From: shenmo <jifengshenmo@outlook.com>
Date: Mon, 11 Apr 2022 00:01:50 +0800
Subject: [PATCH] =?UTF-8?q?=09=E6=96=B0=E6=96=87=E4=BB=B6=EF=BC=9A=20=20?=
 =?UTF-8?q?=20debian/source/format=20=09=E4=BF=AE=E6=94=B9=EF=BC=9A=20=20?=
 =?UTF-8?q?=20=20=20debian/spark-store.postinst=20=09=E4=BF=AE=E6=94=B9?=
 =?UTF-8?q?=EF=BC=9A=20=20=20=20=20debian/spark-store.postrm=20=09?=
 =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=20=20=20=20=20debian/spark-store.pr?=
 =?UTF-8?q?erm=20=09=E4=BF=AE=E6=94=B9=EF=BC=9A=20=20=20=20=20pkg/usr/lib/?=
 =?UTF-8?q?systemd/system/spark-update-notifier.service=20=09=E4=BF=AE?=
 =?UTF-8?q?=E6=94=B9=EF=BC=9A=20=20=20=20=20spark-store-project.pro=20=09?=
 =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=20=20=20=20=20tool/update-upgrade/s?=
 =?UTF-8?q?s-update-controler.sh?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 debian/source/format                                  |  1 +
 debian/spark-store.postinst                           |  9 +++++++++
 debian/spark-store.postrm                             |  0
 debian/spark-store.prerm                              |  9 +++++++++
 .../lib/systemd/system/spark-update-notifier.service  |  2 +-
 spark-store-project.pro                               |  7 ++++++-
 tool/update-upgrade/ss-update-controler.sh            | 11 ++++++-----
 7 files changed, 32 insertions(+), 7 deletions(-)
 create mode 100644 debian/source/format
 mode change 100644 => 100755 debian/spark-store.postrm

diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000..9f8e9b6
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+1.0
\ No newline at end of file
diff --git a/debian/spark-store.postinst b/debian/spark-store.postinst
index 6cb47cc..e109e6b 100755
--- a/debian/spark-store.postinst
+++ b/debian/spark-store.postinst
@@ -12,6 +12,8 @@ case "$1" in
 		ln -s -f /opt/durapps/spark-store/bin/ssinstall /usr/local/bin/ssinstall
 		ln -s -f /opt/durapps/spark-store/bin/spark-dstore-patch /usr/local/bin/spark-dstore-patch
 
+
+
 		# Download and install key
 		wget -O /tmp/spark-store-install/spark-store.asc https://d.store.deepinos.org.cn/dcs-repo.gpg-key.asc 
 		gpg --dearmor /tmp/spark-store-install/spark-store.asc 
@@ -20,6 +22,13 @@ case "$1" in
         	# Run apt update to avoid users being fucked up by the non-exist dependency problem
         	apt update
 
+		# Create symbo links to start upgrade detect
+		ln -s /opt/durapps/spark-store/bin/update-upgrade/autostart/spark-update-notifier.desktop /etc/xdg/autostart/spark-update-notifier.desktop
+
+		# Start upgrade detect service
+		systemctl enable spark-update-notifier
+
+
 		# Update certain caches
 		update-icon-caches /usr/share/icons/hicolor || true
 		update-desktop-database /usr/share/applications || true
diff --git a/debian/spark-store.postrm b/debian/spark-store.postrm
old mode 100644
new mode 100755
diff --git a/debian/spark-store.prerm b/debian/spark-store.prerm
index 416fa09..4103efd 100755
--- a/debian/spark-store.prerm
+++ b/debian/spark-store.prerm
@@ -7,9 +7,18 @@ rm /usr/local/bin/spark-dstore-patch
 rm /usr/local/bin/ussinstall
 rm /usr/local/bin/ussremove
 
+# Remove residual symbol links to stop upgrade detect
+rm /etc/xdg/autostart/spark-update-notifier.desktop
+
+# Stop update detect service
+systemctl disable spark-update-notifier
+
 # Remove gpg key file
 if [ -f "/etc/apt/trusted.gpg.d/spark-store.gpg" ] ; then
 	rm /etc/apt/trusted.gpg.d/spark-store.gpg
 fi
 
 apt-key del '9D9A A859 F750 24B1 A1EC  E16E 0E41 D354 A29A 440C'
+
+# Shutdown services 
+service spark-update-notifier stop
\ No newline at end of file
diff --git a/pkg/usr/lib/systemd/system/spark-update-notifier.service b/pkg/usr/lib/systemd/system/spark-update-notifier.service
index 83b73ac..0a5b2bd 100644
--- a/pkg/usr/lib/systemd/system/spark-update-notifier.service
+++ b/pkg/usr/lib/systemd/system/spark-update-notifier.service
@@ -6,7 +6,7 @@ After=apt-daily.service network.target network-online.target systemd-networkd.se
 [Service]
 Type=oneshot
 RemainAfterExit=yes 
-ExecStart=/opt/durapps/spark-store/bin/update-upgrade/ss-update-notify-placer
+ExecStart=/opt/durapps/spark-store/bin/update-upgrade/ss-update-notify-placer.sh
 Restart=on-failure
 RestartSec=10
 
diff --git a/spark-store-project.pro b/spark-store-project.pro
index 59c4d4c..6a23d9f 100644
--- a/spark-store-project.pro
+++ b/spark-store-project.pro
@@ -30,6 +30,10 @@ sourceslist.path = /etc/apt/sources.list.d
 desktop.files += pkg/usr/share/applications/spark-store.desktop
 desktop.path = /usr/share/applications
 
+service.files += pkg/usr/lib/systemd/system/spark-update-notifier.service
+service.path = /usr/lib/systemd/system/
+
+
 icon.files += pkg/usr/share/icons/hicolor/scalable/apps/spark-store.svg
 icon.path = /usr/share/icons/hicolor/scalable/apps
 
@@ -43,4 +47,5 @@ INSTALLS += \
     icon \
     sourceslist \
     preferences \
-    tmp
+    tmp \
+    service
diff --git a/tool/update-upgrade/ss-update-controler.sh b/tool/update-upgrade/ss-update-controler.sh
index b787498..23d279f 100755
--- a/tool/update-upgrade/ss-update-controler.sh
+++ b/tool/update-upgrade/ss-update-controler.sh
@@ -1,8 +1,6 @@
 #!/bin/bash
 set -e
 echo "因为目前没有有时间的Qt程序员志愿者所以现在加功能只有让shenmo写脚本了..."
-echo "下面一段是shenmo想了半天写出来的(为了让用户认真读操碎了心~"
-echo "请务必认真阅读("
 echo
 echo "此功能被添加的原因是:为了防止影响系统更新,星火源默认的优先级是400,低于默认的500。这导致了与系统仓库相同包名的软件包无法正常更新到比系统仓库更高的版本。例如:hugo,系统仓库中的低版本会被优先安装,而且默认不会更新到星火的更新的版本"
 echo "此脚本可以检测星火源中是否有比当前系统更高版本的软件包,由您决定是否安装"
@@ -31,21 +29,24 @@ case $option in
 	1)
 	echo "执行以下操作需要授权..."
 
-	if [  -f $XDG_CONFIG_HOME/autostart/spark-update-notifier.desktop ];then 
+	if [  -f /etc/xdg/autostart/spark-update-notifier.desktop ];then 
 	echo "检测到已经启动了自动更新检测,关闭中"
 	sudo systemctl disable spark-update-notifier
-	rm $XDG_CONFIG_HOME/autostart/spark-update-notifier.desktop
+	rm /etc/xdg/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
+#	ln -s /opt/durapps/spark-store/bin/update-upgrade/autostart/spark-update-notifier.desktop $XDG_CONFIG_HOME/autostart
+#	
+	ln -s /opt/durapps/spark-store/bin/update-upgrade/autostart/spark-update-notifier.desktop /etc/xdg/autostart
 	/opt/durapps/spark-store/bin/update-upgrade/ss-update-notify.sh
 	fi
 	;;
 
 	2)
+	echo "执行以下操作需要授权..."
 	/opt/durapps/spark-store/bin/update-upgrade/ss-upgrade-list.sh
 	/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade.sh