[Release] wrt-installer_0.1.118
authorsung-su.kim <sung-su.kim@samsung.com>
Wed, 21 Aug 2013 02:20:05 +0000 (11:20 +0900)
committersung-su.kim <sung-su.kim@samsung.com>
Wed, 21 Aug 2013 02:20:05 +0000 (11:20 +0900)
Change-Id: Idbc4bff7105a412f2f5fc1127ed07cb592b9bbe9

configuration/feature-wrt.properties
packaging/wrt-installer.spec
src/jobs/widget_install/job_widget_install.cpp
src/jobs/widget_install/task_file_manipulation.cpp
src/jobs/widget_install/task_pkg_info_update.cpp
src/jobs/widget_install/task_prepare_reinstall.cpp
src/jobs/widget_install/task_smack.cpp
src/jobs/widget_uninstall/task_smack.cpp
src/misc/widget_location.cpp
src/misc/widget_location.h

index e103153..198b659 100644 (file)
@@ -1,28 +1,26 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>\r
-<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">\r
-<properties>\r
-    <entry key="http://tizen.org/feature/network.push"/>\r
-    <entry key="http://tizen.org/feature/network.bluetooth"/>\r
-    <entry key="http://tizen.org/feature/network.telephony"/>\r
-    <entry key="http://tizen.org/feature/network.telephony.mms"/>\r
-    <entry key="http://tizen.org/feature/network.nfc"/>\r
-    <entry key="http://tizen.org/feature/network.secure_element"/>\r
-    <entry key="http://tizen.org/feature/network.wifi"/>\r
-\r
-    <entry key="http://tizen.org/feature/camera"/>\r
-    <entry key="http://tizen.org/feature/microphone"/>\r
-    <entry key="http://tizen.org/feature/location.gps"/>\r
-    <entry key="http://tizen.org/feature/sensor.accelerometer"/>\r
-    <entry key="http://tizen.org/feature/sensor.gyroscope"/>\r
-    <entry key="http://tizen.org/feature/sensor.magnetometer"/>\r
-\r
-    <entry key="http://tizen.org/feature/screen.size.normal"/>\r
-    <entry key="http://tizen.org/feature/screen.size.normal.720.1280"/>\r
-    <entry key="http://tizen.org/feature/screen.size.normal.240.400"/>\r
-    <entry key="http://tizen.org/feature/screen.size.normal.320.480"/>\r
-    <entry key="http://tizen.org/feature/screen.size.normal.480.800"/>\r
-    <entry key="http://tizen.org/feature/screen.size.normal.540.960"/>\r
-    <entry key="http://tizen.org/feature/screen.size.normal.600.1024"/>\r
-    <entry key="http://tizen.org/feature/screen.size.normal.1080.1920"/>\r
-\r
-</properties>\r
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+    <entry key="http://tizen.org/feature/network.push"/>
+    <entry key="http://tizen.org/feature/network.bluetooth"/>
+    <entry key="http://tizen.org/feature/network.telephony"/>
+    <entry key="http://tizen.org/feature/network.telephony.mms"/>
+    <entry key="http://tizen.org/feature/network.nfc"/>
+    <entry key="http://tizen.org/feature/network.secure_element"/>
+    <entry key="http://tizen.org/feature/network.wifi"/>
+
+    <entry key="http://tizen.org/feature/camera"/>
+    <entry key="http://tizen.org/feature/microphone"/>
+    <entry key="http://tizen.org/feature/location.gps"/>
+    <entry key="http://tizen.org/feature/sensor.accelerometer"/>
+    <entry key="http://tizen.org/feature/sensor.gyroscope"/>
+    <entry key="http://tizen.org/feature/sensor.magnetometer"/>
+
+    <entry key="http://tizen.org/feature/screen.size.all"/>
+    <entry key="http://tizen.org/feature/screen.size.normal"/>
+    <entry key="http://tizen.org/feature/screen.size.normal.320.480"/>
+    <entry key="http://tizen.org/feature/screen.size.normal.480.800"/>
+    <entry key="http://tizen.org/feature/screen.size.normal.540.960"/>
+    <entry key="http://tizen.org/feature/screen.size.normal.720.1280"/>
+    <entry key="http://tizen.org/feature/screen.size.normal.1080.1920"/>
+</properties>
index a719f9d..1bb2dc6 100644 (file)
@@ -1,7 +1,7 @@
 #git:framework/web/wrt-installer
 Name:       wrt-installer
 Summary:    Installer for tizen Webruntime
-Version:    0.1.116
+Version:    0.1.118
 Release:    1
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
index e746f01..7af1fb0 100644 (file)
@@ -173,12 +173,6 @@ JobWidgetInstall::JobWidgetInstall(
     m_exceptionCaught(Jobs::Exceptions::Success)
 {
     m_installerContext.mode = m_jobStruct.m_installMode;
-    getInstallerStruct().pkgmgrInterface->sendSignal(
-        PKGMGR_START_KEY,
-        PKGMGR_START_INSTALL);
-    getInstallerStruct().pkgmgrInterface->sendSignal(
-        PKGMGR_PROGRESS_KEY,
-        PKGMGR_START_VALUE);
     ConfigureResult result = prepareInstallation(widgetPath);
 
     if (result == ConfigureResult::Ok) {
@@ -256,6 +250,12 @@ JobWidgetInstall::JobWidgetInstall(
     } else {
         // Installation is not allowed to proceed due to widget update policy
         LogWarning("Configure installation failed!");
+        getInstallerStruct().pkgmgrInterface->sendSignal(
+                PKGMGR_START_KEY,
+                PKGMGR_START_INSTALL);
+        getInstallerStruct().pkgmgrInterface->sendSignal(
+                PKGMGR_PROGRESS_KEY,
+                PKGMGR_START_VALUE);
 
         AddTask(new InstallerTaskFail(result));
     }
@@ -313,6 +313,9 @@ ConfigureResult JobWidgetInstall::prepareInstallation(
 
         // Configure installation
         result = ConfigureInstallation(widgetPath, configData, tempDir);
+        getInstallerStruct().pkgmgrInterface->sendSignal(
+                PKGMGR_PROGRESS_KEY,
+                PKGMGR_START_VALUE);
     }
     Catch(Exceptions::OpenZipFailed)
     {
@@ -499,6 +502,9 @@ ConfigureResult JobWidgetInstall::ConfigureInstallation(
         m_installerContext.isUpdateMode = true;
     }
     Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) {
+        getInstallerStruct().pkgmgrInterface->sendSignal(
+                PKGMGR_START_KEY,
+                PKGMGR_START_INSTALL);
         result = ConfigureResult::Ok;
         m_installerContext.isUpdateMode = false;
 
index c7b0ec6..7b1da06 100644 (file)
@@ -420,17 +420,39 @@ void TaskFileManipulation::StepCreateSharedFolder()
             m_context.locations->getSharedRootDir());
 
     WrtUtilMakeDir(sharedPath);
+    WrtUtilMakeDir(m_context.locations->getSharedResourceDir());
 
     if (m_context.isUpdateMode) { //update
-        std::string backData = m_context.locations->getBackupSharedDir();
-        LogDebug("copy shared storage " << backData << " to " << sharedPath);
-        if (!DirectoryApi::DirectoryCopy(backData, sharedPath)) {
-            LogError("Failed to rename " << backData << " to " << sharedPath);
+        std::string backSharedData = m_context.locations->getBackupSharedDir();
+        std::string BackSharedTrusted = m_context.locations->getBackupSharedDir();
+
+
+        /* Restore /shared/data */
+        LogDebug("copy " << m_context.locations->getBackupSharedDataDir() <<
+                " to " << m_context.locations->getSharedDataDir());
+        if (!DirectoryApi::DirectoryCopy(
+                    m_context.locations->getBackupSharedDataDir(),
+                    m_context.locations->getSharedDataDir())) {
+                LogError("Failed to rename " <<
+                        m_context.locations->getBackupSharedDataDir() <<
+                        " to " << m_context.locations->getSharedDataDir());
+                ThrowMsg(Exceptions::BackupFailed,
+                        "Error occurs copy shared strage files");
+            }
+
+        /* Restore /shared/trusted */
+        LogDebug("copy " << m_context.locations->getBackupSharedTrustedDir() <<
+                " to " << m_context.locations->getSharedTrustedDir());
+        if (!DirectoryApi::DirectoryCopy(
+                    m_context.locations->getBackupSharedTrustedDir(),
+                    m_context.locations->getSharedTrustedDir())) {
+            LogError("Failed to rename " <<
+                    m_context.locations->getBackupSharedTrustedDir() << " to " <<
+                    m_context.locations->getSharedTrustedDir());
             ThrowMsg(Exceptions::BackupFailed,
                     "Error occurs copy shared strage files");
         }
     } else {
-        WrtUtilMakeDir(m_context.locations->getSharedResourceDir());
         changeOwnerForDirectory(m_context.locations->getSharedDataDir(),
                 SHARED_STORAGE_MODE);
         changeOwnerForDirectory(m_context.locations->getSharedTrustedDir(),
index 7f6a1d5..807117f 100644 (file)
@@ -86,14 +86,12 @@ void TaskPkgInfoUpdate::StepPkgInfo()
                 && 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);
+        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);
-            }
+        if (code != 0) {
+            LogError("Manifest parser error: " << code);
+            ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code);
         }
     } else {
         code = pkgmgr_parser_parse_manifest_for_installation(
index 7178db3..8955c19 100644 (file)
@@ -30,6 +30,7 @@
 #include <dpl/string.h>
 #include <dpl/log/log.h>
 #include <dpl/foreach.h>
+#include <dpl/utils/wrt_utility.h>
 
 #include <widget_install/widget_install_context.h>
 #include <widget_install/widget_install_errors.h>
@@ -49,7 +50,27 @@ void verifyFile(const std::string &filePath)
         ThrowMsg(Exceptions::RDSDeltaFailure, "File is missed " << filePath);
     }
 }
+
+std::string parseSubPath(const std::string& filePath)
+{
+    std::string subPath("");
+    size_t pos = filePath.find_last_of('/') + 1;
+
+    if (pos != std::string::npos) {
+        subPath = filePath.substr(0, pos);
+    }
+    return subPath;
+}
+
+void createDir(const std::string& path)
+{
+    if (WrtUtilMakeDir(path)) {
+        LogDebug("Create directory : " << path);
+    } else {
+        ThrowMsg(Exceptions::RDSDeltaFailure, "Fail to create dir" << path);
+    }
 }
+} // namespace anonymous
 
 TaskPrepareReinstall::TaskPrepareReinstall(InstallerContext& context) :
     DPL::TaskDecl<TaskPrepareReinstall>(this),
@@ -154,11 +175,30 @@ void TaskPrepareReinstall::StepAddFile()
         newfile += *file;
         std::string destPath = m_installedPath;
         destPath += *file;
-        if (rename(newfile.c_str(), destPath.c_str()) != 0) {
-            ThrowMsg(Exceptions::RDSDeltaFailure,
-                "Fail to ADD file " << newfile);
+
+        if (WrtUtilDirExists(newfile)) {
+            // In case of a new directory
+            createDir(destPath);
+        } else {
+            // In case of a new file
+
+            // Parse directory and file separately
+            std::string subPath = parseSubPath(destPath);
+            if (subPath.empty()) {
+                ThrowMsg(Exceptions::RDSDeltaFailure,
+                         "Invalid path given" << destPath);
+            }
+
+            // Create a new directory
+            createDir(subPath);
+
+            // Add file
+            if (rename(newfile.c_str(), destPath.c_str()) != 0) {
+                ThrowMsg(Exceptions::RDSDeltaFailure,
+                        "Fail to add file " << newfile);
+            }
+            LogDebug("Add " << newfile << " to " << destPath);
         }
-        LogDebug("Copy " << newfile << " to " << destPath);
     }
 }
 
index f338fc3..2082cbc 100644 (file)
@@ -77,7 +77,7 @@ void TaskSmack::StepSetInstall()
     if (m_context.widgetConfig.packagingType !=
             WrtDB::PkgType::PKG_TYPE_HYBRID_WEB_APP)
     {
-            if (PC_OPERATION_SUCCESS != app_install(m_pkgId)) {
+            if (PC_OPERATION_SUCCESS != perm_app_install(m_pkgId)) {
             free(m_pkgId);
             ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
                     "failure in creating smack rules file.");
@@ -92,7 +92,7 @@ void TaskSmack::StepSmackFolderLabeling()
             Jobs::WidgetInstall::TaskSmack::SmackFolderLabelingStep()");
 #ifdef WRT_SMACK_ENABLED
     /* /opt/usr/apps/[pkgid] directory's label is "_" */
-    if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+    if (PC_OPERATION_SUCCESS != perm_app_setup_path(m_pkgId,
                 m_context.locations->getPackageInstallationDir().c_str(),
                 APP_PATH_ANY_LABEL, "_")) {
         LogWarning("Add label to " <<
@@ -103,7 +103,7 @@ void TaskSmack::StepSmackFolderLabeling()
     if (m_context.mode.installTime == InstallMode::InstallTime::PRELOAD &&
             m_context.mode.extension != InstallMode::ExtensionType::DIR)
     {
-        if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+        if (PC_OPERATION_SUCCESS != perm_app_setup_path(m_pkgId,
                     m_context.locations->getUserDataRootDir().c_str(),
                     APP_PATH_ANY_LABEL, "_")) {
         }
@@ -113,20 +113,20 @@ void TaskSmack::StepSmackFolderLabeling()
     std::string resDir = m_context.locations->getPackageInstallationDir() +
         "/res";
 
-    if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId, resDir.c_str(),
+    if (PC_OPERATION_SUCCESS != perm_app_setup_path(m_pkgId, resDir.c_str(),
                 APP_PATH_PRIVATE)) {
         LogWarning("Add label to " << resDir);
     }
 
     /* data directory */
-    if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+    if (PC_OPERATION_SUCCESS != perm_app_setup_path(m_pkgId,
                 m_context.locations->getPrivateStorageDir().c_str(),
                 APP_PATH_PRIVATE)) {
         LogWarning("Add label to " << m_context.locations->getPrivateStorageDir());
     }
 
     /* tmp directory */
-    if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+    if (PC_OPERATION_SUCCESS != perm_app_setup_path(m_pkgId,
                 m_context.locations->getPrivateTempStorageDir().c_str(),
                 APP_PATH_PRIVATE))
     {
@@ -134,7 +134,7 @@ void TaskSmack::StepSmackFolderLabeling()
     }
 
     /* bin directory */
-    if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+    if (PC_OPERATION_SUCCESS != perm_app_setup_path(m_pkgId,
                 m_context.locations->getBinaryDir().c_str(),
                 APP_PATH_PRIVATE)) {
         LogWarning("Add label to " << m_context.locations->getBinaryDir());
@@ -178,7 +178,7 @@ void TaskSmack::StepSmackPrivilege()
     }
     perm_list[index] = NULL;
 
-    if (PC_OPERATION_SUCCESS != app_enable_permissions(appId, APP_TYPE_WGT,
+    if (PC_OPERATION_SUCCESS != perm_app_enable_permissions(appId, APP_TYPE_WGT,
                 const_cast<const char **>(perm_list), true)) {
         LogWarning("failure in contructing smack rules based on perm_list");
     }
@@ -201,7 +201,7 @@ void TaskSmack::StepRevokeForUpdate()
     LogDebug("----------------> SMACK:\
             Jobs::WidgetInstall::TaskSmack::StepRevokePrivilegeForUpdate()");
 #ifdef WRT_SMACK_ENABLED
-    if (PC_OPERATION_SUCCESS != app_revoke_permissions(m_pkgId)) {
+    if (PC_OPERATION_SUCCESS != perm_app_revoke_permissions(m_pkgId)) {
         LogWarning("failure in revoking smack permissions");
     }
 #endif
@@ -213,11 +213,11 @@ void TaskSmack::StepAbortSmack()
             Jobs::WidgetInstall::TaskSmack::StepAbortSmack()");
 #ifdef WRT_SMACK_ENABLED
 
-    if (PC_OPERATION_SUCCESS != app_revoke_permissions(m_pkgId)) {
+    if (PC_OPERATION_SUCCESS != perm_app_revoke_permissions(m_pkgId)) {
         LogWarning("failure in revoking smack permissions");
     }
 
-    if (PC_OPERATION_SUCCESS != app_uninstall(m_pkgId)) {
+    if (PC_OPERATION_SUCCESS != perm_app_uninstall(m_pkgId)) {
         LogWarning("failure in removing smack rules file");
     }
     free(m_pkgId);
@@ -227,14 +227,14 @@ void TaskSmack::StepAbortSmack()
 bool TaskSmack::setLabelForSharedDir(const char* pkgId)
 {
     /* /shared directory */
-    if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+    if (PC_OPERATION_SUCCESS != perm_app_setup_path(m_pkgId,
                 m_context.locations->getSharedRootDir().c_str(),
                 APP_PATH_ANY_LABEL, "_")) {
         LogWarning("Add label to " << m_context.locations->getUserDataRootDir());
     }
 
     /* /shared/res directory */
-    if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+    if (PC_OPERATION_SUCCESS != perm_app_setup_path(m_pkgId,
                 m_context.locations->getSharedResourceDir().c_str(),
                 APP_PATH_ANY_LABEL, "_")) {
         LogWarning("Add label to " << m_context.locations->getSharedResourceDir());
@@ -255,7 +255,7 @@ bool TaskSmack::setLabelForSharedDir(const char* pkgId)
 
         LogDebug("sha1 label string : " << sha1String);
 
-        if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+        if (PC_OPERATION_SUCCESS != perm_app_setup_path(m_pkgId,
                     m_context.locations->getSharedTrustedDir().c_str(),
                     APP_PATH_GROUP_RW, sha1String.c_str())) {
             LogWarning("Add label to " << m_context.locations->getBinaryDir());
@@ -263,7 +263,7 @@ bool TaskSmack::setLabelForSharedDir(const char* pkgId)
     }
 
     /* /shared/data directory */
-    if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+    if (PC_OPERATION_SUCCESS != perm_app_setup_path(m_pkgId,
                 m_context.locations->getSharedDataDir().c_str(),
                 APP_PATH_PUBLIC_RO)) {
         LogWarning("Add label to " << m_context.locations->getSharedDataDir());
index 353aaaf..c8079a2 100644 (file)
@@ -46,11 +46,11 @@ void TaskSmack::Step()
         "------------------------> SMACK: Jobs::WidgetUninstall::TaskSmack::Step()");
 #ifdef WRT_SMACK_ENABLED
     const char* pkgId = m_context.tzPkgid.c_str();
-    if (PC_OPERATION_SUCCESS != app_revoke_permissions(pkgId)) {
+    if (PC_OPERATION_SUCCESS != perm_app_revoke_permissions(pkgId)) {
         LogError("failure in revoking smack permissions");
     }
 
-    if (PC_OPERATION_SUCCESS != app_uninstall(pkgId)) {
+    if (PC_OPERATION_SUCCESS != perm_app_uninstall(pkgId)) {
         LogError("failure in removing smack rules file");
     }
 #endif
index 40b2129..32d0a16 100644 (file)
@@ -276,3 +276,13 @@ std::string WidgetLocation::getBackupSharedDir() const
 {
     return getBackupDir() + "/shared";
 }
+
+std::string WidgetLocation::getBackupSharedDataDir() const
+{
+    return getBackupSharedDir() + "/data";
+}
+
+std::string WidgetLocation::getBackupSharedTrustedDir() const
+{
+    return getBackupSharedDir() + "/trusted";
+}
index c3f8c39..a3b3e74 100644 (file)
@@ -135,6 +135,8 @@ class WidgetLocation
     std::string getSharedDataDir() const; // /opt/usr/apps/[package]/shared/data
     std::string getSharedTrustedDir() const; // /opt/usr/apps/[package]/shared/trusted
     std::string getBackupSharedDir() const; // /opt/usr/apps/[package].backup/shared
+    std::string getBackupSharedDataDir() const; // /opt/usr/apps/[package].backup/shared/data
+    std::string getBackupSharedTrustedDir() const; // /opt/usr/apps/[package].backup/shared/trusted
 
     // Temporary paths
     /**