1 /* 2014, Copyright © Eurogiciel Coporation, APACHE-2.0, see LICENSE file */
2 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3 // Use of this source code is governed by a apache 2.0 license that can be
4 // found in the LICENSE file.
6 #include "wgt/step/step_create_symbolic_link.h"
8 #include <pkgmgr-info.h>
11 #include <boost/filesystem.hpp>
17 #include "common/utils/file_util.h"
18 #include "common/utils/glist_range.h"
21 namespace filesystem {
23 namespace bf = boost::filesystem;
25 common_installer::Step::Status StepCreateSymbolicLink::process() {
26 assert(context_->manifest_data.get());
27 boost::system::error_code error;
28 for (application_x* app :
29 GListRange<application_x*>(context_->manifest_data.get()->application)) {
30 // binary is a symbolic link named <appid> and is located in <pkgid>/<appid>
32 context_->pkg_path.get()
34 common_installer::CreateDir(exec_path);
36 exec_path /= bf::path(app->appid);
38 bf::create_symlink(bf::path(WRT_LAUNCHER), exec_path, error);
40 LOG(ERROR) << "Failed to set symbolic link "
41 << boost::system::system_error(error).what();
42 return Step::Status::ERROR;
45 LOG(DEBUG) << "Successfully parse tizen manifest xml";
50 common_installer::Step::Status StepCreateSymbolicLink::undo() {
51 for (application_x* app :
52 GListRange<application_x*>(context_->manifest_data.get()->application)) {
53 bf::path exec_path = context_->pkg_path.get() / "bin" / app->appid;
54 if (bf::exists(exec_path))
55 bf::remove_all(exec_path);
60 } // namespace filesystem