#include <parser_runner.h>
#include <widget_parser.h>
#include <root_parser.h>
-#include <pkg-manager/pkgmgr_signal.h>
+
+
#define NOFILE_CNT_FOR_INSTALLER 9999
m_installByPkgmgr(false),
m_quiet(true),
m_popup(NULL),
- m_startupPluginInstallation(false)
+ m_startupPluginInstallation(false),
+ m_preloadWidget(false)
{
Touch();
LogDebug("App Created");
void WrtInstaller::OnCreate()
{
LogInfo("Creating DummyClient");
+ fprintf(stderr,
+ "===========================================================\n");
+ fprintf(stderr, "# wrt-installer #\n");
+ fprintf(stderr, "# argc [%ld]\n", m_argc);
+ fprintf(stderr, "# argv[0] = [%s]\n", m_argv[0]);
+ fprintf(stderr, "# argv[1] = [%s]\n", m_argv[1]);
+ fprintf(stderr, "# argv[2] = [%s]\n", m_argv[2]);
+ fprintf(stderr,
+ "===========================================================\n");
AddStep(&WrtInstaller::initStep);
std::string arg = m_argv[0];
+ pkgmgrSignalInterface = std::static_pointer_cast<PackageManager::IPkgmgrSignal>(
+ std::shared_ptr<PackageManager::PkgmgrSignalDummy>(
+ new PackageManager::PkgmgrSignalDummy()
+ )
+ );
+
if (arg.empty()) {
return showHelpAndQuit();
}
return showHelpAndQuit();
}
+ struct stat info;
+ if (-1 != stat(m_argv[2], &info) && S_ISDIR(info.st_mode)) {
+ LogInfo("Installing package directly from directory");
+ m_installPolicy = WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL;
+ }
+ else
+ {
+ LogInfo("Installing from regular location");
+ m_installPolicy = WRT_WIM_POLICY_WAC;
+ }
m_packagePath = m_argv[2];
- m_installPolicy = WRT_WIM_POLICY_WAC;
AddStep(&WrtInstaller::installStep);
} else if (arg == "-if" || arg == "--install-force") {
if (m_argc != 3) {
m_packagePath = m_argv[2];
m_installPolicy = WRT_WIM_POLICY_FORCE_INSTALL;
AddStep(&WrtInstaller::installStep);
- } else if (arg == "-u" || arg == "--uninstall") {
+ } else if (arg == "-il" || arg == "--install-preload") {
if (m_argc != 3) {
return showHelpAndQuit();
}
- m_handle = atoi(m_argv[2]);
- AddStep(&WrtInstaller::uninstallStep);
+ m_packagePath = m_argv[2];
+ m_preloadWidget = true;
+ m_installPolicy = WRT_WIM_POLICY_WAC;
+ AddStep(&WrtInstaller::installStep);
} else if (arg == "-un" || arg == "--uninstall-name") {
if (m_argc != 3) {
return showHelpAndQuit();
using namespace PackageManager;
m_installByPkgmgr = true;
- PkgmgrSignalSingleton::Instance().initialize(m_argc, m_argv);
- m_quiet = PkgmgrSignalSingleton::Instance().isNoPopupRequired();
+ auto pkgmgrSignal = std::shared_ptr<PackageManager::PkgmgrSignal>(
+ new PackageManager::PkgmgrSignal()
+ );
+
+ pkgmgrSignal->initialize(m_argc, m_argv);
+ m_quiet = pkgmgrSignal->isNoPopupRequired();
LogDebug("backend m_quiet"<<m_quiet);
- int reqType = PkgmgrSignalSingleton::Instance().getRequestedType();
+ int reqType = pkgmgrSignal->getRequestedType();
+ pkgmgrSignalInterface =
+ std::static_pointer_cast<PackageManager::IPkgmgrSignal>(pkgmgrSignal);
switch (reqType) {
case PKGMGR_REQ_INSTALL:
m_packagePath = m_argv[4];
- m_installPolicy = WRT_WIM_POLICY_WAC;
+ struct stat info;
+ if (-1 != stat(m_argv[4], &info) && S_ISDIR(info.st_mode)) {
+ LogInfo("Installing package directly from directory");
+ m_installPolicy = WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL;
+ }
+ else
+ {
+ LogInfo("Installing from regular location");
+ m_installPolicy = WRT_WIM_POLICY_WAC;
+ }
AddStep(&WrtInstaller::installStep);
break;
case PKGMGR_REQ_UNINSTALL:
LogDebug("Not available type");
break;
}
- } else {
- // Launch widget based on application basename
- size_t pos = arg.find_last_of('/');
-
- if (pos != std::string::npos) {
- arg = arg.erase(0, pos + 1);
- }
-
- if (sscanf(arg.c_str(), "%i", &m_handle) != 1) {
- printf("failed: invalid widget handle\n");
- return showHelpAndQuit();
- }
-
- LogDebug("Widget Id: " << m_handle << " (" << arg << ")");
}
AddStep(&WrtInstaller::shutdownStep);
"install or update widget package for given path\n"
" -if, --install-force "
"install forcibly widget package for given path\n"
- " -u, --uninstall "
- "uninstall widget for given ID\n"
- " -un, --uninstall for given package name "
+ " -un, --uninstall-name "
"uninstall widget for given package name\n"
" -ug, --uninstall-guid "
- "uninstall widget for given package path\n"
- " -up, --uninstall-packagepath "
"uninstall widget for given Global Unique IDentifier\n"
+ " -up, --uninstall-packagepath "
+ "uninstall widget for given package file path\n"
"\n");
Quit();
(!m_quiet || m_installByPkgmgr)
? &staticWrtInstallProgressCallback : NULL,
m_installPolicy,
- m_quiet);
+ m_quiet,
+ m_preloadWidget,
+ pkgmgrSignalInterface);
}
void WrtInstaller::installPluginsStep()
{
LogDebug("Installing plugins ...");
+ fprintf(stderr,"Installing plugins ...\n");
if (m_startupPluginInstallation) {
LogInfo("Plugin installation started because new plugin package found");
}
}
-void WrtInstaller::uninstallStep()
-{
- LogDebug("Uninstalling widget ...");
- wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
- (!m_quiet || m_installByPkgmgr)
- ? &staticWrtUninstallProgressCallback : NULL);
-}
-
void WrtInstaller::uninstallPkgNameStep()
{
LogDebug("Uninstalling widget ...");
- WrtErrStatus status = wrt_get_widget_by_pkgname(m_name, &m_handle);
- if (status == WRT_SUCCESS) {
- LogDebug("Get Widget Handle by package name : " << m_handle);
- wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
- (!m_quiet || m_installByPkgmgr)
- ? &staticWrtUninstallProgressCallback : NULL);
- } else {
- printf("failed: can not uninstall widget\n");
- LogError("Fail to uninstalling widget... ");
- m_returnStatus = -1;
- DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
- WRTInstallerNS::QuitEvent());
- }
+ LogDebug("Package name : " << m_name);
+ wrt_uninstall_widget(m_name.c_str(), this, &staticWrtStatusCallback,
+ (!m_quiet || m_installByPkgmgr)
+ ? &staticWrtUninstallProgressCallback : NULL,
+ pkgmgrSignalInterface);
}
void WrtInstaller::uninstallGuidStep()
{
LogDebug("Uninstalling widget ...");
- WrtErrStatus status = wrt_get_widget_by_guid(m_name, &m_handle);
+ std::string pkgname;
+ WrtErrStatus status = wrt_get_widget_by_guid(pkgname, m_name);
if (status == WRT_SUCCESS) {
- LogDebug("Get Widget Handle by guid : " << m_handle);
- wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
- !m_quiet ? &staticWrtUninstallProgressCallback : NULL);
+ LogDebug("Guid : " << m_name);
+ wrt_uninstall_widget(pkgname.c_str(), this, &staticWrtStatusCallback,
+ !m_quiet ? &staticWrtUninstallProgressCallback : NULL,
+ pkgmgrSignalInterface);
} else {
printf("failed: can not uninstall widget\n");
LogError("Fail to uninstalling widget... ");
std::string guid = DPL::ToUTF8String(*widgetGUID);
- WrtErrStatus status = wrt_get_widget_by_guid(guid, &m_handle);
+ std::string pkgname;
+ WrtErrStatus status = wrt_get_widget_by_guid(pkgname, guid);
if (status == WRT_SUCCESS) {
- LogDebug("Get Widget Handle by guid : " << m_handle);
- wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
- !m_quiet ? &staticWrtUninstallProgressCallback : NULL);
+ LogDebug("Pkgname from packagePath : " << pkgname);
+ wrt_uninstall_widget(pkgname.c_str(), this, &staticWrtStatusCallback,
+ !m_quiet ? &staticWrtUninstallProgressCallback : NULL,
+ pkgmgrSignalInterface);
} else {
LogError("Fail to uninstalling widget... ");
m_returnStatus = -1;
if (current == &WrtInstaller::installStep)
{
resultMsg = DPL::FromUTF8String(PKGMGR_INSTALL_MSG);
- printMsg = "installed";
- } else if (current == &WrtInstaller::uninstallStep ||
- current == &WrtInstaller::uninstallPkgNameStep ||
+ printMsg = "installation";
+ } else if (current == &WrtInstaller::uninstallPkgNameStep ||
current == &WrtInstaller::uninstallGuidStep ||
current == &WrtInstaller::unistallWgtFileStep)
{
resultMsg = DPL::FromUTF8String(PKGMGR_UNINSTALL_MSG);
- printMsg = "uninstalled";
+ printMsg = "uninstallation";
}
if (WRT_SUCCESS != status) {
switch (status) {
case WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE:
This->m_returnStatus = 1; //this status is specific
- printf("failed: invalid widget package\n");
+ fprintf(stderr, "## wrt-installer : %s %s has failed - invalid widget package\n",
+ tizenId.c_str(), printMsg.c_str());
break;
case WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST:
- printf("failed: widget package does not exist\n");
+ fprintf(stderr, "## wrt-installer : %s %s has failed - widget package does not exist\n",
+ tizenId.c_str(), printMsg.c_str());
break;
case WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING:
- printf("failed: already uninstalling\n");
+ fprintf(stderr, "## wrt-installer : %s %s has failed - already uninstalling\n",
+ tizenId.c_str(), printMsg.c_str());
break;
case WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE:
- printf("failed: out of disk space\n");
+ fprintf(stderr,"## wrt-installer : %s %s has failed - out of disk space\n",
+ tizenId.c_str(), printMsg.c_str());
break;
case WRT_INSTALLER_ERROR_INVALID_CERTIFICATE:
- printf("failed: invalid certificate\n");
+ fprintf(stderr,"## wrt-installer : %s %s has failed - invalid certificate\n",
+ tizenId.c_str(), printMsg.c_str());
break;
case WRT_INSTALLER_ERROR_ALREADY_INSTALLED:
- printf("failed: already installed\n");
+ fprintf(stderr,"## wrt-installer : %s %s has failed - already installed\n",
+ tizenId.c_str(), printMsg.c_str());
break;
case WRT_INSTALLER_ERROR_INTERNAL:
- printf("failed: internal error\n");
+ fprintf(stderr,"## wrt-installer : %s %s has failed - internal error\n",
+ tizenId.c_str(), printMsg.c_str());
break;
case WRT_INSTALLER_ERROR_NOT_ALLOWED:
- printf("failed: installation or update not allowed; invalid"
- " mode\n");
+ fprintf(stderr,"## wrt-installer : %s %s has failed - installation or update not allowed; invalid"
+ " mode\n", tizenId.c_str(), printMsg.c_str());
break;
case WRT_INSTALLER_ERROR_DEFERRED:
- printf("deferred: widget update will continue after the widget"
+ fprintf(stderr,"## wrt-installer : deferred: widget update will continue after the widget"
" has been stopped\n");
break;
case WRT_INSTALLER_ERROR_DATABASE_FAILURE:
- printf("failed: database failure\n");
+ fprintf(stderr,"## wrt-installer : %s %s has failed - database failure\n",
+ tizenId.c_str(), printMsg.c_str());
break;
case WRT_INSTALLER_ERROR_OSPSVC:
- printf("failed: during installation or uninstallation osp service\n");
+ fprintf(stderr,"## wrt-installer : %s %s has failed - during installation or"
+ " uninstallation osp service\n", tizenId.c_str(),
+ printMsg.c_str());
break;
case WRT_INSTALLER_ERROR_UNKNOWN:
- printf("failed: unknown error\n");
+ fprintf(stderr,"## wrt-installer : %s %s has failed - unknown error\n",
+ tizenId.c_str(), printMsg.c_str());
break;
default:
break;
+
}
} else {
-
- printf("%s : %s\n", printMsg.c_str(), tizenId.c_str());
+ fprintf(stderr, "## wrt-installer : %s %s was successful.\n", tizenId.c_str(), printMsg.c_str());
LogDebug("Status succesfull");
This->m_returnStatus = 0;
resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS);
if (This->m_numPluginsToInstall < 1) {
LogDebug("All plugins installation completed");
+ fprintf(stderr,"All plugins installation completed.\n");
//remove installation request
if (!PluginUtils::removeInstallationRequiredFlag()) {
if (WRT_SUCCESS == status) {
This->m_returnStatus = 0;
+ fprintf(stderr, "## wrt-installer : plugin installation successfull [%s]\n",
+ path.c_str());
LogDebug("One plugin Installation succesfull: " << path);
return;
}
if (WRT_PLUGIN_INSTALLER_ERROR_WAITING == status) {
LogInfo("Plugin installation is waiting for dependencies");
+ fprintf(stderr, "## wrt-installer : plugin installation failed [%s]\n",
+ path.c_str());
}
switch (status) {
int main(int argc, char *argv[])
{
- // Output on stdout will be flushed after every newline character,
- // even if it is redirected to a pipe. This is useful for running
- // from a script and parsing output.
- // (Standard behavior of stdlib is to use full buffering when
- // redirected to a pipe, which means even after an end of line
- // the output may not be flushed).
- setlinebuf(stdout);
-
- // Check and re-set the file open limitation
- struct rlimit rlim;
- if (getrlimit(RLIMIT_NOFILE, &rlim) != -1) {
- LogDebug("RLIMIT_NOFILE sft(" << rlim.rlim_cur << ")" );
- LogDebug("RLIMIT_NOFILE hrd(" << rlim.rlim_max << ")" );
-
- if (rlim.rlim_cur < NOFILE_CNT_FOR_INSTALLER) {
- rlim.rlim_cur = NOFILE_CNT_FOR_INSTALLER;
- rlim.rlim_max = NOFILE_CNT_FOR_INSTALLER;
- if (setrlimit(RLIMIT_NOFILE, &rlim) == -1) {
- LogError("setrlimit is fail!!");
+ UNHANDLED_EXCEPTION_HANDLER_BEGIN
+ {
+ // Output on stdout will be flushed after every newline character,
+ // even if it is redirected to a pipe. This is useful for running
+ // from a script and parsing output.
+ // (Standard behavior of stdlib is to use full buffering when
+ // redirected to a pipe, which means even after an end of line
+ // the output may not be flushed).
+ setlinebuf(stdout);
+
+ // Check and re-set the file open limitation
+ struct rlimit rlim;
+ if (getrlimit(RLIMIT_NOFILE, &rlim) != -1) {
+ LogDebug("RLIMIT_NOFILE sft(" << rlim.rlim_cur << ")" );
+ LogDebug("RLIMIT_NOFILE hrd(" << rlim.rlim_max << ")" );
+
+ if (rlim.rlim_cur < NOFILE_CNT_FOR_INSTALLER) {
+ rlim.rlim_cur = NOFILE_CNT_FOR_INSTALLER;
+ rlim.rlim_max = NOFILE_CNT_FOR_INSTALLER;
+ if (setrlimit(RLIMIT_NOFILE, &rlim) == -1) {
+ LogError("setrlimit is fail!!");
+ }
}
+ } else {
+ LogError("getrlimit is fail!!");
}
- } else {
- LogError("getrlimit is fail!!");
- }
- // set evas backend type for emulator
- // popup isn't showed in the emulator,
- // if backend isn't set to SW backend
- if (GlobalSettings::IsEmulator()) {
- if (setenv("ELM_ENGINE", "x11", 1)) {
- LogDebug("Enable backend");
+ // set evas backend type for emulator
+ // popup isn't showed in the emulator,
+ // if backend isn't set to SW backend
+ if (GlobalSettings::IsEmulator()) {
+ if (setenv("ELM_ENGINE", "x11", 1)) {
+ LogDebug("Enable backend");
+ }
}
- }
- WrtInstaller app(argc, argv);
- int ret = app.Exec();
- LogDebug("App returned: " << ret);
- ret = app.getReturnStatus();
- LogDebug("WrtInstaller returned: " << ret);
- return ret;
+ WrtInstaller app(argc, argv);
+ int ret = app.Exec();
+ LogDebug("App returned: " << ret);
+ ret = app.getReturnStatus();
+ LogDebug("WrtInstaller returned: " << ret);
+ return ret;
+ }
+ UNHANDLED_EXCEPTION_HANDLER_END
}