summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDongeup Ham <dongeup.ham@samsung.com>2013-08-22 12:06:43 +0900
committerDongeup Ham <dongeup.ham@samsung.com>2013-08-22 12:06:43 +0900
commitb0d69d6fae4d3728be650c42a0614af77e40a6e6 (patch)
tree2b42d0132624f702684d6a7b9b8b4af00781ff48
parent55e1ba9c85d7ab0d0975d52631b5d49e38b9ae27 (diff)
downloadinstaller-b0d69d6fae4d3728be650c42a0614af77e40a6e6.tar.gz
installer-b0d69d6fae4d3728be650c42a0614af77e40a6e6.tar.bz2
installer-b0d69d6fae4d3728be650c42a0614af77e40a6e6.zip
logs are changed.
Change-Id: I728187aa51eeedea66c61cc6708e62e4a25e4f64 Signed-off-by: Dongeup Ham <dongeup.ham@samsung.com>
-rwxr-xr-xinc/InstallerDefs.h2
-rwxr-xr-xsrc/Context/InstallationContext.h2
-rwxr-xr-xsrc/Manager/InstallerManager.cpp77
-rwxr-xr-xsrc/Manager/InstallerManager.h4
-rwxr-xr-xsrc/Util/InstallerUtil.cpp125
-rwxr-xr-xsrc/Util/InstallerUtil.h2
6 files changed, 195 insertions, 17 deletions
diff --git a/inc/InstallerDefs.h b/inc/InstallerDefs.h
index 45ed0de..6526a3c 100755
--- a/inc/InstallerDefs.h
+++ b/inc/InstallerDefs.h
@@ -23,7 +23,7 @@
#include "InstallerUtil.h"
-#define OSP_INSTALLER_VERSION "version=[20130819.1]"
+#define OSP_INSTALLER_VERSION "version=[20130822.1]"
#define DIR_BIN L"/bin"
#define DIR_INFO L"/info"
diff --git a/src/Context/InstallationContext.h b/src/Context/InstallationContext.h
index 1519d75..810b789 100755
--- a/src/Context/InstallationContext.h
+++ b/src/Context/InstallationContext.h
@@ -141,6 +141,8 @@ public:
Tizen::Base::String __cscInfo;
Tizen::Base::String __virtualRootPath;
+ Tizen::Base::String __packageSize;
+
int __certType;
void* __pPkgmgrInstaller;
diff --git a/src/Manager/InstallerManager.cpp b/src/Manager/InstallerManager.cpp
index 6ede15c..828978d 100755
--- a/src/Manager/InstallerManager.cpp
+++ b/src/Manager/InstallerManager.cpp
@@ -178,6 +178,7 @@ InstallerManager::Construct(const String& path, InstallerOperation operation, In
__pContext->__inputPath = newPath;
__pContext->__installDir = newPath;
+ __pContext->__packageSize = InstallerUtil::GetDisplaySize(newPath);
}
else
{
@@ -190,6 +191,7 @@ InstallerManager::Construct(const String& path, InstallerOperation operation, In
installerType = INSTALLER_TYPE_PACKAGE;
__pContext->__packagePath = newPath;
+ __pContext->__packageSize = InstallerUtil::GetDisplaySize(newPath);
}
if (pOptionalData)
@@ -756,32 +758,39 @@ InstallerManager::PrintResult(void)
pPackageId = __pContext->__packageId.GetPointer();
}
- const wchar_t* pMainAppName = L"Unknown";
- if (!__pContext->__mainAppName.IsEmpty())
+ const wchar_t* pPackageSize = L"0 B";
+ if (!__pContext->__packageSize.IsEmpty())
{
- pMainAppName = __pContext->__mainAppName.GetPointer();
+ pPackageSize = __pContext->__packageSize.GetPointer();
}
- const char* pError = null;
- (errorType == 0)?(pError = "Success"):(pError = "Failure");
+ const wchar_t* pAppInfoStr = L"Unknown";
+ String appInfoStr = GetAppInfoString();
+ if (!appInfoStr.IsEmpty())
+ {
+ pAppInfoStr = appInfoStr.GetPointer();
+ }
+ String error = GetErrorString(errorType);
int duration = (int)(__endTick - __startTick);
AppLog("==========================================");
- AppLog(" # operation = %s", pOperation);
- AppLog(" # %s", OSP_INSTALLER_VERSION);
- AppLog(" # Package = [%ls]", pPackageId);
- AppLog(" # MainApp = [%ls]", pMainAppName);
+ AppLog(" # osp-installer: %s", OSP_INSTALLER_VERSION);
+ AppLog("------------------------------------------");
+ AppLog(" # Operation = [%s]", pOperation);
+ AppLog(" # Package = [%ls](%ls)", pPackageId, pPackageSize);
+ AppLog(" # Apps = [%ls]", pAppInfoStr);
AppLog(" # Time = [%d]ms", duration);
- PrintError(errorType);
+ AppLog(" # Result = [%ls(%03d)]", error.GetPointer(), errorType);
AppLog("==========================================");
- fprintf(stderr, " ## osp-installer: operation=[%s] result=[%s(%03d)] package=[%ls] main appname=[%ls] time=[%d]ms\n",
- pOperation, pError, errorType, pPackageId, pMainAppName, duration);
+ fprintf(stderr, " ## osp-installer: package=[%ls](%ls) operation=[%s] result=[%ls](%03d)\n",
+ pPackageId, pPackageSize, pOperation, error.GetPointer(), errorType);
+ fprintf(stderr, " ## osp-installer: apps=[%ls] time=[%d]ms\n", pAppInfoStr, duration);
}
-void
-InstallerManager::PrintError(int errorType)
+String
+InstallerManager::GetErrorString(int errorType)
{
const char* pError = null;
@@ -868,7 +877,45 @@ InstallerManager::PrintError(int errorType)
break;
}
- AppLog(" # Error = %s(%d)", pError, errorType);
+ String error = pError;
+ return error;
+}
+
+String
+InstallerManager::GetAppInfoString()
+{
+ String appInfoStr;
+ TryReturn(__pContext, appInfoStr, "__pContext is null");
+
+ String appRootPath = __pContext->__rootPath;
+
+ IListT<AppData*>* pAppDataList = __pContext->__pAppDataList;
+ TryReturn(pAppDataList, appInfoStr, "pAppDataList is null.");
+
+ for (int i = 0 ; i < pAppDataList->GetCount(); i++)
+ {
+ AppData* pAppData = null;
+ pAppDataList->GetAt(i, pAppData);
+ TryReturn(pAppData, appInfoStr, "pAppData is null.");
+
+ String destPath = appRootPath + DIR_BIN + L"/" + pAppData->__name + L".exe";
+
+ if (i != 0)
+ {
+ appInfoStr += L" ";
+ }
+
+ appInfoStr += pAppData->__name;
+ if (pAppData->__main.Equals("True", false) == true)
+ {
+ appInfoStr += L"(main)";
+ }
+
+ String sizeStr = L"(" + InstallerUtil::GetDisplaySize(destPath) + L")";
+ appInfoStr += sizeStr;
+ }
+
+ return appInfoStr;
}
int
diff --git a/src/Manager/InstallerManager.h b/src/Manager/InstallerManager.h
index 530d113..20b5c8b 100755
--- a/src/Manager/InstallerManager.h
+++ b/src/Manager/InstallerManager.h
@@ -47,7 +47,6 @@ public:
bool RemoveGarbage(const Tizen::Base::String& filePath);
void PrintResult(void);
- void PrintError(int errorType);
int GetErrorType(void) const;
void SetErrorType(int errorType);
@@ -94,6 +93,9 @@ private:
static int ParseCommandArg(int argc, char **argv, int *mode, char *buf, InstallerOption& option);
+ Tizen::Base::String GetErrorString(int errorType);
+ Tizen::Base::String GetAppInfoString();
+
private:
static InstallerManager* __pInstallerManager;
InstallationContext* __pContext;
diff --git a/src/Util/InstallerUtil.cpp b/src/Util/InstallerUtil.cpp
index fe5cb5b..b2086ee 100755
--- a/src/Util/InstallerUtil.cpp
+++ b/src/Util/InstallerUtil.cpp
@@ -1232,3 +1232,128 @@ InstallerUtil::IsAuthorSignatureVerificationEnabled()
return false;
}
+
+long long
+InstallerUtil::GetDirectorySize(const String& rootPath)
+{
+ long long total = 0;
+ long long ret = 0;
+ int q = 0;
+ int r = 0;
+ DIR *dp = NULL;
+ struct dirent *ep = NULL;
+ struct stat fileinfo;
+ char file[FILENAME_MAX] = { 0, };
+ char *pDirName = null;
+
+ pDirName = _StringConverter::CopyToCharArrayN(rootPath);
+ TryCatch(pDirName, total = 0, "[osp-installer][libtpk] pDirName is null");
+
+ dp = opendir(pDirName);
+ TryCatch(dp, total = 0, "[osp-installer][libtpk] dp is null");
+
+ while ((ep = readdir(dp)) != NULL)
+ {
+ if (!strcmp(ep->d_name, ".") || !strcmp(ep->d_name, ".."))
+ {
+ continue;
+ }
+
+ snprintf(file, FILENAME_MAX, "%s/%s", pDirName, ep->d_name);
+
+ if (lstat(file, &fileinfo) < 0)
+ {
+ continue;
+ }
+
+ if (S_ISLNK(fileinfo.st_mode))
+ {
+ AppLog("SYMLINK=%s", file);
+ total += INSTALLER_BLOCK_SIZE;
+ continue;
+ }
+ else if (S_ISDIR(fileinfo.st_mode))
+ {
+ ret = GetDirectorySize(file);
+ ret += fileinfo.st_size;
+ total += ret;
+ AppLog("DIR=%s, size=%d[%d KB],", file, (int)ret, (int)(ret/1024));
+ }
+ else
+ {
+ /*It is a file. Calculate the actual size occupied (in terms of 4096 blocks)*/
+ q = (fileinfo.st_size / INSTALLER_BLOCK_SIZE);
+ r = (fileinfo.st_size % INSTALLER_BLOCK_SIZE);
+ if (r)
+ {
+ q++;
+ }
+ total += q * INSTALLER_BLOCK_SIZE;
+
+ if (q)
+ {
+ // AppLog("File=%s, size=%d[%d KB]", file, (q * INSTALLER_BLOCK_SIZE), (q * INSTALLER_BLOCK_SIZE)/1024);
+ }
+ }
+ }
+
+ closedir(dp);
+ dp = null;
+
+CATCH:
+ delete [] pDirName;
+
+ return total;
+}
+
+String
+InstallerUtil::GetDisplaySize(const Tizen::Base::String& path)
+{
+ long long int size = 0;
+ float sizeRes = 0.0;
+ String unitStr = L"0 B";
+ result r = E_SUCCESS;
+
+ FileAttributes attr;
+ r = File::GetAttributes(path, attr);
+ TryReturn(!IsFailed(r), unitStr, "File::GetAttributes() failed");
+
+ if (attr.IsDirectory())
+ {
+ size = GetDirectorySize(path);
+
+ // root directory
+ size += INSTALLER_BLOCK_SIZE;
+ AppLog("DIR=%ls, size=%d[%d KB],", path.GetPointer(), (int)size, (int)(size/1024));
+ }
+ else
+ {
+ size = attr.GetFileSize();
+ }
+
+ if (size >= 1024*1024*1024)
+ {
+ sizeRes = size / (1024*1024*1024.0);
+ unitStr = L"GB";
+ }
+ else if (size >= 1024*1024)
+ {
+ sizeRes = size / (1024*1024.0);
+ unitStr = L"MB";
+ }
+ else if (size >= 1024)
+ {
+ sizeRes = size / 1024.0;
+ unitStr = L"KB";
+ }
+ else
+ {
+ sizeRes = size;
+ unitStr = L"B";
+ }
+
+ String resStr;
+ resStr.Format(128, L"%.1f %ls", sizeRes, unitStr.GetPointer());
+
+ return resStr;
+}
diff --git a/src/Util/InstallerUtil.h b/src/Util/InstallerUtil.h
index 7a016cd..c114da1 100755
--- a/src/Util/InstallerUtil.h
+++ b/src/Util/InstallerUtil.h
@@ -95,6 +95,8 @@ public:
static bool IsDefaultExternalStorage();
static bool IsSignatureVerificationEnabled();
static bool IsAuthorSignatureVerificationEnabled();
+ static Tizen::Base::String GetDisplaySize(const Tizen::Base::String& path);
+ static long long GetDirectorySize(const Tizen::Base::String& rootPath);
private:
static char LogChangeHexToStr(int hex);