Support preload to writable storage
authorJihoon Chung <jihoon.chung@samsung.com>
Thu, 2 May 2013 07:48:11 +0000 (16:48 +0900)
committerJihoon Chung <jihoon.chung@samsung.com>
Thu, 2 May 2013 11:30:54 +0000 (20:30 +0900)
[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution] Support install Preload application to a writable storage.
This is requirment of operator and preload application can be
uninstalled.
[SCMRequest] N/A

Change-Id: Ibe9af71e1560a01ea8318fc5a9ba2ef28cef5d8d

src/commons/wrt_common_types.h
src/jobs/widget_install/job_widget_install.cpp
src/jobs/widget_install/task_commons.h
src/jobs/widget_install/task_file_manipulation.cpp
src/jobs/widget_install/task_manifest_file.cpp
src/misc/widget_location.cpp
src/misc/widget_location.h
src/wrt-installer/wrt-installer.cpp

index f888c85..965db9c 100644 (file)
@@ -42,7 +42,6 @@ enum InstallLocationType
 {
     INSTALL_LOCATION_TYPE_UNKNOWN = 0,
     INSTALL_LOCATION_TYPE_NOMAL,
-    INSTALL_LOCATION_TYPE_PRELOAD,
     INSTALL_LOCATION_TYPE_EXTERNAL
 };
 
index 1382f0e..57475e9 100644 (file)
@@ -295,8 +295,8 @@ ConfigureResult JobWidgetInstall::PrePareInstallation(
         } else {
             tempDir =
                 Jobs::WidgetInstall::createTempPath(
-                        m_installerContext.mode.installTime ==
-                            InstallMode::InstallTime::PRELOAD);
+                        m_installerContext.mode.rootPath ==
+                            InstallMode::RootPath::RO);
         }
 
         m_isDRM = isDRMWidget(widgetPath);
@@ -450,7 +450,8 @@ void JobWidgetInstall::configureWidgetLocation(const std::string & widgetPath,
                                              tzPkgid),
                        widgetPath, tempPath,
                        m_installerContext.widgetConfig.packagingType,
-                       m_installerContext.locationType);
+                       m_installerContext.mode.rootPath ==
+                           InstallMode::RootPath::RO);
     m_installerContext.locations->registerAppid(
         DPL::ToUTF8String(m_installerContext.widgetConfig.tzAppid));
 
@@ -1106,18 +1107,11 @@ bool JobWidgetInstall::detectResourceEncryption(
 }
 
 void JobWidgetInstall::setInstallLocationType(
-    const
-    WrtDB::ConfigParserData &
-    configData)
+    const WrtDB::ConfigParserData & configData)
 {
     m_installerContext.locationType = INSTALL_LOCATION_TYPE_NOMAL;
-
-    if (m_installerContext.mode.installTime == InstallMode::InstallTime::PRELOAD) {
-        m_installerContext.locationType =
-            INSTALL_LOCATION_TYPE_PRELOAD;
-    } else {
-        FOREACH(it, configData.settingsList)
-        {
+    if (m_installerContext.mode.installTime != InstallMode::InstallTime::PRELOAD) {
+        FOREACH(it, configData.settingsList) {
             if (it->m_name == SETTING_VALUE_INSTALLTOEXT_NAME &&
                 it->m_value ==
                 SETTING_VALUE_INSTALLTOEXT_PREPER_EXT)
index c87541d..caf9660 100644 (file)
@@ -28,7 +28,7 @@ namespace Jobs {
 namespace WidgetInstall {
 //TODO make directory like jobs common?
 
-std::string createTempPath(bool preload = false);
+std::string createTempPath(bool isReadOnly = false);
 void createTempPath(const std::string& path);
 } // WidgetInstall
 } // Jobs
index 111305b..2203828 100644 (file)
@@ -234,7 +234,7 @@ void TaskFileManipulation::StepRenamePath()
 
 void TaskFileManipulation::StepLinkForPreload()
 {
-    if (m_context.mode.installTime == InstallMode::InstallTime::PRELOAD) {
+    if (m_context.mode.rootPath == InstallMode::RootPath::RO) {
         std::string srcDir = m_context.locations->getUserDataRootDir() +
             WrtDB::GlobalConfig::GetWidgetSrcPath();
 
index 24aa446..44985ce 100644 (file)
@@ -563,7 +563,7 @@ void TaskManifestFile::commitManifest()
     LogDebug("Commiting manifest file : " << manifest_file);
 
     std::ostringstream destFile;
-    if (m_context.mode.installTime == InstallMode::InstallTime::PRELOAD) {
+    if (m_context.mode.rootPath == InstallMode::RootPath::RO) {
         destFile << "/usr/share/packages" << "/"; //TODO constant with path
     } else {
         destFile << "/opt/share/packages" << "/"; //TODO constant with path
index f48751f..a0ffb58 100644 (file)
 #include <dpl/log/log.h>
 #include <dpl/sstream.h>
 #include <dpl/localization/localization_utils.h>
-
 #include <widget_install/task_commons.h>
 
-WidgetLocation::DirectoryDeletor::DirectoryDeletor(bool isPreload) :
-    m_dirpath(Jobs::WidgetInstall::createTempPath(isPreload))
+WidgetLocation::DirectoryDeletor::DirectoryDeletor(bool isReadOnly) :
+    m_dirpath(Jobs::WidgetInstall::createTempPath(isReadOnly))
 {}
 
 WidgetLocation::DirectoryDeletor::DirectoryDeletor(std::string tempPath) :
@@ -63,15 +62,14 @@ WidgetLocation::~WidgetLocation()
 WidgetLocation::WidgetLocation(const std::string & widgetname,
                                std::string sourcePath,
                                WrtDB::PackagingType t,
-                               InstallLocationType locationType) :
+                               bool isReadonly) :
     m_pkgid(widgetname),
     m_widgetSource(sourcePath),
     m_type(t),
     m_temp(
-        new WidgetLocation::DirectoryDeletor(
-            INSTALL_LOCATION_TYPE_PRELOAD == locationType))
+        new WidgetLocation::DirectoryDeletor(isReadonly))
 {
-    if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) {
+    if (isReadonly) {
         m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
     } else {
         m_installedPath += WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
@@ -86,14 +84,13 @@ WidgetLocation::WidgetLocation(const std::string & widgetname,
                                std::string sourcePath,
                                std::string dirPath,
                                WrtDB::PackagingType t,
-                               InstallLocationType locationType) :
+                               bool isReadonly) :
     m_pkgid(widgetname),
     m_widgetSource(sourcePath),
     m_type(t),
-    m_temp(new
-           WidgetLocation::DirectoryDeletor(dirPath))
+    m_temp(new WidgetLocation::DirectoryDeletor(dirPath))
 {
-    if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) {
+    if (isReadonly) {
         m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
     } else {
         m_installedPath += WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
index 07ea234..2e5b7c9 100644 (file)
@@ -101,14 +101,12 @@ class WidgetLocation
      */
     WidgetLocation(const std::string & widgetname, std::string sourcePath,
                    WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP,
-                   InstallLocationType ltype =
-                       INSTALL_LOCATION_TYPE_NOMAL);
+                   bool isReadonly = false);
 
     WidgetLocation(const std::string & widgetname, std::string sourcePath,
                    std::string dirPath,
                    WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP,
-                   InstallLocationType ltype =
-                       INSTALL_LOCATION_TYPE_NOMAL);
+                   bool isReadonly = false);
 
     ~WidgetLocation();
 
index b2bccad..77457f5 100644 (file)
@@ -189,6 +189,16 @@ void WrtInstaller::OnCreate()
             }
             m_packagePath = m_argv[2];
             m_installMode.installTime = InstallMode::InstallTime::PRELOAD;
+            m_installMode.rootPath = InstallMode::RootPath::RO;
+            AddStep(&WrtInstaller::installStep);
+        } else if (arg == "-ipw" || arg == "--install-preload-writable") {
+            LogDebug("Install preload web application to writable storage");
+            if (m_argc != 3) {
+                return showHelpAndQuit();
+            }
+            m_packagePath = m_argv[2];
+            m_installMode.installTime = InstallMode::InstallTime::PRELOAD;
+            m_installMode.rootPath = InstallMode::RootPath::RW;
             AddStep(&WrtInstaller::installStep);
         } else if (arg == "-c" || arg == "--csc-update") {
             // "path=/opt/system/csc/Ozq2iEG15R-2.0.0-arm.wgt:op=install:removable=true"