src/Step/LicenseStep.cpp
src/Step/ManifestXmlStep.cpp
src/Step/PackageCheckStep.cpp
+ src/Step/RdsStep.cpp
src/Step/SignatureStep.cpp
src/Step/SystemCheckStep.cpp
src/Step/UninstallStep.cpp
#include "InstallerUtil.h"
-#define OSP_INSTALLER_VERSION "version=[20130328.2]"
+#define OSP_INSTALLER_VERSION "version=[20130331.1]"
#define DIR_BIN L"/bin"
#define DIR_INFO L"/info"
#define DIR_CONTENTS L"/contents"
#define DIR_SHARED_RES L"/shared/res"
#define DIR_SHARED_DATA L"/shared/data"
-#define DIR_SHARED_TRUSTED L"/shared/trusted"
+#define DIR_SHARED_TRUSTED L"/shared/trusted"
#define SLP_DIR_BIN L"/bin"
#define SLP_DIR_RES L"/res"
#define UISCALABILITY_INFO L"1 %ls %ls %ls"
-#define CONFIG_PATH L"/usr/etc/installer-config.ini"
+#define CONFIG_PATH L"/usr/etc/installer-config.ini"
#define UIAPP_LOADER_PATH "/usr/lib/osp/osp-ui-app-loader" // UiApp
#define SERVICEAPP_LOADER_PATH "/usr/lib/osp/osp-service-app-loader" // ServiceApp
#define PERM_EXECUTE (S_IXUSR | S_IXGRP | S_IXOTH)
#define PERM_WRITE (S_IWUSR | S_IWGRP | S_IWOTH)
+#define PERM_OWNER_ROOT 0
+#define PERM_OWNER_APP 1
+
+#define PERM_SMACK_0 0
+#define PERM_SMACK_1 1
+#define PERM_SMACK_2 2
+#define PERM_SMACK_3 3
+
#define TIZEN_PRIVILEGE_WEB_SERVICE "http://tizen.org/privilege/web.service"
#define TIZEN_CATEGORY_IME "http://tizen.org/category/ime"
#define TIZEN_CATEGORY_HOMESCREEN "http://tizen.org/category/homescreen"
#define TIZEN_CATEGORY_LOCKSCREEN "http://tizen.org/category/lockscreen"
#define TIZEN_CATEGORY_MENUSCREEN "http://tizen.org/category/menuscreen"
+#define DIR_APPLICATIONS_TMP "/opt/usr/apps/tmp"
+
+#define INSTALLER_RDS_FILE_NAME ".rds_delta"
+#define INSTALLER_RDS_DELETE_STR "delete"
+#define INSTALLER_RDS_ADD_STR "add"
+#define INSTALLER_RDS_MODIFY_STR "modify"
+
static const int BLOCK_SIZE = 4096;
#define OSP_INSTALLER "osp-installer"
INSTALLER_STEP_UNINSTALL,
INSTALLER_STEP_END,
+ INSTALLER_STEP_RDS_INIT,
+ INSTALLER_STEP_RDS,
+
INSTALLER_STEP_MAX,
};
{
INSTALLER_OPERATION_INSTALL,
INSTALLER_OPERATION_UNINSTALL,
+ INSTALLER_OPERATION_REINSTALL,
};
INSTALLER_MODE_INSTALL = 1,
INSTALLER_MODE_UNINSTALL = 2,
INSTALLER_MODE_RECURSIVE_DIRECTORY_INSTALL = 3,
+ INSTALLER_MODE_REINSTALL = 4,
};
enum CategoryType
};
+enum InstallerRdsState
+{
+ INSTALLER_RDS_STATE_NONE,
+ INSTALLER_RDS_STATE_DELETE,
+ INSTALLER_RDS_STATE_ADD,
+ INSTALLER_RDS_STATE_MODIFY,
+
+};
+
+typedef struct
+{
+ const char* pDir;
+ int dirType;
+ int ownerIndex;
+ int modeIndex;
+ int smackIndex;
+
+} RdsPermssions;
+
+enum PermDirType
+{
+ PERM_DIR_RES = 0,
+ PERM_DIR_DATA = 1,
+ PERM_DIR_BIN = 2,
+ PERM_DIR_INFO = 3,
+ PERM_DIR_LIB = 4,
+ PERM_DIR_SETTING = 5,
+ PERM_DIR_SHARED_RES = 6,
+ PERM_DIR_SHARED_DATA = 7,
+ PERM_DIR_SHARED_TRUSTED = 8,
+ PERM_DIR_SHARED = 9,
+ PERM_DIR_ROOT = 10,
+};
+
#endif // _INSTALLER_DEFS_H_
#include "DrmStep.h"
#include "UninstallStep.h"
#include "UnpackStep.h"
+#include "RdsStep.h"
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
TryReturn(__pStep, false, "DrmStep is failed.");
break;
+ case INSTALLER_STEP_RDS:
+ __pStep = new (std::nothrow) RdsStep();
+ TryReturn(__pStep, false, "DrmStep is failed.");
+ break;
+
case INSTALLER_STEP_END:
break;
AppLog("------------------------------------------");
AppLog("InstallerManager");
AppLog("------------------------------------------");
- AppLog(" # operation = [%s]", (operation == INSTALLER_OPERATION_INSTALL)?"Install":"Uninstall");
+ AppLog(" # operation = [%s]", InstallerUtil::GetInstallerOperationString(operation));
AppLog(" # path = [%ls]", path.GetPointer());
AppLog("------------------------------------------");
__pContext->SetCurrentInstallationStep(INSTALLER_STEP_INIT_UNINSTALL);
__pContext->__packageId = newPath;
}
+ else if (operation == INSTALLER_OPERATION_REINSTALL)
+ {
+ installerType = INSTALLER_TYPE_INSTALLER;
+ AppLog("operation is INSTALLER_OPERATION_REINSTALL");
+ installerType = INSTALLER_TYPE_DIRECTORY;
+
+ __pContext->SetCurrentInstallationStep(INSTALLER_STEP_RDS_INIT);
+ __pContext->__packageId = newPath;
+ }
__pContext->SetInstallerOperation(operation);
error = End();
TryReturn(error == INSTALLER_ERROR_NONE, error, "error is occurred.");
}
+ else if (currentStep == INSTALLER_STEP_RDS)
+ {
+ AppLog("currentStep is INSTALLER_STEP_RDS");
+ __pContext->SetCurrentInstallationStep(INSTALLER_STEP_NONE);
+ }
if (__pContext->IsContinue() == false)
{
int
InstallerManager::ParseCommandArg(int argc, char **argv, int *mode, char *buf, bool *output)
{
- const char* pOpts_str = "u:i:r:v";
+ const char* pOpts_str = "u:i:r:v:m";
int s = 0;
if (mode == NULL)
}
AppLog("__osp_installer_parse_options: r");
- *mode = INSTALLER_MODE_RECURSIVE_DIRECTORY_INSTALL;
+ *mode = INSTALLER_MODE_REINSTALL;
strncpy(buf, optarg, BUFSIZE);
AppLog("__osp_installer_parse_options: optarg = [%s]", optarg);
break;
AppLog("__osp_installer_parse_options: optarg = [%s]", optarg);
break;
+ case 'm':
+ if (*mode)
+ {
+ break;
+ }
+
+ AppLog("__osp_installer_parse_options: m");
+ *mode = INSTALLER_MODE_RECURSIVE_DIRECTORY_INSTALL;
+ strncpy(buf, optarg, BUFSIZE);
+ AppLog("__osp_installer_parse_options: optarg = [%s]", optarg);
+ break;
+
default:
AppLog("Invalid option");
exit(-1);
{
errorType = InstallerManager::RequestMove(path, PM_MOVE_TO_INTERNAL);
}
+ else if (readBuf[0] == '#')
+ {
+ errorType = InstallerManager::Request(path, INSTALLER_OPERATION_REINSTALL, INSTALLER_OPTION_NORMAL, packageId);
+ }
}
CATCH:
InstallerManager::PrintResult(void)
{
int errorType = GetErrorType();
- InstallerOperation operation = GetInstallerOperation();
+ InstallerOperation operation = __pContext->GetInstallerOperation();
Tizen::System::SystemTime::GetTicks(__endTick);
- const char* pOperation = null;
- (operation == INSTALLER_OPERATION_INSTALL)? (pOperation = "Install"): (pOperation = "Uninstall");
+ const char* pOperation = InstallerUtil::GetInstallerOperationString(operation);
const wchar_t* pPackageId = L"Unknown";
if (__pContext && !__pContext->__packageId.IsEmpty())
}
break;
+ case INSTALLER_MODE_REINSTALL:
+ {
+ AppLog("------------------------------------------");
+ AppLog(" # Directory = [%s]", buf);
+
+ option = (InstallerOption)(option | INSTALLER_OPTION_FILELOG_ON);
+ errorType = InstallerManager::Request(buf, INSTALLER_OPERATION_REINSTALL, option, packageId);
+ }
+ break;
+
default:
{
AppLog("__install_package_by_cmd, Invalid mode");
return true;
}
+
+bool
+PermissionManager::CopyForRds(InstallationContext* pContext, IList* pFileList, bool& isInstallRequired)
+{
+ TryReturn(pFileList, false, "pFileList is null.");
+
+ for (int idx = 0; idx < pFileList->GetCount(); idx++)
+ {
+ String* pFilePath = static_cast<String *>(pFileList->GetAt(idx));
+ TryReturn(pFilePath, false, "pFilePath is null.");
+
+ String srcFile = DIR_APPLICATIONS_TMP;
+ srcFile += L"/" + pContext->__packageId + L"/" + *pFilePath;
+ String destFile = pContext->__rootPath + L"/" + *pFilePath;
+
+ AppLog("copy file from[%ls] to[%ls]", srcFile.GetPointer(), destFile.GetPointer());
+
+ int pos = 0;
+ result r = E_SUCCESS;
+ String destDir;
+
+ r = destFile.LastIndexOf(L'/', destFile.GetLength() -1, pos);
+ if (IsFailed(r) == true)
+ {
+ AppLog("destFile is invalid[%ls]", destFile.GetPointer());
+ continue;
+ }
+ destFile.SubString(0, pos, destDir);
+
+ if (File::IsFileExist(destDir) == false)
+ {
+ Directory::Create(destDir, true);
+ }
+ InstallerUtil::Remove(destFile);
+ File::Copy(srcFile, destFile, true);
+
+ if (*pFilePath == L"info/manifest.xml")
+ {
+ AppLog("Install required, [%ls] is found", pFilePath->GetPointer());
+ isInstallRequired = true;
+ }
+ else if (pFilePath->StartsWith("setting/setting", 0) == true)
+ {
+ AppLog("Install required, [%ls] is found", pFilePath->GetPointer());
+ isInstallRequired = true;
+ }
+ }
+
+ return true;
+}
+
+bool
+PermissionManager::ApplyPermissionForRds(InstallationContext* pContext)
+{
+ String destPath;
+ String appRootPath;
+ SmackManager smackManager;
+ smackManager.Construct(pContext);
+
+ appRootPath = pContext->__rootPath;
+ PackageId packageId = pContext->__packageId;
+
+ // appRoot
+ InstallerUtil::ChangeMode(appRootPath, PERM_BASE | PERM_EXECUTE);
+ smackManager.AddLabelDir(packageId, appRootPath, true);
+
+ // appRoot/bin
+ destPath = appRootPath + DIR_BIN;
+ InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE | PERM_EXECUTE, false);
+ smackManager.AddLabelDir(packageId, destPath);
+
+ // appRoot/info
+ destPath = appRootPath + DIR_INFO;
+ InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, false);
+ smackManager.AddLabelDir(packageId, destPath);
+
+ // appRoot/res
+ destPath = appRootPath + DIR_RES;
+ InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, false);
+ smackManager.AddLabelDir(packageId, destPath);
+
+ // appRoot/lib
+ destPath = appRootPath + DIR_LIB;
+ InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE | PERM_EXECUTE, false);
+ smackManager.AddLabelDir(packageId, destPath);
+
+ // appRoot/shared
+ destPath = appRootPath + DIR_SHARED;
+ InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, false);
+ smackManager.AddLabelDir(packageId, destPath);
+
+ // appRoot/shared/res
+ destPath = appRootPath + DIR_SHARED_RES;
+ InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, false);
+ smackManager.AddLabelSharedDir(packageId, destPath);
+
+ // appRoot/shared/data
+ destPath = appRootPath + DIR_SHARED_DATA;
+ InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, true);
+ smackManager.AddLabelSharedDir(packageId, destPath);
+
+ // appRoot/shared/trusted
+ destPath = appRootPath + DIR_SHARED_TRUSTED;
+ InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, true);
+ smackManager.AddLabelSharedDir(packageId, destPath);
+
+ // appRoot/setting
+ destPath = appRootPath + DIR_SETTING;
+ InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE | PERM_WRITE, false);
+ smackManager.AddLabelDir(packageId, destPath);
+
+ // appRoot/data
+ destPath = appRootPath + DIR_DATA;
+ InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, true);
+ smackManager.AddLabelDir(packageId, destPath);
+
+ return true;
+}
+
+#if 0
+bool
+PermissionManager::ApplyPermission(InstallationContext* pContext, const IList* pFileList)
+{
+ TryReturn(pContext, false, "pContext is null");
+ TryReturn(pFileList, false, "pFileList is null");
+
+ // dir | type | owner | mode | smack
+ static RdsPermssions perms[] =
+ {
+ {"res", PERM_DIR_RES, PERM_OWNER_ROOT, PERM_BASE, PERM_SMACK_0},
+ {"data", PERM_DIR_DATA, PERM_OWNER_APP, PERM_BASE, PERM_SMACK_0},
+ {"bin", PERM_DIR_BIN, PERM_OWNER_ROOT, (PERM_BASE | PERM_EXECUTE), PERM_SMACK_0},
+ {"info", PERM_DIR_INFO, PERM_OWNER_ROOT, PERM_BASE, PERM_SMACK_0},
+ {"lib", PERM_DIR_LIB, PERM_OWNER_ROOT, (PERM_BASE | PERM_EXECUTE), PERM_SMACK_0},
+ {"setting", PERM_DIR_SETTING, PERM_OWNER_ROOT, (PERM_BASE | PERM_WRITE), PERM_SMACK_0},
+ {"shared/res", PERM_DIR_SHARED_RES, PERM_OWNER_ROOT, PERM_BASE, PERM_SMACK_0},
+ {"shared/data", PERM_DIR_SHARED_DATA, PERM_OWNER_APP, PERM_BASE, PERM_SMACK_0},
+ {"shared/trusted", PERM_DIR_SHARED_TRUSTED, PERM_OWNER_APP, PERM_BASE, PERM_SMACK_0},
+ {"shared", PERM_DIR_SHARED, PERM_OWNER_ROOT, PERM_BASE, PERM_SMACK_0},
+ {"author", PERM_DIR_ROOT, PERM_OWNER_ROOT, PERM_BASE, PERM_SMACK_0},
+ {"signature", PERM_DIR_ROOT, PERM_OWNER_ROOT, PERM_BASE, PERM_SMACK_0},
+ };
+
+ static int permCount = sizeof(perms) / sizeof(RdsPermssions);
+ bool isInstallRequired = false;
+ SmackManager smackManager;
+ smackManager.Construct(pContext);
+
+ for (int i = 0; i < pFileList->GetCount(); i++)
+ {
+ const String *pFilePath = static_cast<const String *>(pFileList->GetAt(i));
+ TryReturn(pFilePath, false, "pFilePath is null");
+
+ AppLog("pFilePath=(%ls)", pFilePath->GetPointer());
+
+ int permIdx = 0;
+ for (permIdx = 0; permIdx < permCount; permIdx++)
+ {
+ if (pFilePath->StartsWith(perms[permIdx].pDir, 0) == true)
+ {
+ if (perms[permIdx].dirType == PERM_DIR_INFO)
+ {
+ if (*pFilePath == L"info/manifest.xml")
+ {
+ AppLog("Install required, [%ls] is found", pFilePath->GetPointer());
+ isInstallRequired = true;
+ }
+ }
+ else if (perms[permIdx].dirType == PERM_DIR_SETTING)
+ {
+ if (pFilePath->StartsWith("setting/setting", 0) == true)
+ {
+ AppLog("Install required, [%ls] is found", pFilePath->GetPointer());
+ isInstallRequired = true;
+ }
+ }
+
+ AppLog("dirType=(%d), owner=(%d), mode=(%d), smack=(%d)",
+ perms[permIdx].dirType, perms[permIdx].ownerIndex, perms[permIdx].modeIndex, perms[permIdx].smackIndex);
+
+ String srcFile = DIR_APPLICATIONS_TMP;
+ srcFile += L"/" + pContext->__packageId + L"/" + *pFilePath;
+ String destFile = pContext->__rootPath + L"/" + *pFilePath;
+
+ AppLog("copy file: from[%ls] to[%ls]", srcFile.GetPointer(), destFile.GetPointer());
+ File::Copy(srcFile, destFile, false);
+
+ bool isAppOwner = false;
+ if (perms[permIdx].ownerIndex == PERM_OWNER_APP)
+ {
+ isAppOwner = true;
+ }
+
+ String destPath;
+ if (perms[permIdx].dirType != PERM_DIR_ROOT)
+ {
+ destPath = pContext->__rootPath + L"/" + perms[permIdx].pDir;
+ InstallerUtil::ChangeDirectoryPermission(destPath, perms[permIdx].modeIndex, isAppOwner);
+ }
+ else
+ {
+ destPath = pContext->__rootPath + L"/" + *pFilePath;
+ InstallerUtil::ChangeMode(*pFilePath, perms[permIdx].modeIndex);
+ }
+ smackManager.AddLabelSharedDir(pContext->__packageId, destPath);
+
+ break;
+ }
+ }
+ }
+
+ return true;
+}
+#endif
+
+
static bool SetDirectory(InstallationContext* pContext);
static bool SetFile(InstallationContext* pContext);
+ bool CopyForRds(InstallationContext* pContext, Tizen::Base::Collection::IList* pFileList, bool& isInstallRequired);
+ bool ApplyPermissionForRds(InstallationContext* pContext);
+
private:
static bool SetSymLink(InstallationContext* pContext);
static bool PrepareDataCaging(InstallationContext* pContext);
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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 RdsStep.cpp
+ * @brief This is the implementation file for %ApplicationXmlStep class.
+ */
+
+#include <unique_ptr.h>
+
+#include <FIoFile.h>
+#include <FAppPkg_PackageInfoImpl.h>
+
+#include "InstallationContext.h"
+#include "RdsStep.h"
+#include "PermissionManager.h"
+#include "FAppTypes.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::App;
+using namespace Tizen::App::Package;
+using namespace Tizen::Io;
+
+RdsStep::RdsStep(void)
+:__state(STATE_RDS_PROCESSING)
+,__pContext(null)
+,__isInstallRequired(false)
+{
+}
+
+RdsStep::~RdsStep(void)
+{
+}
+
+InstallerError
+RdsStep::Run(InstallationContext* pContext)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ __pContext = pContext;
+
+ while (true)
+ {
+ switch (__state)
+ {
+ case STATE_RDS_PROCESSING:
+ error = OnRdsProcessing();
+ break;
+
+ case STATE_DONE:
+ AppLog("[STATE_DONE]");
+ error = OnStateDone();
+ break;
+
+ default:
+ break;
+ }
+
+ if (error != INSTALLER_ERROR_NONE)
+ {
+ break;
+ }
+
+ if (__state > STATE_DONE)
+ {
+ break;
+ }
+ }
+
+ return error;
+}
+
+void
+RdsStep::GoNextState(void)
+{
+ __state++;
+}
+
+InstallerError
+RdsStep::OnRdsProcessing(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ bool res = false;
+
+ std::unique_ptr<ArrayList> pDeletedList(new (std::nothrow) ArrayList());
+ TryReturn(pDeletedList, INSTALLER_ERROR_OUT_OF_MEMORY, "pDeletedList is null");
+
+ std::unique_ptr<ArrayList> pAddedList(new (std::nothrow) ArrayList());
+ TryReturn(pAddedList, INSTALLER_ERROR_OUT_OF_MEMORY, "pAddedList is null");
+
+ std::unique_ptr<ArrayList> pModifiedList(new (std::nothrow) ArrayList());
+ TryReturn(pModifiedList, INSTALLER_ERROR_OUT_OF_MEMORY, "pModifiedList is null");
+
+ PackageId packageId = __pContext->__packageId;
+
+ res = InstallerUtil::GetRdsList(packageId, pDeletedList.get(), pAddedList.get(), pModifiedList.get());
+ TryReturn(res, INSTALLER_ERROR_INTERNAL_STATE, "GetRdsList() failed");
+
+ PackageInfo* pPackageInfo = _PackageManagerImpl::GetInstance()->GetPackageInfoN(packageId);
+ TryReturn(pPackageInfo != null, INSTALLER_ERROR_INTERNAL_STATE, "GetPackageInfoN() failed");
+
+ _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo);
+ TryReturn(pPackageInfoImpl, INSTALLER_ERROR_INTERNAL_STATE, "GetInstance() failed");
+
+ String rootPath = pPackageInfoImpl->GetAppRootPath();
+ __pContext->__rootPath = rootPath;
+
+ int idx = 0;
+ for (idx = 0; idx < pDeletedList->GetCount(); idx++)
+ {
+ String* pDeletedFile = static_cast<String *>(pDeletedList->GetAt(idx));
+ String destFile = rootPath + L"/" + *pDeletedFile;
+
+ AppLog("deleted file: %ls", destFile.GetPointer());
+ InstallerUtil::Remove(destFile);
+ }
+
+ PermissionManager permissionMgr;
+ permissionMgr.CopyForRds(__pContext, pAddedList.get(), __isInstallRequired);
+ permissionMgr.CopyForRds(__pContext, pModifiedList.get(), __isInstallRequired);
+ permissionMgr.ApplyPermissionForRds(__pContext);
+
+ GoNextState();
+ return error;
+}
+
+InstallerError
+RdsStep::OnStateDone(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+
+ if (__isInstallRequired == true)
+ {
+ __pContext->SetContinue(true);
+ __pContext->__inputPath = __pContext->__rootPath;
+ __pContext->__installDir = __pContext->__rootPath;
+ __pContext->SetInstallerOperation(INSTALLER_OPERATION_INSTALL);
+ }
+ else
+ {
+ __pContext->SetContinue(false);
+ }
+
+ GoNextState();
+ return error;
+}
+
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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 RdsStep.h
+ * @brief This is the header file for the %RdsStep class.
+ *
+ * This header file contains the declarations of the %RdsStep class.
+ */
+#ifndef _RDS_STEP_H_
+#define _RDS_STEP_H_
+
+#include "IInstallationStep.h"
+
+/**
+ * @class RdsStep
+ * @brief This class represents the class of RdsStep.
+ * @since 1.0
+ *
+ * This class represents the class of RdsStep.
+ *
+ */
+class RdsStep
+ : public IInstallationStep
+{
+public:
+ RdsStep(void);
+ virtual ~RdsStep(void);
+
+ virtual InstallerError Run(InstallationContext* pContext);
+
+private:
+ enum
+ {
+ STATE_RDS_PROCESSING,
+ STATE_DONE
+ };
+
+ void GoNextState(void);
+ InstallerError OnRdsProcessing(void);
+ InstallerError OnStateDone(void);
+
+private:
+ int __state;
+ InstallationContext* __pContext;
+ bool __isInstallRequired;
+
+}; // RdsStep
+
+#endif //_RDS_STEP_H_
return true;
}
+
+bool
+InstallerUtil::GetRdsList(const PackageId& packageId, IList* pDeletedList, IList* pAddedList, IList* pModifiedList)
+{
+ FILE* fp = null;
+ char rdsFilePath[1024] = {0};
+ char buffer[1024] = {0};
+ InstallerRdsState state = INSTALLER_RDS_STATE_NONE;
+
+ snprintf(rdsFilePath, sizeof(rdsFilePath), "%s/%ls/%s", DIR_APPLICATIONS_TMP, packageId.GetPointer(), INSTALLER_RDS_FILE_NAME);
+
+ fp = fopen(rdsFilePath, "r");
+ TryReturn(fp, false, "fp is null.");
+ AppLog(".rds_delta file");
+ int line = 1;
+
+ while (fgets(buffer, sizeof(buffer), fp) != null)
+ {
+ if (buffer[0] == '#')
+ {
+ if (strcasestr(buffer, INSTALLER_RDS_DELETE_STR))
+ {
+ state = INSTALLER_RDS_STATE_DELETE;
+ }
+ else if (strcasestr(buffer, INSTALLER_RDS_ADD_STR))
+ {
+ state = INSTALLER_RDS_STATE_ADD;
+ }
+ else if (strcasestr(buffer, INSTALLER_RDS_MODIFY_STR))
+ {
+ state = INSTALLER_RDS_STATE_MODIFY;
+ }
+ }
+
+ if (state == INSTALLER_RDS_STATE_NONE)
+ {
+ AppLog("Unknown RDS State, INSTALLER_RDS_STATE_NONE");
+ continue;
+ }
+
+ std::unique_ptr<String> pStr(new (std::nothrow) String(buffer));
+ TryReturn(pStr, false, "pStr is null.");
+ TryReturn(pStr->IsEmpty() == false, false, "pStr is empty.");
+
+ pStr->Trim();
+ AppLog(".rds_delta: line(%03d)=[%ls]", line, pStr->GetPointer());
+ line++;
+
+ if (state == INSTALLER_RDS_STATE_DELETE)
+ {
+ pDeletedList->Add(pStr.release());
+ }
+ else if (state == INSTALLER_RDS_STATE_ADD)
+ {
+ pAddedList->Add(pStr.release());
+ }
+ else if (state == INSTALLER_RDS_STATE_MODIFY)
+ {
+ pModifiedList->Add(pStr.release());
+ }
+
+ memset(buffer, 0, sizeof(buffer));
+ }
+
+ return true;
+}
+
+const char*
+InstallerUtil::GetInstallerOperationString(int operation)
+{
+ if (operation == INSTALLER_OPERATION_INSTALL)
+ {
+ return "Install";
+ }
+ else if (operation == INSTALLER_OPERATION_UNINSTALL)
+ {
+ return "Uninstall";
+ }
+ else if (operation == INSTALLER_OPERATION_REINSTALL)
+ {
+ return "Reinstall";
+ }
+
+ return "Unknown";
+}
+
#ifndef _INSTALLER_UTIL_H_
#define _INSTALLER_UTIL_H_
+#include <FAppTypes.h>
+
namespace Tizen { namespace Base
{
class String;
}}
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+}}}
+
/**
* @class InstallerUtil
* @brief This class represents the class of InstallerUtil.
static bool CreateLog(const Tizen::Base::String& logFile);
static bool AppendLog(const char* pFunction, int lineNumber, bool fatal, const char* pFormat, ...);
static bool PrintLog(const Tizen::Base::String& logFile);
+ static bool GetRdsList(const Tizen::App::PackageId& packageId,
+ Tizen::Base::Collection::IList* pDeletedList,
+ Tizen::Base::Collection::IList* pAddedList,
+ Tizen::Base::Collection::IList* pModifiedList);
+
+ static const char* GetInstallerOperationString(int operation);
private:
static char LogChangeHexToStr(int hex);
}
break;
+ case PKGMGR_REQ_REINSTALL:
+ {
+ PackageId rdsPackageId;
+
+ path.SubString(0, PACKAGE_ID_LENGTH, rdsPackageId);
+
+ AppLog("rdsPackageId = %ls", rdsPackageId.GetPointer());
+ ret = InstallerManager::Request(rdsPackageId, INSTALLER_OPERATION_REINSTALL, INSTALLER_OPTION_NORMAL, packageId);
+
+ if (_pi != 0)
+ {
+ char resultBuf[128] = {0};
+ snprintf(resultBuf, sizeof(resultBuf), "%ls", packageId.GetPointer());
+ pkgmgr_installer_send_signal(_pi, "tpk", resultBuf, "start", "install");
+ }
+ else
+ {
+ AppLog("_pi is null");
+ }
+
+ __osp_installer_report_result(packageId, errorType);
+ }
+ break;
+
case PKGMGR_REQ_MOVE:
{
if (_pi != 0)