Fixed reinstall hybrid web app.
authorSoyoung Kim <sy037.kim@samsung.com>
Wed, 12 Jun 2013 11:02:27 +0000 (20:02 +0900)
committerSoyoung Kim <sy037.kim@samsung.com>
Thu, 13 Jun 2013 13:23:30 +0000 (22:23 +0900)
[Issue#] N/A
[Problem] failed installation native app
[Cause] can't check whether hybrid web app or not.
[Solution] fixed check routine.
[SCMRequest] N/A

Change-Id: I645a41dbd761135dfa014f86ab7bcc57d008bfdb

src/jobs/widget_install/job_widget_install.cpp
src/jobs/widget_install/task_certify.cpp
src/jobs/widget_install/task_certify.h
src/jobs/widget_install/task_file_manipulation.cpp
src/jobs/widget_install/task_install_ospsvc.cpp
src/jobs/widget_install/task_manifest_file.cpp
src/jobs/widget_install/task_remove_backup.cpp
src/misc/widget_location.cpp
src/misc/widget_location.h

index f837c27..9757223 100644 (file)
@@ -83,6 +83,7 @@ namespace // anonymous
 {
 const char * const CONFIG_XML = "config.xml";
 const char * const WITH_OSP_XML = "res/wgt/config.xml";
+const char * const OSP_MANIFEST_XML = "info/manifest.xml";
 
 //allowed: a-z, A-Z, 0-9
 const char* REG_TIZENID_PATTERN = "^[a-zA-Z0-9]{10}.{1,}$";
@@ -225,9 +226,8 @@ JobWidgetInstall::JobWidgetInstall(
             AddTask(new TaskEncryptResource(m_installerContext));
         }
 
-        if (m_installerContext.widgetConfig.packagingType !=
-            WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
-        {
+        if (m_installerContext.mode.extension !=
+                InstallMode::ExtensionType::DIR) {
             AddTask(new TaskUpdateFiles(m_installerContext));
             AddTask(new TaskFileManipulation(m_installerContext));
         }
@@ -437,7 +437,8 @@ void JobWidgetInstall::configureWidgetLocation(const std::string & widgetPath,
                        widgetPath, tempPath,
                        m_installerContext.widgetConfig.packagingType,
                        m_installerContext.mode.rootPath ==
-                           InstallMode::RootPath::RO);
+                           InstallMode::RootPath::RO,
+                           m_installerContext.mode.extension);
     m_installerContext.locations->registerAppid(
         DPL::ToUTF8String(m_installerContext.widgetConfig.tzAppid));
 
@@ -636,41 +637,26 @@ ConfigParserData JobWidgetInstall::getWidgetDataFromXML(
                              new RootParser<WidgetParser>(configInfo,
                                                           DPL::FromUTF32String(
                                                               L"widget"))));
-        } else if (pkgType == PKG_TYPE_DIRECTORY_WEB_APP) {
-            std::string configPath;
-            configPath = tempPath;
-            configPath += "/";
-            configPath += WITH_OSP_XML;
+        } else {
+            std::string configFile;
+            configFile = tempPath + "/" + CONFIG_XML;
+            if (!WrtUtilFileExists(configFile)) {
+                configFile = tempPath + "/" + WITH_OSP_XML;
+            }
 
             if (isReinstall) {
                 // checking RDS data directory
-                if (access(configPath.c_str(), F_OK) != 0) {
+                if (access(configFile.c_str(), F_OK) != 0) {
                     std::string tzAppId =
                         widgetSource.substr(widgetSource.find_last_of("/")+1);
                     WidgetDAOReadOnly dao(WidgetDAOReadOnly::getTzAppId(DPL::FromUTF8String(tzAppId)));
-                    configPath = DPL::ToUTF8String(*dao.getWidgetInstalledPath());
-                    configPath += "/";
-                    configPath += WITH_OSP_XML;
-                }
-            }
-            parser.Parse(configPath,
-                         ElementParserPtr(
-                             new RootParser<WidgetParser>(
-                                 configInfo,
-                                 DPL::FromUTF32String(L"widget"))));
-        } else {
-            DPL::Utils::Path configFile;
-            if (pkgType == PKG_TYPE_HYBRID_WEB_APP) {
-                configFile = DPL::Utils::Path(tempPath);
-                configFile /= WITH_OSP_XML;
-            } else {
-                configFile = DPL::Utils::Path(tempPath);
-                configFile /= CONFIG_XML;
-                if(!configFile.Exists()){
-                    Throw(Exceptions::WidgetConfigFileNotFound);
+                    configFile = DPL::ToUTF8String(*dao.getWidgetInstalledPath());
+                    configFile += "/";
+                    configFile += WITH_OSP_XML;
                 }
             }
-            parser.Parse(configFile.Fullpath(),
+
+            parser.Parse(configFile,
                     ElementParserPtr(
                         new RootParser<WidgetParser>(configInfo,
                             DPL::
@@ -891,26 +877,17 @@ WrtDB::PackagingType JobWidgetInstall::checkPackageType(
     const std::string &widgetSource,
     const std::string &tempPath)
 {
-    // Check installation type (direcotory/ or config.xml or widget.wgt)
-    if (m_installerContext.mode.extension == InstallMode::ExtensionType::DIR) {
-        LogDebug("Install directly from directory");
-        return PKG_TYPE_DIRECTORY_WEB_APP;
-    }
     if (hasExtension(widgetSource, XML_EXTENSION)) {
         LogInfo("Hosted app installation");
         return PKG_TYPE_HOSTED_WEB_APP;
     }
 
-    std::string configFile = tempPath + "/" + CONFIG_XML;
-    if (WrtUtilFileExists(configFile)) {
-        return PKG_TYPE_NOMAL_WEB_APP;
-    }
-
-    configFile = tempPath + "/" + WITH_OSP_XML;
+    std::string configFile = tempPath + "/" + OSP_MANIFEST_XML;
     if (WrtUtilFileExists(configFile)) {
         return PKG_TYPE_HYBRID_WEB_APP;
     }
-    return PKG_TYPE_UNKNOWN;
+
+    return PKG_TYPE_NOMAL_WEB_APP;
 }
 
 void JobWidgetInstall::setApplicationType(
index 68189ac..9826b04 100644 (file)
@@ -23,6 +23,7 @@
 //SYSTEM INCLUDES
 #include <cstring>
 #include <string>
+#include <sstream>
 #include <dpl/assert.h>
 #include <appcore-common.h> //TODO is it necessary here?
 #include <pcrecpp.h>
@@ -196,25 +197,36 @@ void TaskCertify::processAuthorSignature(const SignatureData &data)
     }
 }
 
+void TaskCertify::getSignatureFiles(std::string path, SignatureFileInfoSet& file)
+{
+    SignatureFileInfoSet signatureFiles;
+    SignatureFinder signatureFinder(path);
+    if (SignatureFinder::NO_ERROR != signatureFinder.find(file)) {
+        LogError("Error in Signature Finder : " << path);
+        ThrowMsg(Exceptions::SignatureNotFound,
+                "Error openig temporary widget directory");
+    }
+}
+
 void TaskCertify::stepSignature()
 {
     LogInfo("================ Step: <<Signature>> ENTER ===============");
 
     std::string widgetPath;
-    if (m_contextData.widgetConfig.packagingType ==
-        WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
-    {
-        widgetPath = m_contextData.locations->getSourceDir() + "/";
-    } else {
-        widgetPath = m_contextData.locations->getTemporaryPackageDir() + "/";
-    }
+    widgetPath = m_contextData.locations->getTemporaryPackageDir() + "/";
 
     SignatureFileInfoSet signatureFiles;
-    SignatureFinder signatureFinder(widgetPath);
-    if (SignatureFinder::NO_ERROR != signatureFinder.find(signatureFiles)) {
-        LogError("Error in Signature Finder");
-        ThrowMsg(Exceptions::SignatureNotFound,
-                 "Error openig temporary widget directory");
+
+    Try {
+        getSignatureFiles(widgetPath, signatureFiles);
+
+        if (signatureFiles.size() <= 0) {
+            widgetPath = m_contextData.locations->getTemporaryPackageDir() +
+                WrtDB::GlobalConfig::GetWidgetSrcPath() + "/";
+            getSignatureFiles(widgetPath, signatureFiles);
+        }
+    } Catch(Exceptions::SignatureNotFound) {
+        ReThrowMsg(Exceptions::SignatureNotFound, widgetPath);
     }
 
     SignatureFileInfoSet::reverse_iterator iter = signatureFiles.rbegin();
index 6c42853..955b8ff 100644 (file)
@@ -25,6 +25,7 @@
 //SYSTEM INCLUDES
 #include <string>
 #include <libxml/c14n.h>
+#include <vcore/SignatureFinder.h>
 
 //WRT INCLUDES
 #include <dpl/task.h>
@@ -54,6 +55,8 @@ class TaskCertify :
 
     void processDistributorSignature(const ValidationCore::SignatureData &data);
     void processAuthorSignature(const ValidationCore::SignatureData &data);
+    void getSignatureFiles(std::string path,
+            ValidationCore::SignatureFileInfoSet& file);
 
     bool isTizenWebApp() const;
 };
index 56a7e63..a338ce8 100644 (file)
@@ -150,8 +150,7 @@ TaskFileManipulation::TaskFileManipulation(InstallerContext& context) :
             m_context.locationType)
     {
         AddStep(&TaskFileManipulation::StepCreateDirs);
-        if (m_context.widgetConfig.packagingType !=
-            WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
+        if (m_context.mode.extension != InstallMode::ExtensionType::DIR)
         {
             AddStep(&TaskFileManipulation::StepRenamePath);
             AddAbortStep(&TaskFileManipulation::StepAbortRenamePath);
index 30c8101..0ef8990 100644 (file)
@@ -116,14 +116,7 @@ void TaskInstallOspsvc::StepUpdateManifestFile()
         manifest_file << ".xml";
         LogDebug("manifest file : " << manifest_file.str());
 
-        int ret = pkgmgr_parser_parse_manifest_for_uninstallation(
-                manifest_file.str().c_str(), NULL);
-
-        if (ret != 0) {
-            LogError("Manifest parser error: " << ret);
-        }
-
-        int code = pkgmgr_parser_parse_manifest_for_installation(
+        int code = pkgmgr_parser_parse_manifest_for_upgrade(
                 manifest_file.str().c_str(), NULL);
 
         if (code != 0) {
index 8a7e3f3..e320362 100755 (executable)
@@ -596,8 +596,12 @@ void TaskManifestFile::stepParseManifest()
 
     commitManifest();
 
-    if (!m_context.isUpdateMode) {
-        code = pkgmgr_parser_parse_manifest_for_installation(
+    if (m_context.isUpdateMode || (
+                m_context.mode.rootPath == InstallMode::RootPath::RO
+                && m_context.mode.installTime == InstallMode::InstallTime::PRELOAD
+                && m_context.mode.extension == InstallMode::ExtensionType::DIR)) {
+
+        code = pkgmgr_parser_parse_manifest_for_upgrade(
                 commit_manifest.c_str(), (updateTags[0] == NULL) ? NULL : updateTags);
 
         if (code != 0) {
@@ -605,7 +609,7 @@ void TaskManifestFile::stepParseManifest()
             ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code);
         }
     } else {
-        code = pkgmgr_parser_parse_manifest_for_upgrade(
+        code = pkgmgr_parser_parse_manifest_for_installation(
                 commit_manifest.c_str(), (updateTags[0] == NULL) ? NULL : updateTags);
 
         if (code != 0) {
index 47e9cf4..e4cc1f0 100644 (file)
@@ -42,8 +42,7 @@ TaskRemoveBackupFiles::TaskRemoveBackupFiles(InstallerContext& context) :
     DPL::TaskDecl<TaskRemoveBackupFiles>(this),
     m_context(context)
 {
-    if (m_context.widgetConfig.packagingType !=
-            WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
+    if (m_context.mode.extension != InstallMode::ExtensionType::DIR)
     {
         AddStep(&TaskRemoveBackupFiles::StepRemoveBackupFiles);
     }
index 4c93057..71f8b28 100644 (file)
@@ -62,12 +62,14 @@ WidgetLocation::~WidgetLocation()
 WidgetLocation::WidgetLocation(const std::string & widgetname,
                                std::string sourcePath,
                                WrtDB::PackagingType t,
-                               bool isReadonly) :
+                               bool isReadonly,
+                               InstallMode::ExtensionType eType) :
     m_pkgid(widgetname),
     m_widgetSource(sourcePath),
     m_type(t),
     m_temp(
-        new WidgetLocation::DirectoryDeletor(isReadonly))
+        new WidgetLocation::DirectoryDeletor(isReadonly)),
+    m_extensionType(eType)
 {
     if (isReadonly) {
         m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
@@ -84,11 +86,13 @@ WidgetLocation::WidgetLocation(const std::string & widgetname,
                                std::string sourcePath,
                                std::string dirPath,
                                WrtDB::PackagingType t,
-                               bool isReadonly) :
+                               bool isReadonly,
+                               InstallMode::ExtensionType eType) :
     m_pkgid(widgetname),
     m_widgetSource(sourcePath),
     m_type(t),
-    m_temp(new WidgetLocation::DirectoryDeletor(dirPath))
+    m_temp(new WidgetLocation::DirectoryDeletor(dirPath)),
+    m_extensionType(eType)
 {
     if (isReadonly) {
         m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
@@ -187,7 +191,7 @@ std::string WidgetLocation::getTemporaryPackageDir() const
 
 std::string WidgetLocation::getTemporaryRootDir() const
 {
-    if (m_type == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP) {
+    if (m_extensionType == InstallMode::ExtensionType::DIR) {
         return getWidgetSource() + WrtDB::GlobalConfig::GetWidgetSrcPath();
     }
     if (m_type == WrtDB::PKG_TYPE_HYBRID_WEB_APP) {
@@ -206,8 +210,6 @@ std::string WidgetLocation::getConfigurationDir() const
             path = m_widgetSource.substr(0, index);
         }
         return path;
-    } else if (m_type == WrtDB::PKG_TYPE_DIRECTORY_WEB_APP) {
-        return getWidgetSource() + WrtDB::GlobalConfig::GetWidgetSrcPath();
     } else {
         return getTemporaryRootDir();
     }
index 2b44d4d..c3f8c39 100644 (file)
@@ -26,6 +26,7 @@
 #include <dpl/wrt-dao-ro/common_dao_types.h>
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 #include <wrt_common_types.h>
+#include <wrt_install_mode.h>
 
 /**
  * @brief The WidgetLocation class
@@ -101,12 +102,16 @@ class WidgetLocation
      */
     WidgetLocation(const std::string & widgetname, std::string sourcePath,
                    WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP,
-                   bool isReadonly = false);
+                   bool isReadonly = false,
+                   InstallMode::ExtensionType eType =
+                   InstallMode::ExtensionType::WGT);
 
     WidgetLocation(const std::string & widgetname, std::string sourcePath,
                    std::string dirPath,
                    WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP,
-                   bool isReadonly = false);
+                   bool isReadonly = false,
+                   InstallMode::ExtensionType eType =
+                   InstallMode::ExtensionType::WGT);
 
     ~WidgetLocation();
 
@@ -215,6 +220,7 @@ class WidgetLocation
     std::shared_ptr<DirectoryDeletor> m_temp;      //directory
     WrtDB::ExternalLocationList m_externals;
     std::string m_installedPath;
+    InstallMode::ExtensionType m_extensionType;
 };
 
 #endif // WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H