Additional steps for creating icons.
Change-Id: Ia5949dcef4f08b3941e0e819c2b973054859d788
step/step_backup_icons.cc
step/step_backup_manifest.cc
step/step_unzip.cc
+ step/step_create_icons.cc
step/step_check_old_certificate.cc
step/step_check_signature.cc
step/step_configure.cc
for (auto& pair : icons_) {
if (!MoveFile(pair.second, pair.first)) {
LOG(ERROR) << "Cannot revert icon from backup: " << pair.first;
-// return Status::ERROR; // undo cannot fail, so no break
+ // undo cannot fail, so no break
}
}
LOG(DEBUG) << "Icons reverted from backup";
--- /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 "common/step/step_create_icons.h"
+
+#include <boost/filesystem/operations.hpp>
+#include <boost/system/error_code.hpp>
+#include <pkgmgr-info.h>
+
+#include "common/utils/clist_helpers.h"
+
+namespace bf = boost::filesystem;
+namespace bs = boost::system;
+
+namespace common_installer {
+namespace filesystem {
+
+Step::Status StepCreateIcons::process() {
+ bf::path icons_directory(getIconPath(context_->uid.get()));
+ if (!bf::exists(icons_directory)) {
+ bs::error_code error;
+ bf::create_directories(icons_directory, error);
+ if (error) {
+ LOG(ERROR) << "Cannot create directory of application icons";
+ return Status::ERROR;
+ }
+ }
+
+ uiapplication_x* ui = nullptr;
+ PKGMGR_LIST_MOVE_NODE_TO_HEAD(context_->manifest_data.get()->uiapplication,
+ ui);
+ for (; ui; ui = ui->next) {
+ // TODO(t.iwanek): this is ignoring icon locale as well as other steps
+ // icons should be localized
+ if (ui->icon && ui->icon->name) {
+ bf::path source = GetIconRoot() / ui->icon->name;
+ bf::path destination = icons_directory / ui->appid;
+ if (destination.has_extension())
+ destination += source.extension();
+ else
+ destination += ".png";
+ bs::error_code error;
+ bf::copy_file(source, destination, error);
+ if (error) {
+ LOG(ERROR) << "Cannot create package icon: " << destination;
+ return Status::ERROR;
+ }
+ icons_.push_back(destination);
+ }
+ }
+ LOG(DEBUG) << "Icon files created";
+ return Status::OK;
+}
+
+Step::Status StepCreateIcons::undo() {
+ for (auto& icon : icons_) {
+ bs::error_code error;
+ bf::remove_all(icon, error);
+ }
+ return Status::OK;
+}
+
+boost::filesystem::path StepCreateIcons::GetIconRoot() const {
+ return context_->pkg_path.get();
+}
+
+} // namespace filesystem
+} // namespace common_installer
--- /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 COMMON_STEP_STEP_CREATE_ICONS_H_
+#define COMMON_STEP_STEP_CREATE_ICONS_H_
+
+#include <boost/filesystem/path.hpp>
+#include <utility>
+#include <vector>
+
+#include "common/context_installer.h"
+#include "common/step/step.h"
+#include "common/utils/logging.h"
+
+namespace common_installer {
+namespace filesystem {
+
+class StepCreateIcons : public Step {
+ public:
+ using Step::Step;
+
+ Status process() override;
+ Status clean() override { return Status::OK; }
+ Status undo() override;
+ Status precheck() override { return Status::OK; }
+
+ protected:
+ virtual boost::filesystem::path GetIconRoot() const;
+
+ private:
+ std::vector<boost::filesystem::path> icons_;
+
+ SCOPE_LOG_TAG(CreateIcons)
+};
+
+} // namespace filesystem
+} // namespace common_installer
+
+#endif // COMMON_STEP_STEP_CREATE_ICONS_H_
#include "common/step/step_generate_xml.h"
+#include <boost/filesystem/path.hpp>
#include <boost/system/error_code.hpp>
#include <libxml/parser.h>
#include <libxml/xmlreader.h>
}
}
- // the icon is renamed to <appid.png>
- icon_path_ = fs::path(getIconPath(context_->uid.get()));
- CreateDir(icon_path_);
- fs::path icon = fs::path(app->appid) += fs::path(".png");
-
+ // icon is renamed to <appid.png>
if (app->icon->name) {
- fs::path app_icon = fs::path(context_->pkg_path.get())
- / fs::path(app->appid)
- / fs::path(app->icon->name);
+ fs::path app_icon = context_->pkg_path.get() / app->icon->name;
+ fs::path icon = app->appid;
+ if (app_icon.has_extension())
+ icon += app_icon.extension();
+ else
+ icon += fs::path(".png");
+
if (fs::exists(app_icon)) {
- fs::copy_file(app_icon, icon_path_ /= icon,
- fs::copy_option::overwrite_if_exists);
xmlTextWriterWriteFormatElement(writer, BAD_CAST "icon",
"%s", BAD_CAST icon.c_str());
}
Step::Status StepGenerateXml::undo() {
bs::error_code error;
- if (fs::exists(icon_path_))
- fs::remove_all(icon_path_, error);
if (fs::exists(context_->xml_path.get()))
fs::remove_all(context_->xml_path.get(), error);
return Status::OK;
#ifndef COMMON_STEP_STEP_GENERATE_XML_H_
#define COMMON_STEP_STEP_GENERATE_XML_H_
-
-#include <boost/filesystem/path.hpp>
#include <libxml/xmlwriter.h>
#include "common/context_installer.h"
template <typename T>
Step::Status GenerateApplicationCommonXml(T* app, xmlTextWriterPtr writer);
- boost::filesystem::path icon_path_;
-
SCOPE_LOG_TAG(GenerateXML)
};
#include "common/step/step_configure.h"
#include "common/step/step_backup_icons.h"
#include "common/step/step_backup_manifest.h"
+#include "common/step/step_create_icons.h"
#include "common/step/step_copy.h"
#include "common/step/step_copy_backup.h"
#include "common/step/step_copy_storage_directories.h"
ai.AddStep<ci::filesystem::StepCopy>();
ai.AddStep<ci::filesystem::StepCreateStorageDirectories>();
ai.AddStep<tpk::filesystem::StepCreateSymbolicLink>();
+ ai.AddStep<ci::filesystem::StepCreateIcons>();
ai.AddStep<ci::security::StepRegisterSecurity>();
ai.AddStep<tpk::filesystem::StepCopyManifestXml>();
ai.AddStep<ci::pkgmgr::StepRegisterApplication>();
ai.AddStep<ci::backup::StepCopyBackup>();
ai.AddStep<ci::filesystem::StepCopyStorageDirectories>();
ai.AddStep<tpk::filesystem::StepCreateSymbolicLink>();
+ ai.AddStep<ci::filesystem::StepCreateIcons>();
ai.AddStep<ci::security::StepUpdateSecurity>();
ai.AddStep<tpk::filesystem::StepCopyManifestXml>();
ai.AddStep<ci::pkgmgr::StepUpdateApplication>();
step/step_parse.cc
step/step_rds_parse.cc
step/step_rds_modify.cc
+ step/step_wgt_create_icons.cc
step/step_wgt_create_storage_directories.cc
step/step_wgt_copy_storage_directories.cc
step/step_wgt_resource_directory.cc
--- /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_icons.h"
+
+namespace {
+
+const char kResWgt[] = "res/wgt";
+
+}
+
+namespace wgt {
+namespace filesystem {
+
+boost::filesystem::path StepWgtCreateIcons::GetIconRoot() const {
+ return context_->pkg_path.get() / kResWgt;
+}
+
+} // namespace filesystem
+} // 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_ICONS_H_
+#define WGT_STEP_STEP_WGT_CREATE_ICONS_H_
+
+#include "common/utils/logging.h"
+#include "common/step/step_create_icons.h"
+
+namespace wgt {
+namespace filesystem {
+
+class StepWgtCreateIcons
+ : public common_installer::filesystem::StepCreateIcons {
+ public:
+ using StepCreateIcons::StepCreateIcons;
+
+ boost::filesystem::path GetIconRoot() const override;
+
+ SCOPE_LOG_TAG(WgtCreateIcons)
+};
+
+} // namespace filesystem
+} // namespace wgt
+
+#endif // WGT_STEP_STEP_WGT_CREATE_ICONS_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_icons.h"
#include "wgt/step/step_wgt_create_storage_directories.h"
#include "wgt/step/step_wgt_copy_storage_directories.h"
#include "wgt/step/step_wgt_resource_directory.h"
installer.AddStep<wgt::filesystem::StepWgtCreateStorageDirectories>();
installer.AddStep<ci::filesystem::StepCreateStorageDirectories>();
installer.AddStep<wgt::filesystem::StepCreateSymbolicLink>();
+ installer.AddStep<wgt::filesystem::StepWgtCreateIcons>();
installer.AddStep<ci::pkgmgr::StepGenerateXml>();
installer.AddStep<ci::pkgmgr::StepRegisterApplication>();
installer.AddStep<ci::security::StepRegisterSecurity>();
installer.AddStep<ci::backup::StepCopyBackup>();
installer.AddStep<wgt::filesystem::StepWgtCopyStorageDirectories>();
installer.AddStep<wgt::filesystem::StepCreateSymbolicLink>();
+ installer.AddStep<wgt::filesystem::StepWgtCreateIcons>();
installer.AddStep<ci::security::StepUpdateSecurity>();
installer.AddStep<ci::pkgmgr::StepGenerateXml>();
installer.AddStep<ci::pkgmgr::StepUpdateApplication>();