From 87a644e4117279d7b8d7c943df2791834de294f7 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 8 Sep 2016 16:29:35 +0900 Subject: [PATCH] Add a script to upgrade alarmmgr db Change-Id: Ib729f0af1409361d05f28cc695a0d79714947f99 Signed-off-by: Hwankyu Jhun --- packaging/alarm-manager.spec | 6 ++++ scripts/108.alarmmgr_upgrade.sh | 68 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100755 scripts/108.alarmmgr_upgrade.sh diff --git a/packaging/alarm-manager.spec b/packaging/alarm-manager.spec index 67bb34a..d6426cc 100644 --- a/packaging/alarm-manager.spec +++ b/packaging/alarm-manager.spec @@ -31,6 +31,8 @@ BuildRequires: pkgconfig(libsystemd) BuildRequires: pkgconfig(eventsystem) BuildRequires: python-xml +%define upgrade_script_path /usr/share/upgrade/scripts + %description Alarm Server and devel libraries @@ -100,6 +102,9 @@ install -m 0644 %SOURCE4 %{buildroot}%{_tmpfilesdir}/alarm-agent.conf mkdir -p %{buildroot}%{_libdir}/udev/rules.d install -m 0644 %SOURCE5 %{buildroot}%{_libdir}/udev/rules.d +mkdir -p %{buildroot}%{upgrade_script_path} +cp -f scripts/108.alarmmgr_upgrade.sh %{buildroot}%{upgrade_script_path} + %post -p /sbin/ldconfig %postun -p /sbin/ldconfig @@ -130,6 +135,7 @@ install -m 0644 %SOURCE5 %{buildroot}%{_libdir}/udev/rules.d %if 0%{?appfw_feature_alarm_manager_module_log} %attr(0755,root,root) %{_sysconfdir}/dump.d/module.d/alarmmgr_log_dump.sh %endif +%{upgrade_script_path}/108.alarmmgr_upgrade.sh %files -n libalarm %manifest alarm-lib.manifest diff --git a/scripts/108.alarmmgr_upgrade.sh b/scripts/108.alarmmgr_upgrade.sh new file mode 100755 index 0000000..ac1a229 --- /dev/null +++ b/scripts/108.alarmmgr_upgrade.sh @@ -0,0 +1,68 @@ +#!/bin/sh + +#------------------------------------------# +# alarmmgr upgrade (2.4 -> 3.0) # +#------------------------------------------# + +# Macro +PATH=/bin:/usr/bin:/sbin:/usr/sbin + +DB_DIR=/opt/dbspace +DB_ALARMMGR=$DB_DIR/.alarmmgr.db + +# Upgrade table +sqlite3 $DB_ALARMMGR << EOF +DROP TABLE IF EXISTS alarmmgr_temp; + +CREATE TABLE alarmmgr_temp ( + alarm_id integer primary key, + start integer, + end integer, + uid integer, + pid integer, + global integer, + caller_pkgid text, + callee_pkgid text, + app_unique_name text, + app_service_name text, + app_service_name_mod text, + bundle text, + year integer, + month integer, + day integer, + hour integer, + min integer, + sec integer, + day_of_week integer, + repeat integer, + alarm_type integer, + reserved_info integer, + dst_service_name text, + dst_service_name_mod text +); + +INSERT INTO alarmmgr_temp \ + (alarm_id, start, end, pid, caller_pkgid, \ + callee_pkgid, app_unique_name, app_service_name, \ + app_service_name_mod, bundle, year, month, \ + day, hour, min, sec, day_of_week, repeat, \ + alarm_type, reserved_info, dst_service_name, \ + dst_service_name_mod) \ + SELECT alarm_id, start, end, pid, caller_pkgid, \ + callee_pkgid, app_unique_name, app_service_name, \ + app_service_name_mod, bundle, year, month, \ + day, hour, min, sec, day_of_week, repeat, \ + alarm_type, reserved_info, dst_service_name, dst_service_name_mod \ + FROM alarmmgr; + +UPDATE alarmmgr_temp SET uid=5001,global=0; +DROP TABLE alarmmgr; +ALTER TABLE alarmmgr_temp RENAME TO alarmmgr; + +EOF + +chown app_fw:app_fw $DB_ALARMMGR +chown app_fw:app_fw $DB_ALARMMGR-journal + +chsmack -a System $DB_ALARMMGR +chsmack -a System $DB_ALARMMGR-journal -- 2.7.4