summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSukhyungKang <shine.kang@samsung.com>2023-11-07 16:20:01 +0900
committerSukhyungKang <shine.kang@samsung.com>2023-11-13 09:39:09 +0900
commitbdbbc67c3b6c2cbc793865b99fdd58b55e3c62f9 (patch)
treea20f06174bce05a8bc8cc8bee81e3c08d414803d
parentf229c8a35622b7677254eb27eeb7c5ae4cb1085f (diff)
downloadnotification-bdbbc67c3b6c2cbc793865b99fdd58b55e3c62f9.tar.gz
notification-bdbbc67c3b6c2cbc793865b99fdd58b55e3c62f9.tar.bz2
notification-bdbbc67c3b6c2cbc793865b99fdd58b55e3c62f9.zip
Update script to add database version
Change-Id: I6fc568d64b2a67b4ebe2535b8a0fae54ca8b1c7d Signed-off-by: SukhyungKang <shine.kang@samsung.com>
-rw-r--r--CMakeLists.txt6
-rw-r--r--packaging/notification.spec4
-rw-r--r--scripts/505.notification_upgrade.sh.in (renamed from scripts/505.notification_upgrade.sh)17
3 files changed, 22 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c07856c..e5e2ab9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,3 +9,9 @@ ENABLE_TESTING()
SET(NOTIFICATION_UNIT_TESTS notification-unittests)
ADD_TEST(NAME ${NOTIFICATION_UNIT_TESTS} COMMAND ${NOTIFICATION_UNIT_TESTS})
ADD_DEPENDENCIES(${NOTIFICATION_UNIT_TESTS} notification)
+
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/scripts/505.notification_upgrade.sh.in 505.notification_upgrade.sh @ONLY)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/505.notification_upgrade.sh DESTINATION /usr/share/upgrade/scripts/)
+
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/scripts/505.notification_upgrade.sh.in upgrade.sh @ONLY)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/upgrade.sh DESTINATION /etc/notification/)
diff --git a/packaging/notification.spec b/packaging/notification.spec
index 78087d9..5f08cd7 100644
--- a/packaging/notification.spec
+++ b/packaging/notification.spec
@@ -121,9 +121,6 @@ mkdir -p %{buildroot}%{_bindir}/tizen-unittests/%{name}
install -m 0755 run-unittest.sh %{buildroot}%{_bindir}/tizen-unittests/%{name}/
sed -i -e 's/<NAME>/notification/g' %{buildroot}%{_bindir}/tizen-unittests/%{name}/run-unittest.sh
-mkdir -p %{buildroot}%{upgrade_script_path}
-cp -f scripts/505.notification_upgrade.sh %{buildroot}%{upgrade_script_path}
-
%clean
rm -rf %{buildroot}
@@ -146,6 +143,7 @@ fi
%{_bindir}/notification_init
%attr(0755,root,root) %{upgrade_script_path}/505.notification_upgrade.sh
#%{_bindir}/notification-test-app
+%attr(0755,root,root) /etc/notification/upgrade.sh
%files devel
%defattr(-,root,root,-)
diff --git a/scripts/505.notification_upgrade.sh b/scripts/505.notification_upgrade.sh.in
index 95ed350..57541a0 100644
--- a/scripts/505.notification_upgrade.sh
+++ b/scripts/505.notification_upgrade.sh.in
@@ -9,15 +9,18 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin
DB_DIR=/opt/dbspace
DB_NOTIFICATION=$DB_DIR/.notification.db
+DB_VERSION=1
CheckListTable() {
ADDED_COLUMN=`sqlite3 $DB_NOTIFICATION 'PRAGMA table_info(noti_list)' | grep b_event_handler_click_on_button_7`
CHECKBOX_COLUMN=`sqlite3 $DB_NOTIFICATION 'PRAGMA table_info(noti_list)' | grep check_box`
+ CURRENT_VERSION=`sqlite3 $DB_NOTIFICATION 'PRAGMA user_version'`
+
echo "## Check list table"
- if [ -z "${ADDED_COLUMN}" ] || [ -z "${CHECKBOX_COLUMN}"]; then
+ if [ -z "${ADDED_COLUMN}" ] || [ -z "${CHECKBOX_COLUMN}" ] || [ ${CURRENT_VERSION} -ne ${DB_VERSION} ]; then
echo "column empty"
return 1
else
@@ -31,9 +34,11 @@ CheckTemplateTable() {
CHECKBOX_COLUMN=`sqlite3 $DB_NOTIFICATION 'PRAGMA table_info(noti_template)' | grep check_box`
+ CURRENT_VERSION=`sqlite3 $DB_NOTIFICATION 'PRAGMA user_version'`
+
echo "## Check template table"
- if [ -z "${ADDED_COLUMN}" ] || [ -z "${CHECKBOX_COLUMN}"]; then
+ if [ -z "${ADDED_COLUMN}" ] || [ -z "${CHECKBOX_COLUMN}" ] || [ ${CURRENT_VERSION} -ne ${DB_VERSION} ]; then
echo "column empty"
return 1
else
@@ -42,6 +47,13 @@ CheckTemplateTable() {
fi
}
+UpdateDBVersion() {
+sqlite3 $DB_NOTIFICATION << EOF
+
+PRAGMA user_version = ${DB_VERSION};
+EOF
+}
+
UpdateListTable() {
sqlite3 $DB_NOTIFICATION << EOF
@@ -224,6 +236,7 @@ UpdateNotiDB() {
RESULT=$?
if [ ${RESULT} == 1 ]; then
UpdateListTable
+ UpdateDBVersion
echo "update list table"
else
echo "list table already updated"