${INSTALLER_JOBS}/widget_install/task_configuration.cpp
${INSTALLER_JOBS}/widget_install/ace_registration.cpp
${INSTALLER_JOBS}/widget_install/task_file_manipulation.cpp
+ ${INSTALLER_JOBS}/widget_install/task_user_data_manipulation.cpp
${INSTALLER_JOBS}/widget_install/task_smack.cpp
${INSTALLER_JOBS}/widget_install/task_ace_check.cpp
${INSTALLER_JOBS}/widget_install/task_manifest_file.cpp
#include <widget_install/task_commons.h>
#include <widget_install/task_prepare_reinstall.h>
#include <widget_install/task_configuration.h>
+#include <widget_install/task_user_data_manipulation.h>
#include <widget_install_to_external.h>
#include <widget_install/widget_unzip.h>
AddTask(new TaskRecovery(m_installerContext));
+ AddTask(new TaskFileManipulation(m_installerContext));
AddTask(new TaskProcessConfig(m_installerContext));
if (m_installerContext.widgetConfig.packagingType ==
WrtDB::PKG_TYPE_HOSTED_WEB_APP)
}
AddTask(new TaskCertify(m_installerContext));
AddTask(new TaskCertifyLevel(m_installerContext));
+ AddTask(new TaskUserDataManipulation(m_installerContext));
if (m_installerContext.needEncryption) {
AddTask(new TaskEncryptResource(m_installerContext));
}
- AddTask(new TaskFileManipulation(m_installerContext));
AddTask(new TaskManifestFile(m_installerContext));
if (m_installerContext.widgetConfig.packagingType ==
PKG_TYPE_HYBRID_WEB_APP)
AddTask(new TaskPrepareReinstall(m_installerContext));
}
+ if (m_installerContext.mode.extension !=
+ InstallMode::ExtensionType::DIR) {
+ AddTask(new TaskUpdateFiles(m_installerContext));
+ AddTask(new TaskFileManipulation(m_installerContext));
+ }
+
AddTask(new TaskProcessConfig(m_installerContext));
if (m_installerContext.widgetConfig.packagingType ==
AddTask(new TaskCertify(m_installerContext));
AddTask(new TaskCertifyLevel(m_installerContext));
+ AddTask(new TaskUserDataManipulation(m_installerContext));
if (m_installerContext.needEncryption) {
AddTask(new TaskEncryptResource(m_installerContext));
}
- if (m_installerContext.mode.extension !=
- InstallMode::ExtensionType::DIR) {
- AddTask(new TaskUpdateFiles(m_installerContext));
- AddTask(new TaskFileManipulation(m_installerContext));
- }
-
AddTask(new TaskManifestFile(m_installerContext));
if (m_installerContext.widgetConfig.packagingType ==
PKG_TYPE_HYBRID_WEB_APP)
_D("================ Step: <<Signature>> ENTER ===============");
std::string widgetPath;
- widgetPath = m_contextData.locations->getTemporaryPackageDir() + "/";
-
- if (m_contextData.mode.command ==
- InstallMode::Command::REINSTALL)
- {
- widgetPath = m_contextData.locations->getPackageInstallationDir() + "/";
- }
+ widgetPath = m_contextData.locations->getPackageInstallationDir() + "/";
SignatureFileInfoSet signatureFiles;
TaskCertifyLevel::Level TaskCertifyLevel::getCertifyLevel()
{
- std::string widgetPath;
- widgetPath = m_contextData.locations->getTemporaryPackageDir() + "/";
-
- if (m_contextData.mode.command == InstallMode::Command::REINSTALL) {
- widgetPath =
- m_contextData.locations->getPackageInstallationDir() + "/";
- }
-
+ std::string widgetPath = m_contextData.locations->getPackageInstallationDir() + "/";
SignatureFileInfoSet signatureFiles;
Try {
AddStep(&TaskConfiguration::SetupTempDirStep);
AddStep(&TaskConfiguration::UnzipConfigurationStep);
AddStep(&TaskConfiguration::ParseXMLConfigStep);
- AddStep(&TaskConfiguration::UnzipWidgetFileStep);
- AddStep(&TaskConfiguration::CheckPackageTypeStep);
AddStep(&TaskConfiguration::TizenIdStep);
AddStep(&TaskConfiguration::CheckAppRunningStateStep);
if(!hasExtension(m_context.requestedPath, XML_EXTENSION)) //unzip everything except xml files
{
WidgetUnzip wgtUnzip;
- wgtUnzip.unzipConfiguration(m_context.requestedPath, m_tempDir);
+ wgtUnzip.unzipConfiguration(m_context.requestedPath, m_tempDir,
+ &m_context.widgetConfig.packagingType);
m_configuration += m_tempDir + "/" + CONFIG_XML;
} else{
+ m_context.widgetConfig.packagingType = PKG_TYPE_HOSTED_WEB_APP;
m_configuration += m_context.requestedPath;
}
} else {
configFile += "/";
configFile += WITH_OSP_XML;
}
+ } else {
+ m_context.widgetConfig.packagingType = PKG_TYPE_NOMAL_WEB_APP;
}
m_configuration = configFile;
} else {
}
}
_D("m_configuration : %s", m_configuration.c_str());
-}
-
-void TaskConfiguration::UnzipWidgetFileStep()
-{
- _D("UnzipWidgetFileStep");
- if (m_context.mode.extension != InstallMode::ExtensionType::DIR) {
- if(!hasExtension(m_context.requestedPath, XML_EXTENSION)) //unzip everything except xml files
- {
- WidgetUnzip wgtUnzip;
- wgtUnzip.unzipWgtFile(m_context.requestedPath, m_tempDir);
- }
- else
- {
- _D("From browser installation - unzip is not done");
- }
- }
+ _D("Package Type : %s", m_context.widgetConfig.packagingType.getPkgtypeToString().c_str());
}
void TaskConfiguration::ParseXMLConfigStep()
incomingVersion);
}
-void TaskConfiguration::CheckPackageTypeStep()
-{
- if (hasExtension(m_context.requestedPath, XML_EXTENSION)) {
- _D("Hosted app installation");
- m_context.widgetConfig.packagingType = PKG_TYPE_HOSTED_WEB_APP;
- return;
- }
-
- std::string configFile = m_tempDir + "/" + OSP_MANIFEST_XML;
- if (WrtUtilFileExists(configFile)) {
- m_context.widgetConfig.packagingType = PKG_TYPE_HYBRID_WEB_APP;
- return;
- }
-
- m_context.widgetConfig.packagingType = PKG_TYPE_NOMAL_WEB_APP;
-}
-
void TaskConfiguration::ApplicationTypeStep() //TODO: is this really needed as WAC is not supported?
{
AppType widgetAppType = APP_TYPE_UNKNOWN;
void SetupTempDirStep();
void UnzipConfigurationStep();
void ParseXMLConfigStep();
- void UnzipWidgetFileStep();
- void CheckPackageTypeStep();
void TizenIdStep();
void CheckAppRunningStateStep();
{
_D("Step Encrypt resource");
- EncryptDirectory(m_context.locations->getTemporaryRootDir());
+ EncryptDirectory(m_context.locations->getSourceDir());
}
void TaskEncryptResource::EncryptDirectory(std::string path)
}
}
- std::string realPath = fileName;
- realPath.replace(0,
- m_context.locations->getTemporaryRootDir().length(),
- m_context.locations->getSourceDir());
-
WrtDB::EncryptedFileInfo fileInfo;
- fileInfo.fileName = DPL::FromUTF8String(realPath);
+ fileInfo.fileName = DPL::FromUTF8String(fileName);
fileInfo.fileSize = fileSize;
m_context.widgetConfig.encryptedFiles.insert(fileInfo);
/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2010 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <fstream>
#include <widget_install_to_external.h>
#include <installer_log.h>
+#include <widget_unzip.h>
#define WEBAPP_DEFAULT_UID 5000
#define WEBAPP_DEFAULT_GID 5000
closedir(dir);
return true;
}
-
-void changeOwnerForDirectory(std::string storagePath, mode_t mode) {
- if (euidaccess(storagePath.c_str(), F_OK) != 0) {
- if (!WrtUtilMakeDir(storagePath, mode)) {
- _E("Failed to create directory : %s", storagePath.c_str());
- ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed,
- "Failed to create directory : " << storagePath);
- }
- // '5000' is default uid, gid for applications.
- // So installed applications should be launched as process of uid
- // '5000'.
- // the process can access private directory 'data' of itself.
- if (chown(storagePath.c_str(),
- WEBAPP_DEFAULT_UID,
- WEBAPP_DEFAULT_GID) != 0)
- {
- ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed,
- "Chown to invaild user");
- }
- } else if (euidaccess(storagePath.c_str(), W_OK | R_OK | X_OK) == 0) {
- _D("%s already exists.", storagePath.c_str());
- // Even if private directory already is created, private dircetory
- // should change owner.
- if (chown(storagePath.c_str(),
- WEBAPP_DEFAULT_UID,
- WEBAPP_DEFAULT_GID) != 0)
- {
- ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed,
- "Chown to invaild user");
- }
- if (chmod(storagePath.c_str(), mode) != 0) {
- ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed,
- "chmod to 0700");
- }
- } else {
- ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed,
- "No access to private storage.");
- }
-}
}
namespace Jobs {
AddStep(&TaskFileManipulation::StepCreateDirs);
if (m_context.mode.extension != InstallMode::ExtensionType::DIR)
{
- AddStep(&TaskFileManipulation::StepRenamePath);
+ AddStep(&TaskFileManipulation::StepUnzipWgtFile);
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);
}
"Widget Directory Created");
}
-void TaskFileManipulation::StepCreatePrivateStorageDir()
+void TaskFileManipulation::StepUnzipWgtFile()
{
- std::string storagePath = m_context.locations->getPrivateStorageDir();
- _D("Create private storage directory : %s", m_context.locations->getPrivateStorageDir().c_str());
-
- changeOwnerForDirectory(storagePath, PRIVATE_STORAGE_MODE);
-
- if (m_context.isUpdateMode) { //update
- std::string backData = m_context.locations->getBackupPrivateDir();
- _D("copy private storage %s to %s", backData.c_str(), storagePath.c_str());
- if (!DirectoryApi::DirectoryCopy(backData, storagePath)) {
- _E("Failed to rename %s to %s", backData.c_str(), storagePath.c_str());
- ThrowMsg(Exceptions::BackupFailed,
- "Error occurs copy private strage files");
+ if (m_context.widgetConfig.packagingType != PKG_TYPE_HOSTED_WEB_APP) {
+ std::string instDir;
+ if (m_context.widgetConfig.packagingType == PKG_TYPE_HYBRID_WEB_APP) {
+ instDir = m_context.locations->getPackageInstallationDir();
+ } else {
+ instDir = m_context.locations->getSourceDir();
}
- }
- std::string tempStoragePath = m_context.locations->getPrivateTempStorageDir();
- _D("Create temp private storage directory : %s", tempStoragePath.c_str());
- changeOwnerForDirectory(tempStoragePath, PRIVATE_STORAGE_MODE);
-}
-
-void TaskFileManipulation::StepRenamePath()
-{
- std::string instDir;
+ _D("unzip file to %s", instDir.c_str());
- if (m_context.widgetConfig.packagingType == PKG_TYPE_HYBRID_WEB_APP) {
- instDir = m_context.locations->getPackageInstallationDir();
+ WidgetUnzip wgtUnzip;
+ wgtUnzip.unzipWgtFile(m_context.requestedPath, instDir);
} else {
- instDir = m_context.locations->getSourceDir();
- }
-
- _D("Copy file from temp directory to %s", instDir.c_str());
- if (!WrtUtilRemove(instDir)) {
- ThrowMsg(Exceptions::RemovingFolderFailure,
- "Error occurs during removing existing folder");
+ _D("From browser installation - unzip is not done");
}
- if (!(rename(m_context.locations->getTemporaryPackageDir().c_str(),
- instDir.c_str()) == 0))
- {
- ThrowMsg(Exceptions::FileOperationFailed,
- "Error occurs during renaming widget folder");
- }
m_context.job->UpdateProgress(
- InstallerContext::INSTALL_RENAME_PATH,
- "Widget Rename path Finished");
-}
-
-void TaskFileManipulation::StepLinkForPreload()
-{
- if (m_context.mode.rootPath == InstallMode::RootPath::RO) {
- std::string optRes = m_context.locations->getUserDataRootDir() +
- WrtDB::GlobalConfig::GetWidgetResPath();
- std::string usrRes = m_context.locations->getPackageInstallationDir() +
- WrtDB::GlobalConfig::GetWidgetResPath();
-
- if (0 != access(optRes.c_str(), F_OK)) {
- _D("Make symbolic name for preload app %s to %s", usrRes.c_str(), optRes.c_str());
-
- if (symlink(usrRes.c_str(), optRes.c_str()) != 0)
- {
- int error = errno;
- if (error)
- _E("Failed to make a symbolic name for a file [%s]", (DPL::GetErrnoString(error)).c_str());
- ThrowMsg(Exceptions::FileOperationFailed,
- "Symbolic link creating is not done.");
- }
- }
-
- /* link for data directory */
- std::string storagePath = m_context.locations->getPrivateStorageDir();
- std::string dataDir = m_context.locations->getPackageInstallationDir() +
- "/" + WrtDB::GlobalConfig::GetWidgetPrivateStoragePath();
- if (0 != access(dataDir.c_str(), F_OK)) {
- _D("Make symbolic name for preload app %s to %s", storagePath.c_str(), dataDir.c_str());
-
- if (symlink(storagePath.c_str(), dataDir.c_str()) != 0)
- {
- int error = errno;
- if (error)
- _E("Failed to make a symbolic name for a file [%s]", (DPL::GetErrnoString(error)).c_str());
- ThrowMsg(Exceptions::FileOperationFailed,
- "Symbolic link creating is not done.");
- }
- changeOwnerForDirectory(dataDir, PRIVATE_STORAGE_MODE);
- }
-
- if (m_context.widgetConfig.packagingType != PKG_TYPE_HYBRID_WEB_APP) {
- std::string widgetBinPath = m_context.locations->getBinaryDir();
- std::string userBinPath = m_context.locations->getUserBinaryDir();
- _D("Make symbolic link for preload app %s to %s", widgetBinPath.c_str(), userBinPath.c_str());
- if (symlink(widgetBinPath.c_str(), userBinPath.c_str()) != 0)
- {
- int error = errno;
- if (error)
- _E("Failed to make a symbolic name for a file [%s]", (DPL::GetErrnoString(error)).c_str());
- ThrowMsg(Exceptions::FileOperationFailed,
- "Symbolic link creating is not done.");
- }
-
- }
- }
+ InstallerContext::INSTALL_UNZIP_WGT,
+ "Unzip WGT File");
}
+/* TODO : modify name */
void TaskFileManipulation::StepAbortRenamePath()
{
_D("[Rename Widget Path] Aborting.... (Rename path)");
WidgetInstallToExtSingleton::Instance().deinitialize();
}
-void TaskFileManipulation::StepCreateSharedFolder()
-{
- _D("StepCreateSharedFolder");
- std::string sharedPath = m_context.locations->getSharedRootDir();
- _D("Create shared directory : %s", m_context.locations->getSharedRootDir().c_str());
-
- WrtUtilMakeDir(sharedPath);
- WrtUtilMakeDir(m_context.locations->getSharedResourceDir());
-
- changeOwnerForDirectory(m_context.locations->getSharedDataDir(),
- SHARED_STORAGE_MODE);
- changeOwnerForDirectory(m_context.locations->getSharedTrustedDir(),
- SHARED_STORAGE_MODE);
-
-
- // additional check for rootPath installation
- // If this app is preloaded, "shared" diretory is already on place and do not needs to be moved
- // TODO: why "shared" is on RW partion always but "data" and "tmp" are linked
- if (m_context.isUpdateMode
- && !(m_context.mode.rootPath == InstallMode::RootPath::RO
- && m_context.mode.installTime == InstallMode::InstallTime::PRELOAD)) {
-
- /* Restore /shared/data */
- _D("copy %s to %s", m_context.locations->getBackupSharedDataDir().c_str(), m_context.locations->getSharedDataDir().c_str());
- if (!DirectoryApi::DirectoryCopy(
- m_context.locations->getBackupSharedDataDir(),
- m_context.locations->getSharedDataDir())) {
- _E("Failed to rename %s to %s", m_context.locations->getBackupSharedDataDir().c_str(), m_context.locations->getSharedDataDir().c_str());
- ThrowMsg(Exceptions::BackupFailed,
- "Error occurs copy shared strage files");
- }
-
- /* Restore /shared/trusted */
- _D("copy %s to %s", m_context.locations->getBackupSharedTrustedDir().c_str(), m_context.locations->getSharedTrustedDir().c_str());
- if (!DirectoryApi::DirectoryCopy(
- m_context.locations->getBackupSharedTrustedDir(),
- m_context.locations->getSharedTrustedDir())) {
- _E("Failed to rename %s to %s", m_context.locations->getBackupSharedTrustedDir().c_str(), m_context.locations->getSharedTrustedDir().c_str());
- ThrowMsg(Exceptions::BackupFailed,
- "Error occurs copy shared strage files");
- }
- }
-}
-
void TaskFileManipulation::StartStep()
{
_D("--------- <TaskFileManipulation> : START ----------");
// install internal location
void StepCreateDirs();
- void StepRenamePath();
- void StepCreatePrivateStorageDir();
- void StepCreateSharedFolder();
+ void StepUnzipWgtFile();
void StepAbortRenamePath();
- void StepLinkForPreload();
// install external location
void StepPrepareExternalDir();
filename = source.substr(last + 1);
}
std::string target =
- m_installerContext.locations->getTemporaryPackageDir() + '/' +
+ m_installerContext.locations->getSourceDir() + '/' +
filename;
_D("source %s", source.c_str());
_D("target %s", target.c_str());
m_localeFolders.insert(L"");
std::string localePath =
- m_installContext.locations->getConfigurationDir() + "/locales";
+ m_installContext.locations->getSourceDir() + "/locales";
+
DIR* localeDir = opendir(localePath.c_str());
if (!localeDir) {
_D("No /locales directory in the widget package.");
DPL::String relativePath = pathPrefix + *path;
DPL::String absolutePath = DPL::FromUTF8String(
- m_installContext.locations->getConfigurationDir()) + L"/" +
+ m_installContext.locations->getSourceDir()) + L"/" +
relativePath;
+ _D("absolutePath : %ls", absolutePath.c_str());
// get property data from packaged app
if (WrtUtilFileExists(DPL::ToUTF8String(absolutePath))) {
if (!!m_installContext.widgetConfig.configInfo.backgroundPage) {
// check whether file exists
DPL::String backgroundPagePath = DPL::FromUTF8String(
- m_installContext.locations->getConfigurationDir()) + L"/" +
+ m_installContext.locations->getSourceDir()) + L"/" +
*m_installContext.widgetConfig.configInfo.backgroundPage;
//if no then cancel installation
if (!WrtUtilFileExists(DPL::ToUTF8String(backgroundPagePath))) {
DPL::String relativePath = pathPrefix + icon.src;
DPL::String absolutePath = DPL::FromUTF8String(
- m_installContext.locations->getConfigurationDir()) + L"/" +
+ m_installContext.locations->getSourceDir()) + L"/" +
relativePath;
if (WrtUtilFileExists(DPL::ToUTF8String(absolutePath))) {
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file task_user_data_manipulation.cpp
+ * @author Soyoung Kim (sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief Implementation file for installer task user data folder
+ */
+#include <unistd.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <widget_install/task_user_data_manipulation.h>
+#include <widget_install/job_widget_install.h>
+#include <widget_install/widget_install_errors.h>
+#include <widget_install/widget_install_context.h>
+#include <widget_install/directory_api.h>
+#include <dpl/utils/wrt_utility.h>
+#include <dpl/assert.h>
+#include <dpl/errno_string.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <string>
+#include <installer_log.h>
+
+#define WEBAPP_DEFAULT_UID 5000
+#define WEBAPP_DEFAULT_GID 5000
+
+namespace {
+const mode_t PRIVATE_STORAGE_MODE = 0700;
+const mode_t SHARED_STORAGE_MODE = 0755;
+}
+
+using namespace WrtDB;
+
+namespace {
+void changeOwnerForDirectory(std::string storagePath, mode_t mode) {
+ if (euidaccess(storagePath.c_str(), F_OK) != 0) {
+ if (!WrtUtilMakeDir(storagePath, mode)) {
+ _E("Failed to create directory : %s", storagePath.c_str());
+ ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed,
+ "Failed to create directory : " << storagePath);
+ }
+ // '5000' is default uid, gid for applications.
+ // So installed applications should be launched as process of uid
+ // '5000'.
+ // the process can access private directory 'data' of itself.
+ if (chown(storagePath.c_str(),
+ WEBAPP_DEFAULT_UID,
+ WEBAPP_DEFAULT_GID) != 0)
+ {
+ ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed,
+ "Chown to invaild user");
+ }
+ } else if (euidaccess(storagePath.c_str(), W_OK | R_OK | X_OK) == 0) {
+ _D("%s already exists.", storagePath.c_str());
+ // Even if private directory already is created, private dircetory
+ // should change owner (recursively).
+ if (chown(storagePath.c_str(),
+ WEBAPP_DEFAULT_UID,
+ WEBAPP_DEFAULT_GID) != 0)
+ {
+ ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed,
+ "Chown to invaild user");
+ }
+ if (chmod(storagePath.c_str(), mode) != 0) {
+ ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed,
+ "chmod to 0700");
+ }
+ } else {
+ ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed,
+ "No access to private storage.");
+ }
+}
+}
+
+namespace Jobs {
+namespace WidgetInstall {
+TaskUserDataManipulation::TaskUserDataManipulation(InstallerContext& context) :
+ DPL::TaskDecl<TaskUserDataManipulation>(this),
+ m_context(context)
+{
+ AddStep(&TaskUserDataManipulation::StartStep);
+ AddStep(&TaskUserDataManipulation::StepCreatePrivateStorageDir);
+ AddStep(&TaskUserDataManipulation::StepCreateSharedFolder);
+ AddStep(&TaskUserDataManipulation::StepLinkForPreload);
+ AddStep(&TaskUserDataManipulation::EndStep);
+}
+
+void TaskUserDataManipulation::StepCreatePrivateStorageDir()
+{
+ std::string storagePath = m_context.locations->getPrivateStorageDir();
+ _D("Create private storage directory : %s", m_context.locations->getPrivateStorageDir().c_str());
+
+ changeOwnerForDirectory(storagePath, PRIVATE_STORAGE_MODE);
+
+ if (m_context.isUpdateMode) { //update
+ std::string backData = m_context.locations->getBackupPrivateDir();
+ _D("copy private storage %s to %s", backData.c_str(), storagePath.c_str());
+ if (!DirectoryApi::DirectoryCopy(backData, storagePath)) {
+ _E("Failed to rename %s to %s", backData.c_str(), storagePath.c_str());
+ ThrowMsg(Exceptions::BackupFailed,
+ "Error occurs copy private strage files");
+ }
+ }
+
+ std::string tempStoragePath = m_context.locations->getPrivateTempStorageDir();
+ _D("Create temp private storage directory : %s", tempStoragePath.c_str());
+ changeOwnerForDirectory(tempStoragePath, PRIVATE_STORAGE_MODE);
+}
+
+void TaskUserDataManipulation::StepLinkForPreload()
+{
+ if (m_context.mode.rootPath == InstallMode::RootPath::RO) {
+ std::string optRes = m_context.locations->getUserDataRootDir() +
+ WrtDB::GlobalConfig::GetWidgetResPath();
+ std::string usrRes = m_context.locations->getPackageInstallationDir() +
+ WrtDB::GlobalConfig::GetWidgetResPath();
+
+ if (0 != access(optRes.c_str(), F_OK)) {
+ _D("Make symbolic name for preload app %s to %s", usrRes.c_str(), optRes.c_str());
+
+ if (symlink(usrRes.c_str(), optRes.c_str()) != 0)
+ {
+ int error = errno;
+ if (error)
+ _E("Failed to make a symbolic name for a file [%s]", (DPL::GetErrnoString(error)).c_str());
+ ThrowMsg(Exceptions::FileOperationFailed,
+ "Symbolic link creating is not done.");
+ }
+ }
+
+ /* link for data directory */
+ std::string storagePath = m_context.locations->getPrivateStorageDir();
+ std::string dataDir = m_context.locations->getPackageInstallationDir() +
+ "/" + WrtDB::GlobalConfig::GetWidgetPrivateStoragePath();
+ if (0 != access(dataDir.c_str(), F_OK)) {
+ _D("Make symbolic name for preload app %s to %s", storagePath.c_str(), dataDir.c_str());
+
+ if (symlink(storagePath.c_str(), dataDir.c_str()) != 0)
+ {
+ int error = errno;
+ if (error)
+ _E("Failed to make a symbolic name for a file [%s]", (DPL::GetErrnoString(error)).c_str());
+ ThrowMsg(Exceptions::FileOperationFailed,
+ "Symbolic link creating is not done.");
+ }
+ changeOwnerForDirectory(dataDir, PRIVATE_STORAGE_MODE);
+ }
+
+ if (m_context.widgetConfig.packagingType != PKG_TYPE_HYBRID_WEB_APP) {
+ std::string widgetBinPath = m_context.locations->getBinaryDir();
+ std::string userBinPath = m_context.locations->getUserBinaryDir();
+ _D("Make symbolic link for preload app %s to %s", widgetBinPath.c_str(), userBinPath.c_str());
+ if (symlink(widgetBinPath.c_str(), userBinPath.c_str()) != 0)
+ {
+ int error = errno;
+ if (error)
+ _E("Failed to make a symbolic name for a file [%s]", (DPL::GetErrnoString(error)).c_str());
+ ThrowMsg(Exceptions::FileOperationFailed,
+ "Symbolic link creating is not done.");
+ }
+
+ }
+ }
+}
+
+void TaskUserDataManipulation::StepCreateSharedFolder()
+{
+ _D("StepCreateSharedFolder");
+ std::string sharedPath = m_context.locations->getSharedRootDir();
+ _D("Create shared directory : %s", m_context.locations->getSharedRootDir().c_str());
+
+ WrtUtilMakeDir(sharedPath);
+ WrtUtilMakeDir(m_context.locations->getSharedResourceDir());
+
+ changeOwnerForDirectory(m_context.locations->getSharedDataDir(),
+ SHARED_STORAGE_MODE);
+ changeOwnerForDirectory(m_context.locations->getSharedTrustedDir(),
+ SHARED_STORAGE_MODE);
+
+
+ // additional check for rootPath installation
+ // If this app is preloaded, "shared" diretory is already on place and do not needs to be moved
+ // TODO: why "shared" is on RW partion always but "data" and "tmp" are linked
+ if (m_context.isUpdateMode
+ && !(m_context.mode.rootPath == InstallMode::RootPath::RO
+ && m_context.mode.installTime == InstallMode::InstallTime::PRELOAD)) {
+
+ /* Restore /shared/data */
+ _D("copy %s to %s", m_context.locations->getBackupSharedDataDir().c_str(), m_context.locations->getSharedDataDir().c_str());
+ if (!DirectoryApi::DirectoryCopy(
+ m_context.locations->getBackupSharedDataDir(),
+ m_context.locations->getSharedDataDir())) {
+ _E("Failed to rename %s to %s", m_context.locations->getBackupSharedDataDir().c_str(), m_context.locations->getSharedDataDir().c_str());
+ ThrowMsg(Exceptions::BackupFailed,
+ "Error occurs copy shared strage files");
+ }
+
+ /* Restore /shared/trusted */
+ _D("copy %s to %s", m_context.locations->getBackupSharedTrustedDir().c_str(), m_context.locations->getSharedTrustedDir().c_str());
+ if (!DirectoryApi::DirectoryCopy(
+ m_context.locations->getBackupSharedTrustedDir(),
+ m_context.locations->getSharedTrustedDir())) {
+ _E("Failed to rename %s to %s", m_context.locations->getBackupSharedTrustedDir().c_str(), m_context.locations->getSharedTrustedDir().c_str());
+ ThrowMsg(Exceptions::BackupFailed,
+ "Error occurs copy shared strage files");
+ }
+ }
+}
+
+void TaskUserDataManipulation::StartStep()
+{
+ _D("--------- <TaskUserDataManipulation> : START ----------");
+}
+
+void TaskUserDataManipulation::EndStep()
+{
+ _D("--------- <TaskUserDataManipulation> : END ----------");
+}
+} //namespace WidgetInstall
+} //namespace Jobs
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file task_user_data_manipulation.cpp
+ * @author Soyoung Kim (sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief Implementation file for installer task user data folder
+ */
+#ifndef JOS_WIDGET_INSTALL_TASK_USER_DATA_MANIPULATION_H
+#define JOS_WIDGET_INSTALL_TASK_USER_DATA_MANIPULATION_H
+
+#include <dpl/task.h>
+
+class InstallerContext;
+
+namespace Jobs {
+namespace WidgetInstall {
+class TaskUserDataManipulation :
+ public DPL::TaskDecl<TaskUserDataManipulation>
+{
+ InstallerContext& m_context;
+
+ void StartStep();
+ void EndStep();
+ void StepCreatePrivateStorageDir();
+ void StepCreateSharedFolder();
+ void StepLinkForPreload();
+
+ public:
+ TaskUserDataManipulation(InstallerContext& context);
+};
+} //namespace WidgetInstall
+} //namespace Jobs
+
+#endif //JOS_WIDGET_INSTALL_TASK_USER_DATA_MANIPULATION_H
INSTALL_RDS_DELTA_CHECK,
INSTALL_RDS_PREPARE,
+ INSTALL_CREATE_BACKUP_DIR, /* For Update */
+ INSTALL_DIR_CREATE,
+ INSTALL_UNZIP_WGT,
INSTALL_WIDGET_CONFIG1,
INSTALL_WIDGET_CONFIG2,
INSTALL_DIGSIG_CHECK,
INSTALL_CERT_CHECK,
INSTALL_CERTIFY_LEVEL_CHECK,
INSTALL_ECRYPTION_FILES,
- INSTALL_CREATE_BACKUP_DIR, /* For Update */
- INSTALL_DIR_CREATE,
- INSTALL_RENAME_PATH,
INSTALL_BACKUP_ICONFILE, /* For Update */
INSTALL_COPY_ICONFILE,
INSTALL_COPY_LIVEBOX_FILES,
}
void WidgetUnzip::unzipConfiguration(const std::string &source,
- const std::string &destination)
+ const std::string &destination, WrtDB::PackagingType* type)
{
_D("unzipConfiguration");
+
Try {
std::string wgtFile = getDecryptedPackage(source);
_D("wgtFile : %s", wgtFile.c_str());
Try {
configFile.reset(zipFile->OpenFile(HYBRID_CONFIG_XML));
+ *type = PKG_TYPE_HYBRID_WEB_APP;
} Catch(DPL::ZipInput::Exception::OpenFileFailed) {
configFile.reset(zipFile->OpenFile(WEB_APP_CONFIG_XML));
+ *type = PKG_TYPE_NOMAL_WEB_APP;
}
std::string extractPath = destination + "/" + WEB_APP_CONFIG_XML;
#include <string>
#include <dpl/zip_input.h>
+#include <dpl/wrt-dao-ro/common_dao_types.h>
namespace Jobs {
namespace WidgetInstall {
{
public:
void unzipWgtFile(const std::string &source, const std::string &destination);
- void unzipConfiguration(const std::string &source, const std::string &destination);
+ void unzipConfiguration(const std::string &source, const std::string
+ &destination, WrtDB::PackagingType *type);
private:
// Unzip state
if (m_extensionType == InstallMode::ExtensionType::DIR) {
return getWidgetSource() + WrtDB::GlobalConfig::GetWidgetSrcPath();
}
- if (m_type == WrtDB::PKG_TYPE_HYBRID_WEB_APP) {
- return getTemporaryPackageDir() + WrtDB::GlobalConfig::GetWidgetSrcPath();
- } else {
- return getTemporaryPackageDir();
- }
-}
-
-std::string WidgetLocation::getConfigurationDir() const
-{
- if (m_type == WrtDB::PKG_TYPE_HOSTED_WEB_APP) {
- std::string path = ".";
- std::size_t index = m_widgetSource.find_last_of("\\/");
- if (index != std::string::npos) {
- path = m_widgetSource.substr(0, index);
- }
- return path;
- } else {
- return getTemporaryRootDir();
- }
+ return getSourceDir();
}
DPL::String WidgetLocation::getPkgId() const
* into 'res/wgt'
*/
std::string getTemporaryRootDir() const;
- /**
- * @brief getConfigurationDir Returns rott directory for configuration
- * requirements
- *
- * 1) For packed widgets it is just root of unpacked sources
- * 2) For browser installation it is directory name of widget passed to
- * installer
- *
- * @return configuration directory
- */
- std::string getConfigurationDir() const;
//icons
/**