From 64adfd29349f450e7739213765abbc2db7f7f57a Mon Sep 17 00:00:00 2001 From: Jihoon Chung Date: Wed, 8 May 2013 18:15:57 +0900 Subject: [PATCH 1/1] [Release] wrt-installer_0.1.54 --- packaging/wrt-installer.spec | 4 +-- src/jobs/job_exception_error.h | 1 + src/jobs/widget_install/job_widget_install.cpp | 42 ++++++++++++++++++++++ src/jobs/widget_install/job_widget_install.h | 2 ++ src/jobs/widget_install/task_file_manipulation.cpp | 26 ++++++++++++++ src/jobs/widget_install/task_file_manipulation.h | 1 + src/jobs/widget_install/task_update_files.cpp | 3 ++ src/jobs/widget_install/widget_install_errors.h | 1 + src/misc/widget_location.cpp | 26 ++++++++++++++ src/misc/widget_location.h | 5 +++ 10 files changed, 109 insertions(+), 2 deletions(-) diff --git a/packaging/wrt-installer.spec b/packaging/wrt-installer.spec index bc8c952..34170e1 100644 --- a/packaging/wrt-installer.spec +++ b/packaging/wrt-installer.spec @@ -1,7 +1,7 @@ -#git:framework/web/wrt-installer wrt-installer_0.1.53 +#git:framework/web/wrt-installer wrt-installer_0.1.54 Name: wrt-installer Summary: Installer for tizen Webruntime -Version: 0.1.53 +Version: 0.1.54 Release: 1 Group: Development/Libraries License: Apache License, Version 2.0 diff --git a/src/jobs/job_exception_error.h b/src/jobs/job_exception_error.h index 9aebb74..1caba99 100644 --- a/src/jobs/job_exception_error.h +++ b/src/jobs/job_exception_error.h @@ -77,6 +77,7 @@ enum Type ErrorInstallOspServcie, ///< Failure in installing osp service ErrorPluginInstallationFailed, ///< failure in plugin installation ErrorWidgetUninstallationFailed, ///< failure in uninstallation + ErrorNotSupportRDSUpdate, ///< failure in rds update ErrorUnknown = 140, ///< do not use this error code. }; diff --git a/src/jobs/widget_install/job_widget_install.cpp b/src/jobs/widget_install/job_widget_install.cpp index aa46a4e..72c2332 100644 --- a/src/jobs/widget_install/job_widget_install.cpp +++ b/src/jobs/widget_install/job_widget_install.cpp @@ -90,6 +90,7 @@ const size_t PACKAGE_ID_LENGTH = 10; static const DPL::String SETTING_VALUE_ENCRYPTION = L"encryption"; static const DPL::String SETTING_VALUE_ENCRYPTION_ENABLE = L"enable"; +static const DPL::String SETTING_VALUE_ENCRYPTION_DISABLE = L"disable"; const DPL::String SETTING_VALUE_INSTALLTOEXT_NAME = L"install-location"; const DPL::String SETTING_VALUE_INSTALLTOEXT_PREPER_EXT = @@ -139,6 +140,9 @@ class InstallerTaskFail : } else if (m_result == ConfigureResult::Failed_DrmError) { ThrowMsg(Jobs::WidgetInstall::Exceptions::DRMFailed, "drm failed"); + } else if (m_result == ConfigureResult::Failed_NotSupportRDSUpdate) { + ThrowMsg(Jobs::WidgetInstall::Exceptions::NotSupportRDSUpdate, + "RDS update failed"); } else { ThrowMsg(Jobs::WidgetInstall::Exceptions::NotAllowed, "widget installation or update not allowed!"); @@ -480,6 +484,9 @@ ConfigureResult JobWidgetInstall::ConfigureInstallation( // Already installed TizenAppId. return failed return ConfigureResult::Failed_AlreadyInstalled; } + if (!checkSupportRDSUpdate(configData)) { + return ConfigureResult::Failed_NotSupportRDSUpdate; + } m_installerContext.isUpdateMode = true; } Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) { @@ -1104,5 +1111,40 @@ bool JobWidgetInstall::DecryptDRMWidget(std::string /*widgetPath*/, /* TODO */ return false; } + +bool JobWidgetInstall::checkSupportRDSUpdate(const WrtDB::ConfigParserData + &configInfo) +{ + if (m_installerContext.mode.command == + InstallMode::Command::REINSTALL) + { + DPL::String configValue = SETTING_VALUE_ENCRYPTION_DISABLE; + DPL::String dbValue = SETTING_VALUE_ENCRYPTION_DISABLE; + + WidgetDAOReadOnly dao(m_installerContext.widgetConfig.tzAppid); + WrtDB::WidgetSettings widgetSettings; + dao.getWidgetSettings(widgetSettings); + + FOREACH(it, widgetSettings) { + if (it->settingName == SETTING_VALUE_ENCRYPTION) { + dbValue = it->settingValue; + } + } + + FOREACH(data, configInfo.settingsList) + { + if (data->m_name == SETTING_VALUE_ENCRYPTION) + { + configValue = data->m_value; + } + } + if (configValue != dbValue) { + LogError("Not Support RDS mode because of encryption setting"); + return false; + } + } + + return true; +} } //namespace WidgetInstall } //namespace Jobs diff --git a/src/jobs/widget_install/job_widget_install.h b/src/jobs/widget_install/job_widget_install.h index 549c80d..7d5862d 100644 --- a/src/jobs/widget_install/job_widget_install.h +++ b/src/jobs/widget_install/job_widget_install.h @@ -48,6 +48,7 @@ enum class ConfigureResult Failed_AlreadyInstalled, Failed_WidgetRunning, Failed_DrmError, + Failed_NotSupportRDSUpdate, }; class JobWidgetInstall : @@ -97,6 +98,7 @@ class JobWidgetInstall : bool validateTizenPackageID(const WrtDB::TizenPkgId &tizenPkgId); ConfigureResult checkWidgetUpdate(const WidgetUpdateInfo &update); void setApplicationType(const WrtDB::ConfigParserData &configInfo); + bool checkSupportRDSUpdate(const WrtDB::ConfigParserData &configInfo); public: /** diff --git a/src/jobs/widget_install/task_file_manipulation.cpp b/src/jobs/widget_install/task_file_manipulation.cpp index e32607b..b1629de 100644 --- a/src/jobs/widget_install/task_file_manipulation.cpp +++ b/src/jobs/widget_install/task_file_manipulation.cpp @@ -157,12 +157,14 @@ TaskFileManipulation::TaskFileManipulation(InstallerContext& context) : AddAbortStep(&TaskFileManipulation::StepAbortRenamePath); } AddStep(&TaskFileManipulation::StepCreatePrivateStorageDir); + AddStep(&TaskFileManipulation::StepCreateSharedFolder); AddStep(&TaskFileManipulation::StepLinkForPreload); } else { AddStep(&TaskFileManipulation::StepPrepareExternalDir); AddStep(&TaskFileManipulation::StepInstallToExternal); AddStep(&TaskFileManipulation::StepCreatePrivateStorageDir); + AddStep(&TaskFileManipulation::StepCreateSharedFolder); AddAbortStep(&TaskFileManipulation::StepAbortCreateExternalDir); } @@ -406,5 +408,29 @@ void TaskFileManipulation::StepAbortCreateExternalDir() } WidgetInstallToExtSingleton::Instance().deinitialize(); } + +void TaskFileManipulation::StepCreateSharedFolder() +{ + LogDebug("StepCreateSharedFolder"); + std::string sharedPath = m_context.locations->getSharedRootDir(); + LogDebug("Create shared directory : " << + m_context.locations->getSharedRootDir()); + + WrtUtilMakeDir(sharedPath); + + 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); + ThrowMsg(Exceptions::BackupFailed, + "Error occurs copy shared strage files"); + } + } else { + WrtUtilMakeDir(m_context.locations->getSharedResourceDir()); + WrtUtilMakeDir(m_context.locations->getSharedDataDir()); + WrtUtilMakeDir(m_context.locations->getSharedTrustedDir()); + } +} } //namespace WidgetInstall } //namespace Jobs diff --git a/src/jobs/widget_install/task_file_manipulation.h b/src/jobs/widget_install/task_file_manipulation.h index 44b20f5..fc1d9ff 100644 --- a/src/jobs/widget_install/task_file_manipulation.h +++ b/src/jobs/widget_install/task_file_manipulation.h @@ -39,6 +39,7 @@ class TaskFileManipulation : void StepCreateDirs(); void StepRenamePath(); void StepCreatePrivateStorageDir(); + void StepCreateSharedFolder(); void StepAbortRenamePath(); void StepLinkForPreload(); diff --git a/src/jobs/widget_install/task_update_files.cpp b/src/jobs/widget_install/task_update_files.cpp index 69b7053..12af068 100644 --- a/src/jobs/widget_install/task_update_files.cpp +++ b/src/jobs/widget_install/task_update_files.cpp @@ -71,6 +71,9 @@ void TaskUpdateFiles::StepBackupDirectory() LogDebug("backup resource directory path : " << backPath); std::string pkgPath = m_context.locations->getPackageInstallationDir(); + if (0 == access(backPath.c_str(), F_OK)) { + WrtUtilRemove(backPath); + } LogDebug("copy : " << pkgPath << " to " << backPath); if ((rename(pkgPath.c_str(), backPath.c_str())) != 0) { LogError("Failed to rename " << pkgPath << " to " << backPath); diff --git a/src/jobs/widget_install/widget_install_errors.h b/src/jobs/widget_install/widget_install_errors.h index 9e3f8c9..eb1a25e 100644 --- a/src/jobs/widget_install/widget_install_errors.h +++ b/src/jobs/widget_install/widget_install_errors.h @@ -89,6 +89,7 @@ DECLARE_JOB_EXCEPTION(Base, AceCheckFailed, ErrorAceCheckFailed) DECLARE_JOB_EXCEPTION(Base, EncryptionFailed, ErrorEncryptionFailed) DECLARE_JOB_EXCEPTION(Base, InstallOspsvcFailed, ErrorInstallOspServcie) DECLARE_JOB_EXCEPTION(Base, PrivilegeLevelViolation, ErrorPrivilegeLevelViolation) +DECLARE_JOB_EXCEPTION(Base, NotSupportRDSUpdate, ErrorNotSupportRDSUpdate) } //namespace } //namespace } //namespace diff --git a/src/misc/widget_location.cpp b/src/misc/widget_location.cpp index adfbd44..a2905aa 100644 --- a/src/misc/widget_location.cpp +++ b/src/misc/widget_location.cpp @@ -240,3 +240,29 @@ void WidgetLocation::registerAppid(const std::string & appid) { m_appid = appid; } + +std::string WidgetLocation::getSharedRootDir() const +{ + /* TODO : add wrt-commons*/ + return getUserDataRootDir() + "/shared"; +} + +std::string WidgetLocation::getSharedResourceDir() const +{ + return getSharedRootDir() + "/res"; +} + +std::string WidgetLocation::getSharedDataDir() const +{ + return getSharedRootDir() + "/data"; +} + +std::string WidgetLocation::getSharedTrustedDir() const +{ + return getSharedRootDir() + "/trusted"; +} + +std::string WidgetLocation::getBackupSharedDir() const +{ + return getBackupDir() + "/shared"; +} diff --git a/src/misc/widget_location.h b/src/misc/widget_location.h index 0cdcbdd..ad73d80 100644 --- a/src/misc/widget_location.h +++ b/src/misc/widget_location.h @@ -124,6 +124,11 @@ class WidgetLocation std::string getBackupPrivateDir() const; // /opt/apps/[pkg].backup/data std::string getUserDataRootDir() const; // /opt/usr/apps/[package] std::string getPrivateStorageDir() const; // /opt/usr/apps/[package]/data + std::string getSharedRootDir() const; // /opt/usr/apps/[package]/shared + std::string getSharedResourceDir() const; // /opt/usr/apps/[package]/shared/res + 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 // Temporary paths /** -- 2.7.4