return true;
}
-bool UpdateTepInfoInPkgmgr(const bf::path& tep_path, const std::string& pkgid,
- uid_t uid, RequestMode request_mode) {
- int ret = request_mode != RequestMode::GLOBAL ?
- pkgmgr_parser_usr_update_tep(
- pkgid.c_str(), tep_path.string().c_str(), uid) :
- pkgmgr_parser_update_tep(
- pkgid.c_str(), tep_path.string().c_str());
-
- if (ret != 0) {
- LOG(ERROR) << "Failed to upgrade tep info: " << pkgid;
- return false;
- }
-
- return true;
-}
-
bool UpgradeAppInPkgmgr(manifest_x* manifest,
const bf::path& xml_path,
const std::string& pkgid,
return old_author_certificate;
}
+std::string QueryTepPath(const std::string& pkgid, uid_t uid) {
+ pkgmgrinfo_pkginfo_h package_info;
+ if (pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid.c_str(), uid, &package_info)
+ != PMINFO_R_OK)
+ return false;
+ char* tep_name = nullptr;
+ int ret = pkgmgrinfo_pkginfo_get_tep_name(package_info, &tep_name);
+ if (ret != PMINFO_R_OK) {
+ LOG(DEBUG) << "pkgmgrinfo_pkginfo_get_tep_name failed with error: "
+ << ret;
+ pkgmgrinfo_pkginfo_destroy_pkginfo(package_info);
+ return {};
+ }
+ std::string tep_name_value;
+ if (tep_name)
+ tep_name_value = tep_name;
+ pkgmgrinfo_pkginfo_destroy_pkginfo(package_info);
+ return tep_name_value;
+}
bool QueryAppidsForPkgId(const std::string& pkg_id,
std::vector<std::string>* result, uid_t uid) {
RequestMode request_mode);
/**
- * \brief Adapter interface for external PkgMgr module used for updating
- * tep info about package within pkgmgr
- *
- * \param tep_path path of tep file
- * \param pkgid package pkgid
- * \param uid user id
- * \param request_mode current request mode
- *
- * \return true if success
- */
-bool UpdateTepInfoInPkgmgr(const boost::filesystem::path& tep_path,
- const std::string& pkgid,
- uid_t uid,
- RequestMode request_mode);
-
-/**
* \brief Adapter interface for external PkgMgr module used for deregistering
* package into pkgmgr
*
/**
* \brief Adapter interface for external PkgMgr module used for getting
+ * tizen extension package path for given package
+ *
+ * @param pkgid package id
+ * @param uid user id
+ * @return path or empty
+ */
+std::string QueryTepPath(const std::string& pkgid, uid_t uid);
+
+/**
+ * \brief Adapter interface for external PkgMgr module used for getting
* list of appids for given package
*
* \param pkg_id[in] package pkgid
#include "common/app_installer.h"
#include "common/backup_paths.h"
#include "common/installer_context.h"
+#include "common/pkgmgr_registration.h"
#include "common/step/step.h"
#include "common/utils/glist_range.h"
return Step::Status::PARSE_ERROR;
}
- if (!context_->tep_path.get().empty())
- manifest->tep_name = strdup(context_->tep_path.get().c_str());
+ if (manifest_location_ == ManifestLocation::INSTALLED) {
+ // recovery tep value for installed package
+ std::string old_tep =
+ QueryTepPath(context_->pkgid.get(), context_->uid.get());
+ if (!old_tep.empty())
+ manifest->tep_name = strdup(old_tep.c_str());
+ }
// write pkgid for recovery file
if (context_->recovery_info.get().recovery_file) {
bf::path tep_path =
context_->pkg_path.get() / "res" / context_->tep_path.get().filename();
- bs::error_code error;
if (context_->is_tep_move.get()) {
if (!MoveFile(context_->tep_path.get(), tep_path)) {
}
}
context_->tep_path.set(tep_path);
+ context_->manifest_data.get()->tep_name =
+ strdup(context_->tep_path.get().c_str());
return Step::Status::OK;
}
#include "common/step/pkgmgr/step_update_tep.h"
#include <pkgmgr-info.h>
-#include <sys/types.h>
-#include <unistd.h>
#include <boost/filesystem.hpp>
-#include <vcore/Certificate.h>
-#include <cassert>
-#include <cstdio>
#include <cstring>
#include <string>
+#include "common/backup_paths.h"
#include "common/pkgmgr_registration.h"
#include "common/utils/file_util.h"
namespace pkgmgr {
Step::Status StepUpdateTep::process() {
- if (context_->tep_path.get().empty())
- return Status::OK;
-
- if (!UpdateTepInfoInPkgmgr(context_->tep_path.get(),
- context_->pkgid.get(),
- context_->uid.get(),
- context_->request_mode.get())) {
- LOG(ERROR) << "Cannot update tep info for application";
- return Status::REGISTER_ERROR;
+ bf::path old_tep;
+ if (context_->old_manifest_data.get()->tep_name)
+ old_tep = context_->old_manifest_data.get()->tep_name;
+ if (!old_tep.empty() && context_->tep_path.get().empty()) {
+ // preserve old tep location during update if no new is given
+ context_->manifest_data.get()->tep_name = strdup(old_tep.c_str());
+
+ bf::path old_tep_location =
+ GetBackupPathForPackagePath(
+ context_->pkg_path.get()) / "res" / old_tep.filename();
+ bf::path new_tep_location = old_tep;
+ if (!MoveFile(old_tep_location, new_tep_location)) {
+ LOG(ERROR) << "Failed to copy tep file";
+ return Status::APP_DIR_ERROR;
+ }
}
-
- LOG(INFO) << "Successfully update the tep info for application";
return Status::OK;
}
Step::Status StepUpdateTep::undo() {
+ bf::path old_tep;
+ if (context_->old_manifest_data.get()->tep_name)
+ old_tep = context_->old_manifest_data.get()->tep_name;
+ if (!old_tep.empty() && context_->tep_path.get().empty()) {
+ // restore old tep location during update rollback
+ bf::path old_tep_location =
+ GetBackupPathForPackagePath(
+ context_->pkg_path.get()) / "res" / old_tep.filename();
+ bf::path new_tep_location = old_tep;
+ if (!MoveFile(new_tep_location, old_tep_location)) {
+ LOG(ERROR) << "Failed to copy tep file";
+ return Status::APP_DIR_ERROR;
+ }
+ }
return Status::OK;
}
#include "common/installer_context.h"
#include "common/step/step.h"
+#include <boost/filesystem/path.hpp>
+
namespace common_installer {
namespace pkgmgr {
Status process() override;
Status clean() override { return Status::OK; }
Status undo() override;
- Status precheck() override { return Status::OK; };
+ Status precheck() override { return Status::OK; }
SCOPE_LOG_TAG(UpdateTep)
};