#ifndef _INSTALLER_DEFS_H_
#define _INSTALLER_DEFS_H_
-#define DIR_BIN L"/bin"
-#define DIR_INFO L"/info"
-#define DIR_RES L"/res"
-#define DIR_DATA L"/data"
-#define DIR_ICONS L"/icons"
-#define DIR_LIB L"/lib"
-#define DIR_SETTING L"/setting"
-#define DIR_CONTENTS L"/contents"
-
-#define SLP_DIR_BIN L"/bin"
-#define SLP_DIR_RES L"/res"
-#define SLP_DIR_DATA L"/data"
-#define SLP_APP_PATH L"/opt/apps"
-
-#define SLP_FONT_PATH L"/opt/share/fonts"
+#define OSP_INSTALLER_VERSION "osp-installer version = 2012/10/31_(7)"
+
+#define DIR_BIN L"/bin"
+#define DIR_INFO L"/info"
+#define DIR_RES L"/res"
+#define DIR_DATA L"/data"
+#define DIR_ICONS L"/icons"
+#define DIR_LIB L"/lib"
+#define DIR_SETTING L"/setting"
+#define DIR_CONTENTS L"/contents"
+
+#define SLP_DIR_BIN L"/bin"
+#define SLP_DIR_RES L"/res"
+#define SLP_DIR_DATA L"/data"
+#define SLP_APP_PATH L"/opt/apps"
+
+#define PATH_OPT_APPS L"/opt/apps"
+#define PATH_USR_APPS L"/usr/apps"
+#define PATH_OPT_USR L"/opt/usr"
+#define PATH_OPT_USR_APPS L"/opt/usr/apps"
+
+#define SLP_FONT_PATH L"/opt/share/fonts"
#define DIR_DESKTOP L"/opt/share/applications/%S.desktop"
#define PACKAGE_NAME_PREFIX_ORG L"org.tizen."
#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 SYSTEMAPP_LOADER_PATH "/usr/lib/osp/osp-system-service-loader" // System Service
-#define IME_PATH "/opt/apps/scim/lib/scim-1.0/1.4.0/Helper"
+#define IME_PATH "/opt/apps/scim/lib/scim-1.0/1.4.0/Helper"
#define APP_OWNER_ID 5000
#define APP_GROUP_ID 5000
#define TEST_ARG_COUNT 1
#define COMMAND_ARG_COUNT 3
-#define DIR_OSP_APPLICATIONS_TEMP L"/opt/apps/__@@osp_tmp@@__"
+#define DIR_OSP_APPLICATIONS_TEMP L"/opt/usr/apps/__@@osp_tmp@@__"
-#define DIR_RO_PACKAGE_SYSTEM_MANIFEST L"/usr/share/packages/%ls.xml"
-#define DIR_RW_PACKAGE_SYSTEM_MANIFEST L"/opt/share/packages/%ls.xml"
+#define DIR_RO_PACKAGE_SYSTEM_MANIFEST L"/usr/share/packages/%ls.xml"
+#define DIR_RW_PACKAGE_SYSTEM_MANIFEST L"/opt/share/packages/%ls.xml"
#define DIR_MEMORYCARD_OSP_APPLICATIONS L"/opt/storage/sdcard/apps"
#define DIR_MEMORYCARD_OSP_APPLICATIONS_TEMP L"/opt/storage/sdcard/apps/__@@osp_tmp@@__"
#define OSP_INSTALLER "osp-installer"
-#define OSP_INSTALLER_VERSION "osp-installer version = 2012/10/29"
enum InstallationSetStep
{
// remove in /info/*.info files
RemoveInfoFiles();
+ InstallationContext* pContext = GetContext();
+ String installPath = pContext->GetInstallDir();
+
+ String newInstallPath;
+
+ InstallerUtil::CreateSymlinkForAppId(installPath, newInstallPath);
+ pContext->SetInstallDir(newInstallPath);
+
+ _PackageInfoImpl *pPackageInfoImpl = null;
+ pPackageInfoImpl = pContext->GetPackageInfoImpl();
+ pPackageInfoImpl->SetAppRootPath(newInstallPath);
+
+ AppLogTag(OSP_INSTALLER, "installation path = [%ls]", newInstallPath.GetPointer());
+
return Installer::OnInit();
}
#include <stdio.h>
#include <sys/stat.h>
+#include <FIoFile.h>
+#include <FIoDirectory.h>
#include <FApp_PackageInfoImpl.h>
#include <FApp_PackageManagerImpl.h>
#include "Installer.h"
#include "PermissionManager.h"
#include "ConfigurationManager.h"
+#include "InstallerUtil.h"
using namespace Osp::Base;
using namespace Osp::Base::Collection;
Installer::Construct(InstallationContext* pContext)
{
__pContext = pContext;
+
+ if (InstallerUtil::IsSymlink(PATH_OPT_APPS) == false)
+ {
+ if (File::IsFileExist(PATH_OPT_APPS) == false)
+ {
+ Directory::Create(PATH_OPT_APPS, false);
+ InstallerUtil::ChangeMode(PATH_OPT_APPS, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+ }
+ }
+
+ if (File::IsFileExist(PATH_OPT_USR) == false)
+ {
+ Directory::Create(PATH_OPT_USR, false);
+ InstallerUtil::ChangeMode(PATH_OPT_USR, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+ }
+
+ if (File::IsFileExist(PATH_OPT_USR_APPS) == false)
+ {
+ Directory::Create(PATH_OPT_USR_APPS, false);
+ InstallerUtil::ChangeMode(PATH_OPT_USR_APPS, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+ }
+
return INSTALLER_ERROR_NONE;
}
*/
#include "PreloadedInstaller.h"
+#include "InstallerUtil.h"
+
+using namespace Osp::Base;
PreloadedInstaller::PreloadedInstaller(void)
{
PreloadedInstaller::OnInit(void)
{
AppLogTag(OSP_INSTALLER, "PreloadedInstaller::OnInit()");
+
+ InstallationContext* pContext = GetContext();
+ String path = pContext->GetInputPath();
+
+ String appId;
+ String prefix(PATH_USR_APPS);
+ prefix += L"/";
+
+ path.SubString(prefix.GetLength(), APPID_LENGTH, appId);
+
+ String destRootPath(PATH_OPT_USR_APPS);
+ destRootPath += L"/";
+ destRootPath += appId;
+
+ InstallerUtil::Remove(destRootPath);
+ InstallerUtil::Remove(destRootPath);
+
+ String srcPath;
+ String destPath;
+
+ // /data
+ srcPath = path + DIR_DATA;
+ destPath = destRootPath + DIR_DATA;
+ InstallerUtil::CopyDirectory(srcPath, destPath);
+
+ // /info
+ srcPath = path + DIR_INFO;
+ destPath = destRootPath + DIR_INFO;
+ InstallerUtil::CopyDirectory(srcPath, destPath);
+
+ // appRoot - signature
+
+ srcPath = path + DIR_BIN;
+ destPath = destRootPath + DIR_BIN;
+ InstallerUtil::CreateSymlink(srcPath, destPath);
+
+ srcPath = path + DIR_RES;
+ destPath = destRootPath + DIR_RES;
+ InstallerUtil::CreateSymlink(srcPath, destPath);
+
+ srcPath = path + DIR_LIB;
+ destPath = destRootPath + DIR_LIB;
+ InstallerUtil::CreateSymlink(srcPath, destPath);
+
+ srcPath = path + DIR_ICONS;
+ destPath = destRootPath + DIR_ICONS;
+ InstallerUtil::CreateSymlink(srcPath, destPath);
+
+ srcPath = path + DIR_SETTING;
+ destPath = destRootPath + DIR_SETTING;
+ InstallerUtil::CreateSymlink(srcPath, destPath);
+
+ // pContext->SetInputPath(destRootPath);
+ pContext->SetInstallDir(destRootPath);
+
return DirectoryInstaller::OnInit();
}
}
InstallerError
-InstallerManager::Construct(const String& path, InstallerType installerType, InstallerOperation operation, RequesterType requesterType, bool hybridService)
+InstallerManager::Construct(const String& path, InstallerOperation operation, RequesterType requesterType, bool hybridService)
{
InstallerError error = INSTALLER_ERROR_NONE;
+ InstallerType installerType = INSTALLER_TYPE_INSTALLER;
+ result r = E_SUCCESS;
__pContext = new InstallationContext();
TryReturn(__pContext, INSTALLER_ERROR_MEMORY, "[osp-installer] __pContext is null.");
error = __pContext->Construct();
TryReturn(error == INSTALLER_ERROR_NONE, INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] __pContext->Construct() failed.");
- __pContext->SetInstallerOperation(operation);
-
- if (requesterType == REQUESTER_TYPE_PRELOADED)
- {
- __pContext->SetPreloaded(true);
- }
-
- if (hybridService == true)
- {
- AppLogTag(OSP_INSTALLER, "Request to install HybridService app!");
- __pContext->SetHybridService(true);
- }
-
- __pInstaller = CreateInstaller(installerType);
- TryReturn(__pInstaller, INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] __pInstaller is null.");
-
- if (installerType == INSTALLER_TYPE_DIRECTORY)
- {
- _PackageInfoImpl *pPackageInfoImpl = null;
-
- pPackageInfoImpl = __pContext->GetPackageInfoImpl();
- pPackageInfoImpl->SetAppRootPath(path);
-
- AppLogTag(OSP_INSTALLER, "path = [%ls]", path.GetPointer());
- }
-
+ // 1. operation
if (operation == INSTALLER_OPERATION_INSTALL)
{
- __pContext->SetInputPath(path);
- __pContext->SetPackagePath(path);
- __pContext->SetInstallDir(path);
+ FileAttributes attr;
+ r = File::GetAttributes(path, attr);
+ TryReturn(!IsFailed(r), INSTALLER_ERROR_INVALID_PACKAGE, "[osp-installer] File::GetAttributes() failed");
+
+ if (attr.IsDirectory())
+ {
+ installerType = INSTALLER_TYPE_DIRECTORY;
+ if (path.StartsWith(PATH_USR_APPS, 0) == true)
+ {
+ installerType = INSTALLER_TYPE_PRELOADED;
+ }
- FileAttributes attribute;
- result r = File::GetAttributes(path, attribute);
- TryReturn(!IsFailed(r), INSTALLER_ERROR_INVALID_PACKAGE, "[osp-installer] path is invalid. path=[%ls]", path.GetPointer());
+ __pContext->SetInputPath(path);
+ __pContext->SetInstallDir(path);
+ }
+ else
+ {
+ installerType = INSTALLER_TYPE_PACKAGE;
+ __pContext->SetPackagePath(path);
+ }
// org.tizen.*
if (path.Contains(PACKAGE_NAME_PREFIX_ORG) == true)
}
else if (operation == INSTALLER_OPERATION_UNINSTALL)
{
+ installerType = INSTALLER_TYPE_INSTALLER;
+
AppLogTag(OSP_INSTALLER, "operation is INSTALLER_OPERATION_UNINSTALL");
__pContext->SetCurrentInstallationStep(INSTALLER_STEP_INIT_UNINSTALL);
__pContext->SetAppId(path);
}
+ __pContext->SetInstallerOperation(operation);
+
+ // 2. requesterType
+ if (requesterType == REQUESTER_TYPE_PRELOADED)
+ {
+ __pContext->SetPreloaded(true);
+ }
+
+ // 3. hybridService
+ if (hybridService == true)
+ {
+ AppLogTag(OSP_INSTALLER, "Request to install HybridService app!");
+ __pContext->SetHybridService(true);
+ }
+
+ __pInstaller = CreateInstaller(installerType);
+ TryReturn(__pInstaller, INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] __pInstaller is null.");
+
error = __pInstaller->Construct(__pContext);
TryReturn(error == INSTALLER_ERROR_NONE, INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] __pInstaller->Construct() failed");
int
InstallerManager::Request(const String& path, InstallerOperation operation, RequesterType requesterType, String& appid, int& errorType, bool hybridService)
{
- InstallerType type = INSTALLER_TYPE_INSTALLER;
InstallationContext* pContext = null;
InstallerError error = INSTALLER_ERROR_NONE;
InstallerManager* pInstallManager = null;
AppLogTag(OSP_INSTALLER, "# path = [%ls]", path.GetPointer());
AppLogTag(OSP_INSTALLER, "------------------------------------------");
- if (operation == INSTALLER_OPERATION_INSTALL)
- {
- FileAttributes attr;
- result r = File::GetAttributes(path, attr);
- TryCatch(!IsFailed(r), error = INSTALLER_ERROR_INVALID_PACKAGE, "[osp-installer] File::GetAttributes() failed");
-
- if (attr.IsDirectory())
- {
- type = INSTALLER_TYPE_DIRECTORY;
- }
- else
- {
- type = INSTALLER_TYPE_PACKAGE;
- }
- }
- else if (operation == INSTALLER_OPERATION_UNINSTALL)
- {
- type = INSTALLER_TYPE_INSTALLER;
- }
-
pInstallManager = InstallerManager::GetInstance();
TryCatch(pInstallManager, error = INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] pInstallManager is null.");
- error = pInstallManager->Construct(path, type, operation, requesterType, hybridService);
+ error = pInstallManager->Construct(path, operation, requesterType, hybridService);
TryCatch(error == INSTALLER_ERROR_NONE, , "[osp-installer] pInstallManager->Construct() failed.");
error = pInstallManager->Activate();
{
public:
InstallerManager(void);
- InstallerError Construct(const Osp::Base::String& path, InstallerType installerType, InstallerOperation op, RequesterType requesterType, bool hybridService = false);
+ InstallerError Construct(const Osp::Base::String& path, InstallerOperation op, RequesterType requesterType, bool hybridService = false);
virtual ~InstallerManager(void);
static InstallerManager* GetInstance(void);
{
}
-bool
-PermissionManager::ChangeHomeDirectoryOwner(const String& rootPath, int depth)
-{
- Directory* pDir = null;
- DirEnumerator* pDirEnum = null;
- result r = E_SUCCESS;
- result res = false;
-
- pDir = new Directory; // Allocate %Directory instance
- TryCatch(pDir, res = false, "[osp-installer] pDir is null");
-
- r = pDir->Construct(rootPath);
- TryCatch(!IsFailed(r), res = false, "[osp-installer] pDir->Construct() failed, rootPath=[%ls]", rootPath.GetPointer());
-
- pDirEnum = pDir->ReadN();
- TryCatch(pDirEnum, res = false, "[osp-installer] pDirEnum is null");
-
- while (pDirEnum->MoveNext() == E_SUCCESS)
- {
- DirEntry entry = pDirEnum->GetCurrentDirEntry();
-
- String entryName = entry.GetName();
- String entryDir = rootPath;
- entryDir += L"/";
- entryDir += entryName;
-
- if (entryName == L".")
- {
- InstallerUtil::ChangeOwner(entryDir);
- InstallerUtil::ChangeMode(entryDir, S_IRUSR | S_IWUSR | S_IXUSR);
- continue;
- }
- else if (entryName == L"..")
- {
- // if (depth != 0)
- // {
- // ChangeOwner(entryDir);
- // }
-
- continue;
- }
-
- if (entry.IsDirectory() == false)
- {
- InstallerUtil::ChangeOwner(entryDir);
- InstallerUtil::ChangeMode(entryDir, S_IRUSR | S_IWUSR | S_IXUSR);
- }
- else
- {
- ChangeHomeDirectoryOwner(entryDir, depth+1);
- InstallerUtil::ChangeMode(entryDir, S_IRUSR | S_IWUSR | S_IXUSR);
- }
- }
-
- delete pDir;
- pDir = null;
- return true;
-
-CATCH:
- delete pDir;
- return false;
-}
-
-
-bool
-PermissionManager::ApplyHomeDirectoryPolicy(const String& rootPath)
-{
- String dataPath;
- //char* pDataPath = null;
- //int res = -1;
-
- dataPath = rootPath;
- dataPath += DIR_DATA;
-
- AppLogTag(OSP_INSTALLER, "ApplyHomeDirectoryPolicy [%ls]", dataPath.GetPointer());
-
- if (File::IsFileExist(dataPath) == false)
- {
- result r = E_SUCCESS;
- r = Directory::Create(dataPath, false);
- TryReturn(!IsFailed(r), INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] Directory::Create() failed");
- }
-// else
+//bool
+//PermissionManager::ChangeHomeDirectoryOwner(const String& rootPath, int depth)
+//{
+// Directory* pDir = null;
+// DirEnumerator* pDirEnum = null;
+// result r = E_SUCCESS;
+// result res = false;
+//
+// pDir = new Directory; // Allocate %Directory instance
+// TryCatch(pDir, res = false, "[osp-installer] pDir is null");
+//
+// r = pDir->Construct(rootPath);
+// TryCatch(!IsFailed(r), res = false, "[osp-installer] pDir->Construct() failed, rootPath=[%ls]", rootPath.GetPointer());
+//
+// pDirEnum = pDir->ReadN();
+// TryCatch(pDirEnum, res = false, "[osp-installer] pDirEnum is null");
+//
+// while (pDirEnum->MoveNext() == E_SUCCESS)
// {
-// if (File::IsFileExist(dataPath) == true)
+// DirEntry entry = pDirEnum->GetCurrentDirEntry();
+//
+// String entryName = entry.GetName();
+// String entryDir = rootPath;
+// entryDir += L"/";
+// entryDir += entryName;
+//
+// if (entryName == L".")
+// {
+// InstallerUtil::ChangeOwner(entryDir);
+// InstallerUtil::ChangeMode(entryDir, S_IRUSR | S_IWUSR | S_IXUSR);
+// continue;
+// }
+// else if (entryName == L"..")
+// {
+// // if (depth != 0)
+// // {
+// // ChangeOwner(entryDir);
+// // }
+//
+// continue;
+// }
+//
+// if (entry.IsDirectory() == false)
// {
-// AppLogTag(OSP_INSTALLER, "ApplyHomeDirectoryPolicy [%ls] is removed.", dataPath.GetPointer());
-// pDataPath = _StringConverter::CopyToCharArrayN(dataPath);
-// remove(pDataPath);
-// delete[] pDataPath;
-// pDataPath = null;
+// InstallerUtil::ChangeOwner(entryDir);
+// InstallerUtil::ChangeMode(entryDir, S_IRUSR | S_IWUSR | S_IXUSR);
+// }
+// else
+// {
+// ChangeHomeDirectoryOwner(entryDir, depth+1);
+// InstallerUtil::ChangeMode(entryDir, S_IRUSR | S_IWUSR | S_IXUSR);
// }
// }
-
- ChangeHomeDirectoryOwner(dataPath, 0);
- InstallerUtil::ChangeMode(dataPath, S_IRUSR | S_IWUSR | S_IXUSR);
-
- return true;
-}
+//
+// delete pDir;
+// pDir = null;
+// return true;
+//
+//CATCH:
+// delete pDir;
+// return false;
+//}
+
+//bool
+//PermissionManager::ApplyHomeDirectoryPolicy(const String& rootPath)
+//{
+// String dataPath;
+// //char* pDataPath = null;
+// //int res = -1;
+//
+// dataPath = rootPath;
+// dataPath += DIR_DATA;
+//
+// AppLogTag(OSP_INSTALLER, "ApplyHomeDirectoryPolicy [%ls]", dataPath.GetPointer());
+//
+// if (File::IsFileExist(dataPath) == false)
+// {
+// result r = E_SUCCESS;
+// r = Directory::Create(dataPath, false);
+// TryReturn(!IsFailed(r), INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] Directory::Create() failed");
+// }
+//
+// ChangeHomeDirectoryOwner(dataPath, 0);
+// InstallerUtil::ChangeMode(dataPath, S_IRUSR | S_IWUSR | S_IXUSR);
+//
+// return true;
+//}
bool
PermissionManager::SetDirectory(InstallationContext* pContext)
InstallerUtil::ChangeOwner(appRootPath);
InstallerUtil::ChangeMode(appRootPath, S_IRUSR | S_IXUSR);
- // appRoot/bin(no permission for app)
+ // appRoot/bin(rx for app)
destPath = appRootPath + DIR_BIN;
InstallerUtil::ChangeDirectoryPermission(destPath, S_IRUSR | S_IXUSR);
if (pAppInfoImpl)
{
// set permission(755) to bin file.
- // sprintf(destPath, "%ls%ls/%ls", appRootPath.GetPointer(), DIR_BIN, (pAppInfoImpl->GetName()).GetPointer());
- // strcat(destPath, ".exe");
destPath = appRootPath + DIR_BIN + L"/" + pAppInfoImpl->GetName() + L".exe";
InstallerUtil::ChangeMode(destPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
- // res = chmod(destPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
-// if (res != 0)
-// {
-// AppLogTag(OSP_INSTALLER, "Fail to set permission(755)[%s], res=%d.\n", destPath, res);
-// }
-// else
-// {
-// AppLogTag(OSP_INSTALLER, "Success to set permission(755)[%s], res=%d.\n", destPath, res);
-// }
}
}
private:
// static bool ChangeOwner(const Osp::Base::String& filePath);
- static bool ChangeHomeDirectoryOwner(const Osp::Base::String&, int depth);
- static bool ApplyHomeDirectoryPolicy(const Osp::Base::String& rootpath);
+ // static bool ChangeHomeDirectoryOwner(const Osp::Base::String&, int depth);
+ // static bool ApplyHomeDirectoryPolicy(const Osp::Base::String& rootpath);
// static bool ChangeMode(const Osp::Base::String& filePath, int mode);
static bool CreateSystemDirectory(InstallationContext* pContext, const Osp::Base::String& rootpath);
static bool SetSymLink(InstallationContext* pContext);
#include "InstallationContext.h"
#include "UnpackStep.h"
+#include "InstallerUtil.h"
using namespace Osp::Base;
using namespace Osp::Base::Utility;
InstallerError
UnpackStep::OnUnzip(void)
{
- // String tempDir;
InstallerError error = INSTALLER_ERROR_NONE;
AppLogTag(OSP_INSTALLER, "OnUnzip()");
_PackageInfoImpl *pPackageInfoImpl = null;
#endif
String installPath;
- installPath = SLP_APP_PATH;
+ installPath = PATH_OPT_USR_APPS;
installPath += "/";
if (__pContext->GetPackageNameType() == INSTALLER_PREFIX_TYPE_ORG)
}
installPath += __pContext->GetAppId();
- __pContext->SetInstallDir(installPath);
if (File::IsFileExist(installPath) == false)
{
result r = E_SUCCESS;
r = Directory::Create(installPath, false);
- TryReturn(!IsFailed(r), INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] Directory::Create() failed");
+ TryReturn(!IsFailed(r), INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] Directory::Create() failed, installPath=%ls", installPath.GetPointer());
}
+ String newInstallPath;
+ InstallerUtil::CreateSymlinkForAppId(installPath, newInstallPath);
+ __pContext->SetInstallDir(newInstallPath);
+
pPackageInfoImpl = __pContext->GetPackageInfoImpl();
- pPackageInfoImpl->SetAppRootPath(installPath);
+ pPackageInfoImpl->SetAppRootPath(newInstallPath);
AppLogTag(OSP_INSTALLER, "UnzipTo - START");
FileUnzipper unzipper;
unzipper.Construct(__pContext->GetPackagePath());
- unzipper.UnzipTo(installPath);
+ unzipper.UnzipTo(newInstallPath);
AppLogTag(OSP_INSTALLER, "UnzipTo - END");
// GoNextState();
}
bool
+InstallerUtil::CopyDirectory(const String& srcFilePath, const String& destFilePath)
+{
+ result r = E_SUCCESS;
+
+ std::unique_ptr<Directory> pDir(new Directory);
+ TryReturn(pDir, false, "[osp-installer] pDir is null.");
+
+ r = pDir->Construct(srcFilePath);
+ TryReturn(!IsFailed(r), false, "[osp-installer] pDir->Construct() failed, srcFilePath=[%ls].", srcFilePath.GetPointer());
+
+ std::unique_ptr<DirEnumerator> pDirEnum(pDir->ReadN());
+ TryReturn(pDirEnum, false, "[osp-installer] pDirEnum is null.");
+
+ while (pDirEnum->MoveNext() == E_SUCCESS)
+ {
+ DirEntry entry = pDirEnum->GetCurrentDirEntry();
+
+ String entryName = entry.GetName();
+ String srcEntryDir = srcFilePath;
+ srcEntryDir += L"/";
+ srcEntryDir += entryName;
+
+ if (entryName == L"." || entryName == L"..")
+ {
+ continue;
+ }
+
+ // if file or directory is symbolic link, skip this.
+ if (InstallerUtil::IsSymlink(srcEntryDir) == true)
+ {
+ continue;
+ }
+
+ String destEntryDir = destFilePath;
+ destEntryDir += L"/";
+ destEntryDir += entryName;
+
+ if (entry.IsDirectory() == false)
+ {
+ // file
+ Directory::Create(destFilePath, true);
+ InstallerUtil::Copy(srcEntryDir, destEntryDir);
+ }
+ else
+ {
+ Directory::Create(destEntryDir, true);
+ CopyDirectory(srcEntryDir, destEntryDir);
+ }
+ }
+
+ return true;
+}
+
+bool
+InstallerUtil::IsSymlink(const Osp::Base::String& filePath)
+{
+ int err = -1;
+ struct stat fileinfo;
+
+ std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
+ TryReturn(pFilePath, false, "[osp-installer] pFilePath is null");
+
+ err = lstat(pFilePath.get(), &fileinfo);
+ TryReturn(err >= 0, false, "[osp-installer] lstat() failed, filepath=%s", pFilePath.get());
+
+ if (S_ISLNK(fileinfo.st_mode))
+ {
+ return true;
+ }
+
+ return false;
+}
+
+bool
InstallerUtil::CreateSymlink(const String& oldPath, const String& newPath)
{
int err = -1;
return category;
}
+
+bool
+InstallerUtil::CreateSymlinkForAppId(const String& inPath, String& outPath)
+{
+ if (InstallerUtil::IsSymlink(PATH_OPT_APPS) == true &&
+ inPath.StartsWith(PATH_OPT_USR_APPS, 0) == true)
+ {
+ outPath = inPath;
+ return false;
+ }
+
+ String appId;
+ int length = inPath.GetLength();
+ inPath.SubString(length - APPID_LENGTH, APPID_LENGTH, appId);
+
+ String newPath;
+ newPath = PATH_OPT_APPS;
+ newPath += L"/";
+ newPath += appId;
+
+ if (inPath == newPath)
+ {
+ outPath = inPath;
+ return false;
+ }
+
+ InstallerUtil::CreateSymlink(inPath, newPath);
+
+ outPath = newPath;
+
+ return true;
+}
InstallerUtil(void);
virtual ~InstallerUtil(void);
+ static bool CreateSymlinkForAppId(const Osp::Base::String& inPath, Osp::Base::String& outPath);
+
static bool Remove(const Osp::Base::String& filePath);
static bool Copy(const Osp::Base::String& srcFilePath, const Osp::Base::String& destFilePath);
+ static bool CopyDirectory(const Osp::Base::String& srcFilePath, const Osp::Base::String& destFilePath);
+ static bool IsSymlink(const Osp::Base::String& filePath);
static bool CreateSymlink(const Osp::Base::String& oldPath, const Osp::Base::String& newPath);
static bool ChangeMode(const Osp::Base::String& filePath, int mode);