AddStep<ci::filesystem::StepCopy>();
AddStep<ci::filesystem::StepCopyTep>();
AddStep<tpk::filesystem::StepTpkPatchIcons>();
- AddStep<wgt::filesystem::StepWgtPatchIcons>();
+ AddStep<wgt::filesystem::StepWgtPatchIcons>(true);
AddStep<ci::filesystem::StepCreateIcons>();
AddStep<wgt::filesystem::StepCopyPreviewIcons>();
AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
AddStep<ci::backup::StepCopyBackup>();
AddStep<ci::filesystem::StepUpdateTep>();
AddStep<tpk::filesystem::StepTpkPatchIcons>();
- AddStep<wgt::filesystem::StepWgtPatchIcons>();
+ AddStep<wgt::filesystem::StepWgtPatchIcons>(true);
AddStep<ci::filesystem::StepCreateIcons>();
AddStep<wgt::filesystem::StepCopyPreviewIcons>();
AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
AddStep<ci::backup::StepCopyBackup>();
AddStep<ci::filesystem::StepUpdateTep>();
AddStep<tpk::filesystem::StepTpkPatchIcons>();
- AddStep<wgt::filesystem::StepWgtPatchIcons>();
+ AddStep<wgt::filesystem::StepWgtPatchIcons>(true);
AddStep<ci::filesystem::StepCreateIcons>();
AddStep<wgt::filesystem::StepCopyPreviewIcons>();
AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
AddStep<tpk::filesystem::StepTpkPreparePackageDirectory>();
AddStep<ci::filesystem::StepCopyTep>();
AddStep<tpk::filesystem::StepTpkPatchIcons>();
- AddStep<wgt::filesystem::StepWgtPatchIcons>();
+ AddStep<wgt::filesystem::StepWgtPatchIcons>(true);
AddStep<ci::filesystem::StepCreateIcons>();
AddStep<wgt::filesystem::StepCopyPreviewIcons>();
AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
AddStep<tpk::filesystem::StepTpkUpdatePackageDirectory>();
AddStep<ci::filesystem::StepUpdateTep>();
AddStep<tpk::filesystem::StepTpkPatchIcons>();
- AddStep<wgt::filesystem::StepWgtPatchIcons>();
+ AddStep<wgt::filesystem::StepWgtPatchIcons>(true);
AddStep<ci::filesystem::StepCreateIcons>();
AddStep<wgt::filesystem::StepCopyPreviewIcons>();
AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
AddStep<ci::security::StepRollbackInstallationSecurity>();
AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
AddStep<tpk::filesystem::StepTpkPatchIcons>();
- AddStep<wgt::filesystem::StepWgtPatchIcons>();
+ AddStep<wgt::filesystem::StepWgtPatchIcons>(true);
AddStep<wgt::pkgmgr::StepGenerateXml>();
AddStep<hybrid::pkgmgr::StepMergeXml>();
AddStep<tpk::pkgmgr::StepManifestAdjustment>();
AddStep<ci::pkgmgr::StepKillApps>();
AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
AddStep<tpk::filesystem::StepTpkPatchIcons>();
- AddStep<wgt::filesystem::StepWgtPatchIcons>();
+ AddStep<wgt::filesystem::StepWgtPatchIcons>(true);
AddStep<wgt::pkgmgr::StepGenerateXml>();
AddStep<hybrid::pkgmgr::StepMergeXml>();
AddStep<tpk::pkgmgr::StepManifestAdjustment>();
AddStep<ci::security::StepPrivilegeCompatibility>(
ci::security::StepPrivilegeCompatibility::InternalPrivType::BOTH);
AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
+ AddStep<wgt::filesystem::StepWgtPatchIcons>(false);
AddStep<ci::pkgmgr::StepRegisterApplication>();
AddStep<ci::security::StepRegisterTrustAnchor>(
ci::security::StepRegisterTrustAnchor::RegisterType::INSTALL);
ci::security::StepPrivilegeCompatibility::InternalPrivType::BOTH);
AddStep<ci::pkgmgr::StepKillApps>();
AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
+ AddStep<wgt::filesystem::StepWgtPatchIcons>(false);
AddStep<ci::pkgmgr::StepUpdateApplication>();
AddStep<ci::security::StepRegisterTrustAnchor>(
ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
AddStep<ci::filesystem::StepCopy>();
AddStep<ci::filesystem::StepCopyTep>();
AddStep<tpk::filesystem::StepTpkPatchIcons>();
- AddStep<wgt::filesystem::StepWgtPatchIcons>();
+ AddStep<wgt::filesystem::StepWgtPatchIcons>(true);
AddStep<ci::filesystem::StepCreateIcons>();
AddStep<wgt::filesystem::StepCopyPreviewIcons>();
AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
const char kDefaultIconPath[] = "/usr/share/wgt-backend/default.png";
-bool PatchIcon(icon_x* icon, const bf::path& dst_path) {
+bool PatchIcon(icon_x* icon, const bf::path& dst_path, bool make_copy) {
if (!icon)
return false;
bs::error_code error;
icon_path += icon_text.extension();
else
icon_path += ".png";
-
- bf::copy_file(icon->text, icon_path,
- bf::copy_option::overwrite_if_exists, error);
- if (error) {
- LOG(ERROR) << "Failed to move icon from " << icon->text << " to "
- << icon_path;
- return false;
+ if (make_copy) {
+ bf::copy_file(icon->text, icon_path,
+ bf::copy_option::overwrite_if_exists, error);
+ if (error) {
+ LOG(ERROR) << "Failed to move icon from " << icon->text << " to "
+ << icon_path;
+ return false;
+ }
+ } else {
+ if (!bf::exists(icon_path)) {
+ LOG(ERROR) << "Can't find icon in " << icon_path;
+ return false;
+ }
}
if (icon->text)
free(const_cast<char*>(icon->text));
return true;
}
+bool GenerateDefaultIcon(const bf::path& icon_path,
+ application_x* app, bool make_copy) {
+ bs::error_code error;
+ if (make_copy) {
+ bf::copy_file(kDefaultIconPath, icon_path,
+ bf::copy_option::overwrite_if_exists, error);
+ if (error) {
+ LOG(ERROR) << "Failed to create default icon for web application";
+ return false;
+ }
+ } else {
+ if (!bf::exists(icon_path)) {
+ LOG(ERROR) << "Can't find icon in " << icon_path;
+ return false;
+ }
+ }
+ icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
+ if (!icon) {
+ LOG(ERROR) << "Out of memory";
+ return false;
+ }
+ icon->text = strdup(icon_path.c_str());
+ icon->lang = strdup(DEFAULT_LOCALE);
+ app->icon = g_list_append(app->icon, icon);
+
+ return true;
+}
+
} // namespace
namespace wgt {
GListRange<icon_x*>(context_->manifest_data.get()->icon)) {
bf::path icon_path = common_icon_location /
context_->manifest_data.get()->mainapp_id;
- if (!PatchIcon(icon, icon_path))
+ if (!PatchIcon(icon, icon_path, make_copy_))
return Status::ICON_ERROR;
}
for (application_x* app :
// edit icon->text and copy icons to common location
for (auto& icon : GListRange<icon_x*>(app->icon)) {
bf::path icon_path = common_icon_location / app->appid;
- if (!PatchIcon(icon, icon_path))
+ if (!PatchIcon(icon, icon_path, make_copy_))
return Status::ICON_ERROR;
}
} else {
// create default icon if there is no icon at all
bf::path icon_path = common_icon_location / app->appid;
icon_path += ".png";
- bf::copy_file(kDefaultIconPath, icon_path,
- bf::copy_option::overwrite_if_exists, error);
- if (error) {
+ if (!GenerateDefaultIcon(icon_path, app, make_copy_)) {
LOG(ERROR) << "Failed to create default icon for web application";
return Status::ICON_ERROR;
}
- icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
- if (!icon) {
- LOG(ERROR) << "Out of memory";
- return Status::ICON_ERROR;
- }
- icon->text = strdup(icon_path.c_str());
- icon->lang = strdup(DEFAULT_LOCALE);
- app->icon = g_list_append(app->icon, icon);
}
}
return Status::OK;
#include <manifest_parser/utils/logging.h>
+#include <common/installer_context.h>
#include <common/step/step.h>
#include <string>
public:
using Step::Step;
+ StepWgtPatchIcons(common_installer::InstallerContext* context, bool make_copy)
+ : Step(context), make_copy_(make_copy) {}
+
Status process() override;
Status undo() override { return Status::OK; }
Status clean() override { return Status::OK; }
Status precheck() override { return Status::OK; }
STEP_NAME(WgtPatchIcons)
+
+ private:
+ bool make_copy_;
};
} // namespace filesystem
AddStep<ci::filesystem::StepCopyTep>();
AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
AddStep<wgt::filesystem::StepCreateSymbolicLink>();
- AddStep<wgt::filesystem::StepWgtPatchIcons>();
+ AddStep<wgt::filesystem::StepWgtPatchIcons>(true);
AddStep<ci::filesystem::StepCreateIcons>();
AddStep<wgt::filesystem::StepCopyPreviewIcons>();
AddStep<wgt::security::StepCheckExtensionPrivileges>();
AddStep<ci::filesystem::StepUpdateTep>();
AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
AddStep<wgt::filesystem::StepCreateSymbolicLink>();
- AddStep<wgt::filesystem::StepWgtPatchIcons>();
+ AddStep<wgt::filesystem::StepWgtPatchIcons>(true);
AddStep<ci::filesystem::StepCreateIcons>();
AddStep<wgt::filesystem::StepCopyPreviewIcons>();
AddStep<ci::filesystem::StepCopyStorageDirectories>();
AddStep<ci::filesystem::StepUpdateTep>();
AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
AddStep<wgt::filesystem::StepCreateSymbolicLink>();
- AddStep<wgt::filesystem::StepWgtPatchIcons>();
+ AddStep<wgt::filesystem::StepWgtPatchIcons>(true);
AddStep<ci::filesystem::StepCreateIcons>();
AddStep<wgt::filesystem::StepCopyPreviewIcons>();
AddStep<ci::filesystem::StepCopyStorageDirectories>();
AddStep<ci::filesystem::StepCopyTep>();
AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
AddStep<wgt::filesystem::StepCreateSymbolicLink>();
- AddStep<wgt::filesystem::StepWgtPatchIcons>();
+ AddStep<wgt::filesystem::StepWgtPatchIcons>(true);
AddStep<ci::filesystem::StepCreateIcons>();
AddStep<wgt::filesystem::StepCopyPreviewIcons>();
AddStep<wgt::pkgmgr::StepGenerateXml>();
AddStep<ci::filesystem::StepUpdateTep>();
AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
AddStep<wgt::filesystem::StepCreateSymbolicLink>();
- AddStep<wgt::filesystem::StepWgtPatchIcons>();
+ AddStep<wgt::filesystem::StepWgtPatchIcons>(true);
AddStep<ci::filesystem::StepCreateIcons>();
AddStep<wgt::filesystem::StepCopyPreviewIcons>();
AddStep<wgt::security::StepCheckExtensionPrivileges>();
AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
AddStep<ci::security::StepRollbackInstallationSecurity>();
AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
- AddStep<wgt::filesystem::StepWgtPatchIcons>();
+ AddStep<wgt::filesystem::StepWgtPatchIcons>(true);
AddStep<wgt::pkgmgr::StepGenerateXml>();
AddStep<ci::pkgmgr::StepRegisterApplication>();
AddStep<ci::security::StepRegisterTrustAnchor>(
AddStep<ci::pkgmgr::StepKillApps>();
AddStep<ci::filesystem::StepCopyTep>();
AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
- AddStep<wgt::filesystem::StepWgtPatchIcons>();
+ AddStep<wgt::filesystem::StepWgtPatchIcons>(true);
AddStep<wgt::pkgmgr::StepGenerateXml>();
AddStep<ci::pkgmgr::StepUpdateApplication>();
AddStep<ci::security::StepRegisterTrustAnchor>(
AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
AddStep<ci::filesystem::StepCreateStorageDirectories>();
AddStep<wgt::filesystem::StepCreateSymbolicLink>();
- AddStep<wgt::filesystem::StepWgtPatchIcons>();
+ AddStep<wgt::filesystem::StepWgtPatchIcons>(true);
AddStep<wgt::filesystem::StepCopyPreviewIcons>();
AddStep<wgt::security::StepCheckExtensionPrivileges>();
AddStep<wgt::pkgmgr::StepGenerateXml>();
ci::security::StepPrivilegeCompatibility::InternalPrivType::WGT);
AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
+ AddStep<wgt::filesystem::StepWgtPatchIcons>(false);
AddStep<ci::pkgmgr::StepRegisterApplication>();
AddStep<ci::security::StepRegisterTrustAnchor>(
ci::security::StepRegisterTrustAnchor::RegisterType::INSTALL);
AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
AddStep<ci::pkgmgr::StepKillApps>();
AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
+ AddStep<wgt::filesystem::StepWgtPatchIcons>(false);
AddStep<ci::pkgmgr::StepUpdateApplication>();
AddStep<ci::security::StepRegisterTrustAnchor>(
ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);