pkg_path is always equal to root_application_path + pkgid.
Storing this information in separate variable is problematic,
because it requires to remember to update pkg_path after
root_application_path or pkgid is changed.
Submit with:
- https://review.tizen.org/gerrit/#/c/160353/
- https://review.tizen.org/gerrit/#/c/154904/
Change-Id: I8cc45cd003a642225be88669360b540186f8c678
Signed-off-by: Damian Pietruchowski <d.pietruchow@samsung.com>
~InstallerContext();
/**
+ * \brief Returns package directory path containing app data
+ */
+ inline boost::filesystem::path GetPkgPath() const {
+ return root_application_path.get() / pkgid.get();
+ }
+
+ /**
+ * \brief path to final location of installed package in filesystem
+ */
+ Property<std::string> pkgid;
+
+ /**
* \brief package type (string representing name of backend)
*/
Property<std::string> pkg_type;
Property<boost::filesystem::path> backup_xml_path;
/**
- * \brief path to final location of installed package in filesystem
- */
- Property<std::string> pkgid;
-
- /**
- * \brief package directory path containing app data
- */
- Property<boost::filesystem::path> pkg_path;
-
- /**
* \brief file path used for installation or reinstallation process
*/
Property<boost::filesystem::path> file_path;
return Step::Status::INVALID_VALUE;
}
- // set package path
- context_->pkg_path.set(
- context_->root_application_path.get() / context_->pkgid.get());
- install_path_ = context_->pkg_path.get();
- backup_path_ = GetBackupPathForPackagePath(context_->pkg_path.get());
+ install_path_ = context_->GetPkgPath();
+ backup_path_ = GetBackupPathForPackagePath(context_->GetPkgPath());
return Status::OK;
}
}
}
// create copy of old package content skipping the external memory mount point
- for (bf::directory_iterator iter(context_->pkg_path.get());
+ for (bf::directory_iterator iter(context_->GetPkgPath());
iter != bf::directory_iterator(); ++iter) {
if (iter->path().filename() == kExternalMemoryMountPoint)
continue;
bool StepCopyBackup::RollbackApplicationDirectory() {
bs::error_code error;
- if (bf::exists(context_->pkg_path.get())) {
- bf::remove_all(context_->pkg_path.get(), error);
+ if (bf::exists(context_->GetPkgPath())) {
+ bf::remove_all(context_->GetPkgPath(), error);
if (error) {
return false;
}
}
- if (!MoveDir(backup_path_, context_->pkg_path.get())) {
+ if (!MoveDir(backup_path_, context_->GetPkgPath())) {
return false;
}
uid_t uid = context_->uid.get();
// restore ownership changed during installation
- if (!SetPackageDirectoryOwnerAndPermissions(context_->pkg_path.get(), uid))
+ if (!SetPackageDirectoryOwnerAndPermissions(context_->GetPkgPath(), uid))
return false;
return true;
case RequestType::Install:
case RequestType::Update:
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::Delta:
context_->unpacked_dir_path.set(kStrEmpty);
- context_->pkgid.set(kStrEmpty);
+ context_->pkgid.set(pkgmgr_->GetRequestInfo());
context_->file_path.set(pkgmgr_->GetRequestInfo());
break;
case RequestType::Move:
break;
case RequestType::Recovery:
context_->file_path.set(pkgmgr_->GetRequestInfo());
- context_->pkgid.set(kStrEmpty);
break;
case RequestType::MountInstall:
case RequestType::MountUpdate:
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());
case RequestType::ManifestDirectInstall:
case RequestType::ManifestDirectUpdate: {
context_->pkgid.set(pkgmgr_->GetRequestInfo());
- bf::path package_directory =
- context_->root_application_path.get() / context_->pkgid.get();
bf::path xml_path =
bf::path(getUserManifestPath(context_->uid.get(),
context_->is_readonly_package.get()))
/ bf::path(context_->pkgid.get());
xml_path += ".xml";
- context_->unpacked_dir_path.set(package_directory);
- context_->pkg_path.set(package_directory);
+ context_->unpacked_dir_path.set(context_->GetPkgPath());
context_->xml_path.set(xml_path);
break;
}
case RequestType::ReadonlyUpdateInstall:
context_->file_path.set(pkgmgr_->GetRequestInfo());
- context_->pkgid.set(kStrEmpty);
+ context_->pkgid.set(pkgmgr_->GetRequestInfo());
if (!pkgmgr_->GetTepPath().empty()) {
context_->tep_path.set(pkgmgr_->GetTepPath());
context_->is_tep_move.set(pkgmgr_->GetIsTepMove());
break;
case RequestType::MigrateExtImg: {
context_->pkgid.set(pkgmgr_->GetRequestInfo());
- bf::path package_directory =
- context_->root_application_path.get() / context_->pkgid.get();
- context_->pkg_path.set(package_directory);
break;
}
default:
boost::filesystem::path manifest;
switch (manifest_location_) {
case ManifestLocation::RECOVERY: {
- context_->pkg_path.set(
- context_->root_application_path.get() / context_->pkgid.get());
bf::path backup_path = common_installer::GetBackupPathForPackagePath(
- context_->pkg_path.get()) / kManifestFileName;
- bf::path in_package_path = context_->pkg_path.get() / kManifestFileName;
+ context_->GetPkgPath()) / kManifestFileName;
+ bf::path in_package_path = context_->GetPkgPath() / kManifestFileName;
bf::path install_path =
bf::path(getUserManifestPath(context_->uid.get(),
context_->is_readonly_package.get()))
if (bf::path(priv.license).is_absolute())
privilege->license = strdup(priv.license.c_str());
else
- privilege->license = strdup((context_->pkg_path.get()
+ privilege->license = strdup((context_->GetPkgPath()
/ priv.license).c_str());
}
manifest->appdefined_privileges =
if (bf::path(priv.license).is_absolute())
privilege->license = strdup(priv.license.c_str());
else
- privilege->license = strdup((context_->pkg_path.get()
+ privilege->license = strdup((context_->GetPkgPath()
/ priv.license).c_str());
}
manifest->provides_appdefined_privileges =
if (bf::path(src).is_absolute()) {
splashscreen->src = strdup(src.c_str());
} else {
- bf::path full_path = context_->pkg_path.get() / src;
+ bf::path full_path = context_->GetPkgPath() / src;
splashscreen->src = strdup(full_path.string().c_str());
}
if (src.substr(src.find_last_of(".") + 1) == "edj")
parser_->GetManifestData(app_keys::kManifestKey));
context_->pkgid.set(info->package());
- context_->pkg_path.set(
- context_->root_application_path.get() / context_->pkgid.get());
manifest_x* manifest =
static_cast<manifest_x*>(calloc(1, sizeof(manifest_x)));
return Status::ERROR;
// Grant default permissions
- if (!GrantDefaultPermissions(context_->pkg_path.get(), skip_symlink_))
+ if (!GrantDefaultPermissions(context_->GetPkgPath(), skip_symlink_))
return Status::GRANT_PERMISSION_ERROR;
// Change owner of files at root path
- if (!ci::SetOwnershipAll(context_->pkg_path.get(), uid, *gid))
+ if (!ci::SetOwnershipAll(context_->GetPkgPath(), uid, *gid))
return Status::ERROR;
- if (!ChangeDataDir(context_->pkg_path.get(), uid))
+ if (!ChangeDataDir(context_->GetPkgPath(), uid))
return Status::ERROR;
// For icon files
}
Step::Status StepCopy::process() {
- // set application path
- context_->pkg_path.set(
- context_->root_application_path.get() / context_->pkgid.get());
-
bf::path install_path;
if (context_->storage.get() == Storage::EXTENDED) {
install_path = bf::path(GetExtendedRootAppPath(context_->uid.get())) /
context_->pkgid.get();
} else {
- install_path = context_->pkg_path.get();
+ install_path = context_->GetPkgPath();
}
bs::error_code error;
if (context_->storage.get() == Storage::EXTENDED) {
bs::error_code error;
- bf::create_symlink(install_path, context_->pkg_path.get(), error);
+ bf::create_symlink(install_path, context_->GetPkgPath(), error);
if (error) {
LOG(ERROR) << "Failed to create symlink for extended path: "
<< error.message();
RemoveAll(install_path);
}
- if (!RemoveAll(context_->pkg_path.get()))
+ if (!RemoveAll(context_->GetPkgPath()))
return Status::APP_DIR_ERROR;
return Status::OK;
}
common_installer::Step::Status StepCopyStorageDirectories::precheck() {
backup_path_ =
- common_installer::GetBackupPathForPackagePath(context_->pkg_path.get());
+ common_installer::GetBackupPathForPackagePath(context_->GetPkgPath());
bs::error_code error_code;
if (!bf::exists(backup_path_, error_code)) {
if (context_->request_mode.get() == RequestMode::GLOBAL)
return Status::OK;
if (!CopyAppStorage(backup_path_,
- context_->pkg_path.get(),
+ context_->GetPkgPath(),
kDataLocation, true)) {
LOG(ERROR) << "Failed to restore private directory for widget in update";
return Status::APP_DIR_ERROR;
}
if (!CopyAppStorage(backup_path_,
- context_->pkg_path.get(),
+ context_->GetPkgPath(),
kSharedResLocation, true)) {
LOG(ERROR) << "Failed to restore shared directory for widget in update";
return Status::APP_DIR_ERROR;
bool StepCopyStorageDirectories::CacheDir() {
bs::error_code error_code;
- bf::path cache_path = context_->pkg_path.get() / kCache;
+ bf::path cache_path = context_->GetPkgPath() / kCache;
bf::create_directory(cache_path, error_code);
if (error_code) {
LOG(ERROR) << "Failed to create cache directory for package";
Step::Status StepCopyTep::process() {
if (context_->tep_path.get().empty())
return Step::Status::OK;
-
- context_->pkg_path.set(
- context_->root_application_path.get() / context_->pkgid.get());
-
bf::path tep_path;
if (context_->external_storage) {
tep_path = GetExternalTepPath(context_->request_mode.get(),
context_->uid.get());
} else {
- tep_path = GetInternalTepPath(context_->pkg_path.get());
+ tep_path = GetInternalTepPath(context_->GetPkgPath());
}
// Keep filename of app store supplied file. Filename contains hash that
common_installer::Step::Status StepCreateStorageDirectories::process() {
if (context_->request_mode.get() == RequestMode::GLOBAL) {
// remove packaged RW diriectories
- if (!common_installer::DeleteStorageDirectories(context_->pkg_path.get())) {
+ if (!common_installer::DeleteStorageDirectories(context_->GetPkgPath())) {
LOG(ERROR) << "Failed to remove storage directories";
return Status::APP_DIR_ERROR;
}
break;
}
}
- if (!common_installer::CreateStorageDirectories(context_->pkg_path.get(),
+ if (!common_installer::CreateStorageDirectories(context_->GetPkgPath(),
manifest->api_version,
true, has_priv)) {
LOG(ERROR) << "Failed to create storage directories";
* * Other methods are empty.
*
* CreateStorageDirectories works on below directories:
- * * context_->pkg_path.get(), eg:
+ * * context_->GetPkgPath(), eg:
* * TZ_SYS_RW/PKGID/<new-dir> (/usr/apps/PKGID/<new-dir>)
* * TZ_SER_APPS/PKGID/<new-dir> (/{HOME}/apps_rw/PKGID/<new-dir>)
*/
return Step::Status::INVALID_VALUE;
}
- if (context_->pkg_path.get().empty()) {
+ if (context_->GetPkgPath().empty()) {
LOG(ERROR) << "pkg_path attribute is empty";
return Step::Status::INVALID_VALUE;
}
- if (!boost::filesystem::exists(context_->pkg_path.get())) {
+ if (!boost::filesystem::exists(context_->GetPkgPath())) {
LOG(ERROR) << "pkg_path ("
- << context_->pkg_path.get()
+ << context_->GetPkgPath()
<< ") path does not exist";
return Step::Status::INVALID_VALUE;
}
std::string error_message;
if (!RegisterSecurityContextForPathExternalOnly(pkgid,
- context_->pkg_type.get(), context_->pkg_path.get(),
+ context_->pkg_type.get(), context_->GetPkgPath(),
uid, &error_message)) {
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
context_->uid.get());
new_tep_location_ /= old_tep_location_.filename();
} else {
- new_tep_location_ = GetInternalTepPath(context_->pkg_path.get()) /
+ new_tep_location_ = GetInternalTepPath(context_->GetPkgPath()) /
old_tep_location_.filename();
}
}
bool StepMoveInstalledStorage::MoveExtended() {
if (move_type_ == MoveType::TO_EXTENDED) {
- old_pkg_location_ = context_->pkg_path.get();
+ old_pkg_location_ = context_->GetPkgPath();
new_pkg_location_ = bf::path(GetExtendedRootAppPath(context_->uid.get())) /
context_->pkgid.get();
context_->storage.set(Storage::EXTENDED);
Step::Status StepRecoverChangeOwner::RecoveryUpdate() {
uid_t uid = context_->uid.get();
// Change owner of files at root path
- if (!ci::SetPackageDirectoryOwnerAndPermissions(context_->pkg_path.get(),
+ if (!ci::SetPackageDirectoryOwnerAndPermissions(context_->GetPkgPath(),
uid))
return Step::Status::ERROR;
Step::Status StepRecoverChangeOwner::RecoveryMountUpdate() {
uid_t uid = context_->uid.get();
// Change owner of files at root path
- if (!ci::SetPackageDirectoryOwnerAndPermissions(context_->pkg_path.get(),
+ if (!ci::SetPackageDirectoryOwnerAndPermissions(context_->GetPkgPath(),
uid))
return Step::Status::ERROR;
return Step::Status::ERROR;
// Change owner of files at root path
- if (!ci::SetOwnershipAll(context_->pkg_path.get(), uid, *gid))
+ if (!ci::SetOwnershipAll(context_->GetPkgPath(), uid, *gid))
return Status::ERROR;
- if (!ChangeDataDir(context_->pkg_path.get(), uid))
+ if (!ChangeDataDir(context_->GetPkgPath(), uid))
return Status::ERROR;
return ChangeOwnershipIconsAndManifest(gid, uid);
Step::Status StepRecoverExternalStorage::process() {
if (!context_->manifest_data.get()) {
- RemoveAll(context_->pkg_path.get());
+ RemoveAll(context_->GetPkgPath());
} else {
(void) StepAcquireExternalStorage::process();
}
namespace filesystem {
Step::Status StepRecoverFiles::RecoveryNew() {
- if (!SetPackagePath()) {
- LOG(DEBUG) << "Package files recovery not needed";
- return Status::OK;
- }
- if (!RemoveAll(context_->pkg_path.get()))
+ if (!RemoveAll(context_->GetPkgPath()))
return Status::RECOVERY_ERROR;
LOG(INFO) << "Package files recovery done";
}
Step::Status StepRecoverFiles::RecoveryUpdate() {
- if (!SetPackagePath()) {
- LOG(DEBUG) << "Package files recovery not needed";
- return Status::OK;
- }
- bf::path backup_path = GetBackupPathForPackagePath(context_->pkg_path.get());
+ bf::path backup_path = GetBackupPathForPackagePath(context_->GetPkgPath());
if (bf::exists(backup_path)) {
- if (!RemoveAll(context_->pkg_path.get())) {
+ if (!RemoveAll(context_->GetPkgPath())) {
LOG(ERROR) << "Cannot restore widget files to its correct location";
return Status::RECOVERY_ERROR;
}
- (void) MoveDir(backup_path, context_->pkg_path.get());
+ (void) MoveDir(backup_path, context_->GetPkgPath());
}
LOG(INFO) << "Package files recovery done";
return Status::OK;
}
Step::Status StepRecoverFiles::RecoveryMountNew() {
- if (!SetPackagePath()) {
- LOG(DEBUG) << "Package files recovery not needed";
- return Status::OK;
- }
bf::path zip_location = GetZipPackageLocation(
- context_->pkg_path.get(), context_->pkgid.get());
+ context_->GetPkgPath(), context_->pkgid.get());
Remove(zip_location);
- RemoveAll(context_->pkg_path.get());
+ RemoveAll(context_->GetPkgPath());
LOG(INFO) << "Package files recovery done";
return Status::OK;
}
Step::Status StepRecoverFiles::RecoveryMountUpdate() {
- if (!SetPackagePath()) {
- LOG(DEBUG) << "Package files recovery not needed";
- return Status::OK;
- }
bf::path zip_location = GetZipPackageLocation(
- context_->pkg_path.get(), context_->pkgid.get());
+ context_->GetPkgPath(), context_->pkgid.get());
bf::path backup_zip_location = GetBackupPathForZipFile(zip_location);
if (bf::exists(backup_zip_location)) {
Remove(zip_location);
// directories without mounting zip package file. In other words in mount
// install or mount update mode we don't mount everything - some files are
// still unpacked due to necessity.
- bf::path backup_path = GetBackupPathForPackagePath(context_->pkg_path.get());
+ bf::path backup_path = GetBackupPathForPackagePath(context_->GetPkgPath());
if (bf::exists(backup_path)) {
- if (!MoveDir(backup_path, context_->pkg_path.get(),
+ if (!MoveDir(backup_path, context_->GetPkgPath(),
FS_MERGE_OVERWRITE | FS_COMMIT_COPY_FILE)) {
LOG(ERROR) << "Failed to recovery backup file "
<< "in recovery of mount update";
return Status::OK;
}
-bool StepRecoverFiles::SetPackagePath() {
- if (context_->pkgid.get().empty())
- return false;
- context_->pkg_path.set(
- context_->root_application_path.get() / context_->pkgid.get());
- return true;
-}
-
} // namespace filesystem
} // namespace common_installer
Status RecoveryMountNew() override;
Status RecoveryMountUpdate() override;
- private:
- bool SetPackagePath();
-
STEP_NAME(RecoverFiles)
};
Step::Status StepRecoverStorageDirectories::RecoveryUpdate() {
if (context_->request_mode.get() == RequestMode::GLOBAL)
return Status::OK;
- if (!context_->pkg_path.get().empty()) {
+ if (!context_->GetPkgPath().empty()) {
bf::path backup_path = common_installer::GetBackupPathForPackagePath(
- context_->pkg_path.get());
+ context_->GetPkgPath());
if (bf::exists(backup_path)) {
- MoveAppStorage(context_->pkg_path.get(), backup_path, kDataLocation);
- MoveAppStorage(context_->pkg_path.get(), backup_path, kSharedResLocation);
+ MoveAppStorage(context_->GetPkgPath(), backup_path, kDataLocation);
+ MoveAppStorage(context_->GetPkgPath(), backup_path, kSharedResLocation);
}
}
return Status::OK;
// Even though, the below checks can fail, StepRemoveFiles should still try
// to remove the files
- if (context_->pkg_path.get().empty())
+ if (context_->GetPkgPath().empty())
LOG(ERROR) << "pkg_path attribute is empty";
- else if (!bf::exists(context_->pkg_path.get()))
+ else if (!bf::exists(context_->GetPkgPath()))
LOG(ERROR) << "pkg_path ("
- << context_->pkg_path.get()
+ << context_->GetPkgPath()
<< ") path does not exist";
return Step::Status::OK;
Step::Status StepRemoveZipImage::process() {
bf::path zip_image_path =
- GetZipPackageLocation(context_->pkg_path.get(), context_->pkgid.get());
+ GetZipPackageLocation(context_->GetPkgPath(), context_->pkgid.get());
if (bf::exists(zip_image_path)) {
if (Remove(zip_image_path))
LOG(INFO) << "Zip image file removed: " << zip_image_path;
std::string str_ver(manifest->api_version);
utils::VersionNumber api_version(str_ver);
- bf::path shared_data_path = context_->pkg_path.get() / kSharedData;
+ bf::path shared_data_path = context_->GetPkgPath() / kSharedData;
if (api_version < ver30) {
return CreateSharedDir(shared_data_path);
} else {
bf::path new_path = context_->manifest_data.get()->tep_name;
bf::path backup_path =
GetInternalTepPath(
- GetBackupPathForPackagePath(context_->pkg_path.get()));
+ GetBackupPathForPackagePath(context_->GetPkgPath()));
backup_path /= new_path.filename();
if (!bf::exists(new_path.parent_path())) {
bs::error_code error;
namespace mount {
Step::Status StepMountInstall::process() {
- context_->pkg_path.set(
- context_->root_application_path.get() / context_->pkgid.get());
-
TzipInterface tzip_unpack(context_->unpacked_dir_path.get());
if (!tzip_unpack.UnmountZip()) {
LOG(ERROR) << "Failed to unmount zip package from temporary path";
}
bf::path zip_destination_path =
- GetZipPackageLocation(context_->pkg_path.get(), context_->pkgid.get());
+ GetZipPackageLocation(context_->GetPkgPath(), context_->pkgid.get());
if (!bf::exists(zip_destination_path.parent_path())) {
bs::error_code error;
bf::create_directories(zip_destination_path.parent_path(), error);
context_->manifest_data.get()->zip_mount_file =
strdup(zip_destination_path.c_str());
- bf::path mount_point = GetMountLocation(context_->pkg_path.get());
+ bf::path mount_point = GetMountLocation(context_->GetPkgPath());
TzipInterface tzip_final(mount_point);
if (!tzip_final.MountZip(zip_destination_path)) {
LOG(ERROR) << "Failed to mount zip package in installation path";
}
Step::Status StepMountInstall::UmountPackagePath() {
- bf::path mount_point = GetMountLocation(context_->pkg_path.get());
+ bf::path mount_point = GetMountLocation(context_->GetPkgPath());
TzipInterface tzip_final(mount_point);
if (!tzip_final.UnmountZip()) {
LOG(ERROR) << "Failed to unmount zip package after installation";
Step::Status StepMountInstall::undo() {
bs::error_code error;
UmountPackagePath();
- bf::remove(GetZipPackageLocation(context_->pkg_path.get(),
+ bf::remove(GetZipPackageLocation(context_->GetPkgPath(),
context_->pkgid.get()), error);
if (error) {
LOG(ERROR) << "Failed to remove zip package";
return Status::APP_DIR_ERROR;
}
- bf::remove_all(context_->pkg_path.get(), error);
+ bf::remove_all(context_->GetPkgPath(), error);
if (error) {
LOG(ERROR) << "Failed to remove package content";
return Status::APP_DIR_ERROR;
Step::Status StepMountRecover::RecoveryMountUpdate() {
bf::path zip_destination_path =
- GetZipPackageLocation(context_->pkg_path.get(), context_->pkgid.get());
+ GetZipPackageLocation(context_->GetPkgPath(), context_->pkgid.get());
context_->manifest_data.get()->zip_mount_file =
strdup(zip_destination_path.c_str());
- bf::path mount_point = GetMountLocation(context_->pkg_path.get());
+ bf::path mount_point = GetMountLocation(context_->GetPkgPath());
TzipInterface tzip_final(mount_point);
if (!tzip_final.MountZip(zip_destination_path)) {
LOG(ERROR) << "Failed to mount zip package in installation path";
}
Step::Status StepMountRecover::UmountPackagePath() {
- bf::path mount_point = GetMountLocation(context_->pkg_path.get());
+ bf::path mount_point = GetMountLocation(context_->GetPkgPath());
TzipInterface tzip_final(mount_point);
if (!tzip_final.UnmountZip()) {
LOG(ERROR) << "Failed to unmount zip package after installation";
namespace mount {
Step::Status StepMountUpdate::process() {
- context_->pkg_path.set(
- context_->root_application_path.get() / context_->pkgid.get());
-
TzipInterface tzip_unpack(context_->unpacked_dir_path.get());
if (!tzip_unpack.UnmountZip()) {
LOG(ERROR) << "Failed to unmount zip package from temporary path";
}
bf::path zip_destination_path =
- GetZipPackageLocation(context_->pkg_path.get(), context_->pkgid.get());
+ GetZipPackageLocation(context_->GetPkgPath(), context_->pkgid.get());
bf::path backup_zip_location = GetBackupPathForZipFile(zip_destination_path);
if (!MoveFile(zip_destination_path, backup_zip_location)) {
context_->manifest_data.get()->zip_mount_file =
strdup(zip_destination_path.c_str());
- bf::path mount_point = GetMountLocation(context_->pkg_path.get());
+ bf::path mount_point = GetMountLocation(context_->GetPkgPath());
TzipInterface tzip_final(mount_point);
if (!tzip_final.MountZip(zip_destination_path)) {
LOG(ERROR) << "Failed to mount zip package in installation path";
Step::Status StepMountUpdate::clean() {
bf::path backup_zip_location =
GetBackupPathForZipFile(GetZipPackageLocation(
- context_->pkg_path.get(), context_->pkgid.get()));
+ context_->GetPkgPath(), context_->pkgid.get()));
bs::error_code error;
bf::remove(backup_zip_location, error);
- bf::path mount_point = GetMountLocation(context_->pkg_path.get());
+ bf::path mount_point = GetMountLocation(context_->GetPkgPath());
TzipInterface tzip_final(mount_point);
if (!tzip_final.UnmountZip()) {
LOG(ERROR) << "Failed to unmount zip package after installation";
}
Step::Status StepMountUpdate::undo() {
- bf::path mount_point = GetMountLocation(context_->pkg_path.get());
+ bf::path mount_point = GetMountLocation(context_->GetPkgPath());
TzipInterface tzip_final(mount_point);
if (!tzip_final.UnmountZip()) {
LOG(ERROR) << "Failed to unmount zip package after installation";
}
bf::path zip_location = GetZipPackageLocation(
- context_->pkg_path.get(), context_->pkgid.get());
+ context_->GetPkgPath(), context_->pkgid.get());
bf::path backup_zip_location = GetBackupPathForZipFile(zip_location);
if (bf::exists(backup_zip_location)) {
if (!PkgmgrGenerateManifestInfoFromDB(manifest, context_->pkgid.get(),
context_->uid.get())) {
context_->manifest_data.set(manifest);
- context_->pkg_path.set(manifest->root_path);
}
}
<< ") path does not exist";
return Step::Status::INVALID_VALUE;
}
+ if (context_->root_application_path.get().empty()) {
+ LOG(ERROR) << "pkgid is not set";
+ return Step::Status::PACKAGE_NOT_FOUND;
+ }
if (context_->pkgid.get().empty()) {
LOG(ERROR) << "pkgid is not set";
return Step::Status::PACKAGE_NOT_FOUND;
LOG(ERROR) << "unable to setup temp directory";
return Step::Status::ERROR;
}
- context_->pkg_path.set(
- context_->root_application_path.get() /context_->pkgid.get());
- bf::path install_path = context_->pkg_path.get();
+ bf::path install_path = context_->GetPkgPath();
bf::path unzip_path = context_->unpacked_dir_path.get();
if (!AddFiles(unzip_path, install_path) ||
!ModifyFiles(unzip_path, install_path) ||
if (backup_temp_dir_.empty())
return false;
if (operation == Operation::DELETE || operation == Operation::MODIFY) {
- bf::path app_path = context_->pkg_path.get();
+ bf::path app_path = context_->GetPkgPath();
bf::path source_path = app_path / relative_path;
if (bf::is_directory(source_path)) {
if (!CreateDir(backup_temp_dir_ / relative_path)) {
void StepRDSModify::RestoreFiles() {
LOG(ERROR) << "error occured about to restore files";
- bf::path app_path(context_->pkg_path.get());
+ bf::path app_path(context_->GetPkgPath());
for (std::pair<std::string, Operation>& modification :
success_modifications_) {
bf::path source_path(backup_temp_dir_ / modification.first);
namespace security {
bool StepRecoverSecurity::Check(bool is_update) {
- if (context_->pkg_path.get().empty())
+ if (context_->GetPkgPath().empty())
return false;
- if (!boost::filesystem::exists(context_->pkg_path.get()) && is_update)
+ if (!boost::filesystem::exists(context_->GetPkgPath()) && is_update)
return false;
if (context_->pkgid.get().empty())
return false;
}
std::string error_message;
if (!RegisterSecurityContextForManifest(
- context_->pkgid.get(), context_->pkg_path.get(), context_->uid.get(),
+ context_->pkgid.get(), context_->GetPkgPath(), context_->uid.get(),
&context_->certificate_info.get(), context_->manifest_data.get(),
context_->cross_app_rules.get(), &error_message)) {
LOG(ERROR) << "Unsuccessful update";
return Status::RECOVERY_ERROR;
}
if (!RegisterSecurityContextForPath(
- context_->pkgid.get(), context_->pkg_path.get(), context_->uid.get(),
+ context_->pkgid.get(), context_->GetPkgPath(), context_->uid.get(),
context_->is_readonly_package.get(), &error_message)) {
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
namespace security {
Step::Status StepRegisterSecurity::precheck() {
- if (context_->pkg_path.get().empty()) {
+ if (context_->GetPkgPath().empty()) {
LOG(ERROR) << "pkg_path attribute is empty";
return Step::Status::INVALID_VALUE;
}
- if (!boost::filesystem::exists(context_->pkg_path.get())) {
+ if (!boost::filesystem::exists(context_->GetPkgPath())) {
LOG(ERROR) << "pkg_path ("
- << context_->pkg_path.get()
+ << context_->GetPkgPath()
<< ") path does not exist";
return Step::Status::INVALID_VALUE;
}
std::string error_message;
if (context_->request_type.get() != RequestType::Move &&
!RegisterSecurityContextForManifest(
- context_->pkgid.get(), context_->pkg_path.get(), context_->uid.get(),
+ context_->pkgid.get(), context_->GetPkgPath(), context_->uid.get(),
&context_->certificate_info.get(), context_->manifest_data.get(),
context_->cross_app_rules.get(), &error_message)) {
if (!error_message.empty()) {
if (context_->partial_rw.get())
return Status::OK;
if (!RegisterSecurityContextForPath(
- context_->pkgid.get(), context_->pkg_path.get(), context_->uid.get(),
+ context_->pkgid.get(), context_->GetPkgPath(), context_->uid.get(),
context_->is_readonly_package.get(), &error_message)) {
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
Step::Status StepRegisterTrustAnchor::process() {
int ret;
- bf::path pkg_certs_path = context_->pkg_path.get() / kTpkTrustAnchorPath;
+ bf::path pkg_certs_path = context_->GetPkgPath() / kTpkTrustAnchorPath;
if (register_type_ == RegisterType::UPDATE) {
ret = trust_anchor_uninstall(context_->pkgid.get().c_str(),
context_->uid.get());
if (!common_installer::CreateDir(pkg_certs_path))
return Step::Status::APP_DIR_ERROR;
bf::path pkg_certs_src_path =
- context_->pkg_path.get() / "res/wgt" / kWgtTrustAnchorPath;
+ context_->GetPkgPath() / "res/wgt" / kWgtTrustAnchorPath;
for (bf::directory_iterator file(pkg_certs_src_path);
file != bf::directory_iterator(); ++file) {
bf::path current(file->path());
Step::Status StepRollbackDeinstallationSecurity::undo() {
std::string error_message;
if (!RegisterSecurityContextForManifest(
- context_->pkgid.get(), context_->pkg_path.get(), context_->uid.get(),
+ context_->pkgid.get(), context_->GetPkgPath(), context_->uid.get(),
&context_->certificate_info.get(), context_->manifest_data.get(),
context_->cross_app_rules.get(), &error_message)) {
LOG(ERROR) << "Failure on re-installing security context for app "
return Status::SECURITY_ERROR;
}
if (!RegisterSecurityContextForPath(
- context_->pkgid.get(), context_->pkg_path.get(), context_->uid.get(),
+ context_->pkgid.get(), context_->GetPkgPath(), context_->uid.get(),
context_->is_readonly_package.get(), &error_message)) {
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
Step::Status StepUpdateSecurity::process() {
std::string error_message;
if (!RegisterSecurityContextForManifest(
- context_->pkgid.get(), context_->pkg_path.get(), context_->uid.get(),
+ context_->pkgid.get(), context_->GetPkgPath(), context_->uid.get(),
&context_->certificate_info.get(), context_->manifest_data.get(),
context_->cross_app_rules.get(), &error_message)) {
if (!error_message.empty()) {
}
if (context_->request_type.get() != RequestType::ReadonlyUpdateUninstall) {
if (!RegisterSecurityContextForPath(
- context_->pkgid.get(), context_->pkg_path.get(), context_->uid.get(),
+ context_->pkgid.get(), context_->GetPkgPath(), context_->uid.get(),
context_->is_readonly_package.get(), &error_message)) {
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
Step::Status StepUpdateSecurity::undo() {
std::string error_message;
if (!RegisterSecurityContextForManifest(
- context_->pkgid.get(), context_->pkg_path.get(), context_->uid.get(),
+ context_->pkgid.get(), context_->GetPkgPath(), context_->uid.get(),
&context_->certificate_info.get(), context_->old_manifest_data.get(),
context_->cross_app_rules.get(), &error_message)) {
if (!error_message.empty()) {
return Status::SECURITY_ERROR;
}
if (!RegisterSecurityContextForPath(
- context_->pkgid.get(), context_->pkg_path.get(), context_->uid.get(),
+ context_->pkgid.get(), context_->GetPkgPath(), context_->uid.get(),
context_->is_readonly_package.get(), &error_message)) {
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;