2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 /* @file wrt-installer.cpp
18 * @brief Implementation file for installer
21 #include "wrt-installer.h"
22 #include "plugin_utils.h"
28 #include <sys/resource.h>
30 #include <dpl/log/log.h>
31 #include <dpl/optional.h>
32 #include <dpl/optional_typedefs.h>
33 #include <dpl/exception.h>
34 #include <dpl/wrt-dao-ro/global_config.h>
35 #include <dpl/wrt-dao-ro/config_parser_data.h>
36 #include <dpl/string.h>
37 #include <dpl/abstract_waitable_input_adapter.h>
38 #include <dpl/abstract_waitable_output_adapter.h>
39 #include <dpl/zip_input.h>
40 #include <dpl/binary_queue.h>
42 #include <dpl/errno_string.h>
43 #include <dpl/utils/wrt_global_settings.h>
44 #include <parser_runner.h>
45 #include <widget_parser.h>
46 #include <root_parser.h>
48 #include <Elementary.h>
50 #include <pkg-manager/pkgmgr_signal_interface.h>
51 #include <pkg-manager/pkgmgr_signal_dummy.h>
52 #include <pkg-manager/pkgmgr_signal.h>
54 using namespace WrtDB;
56 namespace { // anonymous
57 const char * const PKGMGR_INSTALL_MSG = "Install widget";
58 const char * const PKGMGR_UNINSTALL_MSG = "Uninstall widget";
60 const char * const CONFIG_XML = "config.xml";
61 const char * const HYBRID_CONFIG_XML = "res/wgt/config.xml";
63 const unsigned int NOFILE_CNT_FOR_INSTALLER = 9999;
67 void operator()(void* x)
73 struct PluginInstallerData
76 std::string pluginPath;
78 } // namespace anonymous
80 WrtInstaller::WrtInstaller(int argc, char **argv) :
81 Application(argc, argv, "backend", false),
82 DPL::TaskDecl<WrtInstaller>(this),
83 m_installMode(WRT_INSTALL_MODE_UNKNOWN),
86 m_numPluginsToInstall(0),
89 m_installByPkgmgr(false),
91 m_startupPluginInstallation(false)
94 LogDebug("App Created");
97 WrtInstaller::~WrtInstaller()
99 LogDebug("App Finished");
102 int WrtInstaller::getReturnStatus() const
104 if (!m_returnStatus) {
111 void WrtInstaller::OnStop()
113 LogInfo("Stopping Dummy Client");
116 void WrtInstaller::OnCreate()
118 LogInfo("Creating DummyClient");
120 "===========================================================\n");
121 fprintf(stderr, "# wrt-installer #\n");
122 fprintf(stderr, "# argc [%d]\n", m_argc);
123 fprintf(stderr, "# argv[0] = [%s]\n", m_argv[0]);
124 fprintf(stderr, "# argv[1] = [%s]\n", m_argv[1]);
125 fprintf(stderr, "# argv[2] = [%s]\n", m_argv[2]);
127 "===========================================================\n");
129 AddStep(&WrtInstaller::initStep);
131 std::string arg = m_argv[0];
133 pkgmgrSignalInterface =
134 std::static_pointer_cast<PackageManager::IPkgmgrSignal>(
135 std::shared_ptr<PackageManager::PkgmgrSignalDummy>(
136 new PackageManager::PkgmgrSignalDummy()
141 return showHelpAndQuit();
146 if (arg.find("wrt-installer") != std::string::npos) {
148 return showHelpAndQuit();
152 if (arg == "-h" || arg == "--help") {
154 return showHelpAndQuit();
158 return showHelpAndQuit();
159 } else if (arg == "-p" || arg == "--install-plugins") {
161 return showHelpAndQuit();
163 if (!m_startupPluginInstallation) {
164 AddStep(&WrtInstaller::installPluginsStep);
166 LogInfo("Plugin installation alredy started");
168 } else if (arg == "-i" || arg == "--install") {
170 return showHelpAndQuit();
174 if (-1 != stat(m_argv[2], &info) && S_ISDIR(info.st_mode)) {
175 LogInfo("Installing package directly from directory");
176 m_installMode = WRT_INSTALL_MODE_INSTALL_DIRECTORY;
178 LogInfo("Installing from regular location");
179 m_installMode = WRT_INSTALL_MODE_INSTALL_WGT;
181 m_packagePath = m_argv[2];
182 AddStep(&WrtInstaller::installStep);
183 } else if (arg == "-il" || arg == "--install-preload") {
185 return showHelpAndQuit();
187 m_packagePath = m_argv[2];
188 m_installMode = WRT_INSTALL_MODE_INSTALL_PRELOAD;
189 AddStep(&WrtInstaller::installStep);
190 } else if (arg == "-un" || arg == "--uninstall-name") {
192 return showHelpAndQuit();
195 AddStep(&WrtInstaller::uninstallPkgNameStep);
196 } else if (arg == "-up" || arg == "--uninstall-packagepath") {
198 return showHelpAndQuit();
200 m_packagePath = m_argv[2];
201 AddStep(&WrtInstaller::unistallWgtFileStep);
202 } else if (arg == "-r" || arg == "--reinstall") {
204 return showHelpAndQuit();
206 LogInfo("Installing package directly from directory");
207 m_installMode = WRT_INSTALL_MODE_REINSTALL;
208 m_packagePath = m_argv[2];
209 AddStep(&WrtInstaller::installStep);
211 return showHelpAndQuit();
213 } else if (arg.find("backend") != std::string::npos) {
214 using namespace PackageManager;
215 m_installByPkgmgr = true;
217 auto pkgmgrSignal = std::shared_ptr<PackageManager::PkgmgrSignal>(
218 new PackageManager::PkgmgrSignal()
221 pkgmgrSignal->initialize(m_argc, m_argv);
222 m_quiet = pkgmgrSignal->isNoPopupRequired();
223 LogDebug("backend m_quiet" << m_quiet);
225 int reqType = pkgmgrSignal->getRequestedType();
227 pkgmgrSignalInterface =
228 std::static_pointer_cast<PackageManager::IPkgmgrSignal>(
231 case PKGMGR_REQ_INSTALL:
232 m_packagePath = m_argv[4];
234 if (-1 != stat(m_argv[4], &info) && S_ISDIR(info.st_mode)) {
235 LogInfo("Installing package directly from directory");
236 m_installMode = WRT_INSTALL_MODE_INSTALL_DIRECTORY;
238 LogInfo("Installing from regular location");
239 m_installMode = WRT_INSTALL_MODE_INSTALL_WGT;
241 AddStep(&WrtInstaller::installStep);
243 case PKGMGR_REQ_UNINSTALL:
245 AddStep(&WrtInstaller::uninstallPkgNameStep);
247 case PKGMGR_REQ_REINSTALL:
248 m_packagePath = m_argv[4];
249 m_installMode = WRT_INSTALL_MODE_REINSTALL;
250 AddStep(&WrtInstaller::installStep);
253 LogDebug("Not available type");
258 AddStep(&WrtInstaller::shutdownStep);
259 DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::
261 WRTInstallerNS::NextStepEvent());
264 void WrtInstaller::OnReset(bundle* /*b*/)
269 void WrtInstaller::OnTerminate()
271 LogDebug("Wrt Shutdown now");
272 PluginUtils::unlockPluginInstallation();
274 wrt_installer_shutdown();
278 void WrtInstaller::showHelpAndQuit()
280 printf("Usage: wrt-installer [OPTION]... [WIDGET: ID/NAME/PATH]...\n"
281 "Operate with WebRuntime daemon: install, uninstall"
282 " and launch widgets.\n"
283 "Query list of installed widgets and setup up debugging support.\n"
285 "Exactly one option must be selected.\n"
286 "Mandatory arguments to long options are mandatory for short "
288 " -h, --help show this help\n"
289 " -p, --install-plugins install plugins\n"
291 "install or update widget package for given path\n"
292 " -un, --uninstall-name "
293 "uninstall widget for given package name\n"
294 " -up, --uninstall-packagepath "
295 "uninstall widget for given package file path\n"
297 "reinstall web application\n"
303 void WrtInstaller::OnEventReceived(const WRTInstallerNS::QuitEvent& /*event*/)
308 LogDebug("Wrt Shutdown now");
309 SwitchToStep(&WrtInstaller::shutdownStep);
310 DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::
312 WRTInstallerNS::NextStepEvent());
314 LogDebug("Quiting application");
319 void WrtInstaller::OnEventReceived(
320 const WRTInstallerNS::NextStepEvent& /*event*/)
322 LogDebug("Executing next step");
326 void WrtInstaller::OnEventReceived(
327 const WRTInstallerNS::InstallPluginEvent& /*event*/)
329 PluginInstallerData* privateData = new PluginInstallerData;
330 privateData->wrtInstaller = this;
332 if (!(*m_pluginsPaths).empty()) {
333 privateData->pluginPath = (*m_pluginsPaths).front();
334 (*m_pluginsPaths).pop_front();
336 wrt_install_plugin(privateData->pluginPath.c_str(),
337 static_cast<void*>(privateData),
338 &staticWrtPluginInstallationCallback,
339 &staticWrtPluginInstallProgressCb);
345 void WrtInstaller::initStep()
347 wrt_installer_init(this, staticWrtInitCallback);
350 void WrtInstaller::installStep()
352 LogDebug("Installing widget ...");
353 std::unique_ptr<char, free_deleter> packagePath(canonicalize_file_name(
354 m_packagePath.c_str()));
356 wrt_install_widget(packagePath ? packagePath.get() : m_packagePath.c_str(),
357 this, &staticWrtStatusCallback,
358 (!m_quiet || m_installByPkgmgr)
359 ? &staticWrtInstallProgressCallback : NULL,
362 pkgmgrSignalInterface);
365 void WrtInstaller::installPluginsStep()
367 LogDebug("Installing plugins ...");
368 fprintf(stderr, "Installing plugins ...\n");
370 if (m_startupPluginInstallation) {
371 LogInfo("Plugin installation started because new plugin package found");
372 } else if (!PluginUtils::lockPluginInstallation()) {
373 LogError("Failed to open plugin installation lock file"
374 " Plugins are currently installed by other process");
375 staticWrtPluginInstallationCallback(WRT_INSTALLER_ERROR_PLUGIN_INSTALLATION_FAILED,
380 std::string PLUGIN_PATH = std::string(GlobalConfig::GetDevicePluginPath());
383 dir = opendir(PLUGIN_PATH.c_str());
389 LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
391 std::list<std::string> pluginsPaths;
392 struct dirent libdir;
393 struct dirent *result;
396 for (return_code = readdir_r(dir, &libdir, &result);
397 result != NULL && return_code == 0;
398 return_code = readdir_r(dir, &libdir, &result))
400 if (strcmp(libdir.d_name, ".") == 0 ||
401 strcmp(libdir.d_name, "..") == 0)
406 std::string path = PLUGIN_PATH;
408 path += libdir.d_name;
412 if (stat(path.c_str(), &tmp) == -1) {
413 LogError("Failed to open file" << path);
417 if (!S_ISDIR(tmp.st_mode)) {
418 LogError("Not a directory" << path);
422 pluginsPaths.push_back(path);
425 if (return_code != 0 || errno != 0) {
426 LogError("readdir_r() failed with " << DPL::GetErrnoString());
429 //set nb of plugins to install
430 //this value indicate how many callbacks are expected
431 m_numPluginsToInstall = pluginsPaths.size();
432 LogInfo("Plugins to install: " << m_numPluginsToInstall);
433 m_pluginsPaths = pluginsPaths;
435 m_totalPlugins = m_numPluginsToInstall;
436 DPL::Event::ControllerEventHandler<WRTInstallerNS::InstallPluginEvent>
437 ::PostEvent(WRTInstallerNS::InstallPluginEvent());
439 if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
440 LogError("Failed to close dir: " << PLUGIN_PATH << " with error: "
441 << DPL::GetErrnoString());
445 void WrtInstaller::uninstallPkgNameStep()
447 LogDebug("Uninstalling widget ...");
448 LogDebug("Package name : " << m_name);
449 wrt_uninstall_widget(m_name.c_str(), this, &staticWrtStatusCallback,
450 (!m_quiet || m_installByPkgmgr)
451 ? &staticWrtUninstallProgressCallback : NULL,
452 pkgmgrSignalInterface);
455 void WrtInstaller::unistallWgtFileStep()
457 LogDebug("Uninstalling widget ...");
462 ConfigParserData configInfo;
465 std::unique_ptr<DPL::ZipInput> zipFile(
466 new DPL::ZipInput(m_packagePath));
467 std::unique_ptr<DPL::ZipInput::File> configFile;
470 // Open config.xml file
471 configFile.reset(zipFile->OpenFile(CONFIG_XML));
473 Catch(DPL::ZipInput::Exception::OpenFileFailed)
475 // Open config.xml file for hybrid
476 configFile.reset(zipFile->OpenFile(HYBRID_CONFIG_XML));
480 DPL::BinaryQueue buffer;
481 DPL::AbstractWaitableInputAdapter inputAdapter(configFile.get());
482 DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
483 DPL::Copy(&inputAdapter, &outputAdapter);
484 parser.Parse(&buffer,
486 new RootParser<WidgetParser>(configInfo,
487 DPL::FromUTF32String(
490 DPL::OptionalString pkgId = configInfo.tizenPkgId;
491 if (!pkgId.IsNull()) {
492 LogDebug("Pkgid from packagePath : " << pkgId);
493 wrt_uninstall_widget(
494 DPL::ToUTF8String(*pkgId).c_str(), this, &staticWrtStatusCallback,
495 !m_quiet ? &staticWrtUninstallProgressCallback
497 pkgmgrSignalInterface);
499 LogError("Fail to uninstalling widget... ");
501 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
503 WRTInstallerNS::QuitEvent());
506 Catch(DPL::ZipInput::Exception::OpenFailed)
508 LogError("Failed to open widget package");
509 printf("failed: widget package does not exist\n");
511 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
513 WRTInstallerNS::QuitEvent());
515 Catch(DPL::ZipInput::Exception::OpenFileFailed)
517 printf("failed: widget config file does not exist\n");
518 LogError("Failed to open config.xml file");
520 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
522 WRTInstallerNS::QuitEvent());
524 Catch(ElementParser::Exception::ParseError)
526 printf("failed: can not parse config file\n");
527 LogError("Failed to parse config.xml file");
529 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
531 WRTInstallerNS::QuitEvent());
535 void WrtInstaller::shutdownStep()
537 LogDebug("Closing Wrt connection ...");
539 wrt_installer_shutdown();
540 m_initialized = false;
541 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
543 WRTInstallerNS::QuitEvent());
547 void WrtInstaller::staticWrtInitCallback(WrtErrStatus status,
550 WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
553 if (status == WRT_SUCCESS) {
554 LogDebug("Init succesfull");
555 This->m_initialized = true;
556 This->m_returnStatus = 0;
558 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
559 ::PostEvent(WRTInstallerNS::NextStepEvent());
561 LogError("Init unsuccesfull");
562 This->m_returnStatus = -1;
563 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
565 WRTInstallerNS::QuitEvent());
569 void WrtInstaller::staticWrtStatusCallback(std::string tizenId,
573 WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
576 Step current = This->GetCurrentStep();
577 DPL::String resultMsg;
578 std::string printMsg;
580 if (current == &WrtInstaller::installStep) {
581 resultMsg = DPL::FromUTF8String(PKGMGR_INSTALL_MSG);
582 printMsg = "installation";
583 } else if (current == &WrtInstaller::uninstallPkgNameStep ||
584 current == &WrtInstaller::unistallWgtFileStep)
586 resultMsg = DPL::FromUTF8String(PKGMGR_UNINSTALL_MSG);
587 printMsg = "uninstallation";
590 if (WRT_SUCCESS != status) {
592 LogError("Step failed");
593 This->m_returnStatus = -1;
595 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>
596 ::PostEvent(WRTInstallerNS::QuitEvent());
599 case WRT_INSTALLER_ERROR_PACKAGE_NOT_FOUND:
600 This->m_returnStatus = 1; //this status is specific
601 fprintf(stderr, "## wrt-installer : %s %s has failed - widget package does not exist\n",
602 tizenId.c_str(), printMsg.c_str());
605 case WRT_INSTALLER_ERROR_PACKAGE_INVALID:
606 This->m_returnStatus = 1; //this status is specific
607 fprintf(stderr, "## wrt-installer : %s %s has failed - invalid widget package\n",
608 tizenId.c_str(), printMsg.c_str());
611 case WRT_INSTALLER_ERROR_PACKAGE_LOWER_VERSION:
612 This->m_returnStatus = 1; //this status is specific
613 fprintf(stderr, "## wrt-installer : %s %s has failed - given"
614 " version is lower than existing version\n",
615 tizenId.c_str(), printMsg.c_str());
618 case WRT_INSTALLER_ERROR_MANIFEST_NOT_FOUND:
619 This->m_returnStatus = 1; //this status is specific
620 fprintf(stderr, "## wrt-installer : %s %s has failed - manifest"
621 " file doesn't find in package.\n",
622 tizenId.c_str(), printMsg.c_str());
625 case WRT_INSTALLER_ERROR_MANIFEST_INVALID:
626 This->m_returnStatus = 1; //this status is specific
627 fprintf(stderr, "## wrt-installer : %s %s has failed - "
628 "invalid manifestx.xml\n",
629 tizenId.c_str(), printMsg.c_str());
632 case WRT_INSTALLER_CONFIG_NOT_FOUND:
633 This->m_returnStatus = 1; //this status is specific
634 fprintf(stderr, "## wrt-installer : %s %s has failed - "
635 "config.xml does not exist\n",
636 tizenId.c_str(), printMsg.c_str());
639 case WRT_INSTALLER_ERROR_CONFIG_INVALID:
640 This->m_returnStatus = 1; //this status is specific
641 fprintf(stderr, "## wrt-installer : %s %s has failed - "
642 "invalid config.xml\n",
643 tizenId.c_str(), printMsg.c_str());
646 case WRT_INSTALLER_ERROR_SIGNATURE_NOT_FOUND:
647 This->m_returnStatus = 1; //this status is specific
648 fprintf(stderr, "## wrt-installer : %s %s has failed - "
649 "signature doesn't exist in package.\n",
650 tizenId.c_str(), printMsg.c_str());
653 case WRT_INSTALLER_ERROR_SIGNATURE_INVALID:
654 This->m_returnStatus = 1; //this status is specific
655 fprintf(stderr, "## wrt-installer : %s %s has failed - "
656 "invalid signature.\n",
657 tizenId.c_str(), printMsg.c_str());
660 case WRT_INSTALLER_ERROR_SIGNATURE_VERIFICATION_FAILED:
661 This->m_returnStatus = 1; //this status is specific
662 fprintf(stderr, "## wrt-installer : %s %s has failed - "
663 "signature verification failed.\n",
664 tizenId.c_str(), printMsg.c_str());
667 case WRT_INSTALLER_ERROR_ROOT_CERTIFICATE_NOT_FOUND:
668 This->m_returnStatus = 1; //this status is specific
669 fprintf(stderr, "## wrt-installer : %s %s has failed - "
670 "root certificate could not find.\n",
671 tizenId.c_str(), printMsg.c_str());
674 case WRT_INSTALLER_ERROR_CERTIFICATION_INVAID:
675 This->m_returnStatus = 1; //this status is specific
676 fprintf(stderr, "## wrt-installer : %s %s has failed - "
677 "invalid certification.\n",
678 tizenId.c_str(), printMsg.c_str());
681 case WRT_INSTALLER_ERROR_CERTIFICATE_CHAIN_VERIFICATION_FAILED:
682 This->m_returnStatus = 1; //this status is specific
683 fprintf(stderr, "## wrt-installer : %s %s has failed - "
684 "certificate chain verification failed.\n",
685 tizenId.c_str(), printMsg.c_str());
688 case WRT_INSTALLER_ERROR_CERTIFICATE_EXPIRED:
689 This->m_returnStatus = 1; //this status is specific
690 fprintf(stderr, "## wrt-installer : %s %s has failed - "
691 "certificate expired.\n",
692 tizenId.c_str(), printMsg.c_str());
695 case WRT_INSTALLER_ERROR_INVALID_PRIVILEGE:
696 This->m_returnStatus = 1; //this status is specific
697 fprintf(stderr, "## wrt-installer : %s %s has failed - "
698 "invalid privilege\n",
699 tizenId.c_str(), printMsg.c_str());
702 case WRT_INSTALLER_ERROR_MENU_ICON_NOT_FOUND:
703 This->m_returnStatus = 1; //this status is specific
704 fprintf(stderr, "## wrt-installer : %s %s has failed - "
705 "menu icon could not find\n",
706 tizenId.c_str(), printMsg.c_str());
709 case WRT_INSTALLER_ERROR_FATAL_ERROR:
710 This->m_returnStatus = 1; //this status is specific
711 fprintf(stderr, "## wrt-installer : %s %s has failed - "
713 tizenId.c_str(), printMsg.c_str());
716 case WRT_INSTALLER_ERROR_OUT_OF_STORAGE:
717 This->m_returnStatus = 1; //this status is specific
718 fprintf(stderr, "## wrt-installer : %s %s has failed - "
720 tizenId.c_str(), printMsg.c_str());
723 case WRT_INSTALLER_ERROR_OUT_OF_MEMORY:
724 This->m_returnStatus = 1; //this status is specific
725 fprintf(stderr, "## wrt-installer : %s %s has failed - "
727 tizenId.c_str(), printMsg.c_str());
730 case WRT_INSTALLER_ERROR_PACKAGE_ALREADY_INSTALLED:
731 This->m_returnStatus = 1; //this status is specific
732 fprintf(stderr, "## wrt-installer : %s %s has failed - "
733 "package already installed\n",
734 tizenId.c_str(), printMsg.c_str());
737 case WRT_INSTALLER_ERROR_ACE_CHECK_FAILED:
738 This->m_returnStatus = 1; //this status is specific
739 fprintf(stderr, "## wrt-installer : %s %s has failed - "
740 "ace check failure\n",
741 tizenId.c_str(), printMsg.c_str());
744 case WRT_INSTALLER_ERROR_MANIFEST_CREATE_FAILED:
745 This->m_returnStatus = 1; //this status is specific
746 fprintf(stderr, "## wrt-installer : %s %s has failed - "
747 "to create manifest failed\n",
748 tizenId.c_str(), printMsg.c_str());
751 case WRT_INSTALLER_ERROR_ENCRYPTION_FAILED:
752 This->m_returnStatus = 1; //this status is specific
753 fprintf(stderr, "## wrt-installer : %s %s has failed - "
754 "encryption of resource failed\n",
755 tizenId.c_str(), printMsg.c_str());
758 case WRT_INSTALLER_ERROR_INSTALL_OSP_SERVCIE:
759 This->m_returnStatus = 1; //this status is specific
760 fprintf(stderr, "## wrt-installer : %s %s has failed - "
761 "installation of osp service failed\n",
762 tizenId.c_str(), printMsg.c_str());
765 case WRT_INSTALLER_ERROR_UNINSTALLATION_FAILED:
766 This->m_returnStatus = 1; //this status is specific
767 fprintf(stderr, "## wrt-installer : %s %s has failed - "
768 "widget uninstallation failed\n",
769 tizenId.c_str(), printMsg.c_str());
773 case WRT_INSTALLER_ERROR_UNKNOWN:
774 fprintf(stderr,"## wrt-installer : %s %s has failed - unknown error\n",
775 tizenId.c_str(), printMsg.c_str());
783 "## wrt-installer : %s %s was successful.\n",
786 LogDebug("Status succesfull");
787 This->m_returnStatus = 0;
788 resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS);
790 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::
792 ::PostEvent(WRTInstallerNS::NextStepEvent());
796 void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status,
801 PluginInstallerData* data = static_cast<PluginInstallerData*>(userdata);
803 WrtInstaller *This = static_cast<WrtInstaller*>(data->wrtInstaller);
805 std::string path = std::string(data->pluginPath);
808 This->m_numPluginsToInstall--;
809 LogDebug("Plugins to install: " << This->m_numPluginsToInstall);
811 if (This->m_numPluginsToInstall < 1) {
812 LogDebug("All plugins installation completed");
813 fprintf(stderr, "All plugins installation completed.\n");
815 //remove installation request
816 if (!PluginUtils::removeInstallationRequiredFlag()) {
817 LogInfo("Failed to remove file initializing plugin installation");
821 if (!PluginUtils::unlockPluginInstallation()) {
822 LogInfo("Failed to remove installation lock");
825 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
826 ::PostEvent(WRTInstallerNS::NextStepEvent());
828 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::
829 InstallPluginEvent>::
831 WRTInstallerNS::InstallPluginEvent());
834 if (WRT_SUCCESS == status) {
835 This->m_returnStatus = 0;
837 "## wrt-installer : plugin installation successfull [%s]\n",
839 LogDebug("One plugin Installation succesfull: " << path);
844 LogWarning("One of the plugins installation failed!: " << path);
847 case WRT_INSTALLER_ERROR_PLUGIN_INSTALLATION_FAILED:
848 LogError("failed: plugin installation failed\n");
851 case WRT_INSTALLER_ERROR_UNKNOWN:
852 LogError("failed: unknown error\n");
860 void WrtInstaller::staticWrtPluginInstallProgressCb(float percent,
861 const char* description,
864 PluginInstallerData* data = static_cast<PluginInstallerData*>(userdata);
866 std::string path = std::string(data->pluginPath);
868 LogInfo("Plugin Installation: " << path <<
869 " progress: " << percent <<
870 "description " << description);
873 void WrtInstaller::staticWrtInstallProgressCallback(float percent,
874 const char* description,
877 //WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
878 LogInfo(" progress: " << percent <<
879 " description: " << description);
881 void WrtInstaller::staticWrtUninstallProgressCallback(float percent,
882 const char* description,
885 //WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
886 LogInfo(" progress: " << percent <<
887 " description: " << description);
890 void WrtInstaller::showResultCallback(void *data, Evas_Object* /*obj*/,
891 void* /*event_info*/)
893 WrtInstaller *This = static_cast<WrtInstaller*>(data);
896 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
897 ::PostEvent(WRTInstallerNS::NextStepEvent());
900 void WrtInstaller::failResultCallback(void *data, Evas_Object* /*obj*/,
901 void* /*event_info*/)
903 WrtInstaller *This = static_cast<WrtInstaller*>(data);
906 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>
907 ::PostEvent(WRTInstallerNS::QuitEvent());
910 void WrtInstaller::installNewPlugins()
912 LogDebug("Install new plugins");
914 if (!PluginUtils::lockPluginInstallation()) {
915 LogInfo("Lock NOT created");
919 if (!PluginUtils::checkPluginInstallationRequired()) {
920 LogDebug("Plugin installation not required");
921 PluginUtils::unlockPluginInstallation();
925 m_startupPluginInstallation = true;
926 AddStep(&WrtInstaller::installPluginsStep);
929 int main(int argc, char *argv[])
931 UNHANDLED_EXCEPTION_HANDLER_BEGIN
933 // Output on stdout will be flushed after every newline character,
934 // even if it is redirected to a pipe. This is useful for running
935 // from a script and parsing output.
936 // (Standard behavior of stdlib is to use full buffering when
937 // redirected to a pipe, which means even after an end of line
938 // the output may not be flushed).
941 // Check and re-set the file open limitation
943 if (getrlimit(RLIMIT_NOFILE, &rlim) != -1) {
944 LogDebug("RLIMIT_NOFILE sft(" << rlim.rlim_cur << ")");
945 LogDebug("RLIMIT_NOFILE hrd(" << rlim.rlim_max << ")");
947 if (rlim.rlim_cur < NOFILE_CNT_FOR_INSTALLER) {
948 rlim.rlim_cur = NOFILE_CNT_FOR_INSTALLER;
949 rlim.rlim_max = NOFILE_CNT_FOR_INSTALLER;
950 if (setrlimit(RLIMIT_NOFILE, &rlim) == -1) {
951 LogError("setrlimit is fail!!");
955 LogError("getrlimit is fail!!");
958 // set evas backend type for emulator
959 // popup isn't showed in the emulator,
960 // if backend isn't set to SW backend
961 if (GlobalSettings::IsEmulator()) {
962 if (setenv("ELM_ENGINE", "x11", 1)) {
963 LogDebug("Enable backend");
967 WrtInstaller app(argc, argv);
968 int ret = app.Exec();
969 LogDebug("App returned: " << ret);
970 ret = app.getReturnStatus();
971 LogDebug("WrtInstaller returned: " << ret);
974 UNHANDLED_EXCEPTION_HANDLER_END