* \return true if package is installed
*/
virtual bool IsPkgInstalled(const std::string& arg, uid_t uid) = 0;
+
+ /**
+ * \brief abstract method for getting package id from package file
+ *
+ * \return package id
+ */
+ virtual std::string GetPkgId(const std::string& arg) = 0;
};
} // namespace common_installer
#include <fstream>
#include "common/app_query_interface.h"
+#include "common/pkgmgr_query.h"
#include "common/pkgmgr_signal.h"
namespace bf = boost::filesystem;
return RequestType::Install;
}
} else {
- if (extension == kDeltaFileExtension)
+ if (extension == kDeltaFileExtension) {
return RequestType::Delta;
- else
- return RequestType::Update;
+ } else {
+ std::string pkgid = query_interface_->GetPkgId(GetRequestInfo());
+ if (!GetIsPreloadRequest() &&
+ QueryIsReadonlyPackage(pkgid, GetUid()) &&
+ !QueryIsUpdatedReadonlyPackage(pkgid, GetUid()))
+ return RequestType::ReadonlyUpdateInstall;
+ else
+ return RequestType::Update;
+ }
}
}
- case PKGMGR_REQ_UNINSTALL:
- if (GetIsPreloadRequest() && GetIsPartialRW())
+ case PKGMGR_REQ_UNINSTALL: {
+ std::string pkgid = GetRequestInfo();
+ if (!GetIsPreloadRequest() &&
+ QueryIsUpdatedReadonlyPackage(pkgid, GetUid()))
+ return RequestType::ReadonlyUpdateUninstall;
+ else if (GetIsPreloadRequest() && GetIsPartialRW())
return RequestType::PartialUninstall;
else
return RequestType::Uninstall;
+ }
case PKGMGR_REQ_REINSTALL:
return RequestType::Reinstall;
case PKGMGR_REQ_CLEAR:
return true;
}
+bool QueryIsUpdatedReadonlyPackage(const std::string& pkg_id, uid_t uid) {
+ pkgmgrinfo_pkginfo_h handle;
+ int ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkg_id.c_str(), uid, &handle);
+ if (ret != PMINFO_R_OK) {
+ if (ret != PMINFO_R_ENOENT)
+ LOG(ERROR) << "Failed to call pkgmgrinfo_pkginfo_get_usr_pkginfo";
+ return false;
+ }
+
+ bool is_update = false;
+ if (pkgmgrinfo_pkginfo_is_update(handle, &is_update) != PMINFO_R_OK) {
+ LOG(ERROR) << "pkgmgrinfo_pkginfo_is_preload failed";
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return false;
+ }
+
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return is_update;
+}
+
} // namespace common_installer
*/
bool QueryIsDisabledPackage(const std::string& pkg_id, uid_t uid);
+/**
+ * \brief Adapter interface for external PkgMgr module used for checking
+ * if given package is updated readonly package
+ *
+ * \param pkg_id package id
+ * \param uid user id
+ *
+ * \return true if package is updated
+ */
+bool QueryIsUpdatedReadonlyPackage(const std::string& pkg_id, uid_t uid);
+
} // namespace common_installer
#endif // COMMON_PKGMGR_QUERY_H_
// "update" : this package is "preload" and is updated by downloadable update.
// "removable" : this package can be removed.
// "readonly" : this package exists in readonly location.
-bool AssignPackageTags(manifest_x* manifest,
- bool is_update) {
+bool AssignPackageTags(manifest_x* manifest) {
// preload, removalbe and readonly : in parse_preload step.
- if (!strcmp(manifest->preload, "true")) {
- manifest->update = is_update ? strdup("true") : strdup("false");
+ if (!strcmp(manifest->preload, "true"))
manifest->system = !strcmp(manifest->removable, "false") ?
strdup("true") : strdup("false");
- } else {
- manifest->update = strdup("false");
+ else
manifest->system = strdup("false");
- }
return true;
}
if (!tep_path.empty())
manifest->tep_name = strdup(tep_path.c_str());
- if (!AssignPackageTags(manifest, false))
+ if (!AssignPackageTags(manifest))
return false;
int ret = request_mode != RequestMode::GLOBAL ?
const CertificateInfo& cert_info,
uid_t uid,
RequestMode request_mode) {
- if (!AssignPackageTags(manifest, true))
+ if (!AssignPackageTags(manifest))
return false;
int ret = request_mode != RequestMode::GLOBAL ?
{ci::RequestType::Uninstall, PKGMGR_INSTALLER_UNINSTALL_EVENT_STR},
{ci::RequestType::PartialUninstall, PKGMGR_INSTALLER_UNINSTALL_EVENT_STR},
{ci::RequestType::Update, PKGMGR_INSTALLER_UPGRADE_EVENT_STR},
+ {ci::RequestType::ReadonlyUpdateInstall, PKGMGR_INSTALLER_UPGRADE_EVENT_STR},
+ {ci::RequestType::ReadonlyUpdateUninstall,
+ PKGMGR_INSTALLER_UPGRADE_EVENT_STR},
{ci::RequestType::Delta, PKGMGR_INSTALLER_UPGRADE_EVENT_STR},
{ci::RequestType::Move, PKGMGR_INSTALLER_MOVE_EVENT_STR},
{ci::RequestType::MountInstall, PKGMGR_INSTALLER_INSTALL_EVENT_STR},
ManifestPartialInstall,
ManifestPartialUpdate,
PartialUninstall,
+ ReadonlyUpdateInstall,
+ ReadonlyUpdateUninstall,
DisablePkg,
EnablePkg
};
context_->xml_path.set(xml_path);
break;
}
+ case RequestType::ReadonlyUpdateInstall:
+ context_->file_path.set(pkgmgr_->GetRequestInfo());
+ context_->pkgid.set(kStrEmpty);
+ if (!pkgmgr_->GetTepPath().empty()) {
+ context_->tep_path.set(pkgmgr_->GetTepPath());
+ context_->is_tep_move.set(pkgmgr_->GetIsTepMove());
+ }
+ break;
+ case RequestType::ReadonlyUpdateUninstall: {
+ context_->pkgid.set(pkgmgr_->GetRequestInfo());
+ bf::path original_path =
+ bf::path(tzplatform_getenv(TZ_SYS_RO_APP)) / context_->pkgid.get();
+ context_->unpacked_dir_path.set(original_path);
+ context_->file_path.set(kStrEmpty);
+ break;
+ }
case RequestType::DisablePkg:
case RequestType::EnablePkg:
context_->pkgid.set(pkgmgr_->GetRequestInfo());
}
case ManifestLocation::INSTALLED: {
uid_t uid;
- bool is_readonly;
- if (QueryIsGlobalPackage(context_->pkgid.get(), context_->uid.get())) {
+ bool is_readonly = context_->is_readonly_package.get();
+ if (QueryIsGlobalPackage(context_->pkgid.get(), context_->uid.get()))
uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
- is_readonly = QueryIsReadonlyPackage(context_->pkgid.get(),
- context_->uid.get());
- } else {
+ else
uid = context_->uid.get();
- is_readonly = context_->is_readonly_package.get();
- }
bf::path xml_path =
bf::path(getUserManifestPath(uid, is_readonly))
/ bf::path(context_->pkgid.get());
manifest->preload = strdup(pkg_info->preload().c_str());
manifest->removable = strdup(pkg_info->removable().c_str());
+ // set update true if package is updated preload package
+ common_installer::RequestType req_type = context_->request_type.get();
+ if (req_type == RequestType::ReadonlyUpdateInstall)
+ manifest->update = strdup("true");
+ else if (req_type == RequestType::ReadonlyUpdateUninstall)
+ manifest->update = strdup("false");
+ else if (QueryIsUpdatedReadonlyPackage(pkg_info->package(),
+ context_->uid.get()))
+ manifest->update = strdup("true");
+ else
+ manifest->update = strdup("false");
+
if (pkg_info->type().empty()) {
- common_installer::RequestType req_type = context_->request_type.get();
if ((req_type == RequestType::ManifestDirectInstall ||
req_type == RequestType::ManifestDirectUpdate) &&
context_->is_readonly_package.get())
--- /dev/null
+// Copyright (c) 2016 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/configuration/step_switch_readonly_mode.h"
+
+namespace common_installer {
+namespace configuration {
+
+Step::Status StepSwitchReadonlyMode::process() {
+ bool is_readonly_package = context_->is_readonly_package.get();
+ context_->is_readonly_package.set(!is_readonly_package);
+ return Status::OK;
+}
+
+} // namespace configuration
+} // namespace common_installer
--- /dev/null
+// Copyright (c) 2016 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_CONFIGURATION_STEP_SWITCH_READONLY_MODE_H_
+#define COMMON_STEP_CONFIGURATION_STEP_SWITCH_READONLY_MODE_H_
+
+#include <manifest_parser/utils/logging.h>
+
+#include "common/step/step.h"
+
+namespace common_installer {
+namespace configuration {
+
+class StepSwitchReadonlyMode : public common_installer::Step {
+ public:
+ using Step::Step;
+
+ Status process() override;
+ Status clean() override { return Status::OK; }
+ Status undo() override { return Status::OK; }
+ Status precheck() override { return Status::OK; }
+
+ STEP_NAME(SwitchReadonlyMode)
+};
+
+} // namespace configuration
+} // namespace common_installer
+
+#endif // COMMON_STEP_CONFIGURATION_STEP_SWITCH_READONLY_MODE_H_
if (context_->is_readonly_package.get())
return Step::Status::OK;
+ if (context_->request_mode.get() != RequestMode::GLOBAL)
+ return Step::Status::OK;
+
if (!QueryIsPackageInstalled(context_->pkgid.get(), kGlobalUserUid))
return Step::Status::OK;
std::string package_id = context_->pkgid.get();
- if (context_->request_type.get() == RequestType::Uninstall) {
- if (context_->request_mode.get() == RequestMode::GLOBAL) {
- LOG(INFO) << "Deleting globalapp symlinks for all user, package: "
- << package_id;
- if (!DeleteGlobalAppSymlinksForAllUsers(package_id)) {
- LOG(ERROR) << "Failed to delete globalapp symlinks";
- return Status::GLOBALSYMLINK_ERROR;
- }
+ RequestType req_type = context_->request_type.get();
+ if (req_type == RequestType::Uninstall ||
+ req_type == RequestType::ReadonlyUpdateUninstall) {
+ LOG(INFO) << "Deleting globalapp symlinks for all user, package: "
+ << package_id;
+ if (!DeleteGlobalAppSymlinksForAllUsers(package_id)) {
+ LOG(ERROR) << "Failed to delete globalapp symlinks";
+ return Status::GLOBALSYMLINK_ERROR;
}
} else {
LOG(INFO) << "Deleting globalapp symlinks for current user, package: "
#include <pkgmgr-info.h>
#include <pkgmgr_installer.h>
+#include <tzplatform_config.h>
#include <algorithm>
#include <string>
common_installer::Step::Status StepRemoveManifest::process() {
+ bf::path manifest_path;
+ if (context_->request_type.get() == RequestType::ReadonlyUpdateUninstall) {
+ manifest_path = bf::path(tzplatform_getenv(TZ_SYS_RW_PACKAGES)) /
+ context_->pkgid.get();
+ manifest_path += ".xml";
+ } else {
+ manifest_path = context_->xml_path.get();
+ }
bs::error_code error;
- bf::remove(context_->xml_path.get(), error);
+ bf::remove(manifest_path, error);
if (error) {
LOG(ERROR) << "Failed to remove xml manifest file";
PrivilegeLevel level = PrivilegeLevel::UNTRUSTED;
bool check_reference = true;
if (context_->request_type.get() == ci::RequestType::Reinstall ||
+ context_->request_type.get() ==
+ ci::RequestType::ReadonlyUpdateUninstall ||
(getuid() == 0 &&
(context_->request_type.get() == ci::RequestType::ManifestDirectInstall ||
context_->request_type.get() == ci::RequestType::ManifestDirectUpdate)))