Fix for reset scripts.
authorAndrzej Surdej <a.surdej@samsung.com>
Thu, 25 Apr 2013 11:17:19 +0000 (13:17 +0200)
committerGerrit Code Review <gerrit2@kim11>
Tue, 30 Apr 2013 06:46:42 +0000 (15:46 +0900)
[Issue#] LINUXWRT-278
[Problem] N/A
[Cause] N/A
[Solution] Uninstall widget before database reseting. Remove smack files. (Use --old to not uninstall)
[Verification] Install some widgets. Run wrt_reset_all.sh with and without '--old' opt.

Change-Id: Icedab43ca89e0462757d93f6f0a263e8d2bf8b8f

etc/wrt_commons_reset_db.sh

index fb2d4bf..8fd3f3c 100755 (executable)
 #
 
 rm -rf /opt/share/widget/system/*
-
+uninstall_widgets=1
+if [ "$1" == "--old" ]
+then
+    echo "Uninstalling turned off"
+    uninstall_widgets=0
+fi
 #Removing of widget desktop icons
 WIDGET_EXEC_PATH=/opt/usr/apps/
 WIDGET_PRELOAD_EXEC_PATH=/usr/apps/
 WIDGET_DESKTOP_PATH=/opt/share/applications/
+SMACK_RULES_PATH=/etc/smack/accesses.d/
 WRT_DB=/opt/dbspace/.wrt.db
 PLUGINS_INSTALLATION_REQUIRED_PATH=/opt/share/widget/
 PLUGINS_INSTALLATION_REQUIRED=plugin-installation-required
@@ -29,6 +35,10 @@ then
     PKG_NAME_SET=$(sqlite3 $WRT_DB 'select tizen_appid from WidgetInfo;')
     for appid in $PKG_NAME_SET
     do
+        if [ $uninstall_widgets -eq 1 ]
+        then
+            wrt-installer -un $appid 2&>1 >/dev/null
+        fi
         pkgId=`echo "$appid" | cut -f1 -d"."`
         rm -rf ${WIDGET_EXEC_PATH}${pkgId}
         rm -rf ${WIDGET_PRELOAD_EXEC_PATH}${pkgId}
@@ -36,6 +46,10 @@ then
         if [ -f ${widget_desktop_file} ]; then
             rm -f $widget_desktop_file;
         fi
+        widget_smack_rule="${SMACK_RULES_PATH}${pkgId}"
+        if [ -f ${widget_smack_rule} ]; then
+            rm -f $widget_smack_rule;
+        fi
     done
 else
     echo "${WRT_DB} doesn't exist"