${INSTALLER_JOBS}/widget_install/task_encrypt_resource.cpp
${INSTALLER_JOBS}/widget_install/task_plugins_copy.cpp
${INSTALLER_JOBS}/widget_install/task_certificates.cpp
+ ${INSTALLER_JOBS}/widget_install/task_prepare_reinstall.cpp
${INSTALLER_JOBS}/widget_install/wac_security.cpp
${INSTALLER_JOBS}/widget_install/widget_update_info.cpp
${INSTALLER_JOBS}/widget_install/widget_install_popup.cpp
#include <widget_install/task_certificates.h>
#include <widget_install/task_unzip.h>
#include <widget_install/task_commons.h>
-
#include <widget_install/task_plugins_copy.h>
+#include <widget_install/task_prepare_reinstall.h>
#include <widget_install/widget_install_errors.h>
#include <widget_install/widget_install_context.h>
LogInfo("Configure installation updated");
LogInfo("Widget Update");
m_installerContext.job->SetProgressFlag(true);
+
+ if (m_jobStruct.m_installMode ==
+ InstallMode::REINSTALL_MODE_DIRECTORY)
+ {
+ AddTask(new TaskPrepareReinstall(m_installerContext));
+ }
+
if (m_installerContext.widgetConfig.packagingType !=
WrtDB::PKG_TYPE_HOSTED_WEB_APP &&
m_installerContext.widgetConfig.packagingType !=
Try
{
- std::string tempDir =
- Jobs::WidgetInstall::createTempPath(m_jobStruct.m_installMode == InstallMode::INSTALL_MODE_PRELOAD);
+ std::string tempDir;
+ if (m_jobStruct.m_installMode ==
+ InstallMode::REINSTALL_MODE_DIRECTORY)
+ {
+ std::ostringstream tempPathBuilder;
+ tempPathBuilder << WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
+ tempPathBuilder << WrtDB::GlobalConfig::GetTmpDirPath();
+ tempPathBuilder << "/";
+ tempPathBuilder << widgetPath;
+ tempDir = tempPathBuilder.str();;
+ } else {
+ tempDir =
+ Jobs::WidgetInstall::createTempPath(
+ m_jobStruct.m_installMode ==
+ InstallMode::INSTALL_MODE_PRELOAD);
+ }
m_isDRM = isDRMWidget(widgetPath);
if (true == m_isDRM) {
widgetPath,
tempDir,
m_installerContext.widgetConfig.packagingType,
- m_isDRM);
+ m_isDRM,
+ m_jobStruct.m_installMode ==
+ InstallMode::REINSTALL_MODE_DIRECTORY);
LogDebug("widget packaging type : " <<
m_installerContext.widgetConfig.packagingType.pkgType);
void JobWidgetInstall::configureWidgetLocation(const std::string & widgetPath,
const std::string& tempPath)
{
- m_installerContext.locations =
- WidgetLocation(DPL::ToUTF8String(m_installerContext.widgetConfig.
- tzPkgid),
- widgetPath, tempPath,
- m_installerContext.widgetConfig.packagingType,
- m_installerContext.locationType);
+ if (m_jobStruct.m_installMode ==
+ InstallMode::REINSTALL_MODE_DIRECTORY)
+ {
+ // replace widget path to installed path
+ m_installerContext.locations =
+ WidgetLocation(DPL::ToUTF8String(m_installerContext.widgetConfig.
+ tzPkgid),
+ widgetPath, tempPath,
+ m_installerContext.widgetConfig.packagingType,
+ m_installerContext.locationType);
+ } else {
+ m_installerContext.locations =
+ WidgetLocation(DPL::ToUTF8String(m_installerContext.widgetConfig.
+ tzPkgid),
+ widgetPath, tempPath,
+ m_installerContext.widgetConfig.packagingType,
+ m_installerContext.locationType);
+ }
m_installerContext.locations->registerAppid(
DPL::ToUTF8String(m_installerContext.widgetConfig.tzAppid));
m_installerContext.widgetConfig.tzAppid = update.tzAppId;
if (isUpperVersion(update.existingVersion, update.incomingVersion) ||
- m_jobStruct.m_installMode == InstallMode::INSTALL_MODE_DIRECTORY)
+ (m_jobStruct.m_installMode == InstallMode::INSTALL_MODE_DIRECTORY) ||
+ (m_jobStruct.m_installMode == InstallMode::REINSTALL_MODE_DIRECTORY))
{
LogInfo("Whether widget policy allow proceed ok");
return ConfigureResult::Updated;
const std::string &widgetSource,
const std::string &tempPath,
WrtDB::PackagingType pkgType,
- bool isDRM)
+ bool isDRM,
+ bool isReinstall)
{
// Parse config
ParserRunner parser;
DPL::FromUTF32String(
L"widget"))));
} else if (pkgType == PKG_TYPE_DIRECTORY_WEB_APP) {
- parser.Parse(widgetSource + '/' + WITH_OSP_XML,
+ std::string configPath;
+ configPath = tempPath;
+ configPath += "/";
+ configPath += WITH_OSP_XML;
+
+ if (isReinstall) {
+ // checking RDS data directory
+ if (access(configPath.c_str(), F_OK) != 0) {
+ std::string tzAppId =
+ widgetSource.substr(widgetSource.find_last_of("/")+1);
+ WidgetDAOReadOnly dao(WidgetDAOReadOnly::getTzAppId(DPL::FromUTF8String(tzAppId)));
+ configPath = DPL::ToUTF8String(*dao.getWidgetInstalledPath());
+ configPath += "/";
+ configPath += WITH_OSP_XML;
+ }
+ }
+ parser.Parse(configPath,
ElementParserPtr(
new RootParser<WidgetParser>(
configInfo,
const std::string &tempPath)
{
// Check installation type (direcotory/ or config.xml or widget.wgt)
- if (m_jobStruct.m_installMode == InstallMode::INSTALL_MODE_DIRECTORY)
+ if (m_jobStruct.m_installMode == InstallMode::INSTALL_MODE_DIRECTORY ||
+ m_jobStruct.m_installMode == InstallMode::REINSTALL_MODE_DIRECTORY)
{
LogDebug("Install directly from directory");
return PKG_TYPE_DIRECTORY_WEB_APP;
const std::string &widgetSource,
const std::string &tempPath,
WrtDB::PackagingType pkgType,
- bool isDRM);
+ bool isDRM,
+ bool isReinstall);
static WidgetUpdateInfo detectWidgetUpdate(
const WrtDB::ConfigParserData &configInfo,
const WrtDB::TizenAppId &tizenId);
--- /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_prepare_reinstall.cpp
+ * @author Jihoon Chung(jihoon.chung@samsung.com)
+ * @version 1.0
+ * @brief Implementation file for installer task prepare reinstalling
+ */
+
+#include "task_prepare_reinstall.h"
+
+#include <stdio.h>
+#include <fstream>
+
+#include <dpl/task.h>
+#include <dpl/string.h>
+#include <dpl/log/log.h>
+#include <dpl/foreach.h>
+
+#include <widget_install/widget_install_context.h>
+#include <widget_install/widget_install_errors.h>
+#include <widget_install/job_widget_install.h>
+
+namespace Jobs {
+namespace WidgetInstall {
+namespace {
+const char* const KEY_DELETE = "#delete";
+const char* const KEY_ADD = "#add";
+const char* const KEY_MODIFY = "#modify";
+std::list<std::string> keyList = {KEY_DELETE, KEY_ADD, KEY_MODIFY};
+
+void verifyFile(const std::string &filePath)
+{
+ if (access(filePath.c_str(), F_OK) != 0) {
+ ThrowMsg(Exceptions::AceCheckFailed, "File is missed " << filePath);
+ }
+}
+}
+
+TaskPrepareReinstall::TaskPrepareReinstall(InstallerContext& context) :
+ DPL::TaskDecl<TaskPrepareReinstall>(this),
+ m_context(context)
+{
+ AddStep(&TaskPrepareReinstall::StepPrepare);
+ AddStep(&TaskPrepareReinstall::StepParseRDSDelta);
+ AddStep(&TaskPrepareReinstall::StepVerifyRDSDelta);
+ AddStep(&TaskPrepareReinstall::StepAddFile);
+ AddStep(&TaskPrepareReinstall::StepDeleteFile);
+ AddStep(&TaskPrepareReinstall::StepModifyFile);
+}
+
+void TaskPrepareReinstall::StepPrepare()
+{
+ LogInfo("Prepare");
+ m_sourcePath = m_context.locations->getTemporaryPackageDir();
+ m_sourcePath += "/";
+
+ m_installedPath = m_context.locations->getPackageInstallationDir();
+ m_installedPath += "/";
+}
+
+void TaskPrepareReinstall::StepParseRDSDelta()
+{
+ LogInfo("parse RDS delta");
+ std::string rdsDeltaPath = m_sourcePath;
+ rdsDeltaPath += ".rds_delta";
+ std::ifstream delta(rdsDeltaPath);
+
+ if (!delta.is_open()) {
+ // TODO throw exception
+ ThrowMsg(Exceptions::RDSDeltaFailure, "rds_delta file is missed");
+ return;
+ }
+
+ std::string line;
+ std::string key;
+ while (std::getline(delta, line) &&!delta.eof()) {
+ FOREACH(keyIt, keyList) {
+ if (line == *keyIt) {
+ LogInfo("find key = [" << line << "]");
+ key = line;
+ break;
+ }
+ }
+ if (key == line || line.empty() || line == "\n") {
+ continue;
+ }
+ if (key == KEY_DELETE) {
+ m_deleteFileList.push_back(line);
+ LogInfo("line = [" << line << "]");
+ } else if (key == KEY_ADD) {
+ m_addFileList.push_back(line);
+ LogInfo("line = [" << line << "]");
+ } else if (key == KEY_MODIFY) {
+ m_modifyFileList.push_back(line);
+ LogInfo("line = [" << line << "]");
+ }
+ }
+}
+
+void TaskPrepareReinstall::StepVerifyRDSDelta()
+{
+ LogInfo("verify RDS delta");
+ // Verify ADD file
+ FOREACH(file, m_addFileList) {
+ std::string addFilePath = m_sourcePath;
+ addFilePath += *file;
+ verifyFile(addFilePath);
+ }
+ // Verify DELETE file
+ FOREACH(file, m_deleteFileList) {
+ std::string deleteFilePath = m_installedPath;
+ deleteFilePath += *file;
+ verifyFile(deleteFilePath);
+ }
+ // Verify MODIFY file
+ FOREACH(file, m_modifyFileList) {
+ std::string newFilePath = m_sourcePath;
+ newFilePath += *file;
+ verifyFile(newFilePath);
+
+ std::string existingFilePath = m_installedPath;
+ existingFilePath += *file;
+ verifyFile(existingFilePath);
+ }
+ LogInfo("Finished veify RDS Delta");
+
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_RDS_DELTA_CHECK,
+ "RDS delta verify finished");
+}
+
+void TaskPrepareReinstall::StepAddFile()
+{
+ LogInfo("Add file");
+ FOREACH(file, m_addFileList) {
+ std::string newfile = m_sourcePath;
+ 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);
+ }
+ LogInfo("Copy " << newfile << " to " << destPath);
+ }
+}
+
+void TaskPrepareReinstall::StepDeleteFile()
+{
+ LogInfo("Delete file");
+ FOREACH(file, m_deleteFileList) {
+ std::string deleteFilePath = m_installedPath;
+ deleteFilePath += *file;
+ if (remove(deleteFilePath.c_str()) != 0) {
+ ThrowMsg(Exceptions::RDSDeltaFailure,
+ "Fail to DELETE file " << deleteFilePath);
+ }
+ LogInfo("Delete " << deleteFilePath);
+ }
+}
+
+void TaskPrepareReinstall::StepModifyFile()
+{
+ LogInfo("Modify file");
+ FOREACH(file, m_modifyFileList) {
+ std::string destPath = m_installedPath;
+ destPath += *file;
+ if (remove(destPath.c_str()) != 0) {
+ ThrowMsg(Exceptions::RDSDeltaFailure,
+ "Fail to delete existing file " << destPath);
+ }
+
+ std::string newfile = m_sourcePath;
+ newfile += *file;
+ if (rename(newfile.c_str(), destPath.c_str()) != 0) {
+ ThrowMsg(Exceptions::RDSDeltaFailure,
+ "Fail to move new file" << destPath);
+ }
+ LogInfo("Replace " << newfile << " to " << destPath);
+ }
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_RDS_PREPARE,
+ "RDS prepare finished");
+}
+
+} //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_prepare_reinstall.h
+ * @author Jihoon Chung(jihoon.chung@samsung.com)
+ * @version 1.0
+ * @brief Header file for installer task prepare reinstalling
+ */
+#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_PREPARE_REINSTALL_H
+#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_PREPARE_REINSTALL_H
+
+#include <list>
+#include <dpl/task.h>
+
+#include <widget_install/widget_install_context.h>
+
+class InstallerContext;
+
+namespace Jobs {
+namespace WidgetInstall {
+class TaskPrepareReinstall :
+ public DPL::TaskDecl<TaskPrepareReinstall>
+{
+ public:
+ TaskPrepareReinstall(InstallerContext& context);
+
+ private:
+ // install internal location
+ void StepPrepare();
+ void StepParseRDSDelta();
+ void StepVerifyRDSDelta();
+ void StepAddFile();
+ void StepDeleteFile();
+ void StepModifyFile();
+
+ void StepAbortPrepareReinstall();
+
+ InstallerContext& m_context;
+ // TODO : replace multimap
+ std::list<std::string> m_addFileList;
+ std::list<std::string> m_deleteFileList;
+ std::list<std::string> m_modifyFileList;
+ std::string m_sourcePath;
+ std::string m_installedPath;
+};
+} //namespace WidgetInstall
+} //namespace Jobs
+
+#endif // INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_PREPARE_REINSTALL_H
{
INSTALL_START = 0,
INSTALL_CHECK_FILE,
+
+ INSTALL_RDS_DELTA_CHECK,
+ INSTALL_RDS_PREPARE,
+
INSTALL_UNZIP_FILES,
INSTALL_WIDGET_CONFIG1,
INSTALL_WIDGET_CONFIG2,
DECLARE_JOB_EXCEPTION(Base, ExtractFileFailed, ErrorPackageInvalid)
DECLARE_JOB_EXCEPTION(Base, EmptyPluginsDirectory, ErrorPackageInvalid)
DECLARE_JOB_EXCEPTION(Base, PluginsSubdirectory, ErrorPackageInvalid)
+DECLARE_JOB_EXCEPTION(Base, RDSDeltaFailure, ErrorPackageInvalid)
DECLARE_JOB_EXCEPTION(Base, PackageLowerVersion, ErrorPackageLowerVersion)
INSTALL_MODE_WGT = 0,
INSTALL_MODE_DIRECTORY,
INSTALL_MODE_PRELOAD,
+ REINSTALL_MODE_DIRECTORY
};
}
#include <widget_install/task_commons.h>
-WidgetLocation::DirectoryDeletor::DirectoryDeletor() :
- m_dirpath(Jobs::WidgetInstall::createTempPath())
+WidgetLocation::DirectoryDeletor::DirectoryDeletor(bool isPreload) :
+ m_dirpath(Jobs::WidgetInstall::createTempPath(isPreload))
{}
WidgetLocation::DirectoryDeletor::DirectoryDeletor(std::string tempPath) :
m_pkgid(widgetname),
m_widgetSource(sourcePath),
m_type(t),
- m_temp(new WidgetLocation::DirectoryDeletor())
+ m_temp(
+ new WidgetLocation::DirectoryDeletor(
+ INSTALL_LOCATION_TYPE_PRELOAD == locationType))
{
if (INSTALL_LOCATION_TYPE_PRELOAD == locationType) {
m_installedPath += WrtDB::GlobalConfig::GetUserPreloadedWidgetPath();
} else {
m_installedPath += WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
}
+ // TODO clean-up
+ if (access(m_widgetSource.c_str(), F_OK) != 0) {
+ m_widgetSource = m_installedPath + "/" + m_pkgid;
+ }
}
WidgetLocation::WidgetLocation(const std::string & widgetname,
} else {
m_installedPath += WrtDB::GlobalConfig::GetUserInstalledWidgetPath();
}
+ // TODO clean-up
+ if (access(m_widgetSource.c_str(), F_OK) != 0) {
+ m_widgetSource = m_installedPath + "/" + m_pkgid;
+ }
}
// TODO cache all these paths
public:
DirectoryDeletor();
DirectoryDeletor(std::string tempPath);
+ DirectoryDeletor(bool isPreload);
+
~DirectoryDeletor();
std::string getTempPath() const;
m_noPopup = pkgmgr_installer_is_quiet(m_handle);
m_reqType = pkgmgr_installer_get_request_type(m_handle);
if (m_reqType != PKGMGR_REQ_INSTALL &&
- m_reqType != PKGMGR_REQ_UNINSTALL)
+ m_reqType != PKGMGR_REQ_UNINSTALL &&
+ m_reqType != PKGMGR_REQ_REINSTALL)
{
LogError("Fail to get request type of pkgmgr");
pkgmgr_installer_free(m_handle);
}
m_packagePath = m_argv[2];
AddStep(&WrtInstaller::unistallWgtFileStep);
+ } else if (arg == "-r" || arg == "--reinstall") {
+ if (m_argc != 3) {
+ return showHelpAndQuit();
+ }
+ LogInfo("Installing package directly from directory");
+ m_installMode = WRT_INSTALL_MODE_REINSTALL;
+ m_packagePath = m_argv[2];
+ AddStep(&WrtInstaller::installStep);
} else {
return showHelpAndQuit();
}
m_name = m_argv[4];
AddStep(&WrtInstaller::uninstallPkgNameStep);
break;
+ case PKGMGR_REQ_REINSTALL:
+ m_packagePath = m_argv[4];
+ m_installMode = WRT_INSTALL_MODE_REINSTALL;
+ AddStep(&WrtInstaller::installStep);
+ break;
default:
LogDebug("Not available type");
break;
"uninstall widget for given package name\n"
" -up, --uninstall-packagepath "
"uninstall widget for given package file path\n"
+ " -r, --reinstall "
+ "reinstall web application\n"
"\n");
Quit();
return InstallMode::INSTALL_MODE_DIRECTORY;
} else if (WRT_INSTALL_MODE_INSTALL_PRELOAD == installMode) {
return InstallMode::INSTALL_MODE_PRELOAD;
+ } else if (WRT_INSTALL_MODE_REINSTALL == installMode) {
+ return InstallMode::REINSTALL_MODE_DIRECTORY;
}
Assert(true && "wrong argument is inputed");
}
WRT_INSTALL_MODE_UNKNOWN = 0,
WRT_INSTALL_MODE_INSTALL_WGT,
WRT_INSTALL_MODE_INSTALL_DIRECTORY,
- WRT_INSTALL_MODE_INSTALL_PRELOAD
+ WRT_INSTALL_MODE_INSTALL_PRELOAD,
+ WRT_INSTALL_MODE_REINSTALL
};
void wrt_installer_init(