BuildRequires: pkgconfig(pkgmgr-installer)
BuildRequires: pkgconfig(pkgmgr-parser)
BuildRequires: pkgconfig(pkgmgr-types)
+BuildRequires: pkgconfig(pkgmgr-info)
BuildRequires: pkgconfig(pkgmgr)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(cert-svc)
${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/directory_api.cpp
${INSTALLER_JOBS}/widget_uninstall/job_widget_uninstall.cpp
${INSTALLER_JOBS}/widget_uninstall/task_check.cpp
${INSTALLER_JOBS}/widget_uninstall/task_remove_files.cpp
wrt-plugins-types
pkgmgr-installer
pkgmgr-parser
+ pkgmgr-info
web-provider
osp-appfw
REQUIRED
delete[] certData;
return retval == ACE_OK;
}
+bool registerAceWidgetFromDB(const WrtDB::DbWidgetHandle& widgetHandle)
+{
+ using namespace WrtDB;
+ LogDebug("Updating Ace database from Widget DB");
+ struct widget_info wi;
+ DPL::OptionalString os;
+ WrtDB::WidgetCertificateDataList certList;
+
+ Try {
+ WidgetDAOReadOnly dao(widgetHandle);
+
+ WidgetType type = dao.getWidgetType();
+ if (type == WrtDB::APP_TYPE_WAC20) {
+ wi.type = WAC20;
+ } else if (type == WrtDB::APP_TYPE_TIZENWEBAPP) {
+ wi.type = Tizen;
+ } else {
+ LogError("Unknown application type");
+ return false;
+ }
+
+ wi.id = toAceString(dao.getGUID());
+ wi.version = toAceString(dao.getVersion());
+ wi.author = toAceString(dao.getAuthorName());
+ wi.shareHerf = strdup(dao.getShareHref().c_str());
+ LogDebug("Basic data converted. Certificates begin.");
+ certList = dao.getCertificateDataList();
+ }
+ Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) {
+ LogError("Widget does not exist");
+ return false;
+ }
+
+ //one more element for NULL termination
+ LogDebug("Found: " << certList.size() << " certificates");
+ ace_certificate_data** certData = new ace_certificate_data *
+ [certList.size() + 1];
+ certData[certList.size()] = NULL; // last element set to NULL
+
+ int i = 0;
+ FOREACH(it, certList)
+ {
+ certData[i] = new ace_certificate_data;
+ switch (it->owner) {
+ case WrtDB::WidgetCertificateData::AUTHOR:
+ certData[i]->owner = AUTHOR;
+ break;
+ case WrtDB::WidgetCertificateData::DISTRIBUTOR:
+ certData[i]->owner = DISTRIBUTOR;
+ break;
+ default:
+ LogDebug("Unknown owner type of cert");
+ certData[i]->owner = UNKNOWN;
+ break;
+ }
+ switch (it->type) {
+ case WrtDB::WidgetCertificateData::ENDENTITY:
+ certData[i]->type = ENDENTITY;
+ break;
+ case WrtDB::WidgetCertificateData::ROOT:
+ certData[i]->type = ROOT;
+ break;
+ default:
+ LogError("Unknown type of cert");
+ certData[i]->type = ENDENTITY;
+ break;
+ }
+ certData[i]->chain_id = it->chainId;
+
+ certData[i]->md5_fp = toAceString(it->strMD5Fingerprint);
+ certData[i]->sha1_fp = toAceString(it->strSHA1Fingerprint);
+ certData[i]->common_name =
+ toAceString(DPL::ToUTF8String(it->strCommonName));
+ ++i;
+ }
+
+ LogDebug("Registerign widget in ace");
+ ace_return_t retval = ace_register_widget(
+ static_cast<ace_widget_handle_t>(widgetHandle), &wi, certData);
+
+ //clean up - WidgetInfo
+ free(wi.author);
+ free(wi.id);
+ free(wi.shareHerf);
+ free(wi.version);
+
+ //free cert list
+ i = 0;
+ while (certData[i] != NULL) {
+ free(certData[i]->common_name);
+ free(certData[i]->md5_fp);
+ free(certData[i]->sha1_fp);
+ delete certData[i];
+ ++i;
+ }
+ delete[] certData;
+ return retval == ACE_OK;
+}
}
bool registerAceWidget(const WrtDB::DbWidgetHandle& widgetHandle,
const WrtDB::WidgetRegisterInfo& widgetConfig,
const WrtDB::WidgetCertificateDataList& certList);
+bool registerAceWidgetFromDB(const WrtDB::DbWidgetHandle& widgetHandle);
}
#endif /* WRT_SRC_INSTALLER_CORE_ACE_REGISTRATION_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2012 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 directory_api.cpp
+ * @author Soyoung Kim(sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief directory api - implementation file
+ */
+
+#include <directory_api.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <fstream>
+#include <dpl/log/log.h>
+#include <dpl/foreach.h>
+#include <dpl/utils/wrt_utility.h>
+
+namespace DirectoryApi {
+bool DirectoryCopy(std::string source, std::string dest)
+{
+ DIR* dir = opendir(source.c_str());
+ if (NULL == dir) {
+ return false;
+ }
+
+ struct dirent dEntry;
+ struct dirent *dEntryResult;
+ int return_code;
+
+ do {
+ struct stat statInfo;
+ return_code = readdir_r(dir, &dEntry, &dEntryResult);
+ if (dEntryResult != NULL && return_code == 0) {
+ std::string fileName = dEntry.d_name;
+ std::string fullName = source + "/" + fileName;
+
+ if (stat(fullName.c_str(), &statInfo) != 0) {
+ closedir(dir);
+ return false;
+ }
+
+ if (S_ISDIR(statInfo.st_mode)) {
+ if (("." == fileName) || (".." == fileName)) {
+ continue;
+ }
+ std::string destFolder = dest + "/" + fileName;
+ WrtUtilMakeDir(destFolder);
+
+ if (!DirectoryCopy(fullName, destFolder)) {
+ closedir(dir);
+ return false;
+ }
+ }
+
+ std::string destFile = dest + "/" + fileName;
+ std::ifstream infile(fullName);
+ std::ofstream outfile(destFile);
+ outfile << infile.rdbuf();
+ outfile.close();
+ infile.close();
+ }
+ } while (dEntryResult != NULL && return_code == 0);
+ closedir(dir);
+ return true;
+}
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 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 directory_api.h
+ * @author Soyoung Kim(sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief directory api - header file
+ */
+#ifndef WRT_SRC_INSTALLER_CORE_DIRECTORY_API_H_
+#define WRT_SRC_INSTALLER_CORE_DIRECTORY_API_H_
+
+#include<string>
+
+namespace DirectoryApi {
+bool DirectoryCopy(std::string source, std::string dest);
+}
+
+#endif /* WRT_SRC_INSTALLER_CORE_DIRECTORY_API_H_ */
+
WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
{
AddTask(new TaskUpdateFiles(m_installerContext));
+ AddTask(new TaskFileManipulation(m_installerContext));
}
AddTask(new TaskManifestFile(m_installerContext));
{
AddTask(new TaskInstallOspsvc(m_installerContext));
}
- if (m_installerContext.widgetConfig.packagingType !=
- WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
- {
- AddTask(new TaskRemoveBackupFiles(m_installerContext));
- }
+ AddTask(new TaskCertificates(m_installerContext));
AddTask(new TaskDatabase(m_installerContext));
AddTask(new TaskAceCheck(m_installerContext));
//TODO: remove widgetHandle from this task and move before database task
// by now widget handle is needed in ace check
// Any error in acecheck while update will break widget
AddTask(new TaskSmack(m_installerContext));
+ AddTask(new TaskRemoveBackupFiles(m_installerContext));
} else if (result == ConfigureResult::Deferred) {
// Installation is deferred
LogInfo("Configure installation deferred");
AddStep(&TaskDatabase::StepLiveboxDBInsert);
AddAbortStep(&TaskDatabase::StepAbortDBInsert);
+ AddAbortStep(&TaskDatabase::StepAbortAceDBInsert);
}
void TaskDatabase::StepWrtDBInsert()
{
m_handleToRemove = WidgetDAOReadOnly::getHandle(
m_context.widgetConfig.tzAppid);
+
+ std::string makeAppid =
+ DPL::ToUTF8String(m_context.widgetConfig.tzAppid) + "." +
+ "backup";
+ m_backAppId = DPL::FromUTF8String(makeAppid);
}
Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
{
ThrowMsg(Exceptions::DatabaseFailure,
"Given tizenId not found for update installation");
}
- WidgetDAO::registerOrUpdateWidget(
+
+ WidgetDAO::backupAndUpdateWidget(
+ m_backAppId,
m_context.widgetConfig.tzAppid,
m_context.widgetConfig,
m_context.wacSecurity);
LogWarning("[DB Update Task] Aborting... (DB Clean)");
Try
{
- WidgetDAO::unregisterWidget(m_context.widgetConfig.tzAppid);
+ WidgetDAO::restoreUpdateWidget(m_backAppId,
+ m_context.widgetConfig.tzAppid);
LogDebug("Cleaning DB successful!");
}
Catch(DPL::DB::SqlConnection::Exception::Base)
{
LogError("Failed to handle StepAbortDBClean!");
}
+}
+
+void TaskDatabase::StepAbortAceDBInsert()
+{
+ LogWarning("[DB Update Task] ACE DB Aborting... (DB Clean)");
ace_unregister_widget(static_cast<ace_widget_handle_t>(m_handle));
// Remove also old one. If it was already updated nothing wrong will happen,
if (INVALID_WIDGET_HANDLE != m_handleToRemove) {
ace_unregister_widget(static_cast<ace_widget_handle_t>(m_handle));
}
+
+ if (!AceApi::registerAceWidgetFromDB(m_handleToRemove))
+ {
+ LogError("ace database restore failed");
+ }
+ LogDebug("Ace data inserted");
}
void TaskDatabase::StepLiveboxDBInsert()
//of widget handle
WrtDB::DbWidgetHandle m_handleToRemove;
WrtDB::DbWidgetHandle m_handle;
+ WrtDB::TizenAppId m_backAppId;
void StepRegisterExternalFiles();
void StepWrtDBInsert();
void StepLiveboxDBInsert();
void StepAbortDBInsert();
+ void StepAbortAceDBInsert();
public:
TaskDatabase(InstallerContext& context);
#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/foreach.h>
#include <dpl/log/log.h>
m_context.locationType)
{
AddStep(&TaskFileManipulation::StepCreateDirs);
- AddStep(&TaskFileManipulation::StepCreatePrivateStorageDir);
if (m_context.widgetConfig.packagingType !=
WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
{
AddStep(&TaskFileManipulation::StepRenamePath);
AddAbortStep(&TaskFileManipulation::StepAbortRenamePath);
}
+ AddStep(&TaskFileManipulation::StepCreatePrivateStorageDir);
AddStep(&TaskFileManipulation::StepLinkForPreload);
} else {
std::string storagePath = m_context.locations->getPrivateStorageDir();
LogDebug("Create private storage directory : " <<
m_context.locations->getPrivateStorageDir());
+
+ if (m_context.isUpdateMode) { //update
+ std::string backData = m_context.locations->getBackupPrivateDir();
+ LogDebug("copy private storage " << backData << " to " << storagePath);
+ WrtUtilMakeDir(storagePath);
+ if (!DirectoryApi::DirectoryCopy(backData, storagePath)) {
+ LogError("Failed to rename " << backData << " to " << storagePath);
+ ThrowMsg(Exceptions::BackupFailed,
+ "Error occurs copy private strage files");
+ }
+ }
changeOwnerForDirectory(storagePath);
}
#include <unistd.h>
#include <string>
+#include <pkgmgr/pkgmgr_parser.h>
+#include <pkgmgr-info.h>
+#include <fstream>
#include <dpl/log/log.h>
#include <dpl/errno_string.h>
#include <dpl/foreach.h>
m_context(context)
{
AddStep(&TaskInstallOspsvc::StepInstallOspService);
+ AddStep(&TaskInstallOspsvc::StepUpdateManifestFile);
}
void TaskInstallOspsvc::StepInstallOspService()
InstallerContext::INSTALL_INSTALL_OSPSVC,
"Installed Osp servcie");
}
+
+void TaskInstallOspsvc::StepUpdateManifestFile()
+{
+ std::string pkgid = DPL::ToUTF8String(m_context.widgetConfig.tzPkgid);
+ pkgmgrinfo_pkginfo_h handle;
+
+ int ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid.c_str(), &handle);
+ if (ret != PMINFO_R_OK) {
+ LogDebug("StepUpdateManifestFile");
+ std::ostringstream manifest_file;
+ if (m_context.mode.rootPath == InstallMode::RootPath::RO) {
+ manifest_file << "/usr/share/packages/"; //TODO constant with path
+ } else {
+ manifest_file << "/opt/share/packages/"; //TODO constant with path
+ }
+ manifest_file << pkgid;
+ manifest_file << ".xml";
+ LogDebug("manifest file : " << manifest_file.str());
+
+ int ret = pkgmgr_parser_parse_manifest_for_uninstallation(
+ manifest_file.str().c_str(), NULL);
+
+ if (ret != 0) {
+ LogError("Manifest parser error: " << ret);
+ }
+
+ int code = pkgmgr_parser_parse_manifest_for_installation(
+ manifest_file.str().c_str(), NULL);
+
+ if (code != 0) {
+ LogError("Manifest parser error: " << code);
+ }
+ }
+}
} //namespace WidgetInstall
} //namespace Jobs
InstallerContext &m_context;
void StepInstallOspService();
+ void StepUpdateManifestFile();
void StepAbortInstall();
// for widget update.
AddStep(&TaskManifestFile::stepBackupIconFiles);
AddStep(&TaskManifestFile::stepCopyIconFiles);
+ AddStep(&TaskManifestFile::stepCreateExecFile);
AddStep(&TaskManifestFile::stepGenerateManifest);
AddStep(&TaskManifestFile::stepParseUpgradedManifest);
AddStep(&TaskManifestFile::stepUpdateFinalize);
{
LogDebug("Backup Icon Files");
- backup_dir << m_context.locations->getPackageInstallationDir();
- backup_dir << "/" << "backup" << "/";
+ backup_dir << m_context.locations->getBackupDir() << "/";
backupIconFiles();
void TaskManifestFile::stepParseUpgradedManifest()
{
- int code = pkgmgr_parser_parse_manifest_for_upgrade(
- DPL::ToUTF8String(manifest_file).c_str(), NULL);
+ if (m_context.widgetConfig.packagingType !=
+ PKG_TYPE_HYBRID_WEB_APP)
+ {
+ int code = pkgmgr_parser_parse_manifest_for_upgrade(
+ DPL::ToUTF8String(manifest_file).c_str(), NULL);
- 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);
+ }
- m_context.job->UpdateProgress(
- InstallerContext::INSTALL_CREATE_MANIFEST,
- "Widget Manifest Parsing Finished");
- LogDebug("Manifest parsed");
+ m_context.job->UpdateProgress(
+ InstallerContext::INSTALL_CREATE_MANIFEST,
+ "Widget Manifest Parsing Finished");
+ LogDebug("Manifest parsed");
+ }
}
void TaskManifestFile::commitManifest()
#include <dpl/log/log.h>
#include <dpl/assert.h>
#include <dpl/utils/wrt_utility.h>
+#include <dpl/wrt-dao-rw/widget_dao.h>
#include <widget_install/job_widget_install.h>
#include <widget_install/widget_install_errors.h>
#include <widget_install/widget_install_context.h>
DPL::TaskDecl<TaskRemoveBackupFiles>(this),
m_context(context)
{
- AddStep(&TaskRemoveBackupFiles::StepRemoveBackupFiles);
+ if (m_context.widgetConfig.packagingType !=
+ WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
+ {
+ AddStep(&TaskRemoveBackupFiles::StepRemoveBackupFiles);
+ }
+ AddStep(&TaskRemoveBackupFiles::StepDeleteBackupDB);
}
void TaskRemoveBackupFiles::StepRemoveBackupFiles()
LogDebug("Success to remove temp directory : " << tmp);
} else {
LogError("Failed to remove temp directory : " << tmp);
- ThrowMsg(Exceptions::RemoveBackupFailed,
- "Error occurs during removing existing folder");
}
+}
- m_context.job->UpdateProgress(
- InstallerContext::INSTALL_REMOVE_BACKUP_FILE,
- "Backup widget file delete Finished");
+void TaskRemoveBackupFiles::StepDeleteBackupDB()
+{
+ LogDebug("StepDeleteBackupDB");
+ std::string oldAppid =
+ DPL::ToUTF8String(m_context.widgetConfig.tzAppid) + ".backup";
+
+ Try
+ {
+ WidgetDAO::unregisterWidget(DPL::FromUTF8String(oldAppid));
+ }
+ Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
+ {
+ LogError("Fail to delete old version db information");
+ }
}
+
} //namespace WidgetInstall
} //namespace Jobs
InstallerContext& m_context;
void StepRemoveBackupFiles();
+ void StepDeleteBackupDB();
public:
TaskRemoveBackupFiles(InstallerContext& context);
#include <widget_install/widget_install_context.h>
#include <widget_install/widget_install_errors.h>
#include <widget_install/job_widget_install.h>
+#include <widget_install/directory_api.h>
#include <dpl/wrt-dao-ro/global_config.h>
#include <dpl/exception.h>
DPL::TaskDecl<TaskUpdateFiles>(this),
m_context(context)
{
- AddStep(&TaskUpdateFiles::StepCreateBackupFolder);
- AddStep(&TaskUpdateFiles::StepResourceFilesBackup);
- AddStep(&TaskUpdateFiles::StepExecFileBackup);
+ AddStep(&TaskUpdateFiles::StepBackupDirectory);
- AddAbortStep(&TaskUpdateFiles::StepAbortCreateBackupFolder);
- AddAbortStep(&TaskUpdateFiles::StepAbortExecFileBackup);
- AddAbortStep(&TaskUpdateFiles::StepAbortResourceFilesBackup);
+ AddAbortStep(&TaskUpdateFiles::StepAbortBackupDirectory);
}
-void TaskUpdateFiles::StepCreateBackupFolder()
+void TaskUpdateFiles::StepBackupDirectory()
{
LogDebug("StepCreateBackupFolder");
- std::string srcBuPath = m_context.locations->getBackupSourceDir();
- LogDebug("backup resource directory path : " << srcBuPath);
- if (!WrtUtilMakeDir(srcBuPath)) {
- ThrowMsg(
- Exceptions::BackupFailed,
- "Error occurs during create \
- backup directory.");
- }
-
- std::string binBuPath = m_context.locations->getBackupBinaryDir();
- LogDebug("backup execution directory path : " << binBuPath);
- if (!WrtUtilMakeDir(binBuPath)) {
- ThrowMsg(
- Exceptions::BackupFailed,
- "Error occurs during create backup \
- directory.");
- }
-
- m_context.job->UpdateProgress(
- InstallerContext::INSTALL_CREATE_BACKUP_DIR,
- "Backup directory created for update");
-}
-
-void TaskUpdateFiles::ReadDirList(std::string dirPath, ExistFileList &list,
- size_t subLen)
-{
- DIR* pkgDir = opendir(dirPath.c_str());
- if (!pkgDir) {
- LogError("Package directory " << dirPath << " doesn't exist");
- ThrowMsg(Exceptions::BackupFailed,
- "Error occurs during read \
- directory");
- }
-
- struct stat statInfo;
- struct dirent dirent;
- struct dirent *result;
- int return_code;
- errno = 0;
- for (return_code = readdir_r(pkgDir, &dirent, &result);
- result != NULL && return_code == 0;
- return_code = readdir_r(pkgDir, &dirent, &result))
- {
- std::string dirName = dirent.d_name;
- std::string absFileName = dirPath + "/" + dirName;
- if (stat(absFileName.c_str(), &statInfo) != 0) {
- ThrowMsg(Exceptions::BackupFailed, "Error occurs read file");
- }
-
- if (S_ISDIR(statInfo.st_mode)) {
- if (strcmp(dirent.d_name, ".") == 0 || strcmp(dirent.d_name,
- "..") == 0)
- {
- continue;
- }
- ReadDirList(absFileName, list, subLen);
- }
-
- list.insert(absFileName.substr(subLen));
- }
- if (return_code != 0 || errno != 0) {
- LogError("readdir_r() failed with " << DPL::GetErrnoString());
- }
- errno = 0;
- //closing the directory
- if (-1 == TEMP_FAILURE_RETRY(closedir(pkgDir))) {
- LogError("Failed to close dir: " << dirPath << " with error: "
- << DPL::GetErrnoString());
- }
-}
-
-void TaskUpdateFiles::StepResourceFilesBackup()
-{
- LogDebug("StepCopyFiles");
-
- ExistFileList resList;
- ExistFileList tempList;
-
- std::string pkgSrc = m_context.locations->getSourceDir();
- ReadDirList(pkgSrc, resList, strlen(pkgSrc.c_str()) + 1);
-
- std::string tempSrc = m_context.locations->getTemporaryPackageDir();
- ReadDirList(tempSrc, tempList, strlen(tempSrc.c_str()) + 1);
-
- FOREACH(it, tempList) {
- std::set<std::string>::iterator res;
- res = resList.find(*it);
- std::string resFile = pkgSrc + "/" + (*it);
- std::string newFile = tempSrc + "/" + (*it);
-
- if (res != resList.end()) {
- std::string backupFile =
- m_context.locations->getBackupSourceDir() +
- "/" + (*it);
-
- struct stat sInfo;
- if (stat(resFile.c_str(), &sInfo) != 0) {
- ThrowMsg(Exceptions::BackupFailed, "Error occurs read file");
- }
-
- if (S_ISDIR(sInfo.st_mode)) {
- LogDebug(resFile << " is a directory. so create a folder : " <<
- backupFile);
- WrtUtilMakeDir(backupFile);
- } else {
- if ((rename(resFile.c_str(), backupFile.c_str())) != 0) {
- LogError(
- "Failed to rename " << resFile << " to " <<
- backupFile);
- ThrowMsg(
- Exceptions::BackupFailed,
- "Error occurs during \
- rename file");
- }
-
- LogDebug("backup : " << resFile << " to " << backupFile);
+ std::string backPath = m_context.locations->getBackupDir();
+ LogDebug("backup resource directory path : " << backPath);
+ std::string pkgPath = m_context.locations->getPackageInstallationDir();
- if ((rename(newFile.c_str(), resFile.c_str())) != 0) {
- LogError(
- "Failed to rename " << newFile << " to " << resFile);
- ThrowMsg(
- Exceptions::BackupFailed,
- "Error occurs during \
- rename file");
- }
- LogDebug("copy : " << newFile << " to " << resFile);
- }
- resList.erase(res);
- } else {
- if ((rename(newFile.c_str(), resFile.c_str())) != 0) {
- LogError("Failed to rename " << newFile << " to " << resFile);
- ThrowMsg(
- Exceptions::BackupFailed,
- "Error occurs during \
- rename file");
- }
- LogDebug("only copy : " << newFile << " to " << resFile);
- }
- }
-
- if (resList.empty() != 0) {
- FOREACH(remain, resList) {
- std::string pkgFile = pkgSrc + "/" + (*remain);
- std::string backFile = tempSrc + "/" + (*remain);
- if ((rename(pkgFile.c_str(), backFile.c_str())) != 0) {
- LogError("Failed to backup : " << pkgFile << " to " << backFile);
- ThrowMsg(
- Exceptions::BackupFailed,
- "Error occurs during \
- rename file");
- }
- LogDebug("only backup : " << pkgFile << " to " << backFile);
- }
- }
-
- m_context.job->UpdateProgress(
- InstallerContext::INSTALL_BACKUP_RES_FILES,
- "Backup resource file for update");
-}
-
-void TaskUpdateFiles::StepExecFileBackup()
-{
- std::string execFile = m_context.locations->getExecFile();
-
- LogDebug(" source : " << execFile);
-
- std::string tempSource = m_context.locations->getBackupExecFile();
- LogDebug(" source : " << tempSource);
-
- if ((rename(execFile.c_str(), tempSource.c_str())) != 0) {
- LogError("Failed to rename " << execFile << " to " <<
- tempSource);
+ LogDebug("copy : " << pkgPath << " to " << backPath);
+ if ((rename(pkgPath.c_str(), backPath.c_str())) != 0) {
+ LogError("Failed to rename " << pkgPath << " to " << backPath);
ThrowMsg(Exceptions::BackupFailed,
- "Error occurs during \
- rename file");
+ "Error occurs during rename file");
}
- LogDebug("Backup : " << execFile << " to " << tempSource);
- std::string clientPath = GlobalConfig::GetWrtClientExec();
+ WrtUtilMakeDir(pkgPath);
- LogInfo("link -s " << clientPath << " " << execFile);
-
- errno = 0;
- if( symlink(clientPath.c_str(), execFile.c_str()) != 0 )
- {
- int error = errno;
- if(error)
- LogPedantic("Failed to make a symbolic name for a file "
- << "[" << DPL::GetErrnoString(error) << "]");
- ThrowMsg(Exceptions::BackupFailed,
- "Error occurs during rename file");
- }
m_context.job->UpdateProgress(
- InstallerContext::INSTALL_BACKUP_EXEC,
- "Backup execution file for update");
+ InstallerContext::INSTALL_CREATE_BACKUP_DIR,
+ "Backup directory created for update");
}
-void TaskUpdateFiles::StepAbortResourceFilesBackup()
+void TaskUpdateFiles::StepAbortBackupDirectory()
{
LogDebug("StepAbortCopyFiles");
- std::string srcPath = m_context.locations->getSourceDir();
- std::string srcBuPath = m_context.locations->getBackupSourceDir();
-
- LogDebug("Backup Folder " << srcBuPath << " to " << srcPath);
-
- if (!WrtUtilRemove(srcPath)) {
- LogError("Failed to remove " << srcPath);
- }
-
- if (rename(srcBuPath.c_str(), srcPath.c_str()) != 0) {
- LogError("Failed to rename " << srcBuPath << " to " << srcPath);
- }
-}
-void TaskUpdateFiles::StepAbortExecFileBackup()
-{
- LogDebug("StepAbortExecFileBackup");
- std::string binPath = m_context.locations->getBinaryDir();
+ std::string backPath = m_context.locations->getBackupDir();
+ std::string pkgPath = m_context.locations->getPackageInstallationDir();
- if (!WrtUtilRemove(binPath)) {
- LogError("Failed to remove " << binPath);
- }
+ LogDebug("Backup Folder " << backPath << " to " << pkgPath);
- std::string binBuPath = m_context.locations->getBackupBinaryDir();
- if (rename(binBuPath.c_str(), binPath.c_str()) != 0) {
- LogError("Failed to rename " << binBuPath << " to " << binPath);
+ if (!WrtUtilRemove(pkgPath)) {
+ LogError("Failed to remove " << pkgPath);
}
- LogDebug("Backup Folder " << binBuPath << "move to " << binPath);
-}
-
-void TaskUpdateFiles::StepAbortCreateBackupFolder()
-{
- LogDebug("StepAbortCreateBackupFolder");
- std::ostringstream path;
- path << m_context.locations->getBackupDir();
- LogDebug("Remove backup directory : " << path.str());
- if (!WrtUtilRemove(path.str())) {
- LogError("Failed to remove " << path);
+ if (rename(backPath.c_str(), pkgPath.c_str()) != 0) {
+ LogError("Failed to rename " << backPath << " to " << pkgPath);
}
}
} //namespace WidgetInstall
private:
InstallerContext& m_context;
- /* TODO : md5 check */
- void StepCreateBackupFolder();
- void StepResourceFilesBackup();
- void StepExecFileBackup();
+ void StepBackupDirectory();
- void ReadDirList(std::string dirPath, ExistFileList &list, size_t subLen);
-
- void StepAbortResourceFilesBackup();
- void StepAbortCreateBackupFolder();
- void StepAbortExecFileBackup();
+ void StepAbortBackupDirectory();
public:
TaskUpdateFiles(InstallerContext& context);
std::string WidgetLocation::getBackupDir() const
{
- return getPackageInstallationDir() + "/backup";
+ return getPackageInstallationDir() + ".backup";
}
std::string WidgetLocation::getBackupSourceDir() const
return getBackupBinaryDir() + "/" + m_appid;
}
+std::string WidgetLocation::getBackupPrivateDir() const
+{
+ return getBackupDir() + "/" +
+ WrtDB::GlobalConfig::GetWidgetPrivateStoragePath();
+}
+
std::string WidgetLocation::getUserDataRootDir() const
{
return std::string(WrtDB::GlobalConfig::GetWidgetUserDataPath()) +
std::string getBinaryDir() const; // /opt/apps/[package]/bin or /usr/apps/[package]/bin
std::string getUserBinaryDir() const; // /opt/apps/[package]/bin
std::string getExecFile() const; // /opt/apps/[package]/bin/[package]
- std::string getBackupDir() const; // /opt/apps/[package]/backup
- std::string getBackupSourceDir() const; // /opt/apps/[pkg]/backup/res/wgt
- std::string getBackupBinaryDir() const; // /opt/apps/[pkg]/backup/bin
- std::string getBackupExecFile() const; // /opt/apps/[pkg]/backup/bin/[pkg]
+ std::string getBackupDir() const; // /opt/apps/[package].backup
+ std::string getBackupSourceDir() const; // /opt/apps/[pkg].backup/res/wgt
+ std::string getBackupBinaryDir() const; // /opt/apps/[pkg].backup/bin
+ std::string getBackupExecFile() const; // /opt/apps/[pkg].backup/bin/[pkg]
+ 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