Add preload web app for installer
authorSoyoung Kim <sy037.kim@samsung.com>
Fri, 19 Apr 2013 15:21:21 +0000 (00:21 +0900)
committerSoyoung Kim <sy037.kim@samsung.com>
Fri, 19 Apr 2013 17:25:48 +0000 (02:25 +0900)
[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution]
1. Add command "-ip" for preload webapp.
2. skip verify certificate during install preload webapp.
3. Add show install error during generate binary.
4. Preload web app cann't uninstall.
5. preload widget source file will be removed if installation success after install webapp.
[SCMRequest] This package should release with wrt-commons.

Change-Id: Ibd6d82f49d0c7d9026edd64d508afb75170a7095

15 files changed:
etc/wrt_preinstall_widgets.sh
packaging/wrt-installer.spec
src/jobs/plugin_install/plugin_install_task.cpp
src/jobs/widget_install/task_certify.cpp
src/jobs/widget_install/task_file_manipulation.cpp
src/jobs/widget_install/task_file_manipulation.h
src/jobs/widget_install/task_manifest_file.cpp
src/jobs/widget_uninstall/job_widget_uninstall.cpp
src/jobs/widget_uninstall/job_widget_uninstall.h
src/jobs/widget_uninstall/task_remove_files.cpp
src/jobs/widget_uninstall/widget_uninstall_errors.h
src/wrt-installer/plugin_utils.cpp
src/wrt-installer/plugin_utils.h
src/wrt-installer/wrt-installer.cpp
src/wrt-installer/wrt_installer_api.cpp

index 61935a3..996d6a3 100755 (executable)
@@ -26,7 +26,7 @@ install_widgets() {
        for list in $_wgt_list
        do
                echo "Install $list"
-               return_string=`wrt-installer -il $list 2>&1 | grep -v plugin`
+               return_string=`wrt-installer -i $list 2>&1 | grep -v plugin`
         if [ "$return_string" != "${return_string/successful/}" ]; then
             echo "$list widget installation success"
             rm -rf $list
index faa58eb..46197ce 100644 (file)
@@ -87,6 +87,7 @@ ln -s ../init.d/wrt_preinstall_widgets.sh %{buildroot}%{_sysconfdir}/rc.d/rc5.d/
 rm -rf %{buildroot}
 
 %post
+/sbin/ldconfig
 chmod +s /usr/bin/wrt-installer
 
 #symlink for package manager
@@ -102,6 +103,8 @@ ln -s /etc/rc.d/init.d/wrt_preinstall_widgets.sh /etc/rc.d/rc5.d/S48lwrt_preinst
 # for downloadable Application icons path
 mkdir -p /opt/share/icons/default/small
 
+%postun -p /sbin/ldconfig
+
 %files
 %manifest wrt-installer.manifest
 %attr(755,root,root) %{_bindir}/wrt-installer
index c7a1fd8..4c87f62 100644 (file)
@@ -185,7 +185,7 @@ void PluginInstallTask::stepLoadPluginLibrary()
 
     LogDebug("Loading plugin: " << filename);
 
-    void *dlHandle = dlopen(filename.c_str(), RTLD_NOW);
+    void *dlHandle = dlopen(filename.c_str(), RTLD_LAZY);
     if (dlHandle == NULL) {
         LogError(
             "Failed to load plugin: " << filename <<
index 4705fcb..343eadc 100644 (file)
@@ -258,7 +258,9 @@ void TaskCertify::stepSignature()
             result = validator.check(data, widgetPath);
 
             if (m_contextData.widgetConfig.packagingType
-                == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
+                == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP ||
+               m_contextData.job->getInstallerStruct().m_installMode
+               == InstallMode::INSTALL_MODE_PRELOAD)
             {
                 // In directory installation mode, the validation is skipped.
 
index f044af9..dcb4884 100644 (file)
@@ -30,7 +30,9 @@
 #include <dpl/foreach.h>
 #include <dpl/log/log.h>
 #include <dpl/assert.h>
+#include <dpl/errno_string.h>
 #include <dpl/utils/folder_size.h>
+#include <dpl/wrt-dao-ro/global_config.h>
 #include <string>
 #include <fstream>
 #include <widget_install_to_external.h>
@@ -95,6 +97,45 @@ bool _FolderCopy(std::string source, std::string dest)
     closedir(dir);
     return true;
 }
+
+void changeOwnerForDirectory(std::string storagePath) {
+    if (euidaccess(storagePath.c_str(), F_OK) != 0) {
+        if (!WrtUtilMakeDir(storagePath, PRIVATE_STORAGE_MODE)) {
+            LogError("Failed to create directory for private storage");
+            ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed,
+                     "Failed to create directory for private storage");
+        }
+        // '5000' is default uid, gid for applications.
+        // So installed applications should be launched as process of uid
+        // '5000'.
+        // the process can access private directory 'data' of itself.
+        if (chown(storagePath.c_str(),
+                  WEBAPP_DEFAULT_UID,
+                  WEBAPP_DEFAULT_GID) != 0)
+        {
+            ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed,
+                     "Chown to invaild user");
+        }
+    } else if (euidaccess(storagePath.c_str(), W_OK | R_OK | X_OK) == 0) {
+        LogInfo("Private storage already exists.");
+        // Even if private directory already is created, private dircetory
+        // should change owner.
+        if (chown(storagePath.c_str(),
+                  WEBAPP_DEFAULT_UID,
+                  WEBAPP_DEFAULT_GID) != 0)
+        {
+            ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed,
+                     "Chown to invaild user");
+        }
+        if (chmod(storagePath.c_str(), PRIVATE_STORAGE_MODE) != 0) {
+            ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed,
+                     "chmod to 0700");
+        }
+    } else {
+        ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed,
+                 "No access to private storage.");
+    }
+}
 }
 
 namespace Jobs {
@@ -115,6 +156,8 @@ TaskFileManipulation::TaskFileManipulation(InstallerContext& context) :
             AddStep(&TaskFileManipulation::StepRenamePath);
             AddAbortStep(&TaskFileManipulation::StepAbortRenamePath);
         }
+        AddStep(&TaskFileManipulation::StepLinkForPreload);
+
     } else {
         AddStep(&TaskFileManipulation::StepPrepareExternalDir);
         AddStep(&TaskFileManipulation::StepInstallToExternal);
@@ -153,43 +196,9 @@ void TaskFileManipulation::StepCreateDirs()
 void TaskFileManipulation::StepCreatePrivateStorageDir()
 {
     std::string storagePath = m_context.locations->getPrivateStorageDir();
-
-    if (euidaccess(storagePath.c_str(), F_OK) != 0) {
-        if (!WrtUtilMakeDir(storagePath, PRIVATE_STORAGE_MODE)) {
-            LogError("Failed to create directory for private storage");
-            ThrowMsg(Exceptions::FileOperationFailed,
-                     "Failed to create directory for private storage");
-        }
-        // '5000' is default uid, gid for applications.
-        // So installed applications should be launched as process of uid
-        // '5000'.
-        // the process can access private directory 'data' of itself.
-        if (chown(storagePath.c_str(),
-                  WEBAPP_DEFAULT_UID,
-                  WEBAPP_DEFAULT_GID) != 0)
-        {
-            ThrowMsg(Exceptions::FileOperationFailed,
-                     "Chown to invaild user");
-        }
-    } else if (euidaccess(storagePath.c_str(), W_OK | R_OK | X_OK) == 0) {
-        LogInfo("Private storage already exists.");
-        // Even if private directory already is created, private dircetory
-        // should change owner.
-        if (chown(storagePath.c_str(),
-                  WEBAPP_DEFAULT_UID,
-                  WEBAPP_DEFAULT_GID) != 0)
-        {
-            ThrowMsg(Exceptions::FileOperationFailed,
-                     "Chown to invaild user");
-        }
-        if (chmod(storagePath.c_str(), PRIVATE_STORAGE_MODE) != 0) {
-            ThrowMsg(Exceptions::FileOperationFailed,
-                     "chmod to 0700");
-        }
-    } else {
-        ThrowMsg(Exceptions::FileOperationFailed,
-                 "No access to private storage.");
-    }
+    LogDebug("Create private storage directory : " <<
+            m_context.locations->getPrivateStorageDir());
+    changeOwnerForDirectory(storagePath);
 }
 
 void TaskFileManipulation::StepRenamePath()
@@ -219,6 +228,50 @@ void TaskFileManipulation::StepRenamePath()
         "Widget Rename path Finished");
 }
 
+void TaskFileManipulation::StepLinkForPreload()
+{
+    if (m_context.job->getInstallerStruct().m_installMode
+            == InstallMode::INSTALL_MODE_PRELOAD)
+    {
+        std::string srcDir = m_context.locations->getUserDataRootDir() +
+            WrtDB::GlobalConfig::GetWidgetSrcPath();
+
+        if (0 != access(srcDir.c_str(), F_OK)) {
+            LogDebug("Make symbolic name for preaload app" << " to " << srcDir <<
+                    "from " << m_context.locations->getSourceDir());
+            std::string resDir = m_context.locations->getUserDataRootDir() +
+                "/res";
+
+            WrtUtilMakeDir(resDir);
+            if (symlink(m_context.locations->getSourceDir().c_str(), srcDir.c_str()) != 0)
+            {
+                int error = errno;
+                if (error)
+                    LogPedantic("Failed to make a symbolic name for a file "
+                            << "[" <<  DPL::GetErrnoString(error) << "]");
+                ThrowMsg(Exceptions::FileOperationFailed,
+                        "Symbolic link creating is not done.");
+            }
+        }
+
+        /* link for data directory */
+        std::string storagePath = m_context.locations->getPrivateStorageDir();
+        std::string dataDir = m_context.locations->getPackageInstallationDir() +
+            "/" + WrtDB::GlobalConfig::GetWidgetPrivateStoragePath();
+
+        if (symlink(storagePath.c_str(), dataDir.c_str()) != 0)
+        {
+            int error = errno;
+            if (error)
+                LogPedantic("Failed to make a symbolic name for a file "
+                        << "[" <<  DPL::GetErrnoString(error) << "]");
+            ThrowMsg(Exceptions::FileOperationFailed,
+                    "Symbolic link creating is not done.");
+        }
+        changeOwnerForDirectory(dataDir);
+    }
+}
+
 void TaskFileManipulation::StepAbortRenamePath()
 {
     LogDebug("[Rename Widget Path] Aborting.... (Rename path)");
index bce099f..44b20f5 100644 (file)
@@ -41,6 +41,7 @@ class TaskFileManipulation :
     void StepCreatePrivateStorageDir();
 
     void StepAbortRenamePath();
+    void StepLinkForPreload();
 
     // install external location
     void StepPrepareExternalDir();
index 41767b0..c204226 100644 (file)
@@ -542,7 +542,13 @@ void TaskManifestFile::commitManifest()
     LogDebug("Commiting manifest file : " << manifest_file);
 
     std::ostringstream destFile;
-    destFile << "/opt/share/packages" << "/"; //TODO constant with path
+    if (m_context.job->getInstallerStruct().m_installMode
+            == InstallMode::INSTALL_MODE_PRELOAD)
+    {
+        destFile << "/usr/share/packages" << "/"; //TODO constant with path
+    } else {
+        destFile << "/opt/share/packages" << "/"; //TODO constant with path
+    }
     destFile << DPL::ToUTF8String(manifest_name);
     LogInfo("cp " << manifest_file << " " << destFile.str());
 
index 4dc7745..322d66c 100644 (file)
@@ -34,6 +34,7 @@ using namespace WrtDB;
 namespace { //anonymous
 const char* REG_TIZEN_PKGID_PATTERN = "^[a-zA-Z0-9]{10}$";
 const int PKGID_LENTH = 10;
+const std::string PRELOAD_INSTALLED_PATH = "/usr/apps";
 
 bool checkDirectoryExist(const std::string& pkgId)
 {
@@ -47,35 +48,40 @@ bool checkDirectoryExist(const std::string& pkgId)
     }
     return false;
 }
+}
+
+namespace Jobs {
+namespace WidgetUninstall {
 
 class UninstallerTaskFail :
     public DPL::TaskDecl<UninstallerTaskFail>
 {
   private:
-    bool m_uninstalled;
+    WidgetStatus m_status;
 
     void StepFail()
     {
-        if (m_uninstalled) {
+        if (WidgetStatus::NOT_INSTALLED == m_status) {
             ThrowMsg(Jobs::WidgetUninstall::Exceptions::WidgetNotExist,
                      "Widget does not exist");
+        } else if (WidgetStatus::PREALOAD == m_status) {
+            ThrowMsg(Jobs::WidgetUninstall::Exceptions::Unremovable,
+                     "Widget cann't uninstall");
         } else {
             Throw(Jobs::WidgetUninstall::Exceptions::Base);
         }
     }
 
   public:
-    UninstallerTaskFail(bool uninstalled) :
+    UninstallerTaskFail(WidgetStatus status) :
         DPL::TaskDecl<UninstallerTaskFail>(this),
-        m_uninstalled(uninstalled)
+        m_status(status)
+
     {
         AddStep(&UninstallerTaskFail::StepFail);
     }
 };
-}
 
-namespace Jobs {
-namespace WidgetUninstall {
 JobWidgetUninstall::JobWidgetUninstall(
     const std::string & tizenAppId,
     const WidgetUninstallationStruct &
@@ -120,27 +126,29 @@ JobWidgetUninstall::JobWidgetUninstall(
                         PKGMGR_START_KEY,
                         PKGMGR_START_UNINSTALL);
             }
-        } else if (WidgetStatus::NOT_INSTALLED == status) {
-            AddTask(new UninstallerTaskFail(true));
+        } else if (WidgetStatus::NOT_INSTALLED == status ||
+                WidgetStatus::PREALOAD == status) {
+            AddTask(new UninstallerTaskFail(status));
         } else if (WidgetStatus::ABNORMAL == status) {
             m_context.locations = WidgetLocation(m_context.tzPkgid);
             m_context.removeAbnormal = true;
             AddTask(new TaskRemoveFiles(m_context));
         } else {
-            AddTask(new UninstallerTaskFail(false));
+            AddTask(new UninstallerTaskFail(WidgetStatus::UNRECOGNIZED));
         }
     } Catch(WidgetDAOReadOnly::Exception::Base) {
-        AddTask(new UninstallerTaskFail(false));
+        AddTask(new UninstallerTaskFail(WidgetStatus::UNRECOGNIZED));
     }
 }
 
-JobWidgetUninstall::WidgetStatus JobWidgetUninstall::getWidgetStatus(const std::string &id)
+WidgetStatus JobWidgetUninstall::getWidgetStatus(const std::string &id)
 {
     regex_t regx;
     if(regcomp(&regx, REG_TIZEN_PKGID_PATTERN, REG_NOSUB | REG_EXTENDED)!=0){
         LogDebug("Regcomp failed");
     }
     std::string pkgId;
+    std::string installPath;
 
     Try {
         if ((regexec(&regx, id.c_str(),
@@ -152,10 +160,19 @@ JobWidgetUninstall::WidgetStatus JobWidgetUninstall::getWidgetStatus(const std::
                         DPL::FromUTF8String(id));
             LogDebug("Get appid from pkgid : " << appid);
             m_context.tzAppid = DPL::ToUTF8String(appid);
+            WrtDB::WidgetDAOReadOnly dao(appid);
+            installPath = DPL::ToUTF8String(*dao.getWidgetInstalledPath());
         } else {
             pkgId = id.substr(0, PKGID_LENTH);
             WrtDB::WidgetDAOReadOnly dao(DPL::FromUTF8String(id));
             m_context.tzAppid = id;
+            installPath = DPL::ToUTF8String(*dao.getWidgetInstalledPath());
+        }
+
+        if (0 == installPath.compare(0, PRELOAD_INSTALLED_PATH.length(),
+                    PRELOAD_INSTALLED_PATH)) {
+            LogError("This widget is prealoaded. So it cann't be removed");
+            return WidgetStatus::PREALOAD;
         }
     } Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) {
         LogDebug("package id : " << pkgId);
index 1ea6fe5..c787fb5 100644 (file)
 
 namespace Jobs {
 namespace WidgetUninstall {
+
+enum class WidgetStatus
+{
+    Ok, NOT_INSTALLED, PREALOAD, ABNORMAL, UNRECOGNIZED
+};
+
 class JobWidgetUninstall :
     public Job,
     public JobProgressBase<UninstallerContext::UninstallStep,
@@ -56,11 +62,6 @@ class JobWidgetUninstall :
     bool getRemoveStartedFlag() const;
     bool getRemoveFinishedFlag() const;
 
-    enum class WidgetStatus
-    {
-        Ok, NOT_INSTALLED, ABNORMAL
-    };
-
     WidgetStatus getWidgetStatus(const std::string &appId);
 
     void SendProgress();
index 7d501be..47ae2ff 100644 (file)
 #include <widget_uninstall/task_remove_files.h>
 #include <widget_uninstall/job_widget_uninstall.h>
 #include <widget_uninstall/uninstaller_context.h>
+#include <widget_uninstall/widget_uninstall_errors.h>
 #include <dpl/wrt-dao-rw/widget_dao.h>
 #include <dpl/wrt-dao-ro/widget_config.h>
 #include <dpl/wrt-dao-ro/vconf_config.h>
 #include <dpl/assert.h>
+#include <dpl/exception.h>
 #include <dpl/utils/wrt_utility.h>
 #include <ail.h>
 #include <pkgmgr/pkgmgr_parser.h>
@@ -61,32 +63,37 @@ TaskRemoveFiles::~TaskRemoveFiles()
 void TaskRemoveFiles::StepRemoveInstallationDirectory()
 {
     LogInfo("StepRemoveInstallationDirectory started");
-    if (APP2EXT_SD_CARD !=
-            app2ext_get_app_location(m_context.tzPkgid.c_str()))
-    {
-        LogDebug("Removing directory");
-        m_context.removeStarted = true;
-        std::string widgetDir =
-            m_context.locations->getPackageInstallationDir();
-        if (!WrtUtilRemove(widgetDir)) {
-            LogWarning("Removing widget installation directory failed");
-        }
-        std::string dataDir = m_context.locations->getUserDataRootDir();
-        if (!WrtUtilRemove(dataDir)) {
-            LogWarning(dataDir + " is already removed");
-        }
-    } else {
-        LogDebug("Removing sdcard directory");
-        Try {
-            WidgetInstallToExtSingleton::Instance().initialize(m_context.tzPkgid);
-            WidgetInstallToExtSingleton::Instance().uninstallation();
-            WidgetInstallToExtSingleton::Instance().deinitialize();
-        }
-        Catch(WidgetInstallToExt::Exception::ErrorInstallToExt)
+    Try {
+        if (APP2EXT_SD_CARD !=
+                app2ext_get_app_location(m_context.tzPkgid.c_str()))
         {
-            Throw(Jobs::WidgetUninstall::TaskRemoveFiles::Exception::
-                    RemoveFilesFailed);
+            LogDebug("Removing directory");
+            m_context.removeStarted = true;
+            std::string widgetDir =
+                m_context.locations->getPackageInstallationDir();
+            if (!WrtUtilRemove(widgetDir)) {
+                LogError("Removing widget installation directory failed");
+            }
+            std::string dataDir = m_context.locations->getUserDataRootDir();
+            if (!WrtUtilRemove(dataDir)) {
+                LogWarning(dataDir + " is already removed");
+            }
+        } else {
+            LogDebug("Removing sdcard directory");
+            Try {
+                WidgetInstallToExtSingleton::Instance().initialize(m_context.tzPkgid);
+                WidgetInstallToExtSingleton::Instance().uninstallation();
+                WidgetInstallToExtSingleton::Instance().deinitialize();
+            }
+            Catch(WidgetInstallToExt::Exception::ErrorInstallToExt)
+            {
+                Throw(Jobs::WidgetUninstall::TaskRemoveFiles::Exception::
+                        RemoveFilesFailed);
+            }
         }
+    } Catch(Exception::RemoveFilesFailed) {
+        ThrowMsg(Exceptions::RemoveFileFailure, "Cann't remove directory");
+
     }
     m_context.job->UpdateProgress(
         UninstallerContext::UNINSTALL_REMOVE_WIDGETDIR,
index 3f1dbf5..93f3031 100644 (file)
@@ -42,6 +42,8 @@ DECLARE_JOB_EXCEPTION(Base, WidgetNotExist, ErrorWidgetUninstallationFailed)
 DECLARE_JOB_EXCEPTION(Base, UninstallOspSvcFailed,
         ErrorWidgetUninstallationFailed)
 DECLARE_JOB_EXCEPTION(Base, PlatformAPIFailure, ErrorWidgetUninstallationFailed)
+DECLARE_JOB_EXCEPTION(Base, RemoveFileFailure, ErrorWidgetUninstallationFailed)
+DECLARE_JOB_EXCEPTION(Base, Unremovable, ErrorWidgetUninstallationFailed)
 } //namespace
 } //namespace
 } //namespace
index f168866..5368f3f 100644 (file)
@@ -34,8 +34,13 @@ const char* PLUGIN_INSTALL_LOCK_FILE = "/tmp/.wrt_plugin_install_lock";
 
 static int s_plugin_install_lock_fd = -1;
 
-bool lockPluginInstallation()
+bool lockPluginInstallation(bool isPreload)
 {
+    if (isPreload) {
+        fprintf(stderr, "Skip create lock file.. \n");
+        return true;
+    }
+
     int ret = 0;
 
     LogInfo("Try to lock for plugins installation.");
@@ -63,9 +68,13 @@ bool lockPluginInstallation()
     return true;
 }
 
-bool unlockPluginInstallation()
+bool unlockPluginInstallation(bool isPreload)
 {
     LogInfo("Unlock for plugins installation.");
+    if (isPreload) {
+        fprintf(stderr, "Skip plugin unlock.. \n");
+        return true;
+    }
 
     if (s_plugin_install_lock_fd != -1) {
         int ret = 0;
index 7b58e56..8659f20 100644 (file)
@@ -37,8 +37,8 @@ struct FileState
     };
 };
 
-bool lockPluginInstallation();
-bool unlockPluginInstallation();
+bool lockPluginInstallation(bool isPreload);
+bool unlockPluginInstallation(bool isPreload);
 bool checkPluginInstallationRequired();
 bool removeInstallationRequiredFlag();
 FileState::Type checkFile(const std::string& filename);
index 0a12e5d..1f5bc8c 100644 (file)
@@ -41,6 +41,7 @@
 #include <dpl/copy.h>
 #include <dpl/errno_string.h>
 #include <dpl/utils/wrt_global_settings.h>
+#include <dpl/utils/wrt_utility.h>
 #include <parser_runner.h>
 #include <widget_parser.h>
 #include <root_parser.h>
@@ -160,6 +161,7 @@ void WrtInstaller::OnCreate()
             if (m_argc != 2) {
                 return showHelpAndQuit();
             }
+
             if (!m_startupPluginInstallation) {
                 AddStep(&WrtInstaller::installPluginsStep);
             } else {
@@ -179,8 +181,10 @@ void WrtInstaller::OnCreate()
                 m_installMode = WRT_INSTALL_MODE_INSTALL_WGT;
             }
             m_packagePath = m_argv[2];
+
             AddStep(&WrtInstaller::installStep);
-        } else if (arg == "-il" || arg == "--install-preload") {
+        } else if (arg == "-ip" || arg == "--install-preload") {
+            LogDebug("Install preload web app");
             if (m_argc != 3) {
                 return showHelpAndQuit();
             }
@@ -269,7 +273,8 @@ void WrtInstaller::OnReset(bundle* /*b*/)
 void WrtInstaller::OnTerminate()
 {
     LogDebug("Wrt Shutdown now");
-    PluginUtils::unlockPluginInstallation();
+    PluginUtils::unlockPluginInstallation(m_installMode ==
+            WRT_INSTALL_MODE_INSTALL_PRELOAD);
     if (m_initialized) {
         wrt_installer_shutdown();
     }
@@ -369,7 +374,8 @@ void WrtInstaller::installPluginsStep()
 
     if (m_startupPluginInstallation) {
         LogInfo("Plugin installation started because new plugin package found");
-    } else if (!PluginUtils::lockPluginInstallation()) {
+    } else if (!PluginUtils::lockPluginInstallation(m_installMode ==
+                WRT_INSTALL_MODE_INSTALL_PRELOAD)) {
         LogError("Failed to open plugin installation lock file"
                  " Plugins are currently installed by other process");
         staticWrtPluginInstallationCallback(WRT_INSTALLER_ERROR_PLUGIN_INSTALLATION_FAILED,
@@ -787,6 +793,15 @@ void WrtInstaller::staticWrtStatusCallback(std::string tizenId,
         This->m_returnStatus = 0;
         resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS);
 
+        if (This->m_installMode == WRT_INSTALL_MODE_INSTALL_PRELOAD &&
+                !This->m_packagePath.empty()) {
+            LogDebug("This widget is preloaded so it will be removed : "
+                    << This->m_packagePath);
+            if (!WrtUtilRemove(This->m_packagePath)) {
+                LogError("Failed to remove " << This->m_packagePath);
+            }
+        }
+
         This->DPL::Event::ControllerEventHandler<WRTInstallerNS::
                                                      NextStepEvent>
             ::PostEvent(WRTInstallerNS::NextStepEvent());
@@ -818,7 +833,8 @@ void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status,
         }
 
         //remove lock file
-        if (!PluginUtils::unlockPluginInstallation()) {
+        if (!PluginUtils::unlockPluginInstallation(This->m_installMode ==
+                WRT_INSTALL_MODE_INSTALL_PRELOAD)) {
             LogInfo("Failed to remove installation lock");
         }
 
@@ -911,14 +927,16 @@ void WrtInstaller::installNewPlugins()
 {
     LogDebug("Install new plugins");
 
-    if (!PluginUtils::lockPluginInstallation()) {
+    if (!PluginUtils::lockPluginInstallation(m_installMode ==
+                WRT_INSTALL_MODE_INSTALL_PRELOAD)) {
         LogInfo("Lock NOT created");
         return;
     }
 
     if (!PluginUtils::checkPluginInstallationRequired()) {
         LogDebug("Plugin installation not required");
-        PluginUtils::unlockPluginInstallation();
+        PluginUtils::unlockPluginInstallation(m_installMode ==
+            WRT_INSTALL_MODE_INSTALL_PRELOAD);
         return;
     }
 
index 6280dd6..1f7c4a4 100644 (file)
@@ -202,6 +202,13 @@ EXPORT_API void wrt_install_widget(
 {
     UNHANDLED_EXCEPTION_HANDLER_BEGIN
     {
+        if ( WRT_INSTALL_MODE_INSTALL_PRELOAD == installMode) {
+            DPL::Log::OldStyleLogProvider *oldStyleProvider =
+                new DPL::Log::OldStyleLogProvider(false, false, false, true,
+                        false, true);
+            DPL::Log::LogSystemSingleton::Instance().AddProvider(oldStyleProvider);
+        }
+
         LogInfo("[WRT-API] INSTALL WIDGET: " << path);
         // Post installation event
         CONTROLLER_POST_EVENT(