Fixed installation failure during install preload webapp
authorSoyoung Kim <sy037.kim@samsung.com>
Sun, 21 Apr 2013 08:38:44 +0000 (17:38 +0900)
committerGerrit Code Review <gerrit2@kim11>
Sun, 21 Apr 2013 13:06:19 +0000 (22:06 +0900)
[Issue#] N/A
[Problem] cann't install preload webapp.
[Cause] fail during ace check.
[Solution] skip ace check when install preload webapp.
[SCMRequest] N/A

src/jobs/widget_install/task_ace_check.cpp
src/jobs/widget_install/task_file_manipulation.cpp
src/misc/widget_location.cpp
src/misc/widget_location.h

index c8fdbe6..b8e4c70 100644 (file)
@@ -76,13 +76,20 @@ void TaskAceCheck::StepAceCheck()
     ace_policy_result_t policyResult = ACE_DENY;
 
     //TODO: remove dao.getHandle()
-    ace_return_t ret = ace_get_policy_result(
-            const_cast<const ace_resource_t>(devCapStr.c_str()),
-            dao.getHandle(),
-            &policyResult);
-    if (ACE_OK != ret) {
-        ThrowMsg(Exceptions::AceCheckFailed, "Instalation failure. "
-                                         "ACE check failure");
+    if (m_context.job->getInstallerStruct().m_installMode
+            == InstallMode::INSTALL_MODE_PRELOAD)
+    {
+        LogDebug("This widget is prealoaded. So ace check will be skiped");
+        policyResult = ACE_PERMIT;
+    } else {
+        ace_return_t ret = ace_get_policy_result(
+                const_cast<const ace_resource_t>(devCapStr.c_str()),
+                dao.getHandle(),
+                &policyResult);
+        if (ACE_OK != ret) {
+            ThrowMsg(Exceptions::AceCheckFailed, "Instalation failure. "
+                    "ACE check failure");
+        }
     }
 
     LogInfo("PolicyResult is : " << static_cast<int>(policyResult));
index dcb4884..a07944d 100644 (file)
@@ -186,6 +186,12 @@ void TaskFileManipulation::StepCreateDirs()
         LogDebug("Create resource directory");
         WrtUtilMakeDir(widgetBinPath);
         WrtUtilMakeDir(widgetSrcPath);
+        if (m_context.job->getInstallerStruct().m_installMode
+                == InstallMode::INSTALL_MODE_PRELOAD)
+        {
+            std::string userWidgetDir = m_context.locations->getUserDataRootDir();
+            WrtUtilMakeDir(userWidgetDir);
+        }
     }
 
     m_context.job->UpdateProgress(
@@ -237,8 +243,8 @@ void TaskFileManipulation::StepLinkForPreload()
             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());
+            LogDebug("Make symbolic name for preaload app" <<
+                    m_context.locations->getSourceDir() << " to " << srcDir);
             std::string resDir = m_context.locations->getUserDataRootDir() +
                 "/res";
 
@@ -258,17 +264,38 @@ void TaskFileManipulation::StepLinkForPreload()
         std::string storagePath = m_context.locations->getPrivateStorageDir();
         std::string dataDir = m_context.locations->getPackageInstallationDir() +
             "/" + WrtDB::GlobalConfig::GetWidgetPrivateStoragePath();
+        if (0 != access(dataDir.c_str(), F_OK)) {
+            LogDebug("Make symbolic name for preaload app " <<
+                    storagePath << " to " << dataDir);
+
+            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);
+        }
+
+        if (m_context.widgetConfig.packagingType != PKG_TYPE_HYBRID_WEB_APP) {
+            std::string widgetBinPath = m_context.locations->getBinaryDir();
+            std::string userBinPath = m_context.locations->getUserBinaryDir();
+            LogDebug("Make symbolic link for preload app " << widgetBinPath <<
+                    " to " << userBinPath);
+            if (symlink(widgetBinPath.c_str(), userBinPath.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.");
+            }
 
-        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);
     }
 }
 
index 8a080da..f48751f 100644 (file)
@@ -41,7 +41,7 @@ WidgetLocation::DirectoryDeletor::~DirectoryDeletor()
     LogDebug(
         "Removing widget installation temporary directory: " << m_dirpath.c_str());
     if (!WrtUtilRemove(m_dirpath)) {
-        LogError("Fail at removing directory: " << m_dirpath.c_str());
+        LogWarning("Fail at removing directory: " << m_dirpath.c_str());
     }
 }
 
@@ -127,6 +127,12 @@ std::string WidgetLocation::getBinaryDir() const
            + m_pkgid + WrtDB::GlobalConfig::GetUserWidgetExecPath();
 }
 
+std::string WidgetLocation::getUserBinaryDir() const
+{
+    return getUserDataRootDir() + "/"
+           + WrtDB::GlobalConfig::GetUserWidgetExecPath();
+}
+
 std::string WidgetLocation::getExecFile() const
 {
     return getBinaryDir() + "/" + m_appid;
index ad240ac..07ea234 100644 (file)
@@ -116,7 +116,8 @@ class WidgetLocation
     std::string getInstallationDir() const; // /opt/apps or /usr/apps
     std::string getPackageInstallationDir() const; // /opt/apps/[package]
     std::string getSourceDir() const;  // /opt/apps/[package]/res/wgt
-    std::string getBinaryDir() const;  // /opt/apps/[package]/bin
+    std::string getBinaryDir() const;  // /opt/apps/[package]/bin or /usr/apps/[package]/bin
+    std::string getUserBinaryDir() const;  // /opt/apps/[package]/bin
     std::string getExecFile() const;   // /opt/apps/[package]/bin/[package]
     std::string getBackupDir() const;  // /opt/apps/[package]/backup
     std::string getBackupSourceDir() const; // /opt/apps/[pkg]/backup/res/wgt