#include <unistd.h>
#include <string>
+#include <pkgmgr/pkgmgr_parser.h>
+#include <pkgmgr-info.h>
+#include <fstream>
#include <dpl/log/log.h>
#include <dpl/errno_string.h>
#include <dpl/foreach.h>
#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/utils/bash_utils.h>
#include <widget_install/job_widget_install.h>
#include <widget_install/widget_install_context.h>
namespace {
const int MAX_BUF_SIZE = 128;
-const char* OSP_INSTALL_STR = "/usr/etc/package-manager/backend/oap -iv ";
+const char* OSP_INSTALL_STR = "/usr/etc/package-manager/backend/tpk -iv ";
}
namespace Jobs {
DPL::TaskDecl<TaskInstallOspsvc>(this),
m_context(context)
{
+ AddStep(&TaskInstallOspsvc::StartStep);
AddStep(&TaskInstallOspsvc::StepInstallOspService);
+ AddStep(&TaskInstallOspsvc::EndStep);
}
void TaskInstallOspsvc::StepInstallOspService()
{
- LogInfo("Step: installation for osp service");
+ LogDebug("Step: installation for osp service");
std::ostringstream commStr;
- commStr << OSP_INSTALL_STR << GlobalConfig::GetUserInstalledWidgetPath();
- commStr << "/" << m_context.widgetConfig.pkgname;
+ commStr << OSP_INSTALL_STR << BashUtils::escape_arg(
+ m_context.locations->getPackageInstallationDir());
//commStr << " 2>&1";
LogDebug("osp install command : " << commStr.str());
fd = popen(commStr.str().c_str(), "r");
if (NULL == fd) {
LogError("Failed to installtion osp service");
- ThrowMsg(Exceptions::InstallOspsvcFailed, "Error occurs during\
+ ThrowMsg(Exceptions::InstallOspsvcFailed,
+ "Error occurs during\
+ install osp service");
+ }
+
+ if (fgets(readBuf, MAX_BUF_SIZE, fd) == NULL)
+ {
+ LogError("Failed to installtion osp service.\
+ Inability of reading file.");
+ ThrowMsg(Exceptions::InstallOspsvcFailed,
+ "Error occurs during\
install osp service");
}
- fgets(readBuf, MAX_BUF_SIZE, fd);
LogDebug("return value : " << readBuf);
int result = atoi(readBuf);
if (0 != result) {
- ThrowMsg(Exceptions::InstallOspsvcFailed, "Error occurs during\
+ ThrowMsg(Exceptions::InstallOspsvcFailed,
+ "Error occurs during\
install osp service");
}
pclose(fd);
+}
+void TaskInstallOspsvc::StartStep()
+{
+ LogDebug("--------- <TaskInstallOspsvc> : START ----------");
+}
+
+void TaskInstallOspsvc::EndStep()
+{
m_context.job->UpdateProgress(
InstallerContext::INSTALL_INSTALL_OSPSVC,
"Installed Osp servcie");
+
+ LogDebug("--------- <TaskInstallOspsvc> : END ----------");
}
} //namespace WidgetInstall
} //namespace Jobs