class ConfigData {
public:
ConfigData() {}
- Property<std::string> application_name;
- Property<std::string> required_version;
+ /** version pointed in <application> tag*/
+ Property<std::string> required_api_version;
+ /** version pointed int <widget> tag*/
+ Property<std::string> required_tizen_version;
};
class BackendData {
// TODO(t.iwanek): refactoring, move to wgt backend
bool is_webapp = context_->pkg_type.get() == "wgt";
if (!ValidatePrivilegeLevel(level, is_webapp,
- context_->config_data.get().required_version.get().c_str(),
+ context_->config_data.get().required_api_version.get().c_str(),
context_->manifest_data.get()->privileges))
return Status::ERROR;
namespace {
-const char kDataLocation[] = "data";
-const char kSharedLocation[] = "shared";
+const char kData[] = "data";
+const char kShared[] = "shared";
+const char kSharedData[] = "data";
+const char kSharedTrusted[] = "trusted";
-bool CreateStorageDirectoriesForPath(const bf::path& path) {
+} // namespace
+
+namespace common_installer {
+namespace create_storage {
+
+common_installer::Step::Status StepCreateStorageDirectories::process() {
+ if (!ShareDir())
+ return Status::ERROR;
+ if (!PrivateDir())
+ return Status::ERROR;
+
+ return Status::OK;
+}
+
+bool StepCreateStorageDirectories::ShareDir() {
bs::error_code error_code;
- bf::path data_path = path / kDataLocation;
- bf::create_directory(data_path, error_code);
- if (error_code) {
- LOG(ERROR) << "Failed to create private directory for widget";
- return false;
- }
- bf::path shared_path = path / kSharedLocation;
+ bf::path shared_path = context_->pkg_path.get() / kShared;
bf::create_directory(shared_path, error_code);
if (error_code) {
- LOG(ERROR) << "Failed to create shared directory for widget";
+ LOG(ERROR) << "Failed to create shared directory for package";
return false;
}
+
+ if (!SubShareDir())
+ return false;
+
return true;
}
-} // namespace
+bool StepCreateStorageDirectories::SubShareDir() {
+ bs::error_code error_code;
+ bf::path shared_path = context_->pkg_path.get() / kShared;
+ bf::path shared_trusted_path = shared_path / kSharedTrusted;
+ bf::create_directory(shared_trusted_path, error_code);
+ if (error_code) {
+ LOG(ERROR) << "Failed to create shared/trusted directory for package";
+ return false;
+ }
-namespace common_installer {
-namespace create_storage {
+ bf::path shared_data_path = shared_path / kSharedData;
+ bf::create_directory(shared_data_path, error_code);
+ if (error_code) {
+ LOG(ERROR) << "Failed to create shared/data directory for package";
+ return false;
+ }
-common_installer::Step::Status StepCreateStorageDirectories::process() {
- if (!CreateStorageDirectoriesForPath(context_->pkg_path.get()))
- return Status::ERROR;
- return Status::OK;
+ return true;
+}
+
+bool StepCreateStorageDirectories::PrivateDir() {
+ bs::error_code error_code;
+ bf::path data_path = context_->pkg_path.get() / kData;
+ bf::create_directory(data_path, error_code);
+ if (error_code) {
+ LOG(ERROR) << "Failed to create private directory for package";
+ return false;
+ }
+ return true;
}
+
} // namespace create_storage
} // namespace common_installer
namespace common_installer {
namespace create_storage {
+/**
+ * \brief Installation.
+ * Responsible for creating shared and data directories (wgt/tpk)
+ *
+ * * process method implements creation of data and shared directories for
+ * package.
+ * * Other methods are empty.
+ *
+ * CreateStorageDirectories works on below directories:
+ * * context_->pkg_path.get(), eg:
+ * * TZ_SYS_RW/PKGID/<new-dir> (/usr/apps/PKGID/<new-dir>)
+ * * TZ_SER_APPS/PKGID/<new-dir> (/{HOME}/apps_rw/PKGID/<new-dir>)
+ */
class StepCreateStorageDirectories : public common_installer::Step {
public:
using Step::Step;
Status undo() override { return Status::OK; }
Status precheck() override { return Status::OK; }
+ protected:
+ bool ShareDir();
+ bool SubShareDir();
+ bool PrivateDir();
+
SCOPE_LOG_TAG(CreateStorageDirectories)
};
* rough space requirements vs availability.
* Since process method unpacks the package to given directory, undo method
* removes them.
+ *
+ * Unzip unpacks resources to following directory:
+ * * TZ_SYS_RW/tmpuniquedir (/usr/apps/tmpuniquedir)
+ * * TZ_SER_APPS/tmpdir (/{HOME}/apps_rw/tmpuniquedir)
+ * ContextInstaller::unpacked_dir_path points to this location.
*/
class StepUnzip : public Step {
public:
}
// set context_
- context_->config_data.get().application_name.set(label->content());
- context_->config_data.get().required_version.set(
+ context_->config_data.get().required_api_version.set(
manifest->attr("api-version"));
context_->pkgid.set(manifest->attr("package"));
context_->manifest_data.set(static_cast<manifest_x*>(
step/step_parse.cc
step/step_rds_parse.cc
step/step_rds_modify.cc
+ step/step_wgt_create_storage_directories.cc
step/step_wgt_resource_directory.cc
wgt_app_query_interface.cc
wgt_backend.cc
if (short_name_set.begin() != short_name_set.end())
short_name = short_name_set.begin()->second;
- const std::string& version = wgt_info->version();
+ const std::string& tizen_version = wgt_info->version();
const std::string& required_api_version = info->required_version();
- if (manifest->uiapplication->label) {
- context_->config_data.get().application_name.set(
- std::string(manifest->uiapplication->label->name));
- }
-
- context_->config_data.get().required_version.set(required_api_version);
+ context_->config_data.get().required_api_version.set(required_api_version);
+ context_->config_data.get().required_tizen_version.set(tizen_version);
context_->pkgid.set(std::string(manifest->package));
std::shared_ptr<const PermissionsInfo> perm_info =
LOG(DEBUG) << " id = " << info->id();
LOG(DEBUG) << " name = " << name;
LOG(DEBUG) << " short_name = " << short_name;
- LOG(DEBUG) << " version = " << version;
+ LOG(DEBUG) << " tizen_version = " << tizen_version;
LOG(DEBUG) << " icon = " << manifest->uiapplication->icon->name;
LOG(DEBUG) << " api_version = " << info->required_version();
LOG(DEBUG) << " privileges -[";
--- /dev/null
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache 2.0 license that can be
+// found in the LICENSE file.
+
+#include "wgt/step/step_wgt_create_storage_directories.h"
+
+#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/path.hpp>
+#include <boost/system/error_code.hpp>
+
+#include "common/utils/file_util.h"
+
+namespace bf = boost::filesystem;
+namespace bs = boost::system;
+
+namespace {
+
+const char kSharedLocation[] = "shared";
+const char kResWgt[] = "res/wgt";
+
+} // namespace
+
+namespace wgt {
+namespace create_storage {
+
+common_installer::Step::Status StepWgtCreateStorageDirectories::process() {
+ if (!PrivateDir())
+ return Status::ERROR;
+
+ char rel_version =
+ context_->config_data.get().required_tizen_version.get().at(0);
+
+ if ((rel_version-'0') < 3) {
+ LOG(DEBUG) << "Shared directory preparation for tizen 2.x";
+ if (!ShareDir())
+ return Status::ERROR;
+ } else {
+ LOG(DEBUG) << "Shared directory preparation for tizen 3.x";
+ if (!ShareDirFor3x())
+ return Status::ERROR;
+ }
+
+ if (!SubShareDir())
+ return Status::ERROR;
+
+ return Status::OK;
+}
+
+bool StepWgtCreateStorageDirectories::ShareDirFor2x() {
+ bs::error_code error_code;
+ bf::path shared_path = context_->pkg_path.get() / kSharedLocation;
+ bf::create_directory(shared_path, error_code);
+ if (error_code) {
+ LOG(ERROR) << "Failed to create shared directory for widget";
+ return false;
+ }
+ return true;
+}
+
+bool StepWgtCreateStorageDirectories::ShareDirFor3x() {
+ bf::path res_wgt_path = context_->pkg_path.get() / kResWgt;
+ if (!bf::exists(res_wgt_path / kSharedLocation)) {
+ if (!ShareDir())
+ return false;
+ } else {
+ bf::path src = res_wgt_path / kSharedLocation;
+ bf::path dst = context_->pkg_path.get() / kSharedLocation;
+ if (!common_installer::MoveDir(src, dst)) {
+ LOG(ERROR) << "Failed to move shared data from res/wgt to shared";
+ return false;
+ }
+
+ bs::error_code error_code;
+ bf::create_symlink(dst, src, error_code);
+ if (error_code) {
+ LOG(ERROR) << "Failed to create symbolic link for shared dir"
+ << boost::system::system_error(error_code).what();
+ return false;
+ }
+ } // else
+ return true;
+}
+
+} // namespace create_storage
+} // namespace wgt
--- /dev/null
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache 2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef WGT_STEP_STEP_WGT_CREATE_STORAGE_DIRECTORIES_H_
+#define WGT_STEP_STEP_WGT_CREATE_STORAGE_DIRECTORIES_H_
+
+#include "common/step/step_create_storage_directories.h"
+#include "utils/logging.h"
+
+namespace wgt {
+namespace create_storage {
+
+/**
+ * \brief Installation (WGT).
+ * Responsible for creating shared and data directories.
+ * It extends StepCreateStorageDirectories (it adds distinction between
+ * 2.x and 3.x shared dir handling
+ *
+ * process method implements creation of shared and data directories.
+ * Depending on tizen required version it can also move "shared" resources
+ * from ./res/wgt/shared to ./shared dir (and create symlink back
+ * to ./res/wgt/shared).
+ *
+ * StepWgtCreateStorageDirectories works on following directory:
+ * * TZ_SYS_RW/PKGID (/usr/apps/PKGID)
+ * * TZ_SER_APPS/PKGID (/{HOME}/apps_rw/PKGID)
+ */
+class StepWgtCreateStorageDirectories :
+ public common_installer::create_storage::StepCreateStorageDirectories {
+ public:
+ using common_installer::create_storage::
+ StepCreateStorageDirectories::StepCreateStorageDirectories;
+
+ Status process() override;
+ Status clean() override { return Status::OK; }
+ Status undo() override { return Status::OK; }
+ Status precheck() override { return Status::OK; }
+
+ private:
+ bool ShareDirFor2x();
+ bool ShareDirFor3x();
+
+ SCOPE_LOG_TAG(CreateWgtStorageDirectories)
+};
+
+} // namespace create_storage
+} // namespace wgt
+
+#endif // WGT_STEP_STEP_WGT_CREATE_STORAGE_DIRECTORIES_H_
#include "common/step/step_copy.h"
#include "common/step/step_copy_backup.h"
#include "common/step/step_copy_storage_directories.h"
-#include "common/step/step_create_storage_directories.h"
#include "common/step/step_generate_xml.h"
#include "common/step/step_parse.h"
#include "common/step/step_register_app.h"
#include "wgt/step/step_parse.h"
#include "wgt/step/step_rds_parse.h"
#include "wgt/step/step_rds_modify.h"
+#include "wgt/step/step_wgt_create_storage_directories.h"
#include "wgt/step/step_wgt_resource_directory.h"
#include "wgt/wgt_app_query_interface.h"
installer.AddStep<wgt::check_settings::StepCheckSettingsLevel>();
installer.AddStep<wgt::wgt_resources::StepWgtResourceDirectory>();
installer.AddStep<ci::copy::StepCopy>();
- installer.AddStep<ci::create_storage::StepCreateStorageDirectories>();
+ installer.AddStep<wgt::create_storage::StepWgtCreateStorageDirectories>();
installer.AddStep<wgt::symbolic_link::StepCreateSymbolicLink>();
installer.AddStep<ci::generate_xml::StepGenerateXml>();
installer.AddStep<ci::register_app::StepRegisterApplication>();