adding OS upgrade script 07/213507/1
authorAbhishek Vijay <abhishek.v@samsung.com>
Fri, 6 Sep 2019 05:14:23 +0000 (10:44 +0530)
committerAbhishek Vijay <abhishek.v@samsung.com>
Fri, 6 Sep 2019 05:14:23 +0000 (10:44 +0530)
Change-Id: I3e678f63c1465e17778916e4dd7abafcc1a41a2b
Signed-off-by: Abhishek Vijay <abhishek.v@samsung.com>
packaging/account-manager.spec
scripts/500.account-manager.sh [new file with mode: 0644]

index 1842190..a464950 100644 (file)
@@ -1,6 +1,6 @@
 Name:       account-manager
 Summary:    Account Manager
-Version:    0.1.18
+Version:    0.1.19
 Release:    1
 Group:      Social & Content/Other
 License:    Apache-2.0
@@ -28,6 +28,7 @@ Requires(post): /sbin/ldconfig
 Requires(post): /usr/bin/sqlite3
 Requires(postun): /sbin/ldconfig
 
+%define upgrade_script_path            /usr/share/upgrade/scripts
 
 %description
 Account Daemon: no
@@ -67,6 +68,9 @@ mkdir -p %{buildroot}%{_unitdir}/delayed.target.wants
 install -m 644 %SOURCE3 %{buildroot}%{_unitdir}/accounts-service.service
 %install_service delayed.target.wants accounts-service.service
 
+mkdir -p %{buildroot}%{upgrade_script_path}
+cp -f scripts/500.account-manager.sh %{buildroot}%{upgrade_script_path}
+
 %post
 /sbin/ldconfig
 #if [ ! -d /opt/usr/dbspace ]
@@ -109,6 +113,7 @@ chsmack -a 'System' %{TZ_SYS_DB}/.account.db
 %config %{_sysconfdir}/dbus-1/system.d/org.tizen.account.manager.conf
 %license LICENSE.APLv2
 %{_bindir}/account-svcd
+%{upgrade_script_path}/500.account-manager.sh
 %attr(0644,root,root) %{_unitdir}/accounts-service.service
 %attr(0644,root,root) %{_unitdir}/delayed.target.wants/accounts-service.service
 %attr(0644,root,root) /usr/share/dbus-1/system-services/org.tizen.account.manager.service
diff --git a/scripts/500.account-manager.sh b/scripts/500.account-manager.sh
new file mode 100644 (file)
index 0000000..9b1917f
--- /dev/null
@@ -0,0 +1,161 @@
+#!/bin/sh
+#
+#
+# RW update script for 4.0 -> 5.5
+#
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+source /usr/share/upgrade/rw-update-macro.inc
+
+# Macro
+GLOBAL_DB_DIR_55=/opt/dbspace
+GLOBAL_DB_ACCOUNT_MANAGER_55=$GLOBAL_DB_DIR_55/.account.db
+
+USER_DB_DIR_55=/opt/dbspace/5001
+USER_DB_ACCOUNT_MANAGER_55=$USER_DB_DIR_55/.account.db
+
+# Get version info
+get_version_info
+
+#------------------------------------------------#
+# account-manager patch for upgrade (4.0 -> 5.5) #
+#------------------------------------------------#
+if [ "$OLD_VER" = "4.0.0.0" ]; then
+
+#  add new tables in global database
+sqlite3 $GLOBAL_DB_ACCOUNT_MANAGER_55 << EOF
+
+CREATE TABLE IF NOT EXISTS deleted_account
+(
+_id INTEGER,
+user_name TEXT,
+email_address TEXT,
+display_name TEXT,
+icon_path TEXT,
+source TEXT,
+package_name TEXT,
+access_token TEXT,
+domain_name TEXT,
+auth_type INTEGER,
+secret INTEGER,
+sync_support INTEGER,
+txt_custom0 TEXT,
+txt_custom1 TEXT,
+txt_custom2 TEXT,
+txt_custom3 TEXT,
+txt_custom4 TEXT,
+int_custom0 INTEGER,
+int_custom1 INTEGER,
+int_custom2 INTEGER,
+int_custom3 INTEGER,
+int_custom4 INTEGER
+);
+
+CREATE TABLE IF NOT EXISTS deleted_capability
+(
+_id INTEGER,
+key TEXT,
+value INTEGER,
+package_name TEXT,
+user_name TEXT,
+account_id INTEGER
+);
+
+CREATE TABLE IF NOT EXISTS deleted_account_custom
+(
+AccountId INTEGER,
+AppId TEXT,
+Key TEXT,
+Value TEXT
+);
+
+CREATE TRIGGER IF NOT EXISTS aft_acc_del AFTER DELETE ON account
+ BEGIN
+       INSERT INTO deleted_account VALUES (old._id, old.user_name, old.email_address, old.display_name, old.icon_path, old.source, old.package_name,
+                                               old.access_token, old.domain_name, old.auth_type, old.secret, old.sync_support, old.txt_custom0,
+                                               old.txt_custom1, old.txt_custom2, old.txt_custom3, old.txt_custom4, old.int_custom0, old.int_custom1,
+                                               old.int_custom2, old.int_custom3, old.int_custom4);
+ END;
+
+CREATE TRIGGER IF NOT EXISTS aft_capa_del AFTER DELETE ON capability
+ BEGIN
+       INSERT INTO deleted_capability VALUES (old._id, old.key, old.value, old.package_name, old.user_name, old.account_id);
+ END;
+
+CREATE TRIGGER IF NOT EXISTS aft_cust_del AFTER DELETE ON account_custom
+ BEGIN
+       INSERT INTO deleted_account_custom VALUES (old.AccountId, old.AppId, old.Key, old.Value);
+ END;
+
+EOF
+
+if [ -d "$USER_DB_DIR_55"]; then
+
+#  add new tables in user database
+sqlite3 $USER_DB_ACCOUNT_MANAGER_55 << EOF
+
+CREATE TABLE IF NOT EXISTS deleted_account
+(
+_id INTEGER,
+user_name TEXT,
+email_address TEXT,
+display_name TEXT,
+icon_path TEXT,
+source TEXT,
+package_name TEXT,
+access_token TEXT,
+domain_name TEXT,
+auth_type INTEGER,
+secret INTEGER,
+sync_support INTEGER,
+txt_custom0 TEXT,
+txt_custom1 TEXT,
+txt_custom2 TEXT,
+txt_custom3 TEXT,
+txt_custom4 TEXT,
+int_custom0 INTEGER,
+int_custom1 INTEGER,
+int_custom2 INTEGER,
+int_custom3 INTEGER,
+int_custom4 INTEGER
+);
+
+CREATE TABLE IF NOT EXISTS deleted_capability
+(
+_id INTEGER,
+key TEXT,
+value INTEGER,
+package_name TEXT,
+user_name TEXT,
+account_id INTEGER
+);
+
+CREATE TABLE IF NOT EXISTS deleted_account_custom
+(
+AccountId INTEGER,
+AppId TEXT,
+Key TEXT,
+Value TEXT
+);
+
+CREATE TRIGGER IF NOT EXISTS aft_acc_del AFTER DELETE ON account
+ BEGIN
+       INSERT INTO deleted_account VALUES (old._id, old.user_name, old.email_address, old.display_name, old.icon_path, old.source, old.package_name,
+       old.access_token, old.domain_name, old.auth_type, old.secret, old.sync_support, old.txt_custom0, old.txt_custom1, old.txt_custom2, old.txt_custom3,
+       old.txt_custom4, old.int_custom0, old.int_custom1, old.int_custom2, old.int_custom3, old.int_custom4);
+ END;
+
+CREATE TRIGGER IF NOT EXISTS aft_capa_del AFTER DELETE ON capability
+ BEGIN
+       INSERT INTO deleted_capability VALUES (old._id, old.key, old.value, old.package_name, old.user_name, old.account_id);
+ END;
+
+CREATE TRIGGER IF NOT EXISTS aft_cust_del AFTER DELETE ON account_custom
+ BEGIN
+       INSERT INTO deleted_account_custom VALUES (old.AccountId, old.AppId, old.Key, old.Value);
+ END;
+
+EOF
+
+fi #end of "if [ -d "$USER_DB_DIR_55"]"
+
+fi #end of "if [ "$OLD_VER" = "4.0.0.0" ]"