if (hybridService == true)
{
- CreateHybridServiceDesktopFile(pContext);
+ String webXmlPath = pXmlPath;
+ webXmlPath += L".wgt";
+ InstallerUtil::Copy(pXmlPath, webXmlPath);
+
+ pkgmgr_parser_parse_manifest_for_uninstallation(pXmlPath, null);
+ CreateSystemXmlFile(pContext);
+
+ String serviceXmlPath = pXmlPath;
+ serviceXmlPath += L".tpk";
+ InstallerUtil::Copy(pXmlPath, serviceXmlPath);
+ InstallerUtil::Remove(pXmlPath);
+
+ MergeToSystemXmlFile(pXmlPath, webXmlPath, serviceXmlPath);
+ InstallerUtil::Remove(webXmlPath);
+ InstallerUtil::Remove(serviceXmlPath);
}
else
{
AppLogTag(OSP_INSTALLER, "sync() - END");
AppLogTag(OSP_INSTALLER, "------------------------------------------");
- if (hybridService == false)
+ AppLogTag(OSP_INSTALLER, "------------------------------------------");
+ AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_installation() - START");
+ err = pkgmgr_parser_parse_manifest_for_installation(pXmlPath, null);
+ if (err != 0)
{
- AppLogTag(OSP_INSTALLER, "------------------------------------------");
- AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_installation() - START");
- err = pkgmgr_parser_parse_manifest_for_installation(pXmlPath, null);
- if (err != 0)
- {
- AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_installation() is failed. error = [%d][%s]", err, pXmlPath);
- fprintf(stderr, "pkgmgr_parser_parse_manifest_for_installation is failed. error = [%d][%s]\n", err, pXmlPath);
- }
- AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_installation() - END");
- AppLogTag(OSP_INSTALLER, "------------------------------------------");
+ AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_installation() is failed. error = [%d][%s]", err, pXmlPath);
+ fprintf(stderr, "pkgmgr_parser_parse_manifest_for_installation is failed. error = [%d][%s]\n", err, pXmlPath);
}
+ AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_installation() - END");
+ AppLogTag(OSP_INSTALLER, "------------------------------------------");
res = true;
}
bool
+ConfigurationManager::MergeToSystemXmlFile(const String& systemXmlPath, const String& webXmlPath, const String& serviceXmlPath)
+{
+ result r = E_SUCCESS;
+
+ FileAttributes webXmlAttr;
+ r = File::GetAttributes(webXmlPath, webXmlAttr);
+ TryReturn(!IsFailed(r), false, "[osp-installer] File::GetAttributes() failed, webXmlPath=%ls", webXmlPath.GetPointer());
+
+ FileAttributes serviceAttr;
+ r = File::GetAttributes(serviceXmlPath, serviceAttr);
+ TryReturn(!IsFailed(r), false, "[osp-installer] File::GetAttributes() failed, serviceXmlPath=%ls", serviceXmlPath.GetPointer());
+
+ long long webXmlFileSize = webXmlAttr.GetFileSize();
+ long long serviceXmlFileSize = serviceAttr.GetFileSize();
+ long long mergedSize = webXmlFileSize + serviceXmlFileSize;
+
+ File webXml;
+ r = webXml.Construct(webXmlPath, L"r");
+ TryReturn(!IsFailed(r), false, "[osp-installer] webXmlPath.Construct is failed");
+
+ std::unique_ptr<char[]> pMergedBuf(new char[mergedSize + 1]);
+ TryReturn(pMergedBuf, false, "[osp-installer] pMergedBuf is null");
+ memset(pMergedBuf.get(), 0, mergedSize + 1);
+
+ int readBytes = webXml.Read(pMergedBuf.get(), webXmlFileSize);
+ TryReturn(readBytes >= 0, false, "[osp-installer] webXml.Read is failed");
+
+ File serviceXml;
+ r = serviceXml.Construct(serviceXmlPath, L"r");
+ TryReturn(!IsFailed(r), false, "[osp-installer] serviceXmlPath.Construct is failed");
+
+ std::unique_ptr<char[]> pServiceBuf(new char[serviceXmlFileSize + 1]);
+ TryReturn(pServiceBuf, false, "[osp-installer] pServiceBuf is null");
+ memset(pServiceBuf.get(), 0, serviceXmlFileSize + 1);
+
+ readBytes = serviceXml.Read(pServiceBuf.get(), serviceXmlFileSize);
+ TryReturn(readBytes >= 0, false, "[osp-installer] serviceXml.Read is failed");
+
+ char* pManifestTag = strcasestr(pMergedBuf.get(), "</manifest>");
+ TryReturn(pManifestTag, false, "[osp-installer] pManifestTag is null");
+
+ char* pAppTagStart = strcasestr(pServiceBuf.get(), "<ui-application");
+ TryReturn(pAppTagStart, false, "[osp-installer] pAppTagStart is null");
+
+ char* pAppTagEnd = strcasestr(pServiceBuf.get(), "</ui-application>");
+ TryReturn(pAppTagEnd, false, "[osp-installer] pAppTagEnd is null");
+
+ int serviceAppLen = pAppTagEnd - pAppTagStart + strlen("</ui-application>");
+
+ memcpy(pManifestTag, pAppTagStart, serviceAppLen);
+
+ char* pManifestEndTag = pManifestTag + serviceAppLen;
+ strcpy(pManifestEndTag, "\n</manifest>");
+
+ int fileSize = pManifestEndTag - pMergedBuf.get() + strlen("\n</manifest>");
+
+ File systemXml;
+ r = systemXml.Construct(systemXmlPath, L"w");
+ TryReturn(!IsFailed(r), false, "[osp-installer] systemXmlPath.Construct is failed");
+
+ systemXml.Write(pMergedBuf.get(), fileSize);
+
+ AppLogTag(OSP_INSTALLER, "pMergedBuf.get()=0x%0x, length=%d", pMergedBuf.get(), fileSize);
+ InstallerUtil::DumpLogData(pMergedBuf.get(), fileSize);
+
+ return true;
+}
+
+bool
ConfigurationManager::CreateInfoFile(const String& filePath, const String* pContext)
{
result r = E_SUCCESS;
return true;
}
+
+#define LOG_PRINT_LINE_MAX 20
+#define LOG_BUFFER_COUNT_MAX 4096
+bool
+InstallerUtil::DumpLogData(char *pData, int dataLen)
+{
+ const char *szData = (const char*)pData;
+ char ch = 0;
+ int i = 0, j = 0, idx = 0, idx2 = 0, high = 0, low = 0, temp = 0;
+
+ char buf[LOG_PRINT_LINE_MAX + 2] = {0};
+ char buf2[(LOG_PRINT_LINE_MAX + 2) * 3] = {0};
+ char buf_out[sizeof(buf) + sizeof(buf2) + 1] = {0};
+
+
+ if (dataLen > LOG_BUFFER_COUNT_MAX)
+ {
+ dataLen = LOG_BUFFER_COUNT_MAX;
+ }
+
+ // 16 characters by 20 line are proper. // too many logs decrease performance.
+// if (dataLen > 16*20)
+// dataLen = 16*20;
+
+ AppLogTag(OSP_INSTALLER, "------------------------------------------");
+
+ while (i < (int)dataLen)
+ {
+ ch = szData[i];
+
+ /* make ascii table */
+ if (ch >= 32 && ch <= 128)
+ {
+ buf[idx++] = ch;
+ }
+ else
+ buf[idx++] = '.';
+
+ // make binary table
+ high = (ch & 0xf0)>>4;
+ low = ch & 0x0f;
+
+ buf2[idx2++] = LogChangeHexToStr(high);
+ buf2[idx2++] = LogChangeHexToStr(low);
+ buf2[idx2++] = ' ';
+
+ if (idx >= LOG_PRINT_LINE_MAX)
+ {
+ memcpy(buf_out, buf2, idx2);
+
+ buf_out[idx2++] = ' ';
+ buf_out[idx2++] = ' ';
+
+ memcpy(buf_out + idx2, buf, idx);
+ buf_out[idx2+idx] = '\0';
+
+ idx = 0;
+ idx2 = 0;
+
+ AppLogTag(OSP_INSTALLER, "%s\n", buf_out);
+ }
+
+ i++;
+ }
+
+ // last line
+ if (idx > 0)
+ {
+ memcpy(buf_out, buf2, idx2);
+ temp = idx2;
+
+ for (j = 0; j < (LOG_PRINT_LINE_MAX * 3) - temp; j++)
+ {
+ buf_out[idx2++] = ' ';
+ }
+
+ buf_out[idx2++] = ' ';
+ buf_out[idx2++] = ' ';
+
+ memcpy(buf_out+idx2, buf, idx);
+ buf_out[idx2+idx] = '\0';
+
+ AppLogTag(OSP_INSTALLER, "%s\n", buf_out);
+ }
+
+ AppLogTag(OSP_INSTALLER, "------------------------------------------");
+
+ return TRUE;
+}
+
+char
+InstallerUtil::LogChangeHexToStr(int hex)
+{
+ char ch = '0';
+
+ const static char hexValues[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 0};
+
+
+ if (hex >= 0 && hex <= 0x0F)
+ {
+ ch = hexValues[hex];
+ }
+ else
+ {
+ AppLogTag(OSP_INSTALLER, "LogChangeHexToStr: Error! [Hex Val: %d]\n", hex);
+ }
+
+ return ch;
+}
+
+