Custom handlers' db moved to user space.
authorLukasz Marek <l.marek@samsung.com>
Wed, 17 Apr 2013 12:37:57 +0000 (14:37 +0200)
committerGerrit Code Review <gerrit2@kim11>
Thu, 18 Apr 2013 13:05:59 +0000 (22:05 +0900)
[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution] Custom handlers' db moved to user space.
[SCMRequest] N/A

[Verification]
1. Build and install repository
2. Delete old db (rm /usr/dbspace/.wrt_custom_handlers*)
3. Apply commit to wrt-extra http://slp-info.sec.samsung.net/gerrit/#/c/184465/
4. Install and run widget manual_tests/wrt_test_widgets/custom_handlers/custom_handlers.wgt
5. Register handlers for content and scheme (inside widget)
6. Open db /opt/usr/dbspace/.wrt_custom_handlers and check if new records apeared in tables.

Change-Id: I07ce20f03846c3b82fff300810ac9ade99131cee

etc/wrt_commons_create_clean_db.sh
modules/custom_handler_dao/dao/CustomHandlerDatabase.cpp
packaging/wrt-commons.spec

index 710fb97..bb8d16e 100755 (executable)
 #    limitations under the License.
 #
 
-for name in wrt wrt_custom_handler
-do
+DB_PATH=/opt/dbspace/
+DB_USER_PATH=/opt/usr/dbspace/
+
+function create_db {
+    name=$1
+    dbpath=$2
     # extract smack label before removal
     DB_LABEL=""
-    if [ -f /opt/dbspace/.$name.db ]
+    if [ -f $dbpath.$name.db ]
     then
-        DB_LABEL=`chsmack /opt/dbspace/.$name.db | sed -r "s/.*access=\"([^\"]+)\"/\1/"`
+        DB_LABEL=`chsmack $dbpath.$name.db | sed -r "s/.*access=\"([^\"]+)\"/\1/"`
     fi
-    rm -f /opt/dbspace/.$name.db
+    rm -f $dbpath.$name.db
 
     # extract smack label before removal
     JOURNAL_LABEL=""
-    if [ -f /opt/dbspace/.$name.db-journal ]
+    if [ -f $dbpath.$name.db-journal ]
     then
-        JOURNAL_LABEL=`chsmack /opt/dbspace/.$name.db-journal | sed -r "s/.*access=\"([^\"]+)\"/\1/"`
+        JOURNAL_LABEL=`chsmack $dbpath.$name.db-journal | sed -r "s/.*access=\"([^\"]+)\"/\1/"`
     fi
-    rm -f /opt/dbspace/.$name.db-journal
+    rm -f $dbpath.$name.db-journal
 
     SQL="PRAGMA journal_mode = PERSIST;"
-    sqlite3 /opt/dbspace/.$name.db "$SQL"
+    sqlite3 $dbpath.$name.db "$SQL"
     SQL=".read /usr/share/wrt-engine/"$name"_db.sql"
-    sqlite3 /opt/dbspace/.$name.db "$SQL"
-    touch /opt/dbspace/.$name.db-journal
-    chown 0:6026 /opt/dbspace/.$name.db
-    chown 0:6026 /opt/dbspace/.$name.db-journal
-    chmod 660 /opt/dbspace/.$name.db
-    chmod 660 /opt/dbspace/.$name.db-journal
+    sqlite3 $dbpath.$name.db "$SQL"
+    touch $dbpath.$name.db-journal
+    chown 0:6026 $dbpath.$name.db
+    chown 0:6026 $dbpath.$name.db-journal
+    chmod 660 $dbpath.$name.db
+    chmod 660 $dbpath.$name.db-journal
 
     pkill -9 security-serv
 
     # restore smack label
     if [ -n "$DB_LABEL" ]
     then
-        chsmack -a $DB_LABEL /opt/dbspace/.$name.db
+        chsmack -a $DB_LABEL $dbpath.$name.db
     fi
 
     # restore smack label
     if [ -n "$JOURNAL_LABEL" ]
     then
-        chsmack -a $JOURNAL_LABEL /opt/dbspace/.$name.db-journal
+        chsmack -a $JOURNAL_LABEL $dbpath.$name.db-journal
     fi
-done
+}
 
+for name in wrt
+do
+    create_db $name $DB_PATH
+done
 
+for name in wrt_custom_handler
+do
+    create_db $name $DB_USER_PATH
+done
index d6f70a8..5f26fd7 100644 (file)
@@ -18,7 +18,7 @@
 namespace CustomHandlerDB {
 namespace Interface {
 namespace {
-const char* CustomHandler_DB_DATABASE = "/opt/dbspace/.wrt_custom_handler.db";
+const char* CustomHandler_DB_DATABASE = "/opt/usr/dbspace/.wrt_custom_handler.db";
 DPL::DB::SqlConnection::Flag::Type CustomHandler_DB_FLAGS =
     DPL::DB::SqlConnection::Flag::UseLucene;
 }
index 8ffb518..7a1a12c 100644 (file)
@@ -123,8 +123,8 @@ fi
 # Set Smack label for db files
 chsmack -a 'wrt-commons::db_wrt' /opt/dbspace/.wrt.db
 chsmack -a 'wrt-commons::db_wrt' /opt/dbspace/.wrt.db-journal
-chsmack -a 'wrt-commons::db_wrt_custom_handler' /opt/dbspace/.wrt_custom_handler.db
-chsmack -a 'wrt-commons::db_wrt_custom_handler' /opt/dbspace/.wrt_custom_handler.db-journal
+chsmack -a 'wrt-commons::db_wrt_custom_handler' /opt/usr/dbspace/.wrt_custom_handler.db
+chsmack -a 'wrt-commons::db_wrt_custom_handler' /opt/usr/dbspace/.wrt_custom_handler.db-journal
 
 echo "[WRT] wrt-commons postinst done ..."