From 5532866353434bb7f4ee42919526e2dca5f38b16 Mon Sep 17 00:00:00 2001 From: Somin Kim Date: Thu, 17 Aug 2017 21:27:14 +0900 Subject: [PATCH] RW update script Change-Id: I2ac289e47bb1dcbae1b292cdd83bf49342b65476 Signed-off-by: Somin Kim --- packaging/context-service.spec | 6 ++++++ scripts/500.context-service.sh | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 scripts/500.context-service.sh diff --git a/packaging/context-service.spec b/packaging/context-service.spec index 8b54afa..c7bf0a3 100644 --- a/packaging/context-service.spec +++ b/packaging/context-service.spec @@ -10,6 +10,8 @@ Source2: org.tizen.context.conf Source3: contextd-agent.service Source4: contextd-agent.socket +%define upgrade_script_path /usr/share/upgrade/scripts + BuildRequires: cmake BuildRequires: pkgconfig(libsystemd-daemon) BuildRequires: pkgconfig(libsystemd-login) @@ -70,12 +72,16 @@ install -m 0644 %{SOURCE3} %{buildroot}%{_unitdir_user} install -m 0644 %{SOURCE4} %{buildroot}%{_unitdir_user} ln -s ../contextd-agent.socket %{buildroot}%{_unitdir_user}/sockets.target.wants/contextd-agent.socket +mkdir -p %{buildroot}%{upgrade_script_path} +cp -f scripts/500.context-service.sh %{buildroot}%{upgrade_script_path} + %files %manifest packaging/%{name}.manifest %config %{_sysconfdir}/dbus-1/system.d/* %{_bindir}/contextd %{_unitdir}/contextd.service %{_unitdir}/*/contextd.service +%{upgrade_script_path}/500.context-service.sh %license LICENSE %files -n context-agent diff --git a/scripts/500.context-service.sh b/scripts/500.context-service.sh new file mode 100644 index 0000000..fe11dfc --- /dev/null +++ b/scripts/500.context-service.sh @@ -0,0 +1,38 @@ +#!/bin/sh +PATH=/bin:/usr/bin:/sbin:/usr/sbin +source /usr/share/upgrade/rw-update-macro.inc + +# Macro +DB_DIR_30=/opt/usr/home/owner/.applications/dbspace +DB_CONTEXT_30=$DB_DIR_30/.context-service.db + +DB_DIR_40=/opt/usr/home/owner/.applications/dbspace +DB_CONTEXT_40_SENSOR_RECORDER=$DB_DIR_40/.context-sensor-recorder.db + +# Get version info +get_version_info + +#------------------------------------------------# +# context-service patch for upgrade (3.0 -> 4.0) # +#------------------------------------------------# +if [ "$OLD_VER" = "3.0" ]; then + +# Move DB (context-service -> context-sensor-recorder) +mv $DB_CONTEXT_30 $DB_CONTEXT_40_SENSOR_RECORDER +mv $DB_CONTEXT_30-shm $DB_CONTEXT_40_SENSOR_RECORDER-shm +mv $DB_CONTEXT_30-wal $DB_CONTEXT_40_SENSOR_RECORDER-wal + +chown service_fw:service_fw $DB_CONTEXT_40_SENSOR_RECORDER +chown service_fw:service_fw $DB_CONTEXT_40_SENSOR_RECORDER-shm +chown service_fw:service_fw $DB_CONTEXT_40_SENSOR_RECORDER-wal + +chsmack -a User::Home $DB_CONTEXT_40_SENSOR_RECORDER +chsmack -a User::Home $DB_CONTEXT_40_SENSOR_RECORDER-shm +chsmack -a User::Home $DB_CONTEXT_40_SENSOR_RECORDER-wal + +# Drop tables not related to sensor recorder +sqlite3 $DB_CONTEXT_40_SENSOR_RECORDER "DROP TABLE ContextTriggerRule;" +sqlite3 $DB_CONTEXT_40_SENSOR_RECORDER "DROP TABLE ContextTriggerTemplate;" +sqlite3 $DB_CONTEXT_40_SENSOR_RECORDER "DROP TABLE ContextTriggerCustomTemplate;" + +fi -- 2.7.4