separate generation manifest and update pkginfo.
authorSoyoung Kim <sy037.kim@samsung.com>
Mon, 5 Aug 2013 11:32:00 +0000 (20:32 +0900)
committerSoyoung Kim <sy037.kim@samsung.com>
Wed, 7 Aug 2013 08:32:46 +0000 (17:32 +0900)
[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution] To update package info separate from generation manifest file.
Because package info is double updated when hybrid app.
[SCMRequest] N/A

Change-Id: Ib32dd11d6108630480918bff9529aa85a6c56185

src/CMakeLists.txt
src/jobs/widget_install/job_widget_install.cpp
src/jobs/widget_install/task_install_ospsvc.cpp
src/jobs/widget_install/task_install_ospsvc.h
src/jobs/widget_install/task_manifest_file.cpp
src/jobs/widget_install/task_manifest_file.h
src/jobs/widget_install/task_pkg_info_update.cpp [moved from src/jobs/widget_install/task_certificates.cpp with 61% similarity]
src/jobs/widget_install/task_pkg_info_update.h [moved from src/jobs/widget_install/task_certificates.h with 54% similarity]
src/jobs/widget_install/task_smack.cpp
src/jobs/widget_install/widget_install_context.h

index 93a2431..6192474 100644 (file)
@@ -77,8 +77,8 @@ SET(INSTALLER_SOURCES
     ${INSTALLER_JOBS}/widget_install/task_update_files.cpp
     ${INSTALLER_JOBS}/widget_install/task_remove_backup.cpp
     ${INSTALLER_JOBS}/widget_install/task_encrypt_resource.cpp
-    ${INSTALLER_JOBS}/widget_install/task_certificates.cpp
     ${INSTALLER_JOBS}/widget_install/task_prepare_reinstall.cpp
+    ${INSTALLER_JOBS}/widget_install/task_pkg_info_update.cpp
     ${INSTALLER_JOBS}/widget_install/widget_security.cpp
     ${INSTALLER_JOBS}/widget_install/widget_update_info.cpp
     ${INSTALLER_JOBS}/widget_install/directory_api.cpp
index 99d102d..e746f01 100644 (file)
@@ -68,7 +68,7 @@
 #include <widget_install/task_database.h>
 #include <widget_install/task_remove_backup.h>
 #include <widget_install/task_encrypt_resource.h>
-#include <widget_install/task_certificates.h>
+#include <widget_install/task_pkg_info_update.h>
 #include <widget_install/task_commons.h>
 #include <widget_install/task_prepare_reinstall.h>
 
@@ -205,10 +205,10 @@ JobWidgetInstall::JobWidgetInstall(
         {
             AddTask(new TaskInstallOspsvc(m_installerContext));
         }
-        AddTask(new TaskCertificates(m_installerContext));
         AddTask(new TaskDatabase(m_installerContext));
         AddTask(new TaskAceCheck(m_installerContext));
         AddTask(new TaskSmack(m_installerContext));
+        AddTask(new TaskPkgInfoUpdate(m_installerContext));
     } else if (result == ConfigureResult::Updated) {
         LogDebug("Configure installation updated");
         LogDebug("Widget Update");
@@ -245,7 +245,6 @@ JobWidgetInstall::JobWidgetInstall(
         {
             AddTask(new TaskInstallOspsvc(m_installerContext));
         }
-        AddTask(new TaskCertificates(m_installerContext));
         AddTask(new TaskDatabase(m_installerContext));
         AddTask(new TaskAceCheck(m_installerContext));
         //TODO: remove widgetHandle from this task and move before database task
@@ -253,6 +252,7 @@ JobWidgetInstall::JobWidgetInstall(
         // Any error in acecheck while update will break widget
         AddTask(new TaskSmack(m_installerContext));
         AddTask(new TaskRemoveBackupFiles(m_installerContext));
+        AddTask(new TaskPkgInfoUpdate(m_installerContext));
     } else {
         // Installation is not allowed to proceed due to widget update policy
         LogWarning("Configure installation failed!");
index 29228e3..0a3e2f6 100644 (file)
@@ -52,7 +52,6 @@ TaskInstallOspsvc::TaskInstallOspsvc(InstallerContext& context) :
 {
     AddStep(&TaskInstallOspsvc::StartStep);
     AddStep(&TaskInstallOspsvc::StepInstallOspService);
-    AddStep(&TaskInstallOspsvc::StepUpdateManifestFile);
     AddStep(&TaskInstallOspsvc::EndStep);
 }
 
@@ -96,30 +95,6 @@ void TaskInstallOspsvc::StepInstallOspService()
     pclose(fd);
 }
 
-void TaskInstallOspsvc::StepUpdateManifestFile()
-{
-    std::string pkgid = DPL::ToUTF8String(m_context.widgetConfig.tzPkgid);
-    pkgmgrinfo_pkginfo_h handle;
-
-    LogDebug("StepUpdateManifestFile");
-    std::ostringstream manifest_file;
-    if (m_context.mode.rootPath == InstallMode::RootPath::RO) {
-        manifest_file << "/usr/share/packages/"; //TODO constant with path
-    } else {
-        manifest_file << "/opt/share/packages/"; //TODO constant with path
-    }
-    manifest_file << pkgid;
-    manifest_file << ".xml";
-    LogDebug("manifest file : " << manifest_file.str());
-
-    int code = pkgmgr_parser_parse_manifest_for_upgrade(
-            manifest_file.str().c_str(), NULL);
-
-    if (code != 0) {
-        LogError("Manifest parser error: " << code);
-    }
-}
-
 void TaskInstallOspsvc::StartStep()
 {
     LogDebug("--------- <TaskInstallOspsvc> : START ----------");
index 1385580..3e3a7e6 100644 (file)
@@ -36,7 +36,6 @@ class TaskInstallOspsvc : public DPL::TaskDecl<TaskInstallOspsvc>
     InstallerContext &m_context;
 
     void StepInstallOspService();
-    void StepUpdateManifestFile();
 
     void StepAbortInstall();
 
index 7d85146..37d856e 100644 (file)
@@ -117,7 +117,6 @@ TaskManifestFile::TaskManifestFile(InstallerContext &inCont) :
         AddStep(&TaskManifestFile::stepCopyLiveboxFiles);
         AddStep(&TaskManifestFile::stepCreateExecFile);
         AddStep(&TaskManifestFile::stepGenerateManifest);
-        AddStep(&TaskManifestFile::stepParseManifest);
 
         AddAbortStep(&TaskManifestFile::stepAbortIconFiles);
     } else {
@@ -125,9 +124,6 @@ TaskManifestFile::TaskManifestFile(InstallerContext &inCont) :
         AddStep(&TaskManifestFile::stepCopyLiveboxFiles);
         AddStep(&TaskManifestFile::stepCreateExecFile);
         AddStep(&TaskManifestFile::stepGenerateManifest);
-        AddStep(&TaskManifestFile::stepParseManifest);
-
-        AddAbortStep(&TaskManifestFile::stepAbortParseManifest);
     }
 }
 
@@ -599,53 +595,11 @@ void TaskManifestFile::stepGenerateManifest()
     commit_manifest = destFile.str();
     LogDebug("Commiting manifest file : " << commit_manifest);
 
-    m_context.job->UpdateProgress(
-        InstallerContext::INSTALL_CREATE_MANIFEST,
-        "Widget Manifest Creation Finished");
-}
-
-void TaskManifestFile::stepParseManifest()
-{
-    int code = 0;
-    char* updateTags[3] = {NULL, };
-
-    if (!m_context.mode.removable) {
-        updateTags[0] = "preload=false";
-        updateTags[1] = "removable=false";
-        updateTags[2] = NULL;
-
-    }
-
     commitManifest();
 
-    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)) {
-
-        if (m_context.widgetConfig.packagingType != PKG_TYPE_HYBRID_WEB_APP) {
-            code = pkgmgr_parser_parse_manifest_for_upgrade(
-                    commit_manifest.c_str(), (updateTags[0] == NULL) ? NULL : updateTags);
-
-            if (code != 0) {
-                LogError("Manifest parser error: " << code);
-                ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code);
-            }
-        }
-    } else {
-        code = pkgmgr_parser_parse_manifest_for_installation(
-                commit_manifest.c_str(), (updateTags[0] == NULL) ? NULL : updateTags);
-
-        if (code != 0) {
-            LogError("Manifest parser error: " << code);
-            ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code);
-        }
-    }
-
     m_context.job->UpdateProgress(
-            InstallerContext::INSTALL_CREATE_MANIFEST,
-            "Widget Manifest Parsing Finished");
-    LogDebug("Manifest parsed");
+        InstallerContext::INSTALL_CREATE_MANIFEST,
+        "Widget Manifest Creation Finished");
 }
 
 void TaskManifestFile::commitManifest()
@@ -1051,23 +1005,6 @@ void TaskManifestFile::setMetadata(UiApplication &uiApp)
     }
 }
 
-void TaskManifestFile::stepAbortParseManifest()
-{
-    LogError("[Parse Manifest] Abroting....");
-
-    int code = pkgmgr_parser_parse_manifest_for_uninstallation(
-            DPL::ToUTF8String(manifest_file).c_str(), NULL);
-
-    if (0 != code) {
-        LogWarning("Manifest parser error: " << code);
-        ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code);
-    }
-    int ret = unlink(DPL::ToUTF8String(manifest_file).c_str());
-    if (0 != ret) {
-        LogWarning("No manifest file found: " << manifest_file);
-    }
-}
-
 void TaskManifestFile::setLiveBoxInfo(Manifest& manifest)
 {
     FOREACH(it, m_context.widgetConfig.configInfo.m_livebox) {
index 5f006da..a318fc8 100644 (file)
@@ -64,8 +64,6 @@ class TaskManifestFile :
     void stepCopyIconFiles();
     void stepCopyLiveboxFiles();
     void stepGenerateManifest();
-    void stepParseManifest();
-    void stepParseUpgradedManifest();
 
     void stepAbortParseManifest();
 
  *    See the License for the specific language governing permissions and
  *    limitations under the License.
  */
-/*
- * @file    task_certificates.cpp
- * @author  Leerang Song(leerang.song@samsung.com)
+/**
+ * @file    task_pkg_info_update.cpp
+ * @author  Soyoung Kim (sy037.kim@samsung.com)
  * @version 1.0
- * @brief   Implementation file for installer task certificates
+ * @brief   Implementation file for installer task information about package
+ * update
  */
-#include <widget_install/task_certificates.h>
-#include <widget_install/widget_install_context.h>
-#include <widget_install/widget_install_errors.h>
-#include <widget_install/job_widget_install.h>
-#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
-#include <pkgmgr_installer.h>
-#include <vcore/CryptoHash.h>
+#include "task_pkg_info_update.h"
 
+#include <unistd.h>
+#include <string>
+
+#include <fstream>
 #include <dpl/log/log.h>
-#include <dlog.h>
-#include <sstream>
+#include <dpl/wrt-dao-ro/global_config.h>
 #include <dpl/foreach.h>
 #include <dpl/sstream.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+#include <pkgmgr_installer.h>
+#include <pkgmgr/pkgmgr_parser.h>
+#include <pkgmgr-info.h>
+#include <vcore/CryptoHash.h>
+
+#include <widget_install/job_widget_install.h>
+#include <widget_install/widget_install_context.h>
+#include <widget_install/widget_install_errors.h>
 
 using namespace WrtDB;
 
+namespace {
+}
+
 namespace Jobs {
 namespace WidgetInstall {
-TaskCertificates::TaskCertificates(InstallerContext& context) :
-    DPL::TaskDecl<TaskCertificates>(this),
-    m_context(context),
-    m_pkgHandle(NULL)
+TaskPkgInfoUpdate::TaskPkgInfoUpdate(InstallerContext& context) :
+    DPL::TaskDecl<TaskPkgInfoUpdate>(this),
+    m_context(context)
+{
+    AddStep(&TaskPkgInfoUpdate::StartStep);
+    AddStep(&TaskPkgInfoUpdate::StepPkgInfo);
+    AddStep(&TaskPkgInfoUpdate::StepSetCertiInfo);
+    AddStep(&TaskPkgInfoUpdate::EndStep);
+    AddStep(&TaskPkgInfoUpdate::StepSetEndofInstallation);
+
+    AddAbortStep(&TaskPkgInfoUpdate::StepAbortCertiInfo);
+    AddAbortStep(&TaskPkgInfoUpdate::stepAbortParseManifest);
+}
+
+void TaskPkgInfoUpdate::StepPkgInfo()
 {
-    AddStep(&TaskCertificates::StartStep);
-    AddStep(&TaskCertificates::StepSetCertiInfo);
-    AddStep(&TaskCertificates::EndStep);
-    AddAbortStep(&TaskCertificates::StepAbortCertiInfo);
+    int code = 0;
+    char* updateTags[3] = {NULL, };
+
+    if (!m_context.mode.removable) {
+        updateTags[0] = "preload=false";
+        updateTags[1] = "removable=false";
+        updateTags[2] = NULL;
+
+    }
+
+    if (m_context.mode.rootPath == InstallMode::RootPath::RO) {
+        m_manifest += "/usr/share/packages/";
+    } else {
+        m_manifest += "/opt/share/packages/";
+    }
+    m_manifest += DPL::ToUTF8String(m_context.widgetConfig.tzPkgid) + ".xml";
+    LogDebug("manifest file : " << m_manifest);
+
+    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)) {
+
+        if (m_context.widgetConfig.packagingType != PKG_TYPE_HYBRID_WEB_APP) {
+            code = pkgmgr_parser_parse_manifest_for_upgrade(
+                    m_manifest.c_str(), (updateTags[0] == NULL) ? NULL : updateTags);
+
+            if (code != 0) {
+                LogError("Manifest parser error: " << code);
+                ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code);
+            }
+        }
+    } else {
+        code = pkgmgr_parser_parse_manifest_for_installation(
+                m_manifest.c_str(), (updateTags[0] == NULL) ? NULL : updateTags);
+
+        if (code != 0) {
+            LogError("Manifest parser error: " << code);
+            ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code);
+        }
+    }
+
+    m_context.job->UpdateProgress(
+            InstallerContext::INSTALL_PKGINFO_UPDATE,
+            "Manifest Update Finished");
+    LogDebug("Manifest parsed");
 }
 
-void TaskCertificates::StepSetCertiInfo()
+void TaskPkgInfoUpdate::StepSetCertiInfo()
 {
     LogDebug("StepSetCertiInfo");
 
@@ -78,11 +141,12 @@ void TaskCertificates::StepSetCertiInfo()
     }
 }
 
-void TaskCertificates::SetCertiInfo(CertificateSource source)
+void TaskPkgInfoUpdate::SetCertiInfo(int source)
 {
     LogDebug("Set CertiInfo to pkgmgr : " << source);
     CertificateChainList certificateChainList;
-    m_context.widgetSecurity.getCertificateChainList(certificateChainList, source);
+    m_context.widgetSecurity.getCertificateChainList(certificateChainList,
+            (CertificateSource)source);
 
     FOREACH(it, certificateChainList)
     {
@@ -167,7 +231,7 @@ void TaskCertificates::SetCertiInfo(CertificateSource source)
     }
 }
 
-void TaskCertificates::StepAbortCertiInfo()
+void TaskPkgInfoUpdate::StepAbortCertiInfo()
 {
     if ((pkgmgr_installer_delete_certinfo(
              const_cast<char*>(DPL::ToUTF8String(
@@ -178,18 +242,43 @@ void TaskCertificates::StepAbortCertiInfo()
     }
 }
 
-void TaskCertificates::StartStep()
+void TaskPkgInfoUpdate::StartStep()
 {
-    LogDebug("--------- <TaskCertificates> : START ----------");
+    LogDebug("--------- <TaskPkgInfoUpdate> : START ----------");
 }
 
-void TaskCertificates::EndStep()
+void TaskPkgInfoUpdate::EndStep()
 {
     m_context.job->UpdateProgress(
             InstallerContext::INSTALL_SET_CERTINFO,
             "Save certinfo to pkgmgr");
 
-    LogDebug("--------- <TaskCertificates> : END ----------");
+    LogDebug("--------- <TaskPkgInfoUpdate> : END ----------");
 }
+
+void TaskPkgInfoUpdate::stepAbortParseManifest()
+{
+    LogError("[Parse Manifest] Abroting....");
+
+    int code = pkgmgr_parser_parse_manifest_for_uninstallation(
+            m_manifest.c_str(), NULL);
+
+    if (0 != code) {
+        LogWarning("Manifest parser error: " << code);
+        ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code);
+    }
+    int ret = unlink(m_manifest.c_str());
+    if (0 != ret) {
+        LogWarning("No manifest file found: " << m_manifest);
+    }
+}
+
+void TaskPkgInfoUpdate::StepSetEndofInstallation()
+{
+    m_context.job->UpdateProgress(
+        InstallerContext::INSTALL_END,
+        "End installation");
+}
+
 } //namespace WidgetInstall
 } //namespace Jobs
similarity index 54%
rename from src/jobs/widget_install/task_certificates.h
rename to src/jobs/widget_install/task_pkg_info_update.h
index 215f543..e1e9235 100644 (file)
  *    limitations under the License.
  */
 /*
- * @file    task_certificates.h
- * @author  Leerang Song(leerang.song@samsung.com)
- * @version 1.0
- * @brief   Header file for installer task certificates
+ * @file       task_pkg_info_update.h
+ * @author     soyoung kim (sy037.kim@samsung.com)
+ * @version    1.0
  */
-#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_CERTIFICATES_H
-#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_CERTIFICATES_H
 
-#include <dpl/task.h>
-#include <dpl/event/inter_context_delegate.h>
-#include <dpl/foreach.h>
-#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+#ifndef SRC_JOBS_WIDGET_INSTALL_TASK_PKG_INFO_UPDATE_H_
+#define SRC_JOBS_WIDGET_INSTALL_TASK_PKG_INFO_UPDATE_H_
 
+#include <dpl/task.h>
+#include <string>
 #include <pkgmgr_installer.h>
-using namespace WrtDB;
 
 class InstallerContext;
 
 namespace Jobs {
 namespace WidgetInstall {
-class TaskCertificates :
-    public DPL::TaskDecl<TaskCertificates>,
-    public DPL::Event::ICDelegateSupport<TaskCertificates>
+class TaskPkgInfoUpdate : public DPL::TaskDecl<TaskPkgInfoUpdate>
 {
   private:
-    InstallerContext& m_context;
+    // Installation context
+    InstallerContext &m_context;
 
+    void StepPkgInfo();
     void StepSetCertiInfo();
+    void SetCertiInfo(int source);
+    void StepSetEndofInstallation();
+
+    void stepAbortParseManifest();
     void StepAbortCertiInfo();
-    void SetCertiInfo(CertificateSource source);
 
     void StartStep();
     void EndStep();
 
     pkgmgr_instcertinfo_h m_pkgHandle;
+    std::string m_manifest;
 
   public:
-    TaskCertificates(InstallerContext& context);
+    explicit TaskPkgInfoUpdate(InstallerContext &installerContext);
 };
-} //namespace WidgetInstall
-} //namespace Jobs
-
-#endif /* INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_CERTIFICATES_H */
+} // namespace WidgetInstall
+} // namespace Jobs
+#endif /* SRC_JOBS_WIDGET_INSTALL_TASK_PKG_INFO_UPDATE_H_ */
index a86e43e..f338fc3 100644 (file)
@@ -279,10 +279,6 @@ void TaskSmack::StartStep()
 
 void TaskSmack::EndStep()
 {
-    m_context.job->UpdateProgress(
-        InstallerContext::INSTALL_END,
-        "End installation");
-
     LogDebug("--------- <TaskSmack> : END ----------");
 }
 } //namespace WidgetInstall
index 3d735b6..0c118e9 100644 (file)
@@ -67,11 +67,12 @@ struct InstallerContext
         INSTALL_CREATE_EXECFILE,
         INSTALL_CREATE_MANIFEST,
         INSTALL_INSTALL_OSPSVC,
-        INSTALL_SET_CERTINFO,
         INSTALL_NEW_DB_INSERT,
         INSTALL_ACE_PREPARE,
         INSTALL_ACE_CHECK,
         INSTALL_SMACK_ENABLE,
+        INSTALL_PKGINFO_UPDATE,
+        INSTALL_SET_CERTINFO,
 
         INSTALL_END
     } InstallStep;