From e5fb07efdaa1aaa3c764bc33b20e543f6afa79fd Mon Sep 17 00:00:00 2001 From: Dongeup Ham Date: Fri, 9 Nov 2012 16:42:09 +0900 Subject: [PATCH] installer logs are changed. Change-Id: I1921d591c23b2656ef679ca3d459a87e5515a72b --- inc/InstallerDefs.h | 4 +-- src/Installer/DirectoryInstaller.cpp | 2 +- src/Manager/ConfigurationManager.cpp | 7 +--- src/Step/UninstallStep.cpp | 2 -- src/Step/UnpackStep.cpp | 2 +- src/Util/InstallerUtil.cpp | 70 +++++++++++++++++++++--------------- src/Util/InstallerUtil.h | 4 +-- 7 files changed, 47 insertions(+), 44 deletions(-) diff --git a/inc/InstallerDefs.h b/inc/InstallerDefs.h index b731b60..731a799 100755 --- a/inc/InstallerDefs.h +++ b/inc/InstallerDefs.h @@ -21,7 +21,7 @@ #ifndef _INSTALLER_DEFS_H_ #define _INSTALLER_DEFS_H_ -#define OSP_INSTALLER_VERSION "osp-installer version = [2012/11/07]_[2]" +#define OSP_INSTALLER_VERSION "osp-installer version = [2012/11/09]_RC[1]" #define DIR_BIN L"/bin" #define DIR_INFO L"/info" @@ -88,7 +88,7 @@ #ifdef AppLogTag #undef AppLogTag -#define AppLogTag(tag, ...) AppLogTagInternal(tag, "", 0, __VA_ARGS__) +#define AppLogTag(tag, ...) AppLogTagInternal(tag, "| |", 0, __VA_ARGS__) #endif enum InstallationSetStep diff --git a/src/Installer/DirectoryInstaller.cpp b/src/Installer/DirectoryInstaller.cpp index 768f115..6f45d4f 100755 --- a/src/Installer/DirectoryInstaller.cpp +++ b/src/Installer/DirectoryInstaller.cpp @@ -78,7 +78,7 @@ DirectoryInstaller::OnInit(void) String installPath = pContext->GetInstallDir(); String newInstallPath; - InstallerUtil::CreateSymlinkForAppId(installPath, newInstallPath); + InstallerUtil::CreateSymlinkForAppDirectory(installPath, newInstallPath); pContext->SetInstallDir(newInstallPath); _PackageInfoImpl *pPackageInfoImpl = null; diff --git a/src/Manager/ConfigurationManager.cpp b/src/Manager/ConfigurationManager.cpp index 746bc0b..866d0b4 100755 --- a/src/Manager/ConfigurationManager.cpp +++ b/src/Manager/ConfigurationManager.cpp @@ -337,12 +337,7 @@ ConfigurationManager::RemoveFile(InstallationContext* pContext) } AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_uninstallation() END"); - if (File::IsFileExist(xmlPath) == true) - { - AppLogTag(OSP_INSTALLER, "removing xml filePath=[%ls]", xmlPath.GetPointer()); - - InstallerUtil::Remove(xmlPath); - } + InstallerUtil::Remove(xmlPath); } pPackageInfoImpl = pContext->GetPackageInfoImpl(); diff --git a/src/Step/UninstallStep.cpp b/src/Step/UninstallStep.cpp index 2b024a4..06162fb 100755 --- a/src/Step/UninstallStep.cpp +++ b/src/Step/UninstallStep.cpp @@ -229,8 +229,6 @@ UninstallStep::OnStateRemoveDir(void) String packageName = pAppInfoImpl->GetPackageName(); String destPath; destPath.Format(1024, L"%S/%S", SLP_APP_PATH, packageName.GetPointer()); - AppLogTag(OSP_INSTALLER, "destPath[%ls]", destPath.GetPointer()); - InstallerUtil::Remove(destPath); if (pAppInfoImpl->GetAppFeature() == CATEGORY_TYPE_IME) diff --git a/src/Step/UnpackStep.cpp b/src/Step/UnpackStep.cpp index b33bdfd..53ad2da 100755 --- a/src/Step/UnpackStep.cpp +++ b/src/Step/UnpackStep.cpp @@ -136,7 +136,7 @@ UnpackStep::OnUnzip(void) } String newInstallPath; - InstallerUtil::CreateSymlinkForAppId(installPath, newInstallPath); + InstallerUtil::CreateSymlinkForAppDirectory(installPath, newInstallPath); __pContext->SetInstallDir(newInstallPath); pPackageInfoImpl = __pContext->GetPackageInfoImpl(); diff --git a/src/Util/InstallerUtil.cpp b/src/Util/InstallerUtil.cpp index bbdc3cb..afdea15 100755 --- a/src/Util/InstallerUtil.cpp +++ b/src/Util/InstallerUtil.cpp @@ -53,27 +53,33 @@ InstallerUtil::Remove(const Osp::Base::String& filePath) result r = E_SUCCESS; struct stat fileinfo; + AppLogTag(OSP_INSTALLER, "+ Remove(): path=[%ls]", filePath.GetPointer()); + std::unique_ptr 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(%s), filepath = [%s]", strerror(errno), pFilePath.get()); + if (err < 0) + { + AppLogTag(OSP_INSTALLER, "Remove(): lstat(%s): %s[errno:%d]: skip", pFilePath.get(), strerror(errno), errno); + return true; + } if (S_ISLNK(fileinfo.st_mode)) { - AppLogTag(OSP_INSTALLER, "Remove(): symlink, path = [%s]", pFilePath.get()); + AppLogTag(OSP_INSTALLER, "Remove(): symlink, path=[%s]", pFilePath.get()); err = unlink(pFilePath.get()); - TryReturn(err >= 0, false, "[osp-installer] unlink() failed(%s), filepath = [%s]", strerror(errno), pFilePath.get()); + TryReturn(err >= 0, false, "[osp-installer] unlink() failed(%s), filepath=[%s]", strerror(errno), pFilePath.get()); } else if (S_ISDIR(fileinfo.st_mode)) { - AppLogTag(OSP_INSTALLER, "Remove(): directory, path = [%ls]", filePath.GetPointer()); + AppLogTag(OSP_INSTALLER, "Remove(): directory, path=[%ls]", filePath.GetPointer()); r = Directory::Remove(filePath, true); TryReturn(!IsFailed(r), false, "[osp-installer] Directory::Remove() failed, filePath=%ls", filePath.GetPointer()); } else { - AppLogTag(OSP_INSTALLER, "Remove(): file, path = [%ls]", filePath.GetPointer()); + AppLogTag(OSP_INSTALLER, "Remove(): file, path=[%ls]", filePath.GetPointer()); r = File::Remove(filePath); TryReturn(!IsFailed(r), false, "[osp-installer] File::Remove() failed, filePath=%ls", filePath.GetPointer()); } @@ -88,6 +94,8 @@ InstallerUtil::Copy(const String& srcFilePath, const String& destFilePath) int readBytes = 0; result r = E_SUCCESS; + AppLogTag(OSP_INSTALLER, "+ Copy(): src=[%ls], dest=[%ls]", srcFilePath.GetPointer(), destFilePath.GetPointer()); + File srcFile; File destFile; @@ -119,6 +127,8 @@ InstallerUtil::CopyDirectory(const String& srcFilePath, const String& destFilePa { result r = E_SUCCESS; + AppLogTag(OSP_INSTALLER, "+ CopyDirectory(): src=[%ls], dest=[%ls]", srcFilePath.GetPointer(), destFilePath.GetPointer()); + std::unique_ptr pDir(new Directory); TryReturn(pDir, false, "[osp-installer] pDir is null."); @@ -178,7 +188,7 @@ InstallerUtil::IsSymlink(const Osp::Base::String& filePath) TryReturn(pFilePath, false, "[osp-installer] pFilePath is null"); err = lstat(pFilePath.get(), &fileinfo); - TryReturn(err >= 0, false, "[osp-installer] lstat() failed(%s), filepath = [%s]", strerror(errno), pFilePath.get()); + TryReturn(err >= 0, false, "[osp-installer] lstat() failed(%s), filepath=[%s]", strerror(errno), pFilePath.get()); if (S_ISLNK(fileinfo.st_mode)) { @@ -192,6 +202,9 @@ bool InstallerUtil::GetRealPath(const String& filePath, String& realPath) { char* pRealPath = null; + + AppLogTag(OSP_INSTALLER, "+ GetRealPath(): path=[%ls], realPath=[%ls]", filePath.GetPointer(), realPath.GetPointer()); + std::unique_ptr pFilePath(_StringConverter::CopyToCharArrayN(filePath)); TryReturn(pFilePath, false, "[osp-installer] pFilePath is null"); @@ -210,8 +223,10 @@ InstallerUtil::CreateSymlink(const String& oldPath, const String& newPath) int err = -1; bool res = false; + AppLogTag(OSP_INSTALLER, "+ CreateSymlink(): oldPath=[%ls], newPath=[%ls]", oldPath.GetPointer(), newPath.GetPointer()); + res = File::IsFileExist(oldPath); - TryReturn(res == true, false, "[osp-installer] file not found, oldPath=(%ls).", oldPath.GetPointer()); + TryReturn(res == true, false, "[osp-installer] file not found, oldPath=[%ls]", oldPath.GetPointer()); std::unique_ptr pOldPath(_StringConverter::CopyToCharArrayN(oldPath)); TryReturn(pOldPath, false, "[osp-installer] pOldPath is null"); @@ -220,9 +235,9 @@ InstallerUtil::CreateSymlink(const String& oldPath, const String& newPath) TryReturn(pNewPath, false, "[osp-installer] pNewPath is null"); err = symlink(pOldPath.get(), pNewPath.get()); - TryReturn(err == 0, false, "[osp-installer] symlink() is failed(%s), oldpath = [%s], newpath = [%s]", strerror(errno), pOldPath.get(), pNewPath.get()); + TryReturn(err == 0, false, "[osp-installer] symlink() is failed(%s), oldpath=[%s], newpath=[%s]", strerror(errno), pOldPath.get(), pNewPath.get()); - AppLogTag(OSP_INSTALLER, "CreateSymlink() [%ls] -> [%ls]", newPath.GetPointer(), oldPath.GetPointer()); + AppLogTag(OSP_INSTALLER, "CreateSymlink(): [%ls] -> [%ls]", newPath.GetPointer(), oldPath.GetPointer()); return true; } @@ -236,7 +251,7 @@ InstallerUtil::ChangeMode(const String& filePath, int mode) TryReturn(pFilePath, false, "[osp-installer] pFilePath is null"); err = chmod(pFilePath.get(), mode); - TryReturn(err == 0, false, "[osp-installer] chmod() is failed(%s), filepath = [%s], mode = [%o]", strerror(errno), pFilePath.get(), mode); + TryReturn(err == 0, false, "[osp-installer] chmod() is failed(%s), filepath=[%s], mode=[%o]", strerror(errno), pFilePath.get(), mode); return true; } @@ -250,7 +265,7 @@ InstallerUtil::ChangeOwner(const String& filePath) TryReturn(pFilePath, false, "[osp-installer] pFilePath is null"); err = chown(pFilePath.get(), APP_OWNER_ID, APP_GROUP_ID); - TryReturn(err == 0, false, "[osp-installer] chown() is failed(%s), filepath = [%s]", strerror(errno), pFilePath.get()); + TryReturn(err == 0, false, "[osp-installer] chown() is failed(%s), filepath=[%s]", strerror(errno), pFilePath.get()); return true; } @@ -261,14 +276,20 @@ InstallerUtil::ChangeDirectoryPermission(const String& filePath, int mode) result r = E_SUCCESS; bool res = false; + AppLogTag(OSP_INSTALLER, "+ ChangeDirectoryPermission(): path=[%ls], mode=[%04o]", filePath.GetPointer(), mode); + res = File::IsFileExist(filePath); - TryReturn(res == true, false, "[osp-installer] file not found, filePath = [%ls]", filePath.GetPointer()); + if (res == false) + { + AppLogTag(OSP_INSTALLER, "ChangeDirectoryPermission(): path=[%ls]: skip", filePath.GetPointer()); + return true; + } std::unique_ptr pDir(new Directory); TryReturn(pDir, false, "[osp-installer] pDir is null."); r = pDir->Construct(filePath); - TryReturn(!IsFailed(r), false, "[osp-installer] pDir->Construct() failed, filePath = [%ls]", filePath.GetPointer()); + TryReturn(!IsFailed(r), false, "[osp-installer] pDir->Construct() failed, filePath=[%ls]", filePath.GetPointer()); std::unique_ptr pDirEnum(pDir->ReadN()); TryReturn(pDirEnum, false, "[osp-installer] pDirEnum is null."); @@ -311,14 +332,14 @@ InstallerUtil::ChangeDirectoryPermission(const String& filePath, int mode) bool InstallerUtil::IsDrmFile(const Osp::Base::String& path) { - AppLogTag(OSP_INSTALLER, "IsDrmFile() called, path = [%ls]", path.GetPointer()); + AppLogTag(OSP_INSTALLER, "+ IsDrmFile() called, path=[%ls]", path.GetPointer()); return false; } bool InstallerUtil::DecryptPackage(const Osp::Base::String& packagePath) { - AppLogTag(OSP_INSTALLER, "DecryptPackage() called, packagePath = [%ls]", packagePath.GetPointer()); + AppLogTag(OSP_INSTALLER, "+ DecryptPackage() called, packagePath=[%ls]", packagePath.GetPointer()); return true; } @@ -365,9 +386,12 @@ InstallerUtil::GetCategoryType(char* pCategory) } bool -InstallerUtil::CreateSymlinkForAppId(const String& inPath, String& outPath) +InstallerUtil::CreateSymlinkForAppDirectory(const String& inPath, String& outPath) { String appId; + + AppLogTag(OSP_INSTALLER, "+ CreateSymlinkForAppDirectory(): path=[%ls]", inPath.GetPointer()); + int length = inPath.GetLength(); inPath.SubString(length - APPID_LENGTH, APPID_LENGTH, appId); @@ -382,20 +406,8 @@ InstallerUtil::CreateSymlinkForAppId(const String& inPath, String& outPath) } outPath = newPath; + AppLogTag(OSP_INSTALLER, "CreateSymlinkForAppDirectory(): output path=[%ls]", outPath.GetPointer()); return true; } -void -InstallerUtil::Log(const char* pTagName, const char* pFormat, ...) -{ - va_list args; - - va_start(args, pFormat); - - AppLogTagInternal(OSP_INSTALLER, "", 0, pFormat, args); - - va_end(args); - -} - diff --git a/src/Util/InstallerUtil.h b/src/Util/InstallerUtil.h index 2fae278..fa91af7 100755 --- a/src/Util/InstallerUtil.h +++ b/src/Util/InstallerUtil.h @@ -42,8 +42,6 @@ public: 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); @@ -61,7 +59,7 @@ public: static Osp::Base::String GetCategory(int categoryType); static CategoryType GetCategoryType(char* pCategory); - static void Log(const char* pTagName, const char* pFormat, ...); + static bool CreateSymlinkForAppDirectory(const Osp::Base::String& inPath, Osp::Base::String& outPath); private: InstallerUtil(const InstallerUtil& value); -- 2.7.4