And, modify the way of preload decision.
Requires:
https://review.tizen.org/gerrit/#/c/58866
Change-Id: I90a698a721ac58a132862eba7f6e960686b9d152
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
old_manifest_data(nullptr),
uid(getuid()),
backend_data(nullptr),
- privilege_level(PrivilegeLevel::UNTRUSTED) {}
+ privilege_level(PrivilegeLevel::UNTRUSTED),
+ is_preload_request(false) {}
InstallerContext::~InstallerContext() {
if (manifest_data.get())
* \brief installation mode (ONLINE / OFFLINE)
*/
Property<InstallationMode> installation_mode;
+
+ /**
+ * \brief preload request received from pkgmgr_installer
+ */
+ Property<bool> is_preload_request;
};
} // namespace common_installer
return (pkgmgr_installer_get_tep_move_type(pi_) == 1)?true:false;
}
+bool PkgMgrInterface::GetIsPreloadRequest() {
+ return (pkgmgr_installer_get_is_preload(pi_) == 1)?
+ true:(install_mode_ == InstallationMode::OFFLINE)?
+ true:false;
+}
+
} // namespace common_installer
bool GetIsTepMove();
/**
+ * Returns True if the request is for preload. Otherwise, return false
+ *
+ * \return True if the request is for preload. Otherwise, return false
+ */
+ bool GetIsPreloadRequest();
+
+ /**
* Get Raw pointer to pkgmgr_installer object
* NOTE: It should not be used (PkgMgrInterface can destroy it
*
RequestMode::GLOBAL : RequestMode::USER;
}
-const char *GetRootAppPath() {
+const char *GetRootAppPath(bool is_preload) {
return GetRequestMode() == RequestMode::USER ?
- tzplatform_getenv(TZ_USER_APP) : tzplatform_getenv(TZ_SYS_RW_APP);
+ tzplatform_getenv(TZ_USER_APP) : is_preload ?
+ tzplatform_getenv(TZ_SYS_RO_APP) :tzplatform_getenv(TZ_SYS_RW_APP);
}
} // namespace common_installer
*
* \return root application path (eg. $HOME/apps_rw/)
*/
-const char *GetRootAppPath();
+const char *GetRootAppPath(bool is_preload);
} // namespace common_installer
SetupRequestMode();
SetupRequestType();
SetupFileCreationMask();
+ SetupIsPreloadRequest();
if (!SetupRootAppDirectory())
return Status::CONFIG_ERROR;
bool StepConfigure::SetupRootAppDirectory() {
if (context_->root_application_path.get().empty()) {
- std::string root_app_path = GetRootAppPath();
+ std::string root_app_path =
+ GetRootAppPath(context_->is_preload_request.get());
if (root_app_path.empty())
return false;
<< " to " << std::oct << new_mask;
}
+void StepConfigure::SetupIsPreloadRequest() {
+ context_->is_preload_request.set(pkgmgr_->GetIsPreloadRequest());
+}
+
} // namespace configuration
} // namespace common_installer
void SetupRequestMode();
void SetupRequestType();
void SetupFileCreationMask();
+ void SetupIsPreloadRequest();
PkgMgrPtr pkgmgr_;
}
bool ApplyModifiedFiles(const delta::DeltaInfo& info, const bf::path& app_dir,
- const bf::path& patch_dir) {
+ const bf::path& patch_dir, bool is_preload) {
for (auto& relative : info.modified()) {
bf::path temp_file = ci::GenerateTemporaryPath(
- bf::path(ci::GetRootAppPath()) / "tmp_file");
+ bf::path(ci::GetRootAppPath(is_preload)) / "tmp_file");
bf::path patch_file = patch_dir / relative;
bf::path input = app_dir / relative;
if (!bf::is_regular_file(input)) {
}
bool ApplyPatch(const delta::DeltaInfo& info, const bf::path& app_dir,
- const bf::path& patch_dir) {
+ const bf::path& patch_dir, bool is_preload) {
if (!ApplyDeletedFiles(info, app_dir))
return false;
- if (!ApplyModifiedFiles(info, app_dir, patch_dir))
+ if (!ApplyModifiedFiles(info, app_dir, patch_dir, is_preload))
return false;
if (!ApplyAddedFiles(info, app_dir, patch_dir))
return false;
}
// apply changes mentioned in delta
- if (!ApplyPatch(*delta_info, context_->unpacked_dir_path.get(), patch_dir_))
+ if (!ApplyPatch(*delta_info, context_->unpacked_dir_path.get(), patch_dir_,
+ context_->is_preload_request.get()))
return Status::DELTA_ERROR;
bs::error_code error;
const char kBackendDirectoryPath[] = "/etc/package-manager/backend/";
int InstallManifestOffline(const std::string& pkgid,
- const std::string& type) {
+ const std::string& type,
+ const std::string& preload) {
bf::path backend_path(kBackendDirectoryPath);
backend_path /= type;
ci::Subprocess backend(backend_path.string());
- backend.Run("-y", pkgid.c_str());
+ if (preload == "true")
+ backend.Run("-y", pkgid.c_str(), "--preload");
+ else
+ backend.Run("-y", pkgid.c_str());
return backend.Wait();
}
if (type.empty())
type = "tpk";
- return InstallManifestOffline(package_info->package(), type);
+ return InstallManifestOffline(package_info->package(), type,
+ package_info->preload());
}
namespace {
-enum class Action {
- CREATE,
- COPY_OR_CREATE
-};
-
-const std::vector<std::pair<const char*, Action>> kEntries = {
- {"/", Action::CREATE},
- {"cache/", Action::CREATE},
- {"data/", Action::COPY_OR_CREATE} // compatibility -> copy data/ dir for tpk
+const std::vector<const char*> kEntries = {
+ {"/"},
+ {"cache/"},
+ {"data/"}
};
const char kSkelAppDir[] = "/etc/skel/apps_rw";
}
bs::error_code error;
- for (auto& pair : kEntries) {
- bf::path subpath = base_dir / pair.first;
- switch (pair.second) {
- case Action::COPY_OR_CREATE: {
- bf::path global_directory =
- bf::path(tzplatform_getenv(TZ_SYS_RW_APP)) / pkgid / pair.first;
- if (bf::exists(global_directory)) {
- if (!ci::CopyDir(global_directory, subpath)) {
- LOG(ERROR) << "Failed to copy directory: " << global_directory;
- return false;
- }
- break;
- }
- }
- case Action::CREATE: {
- bf::create_directories(subpath, error);
- if (error) {
- LOG(ERROR) << "Failed to create directory: " << subpath;
- return false;
- }
- break;
- }
- default:
- assert(false);
+ for (auto& entry : kEntries) {
+ bf::path subpath = base_dir / entry;
+ bf::create_directories(subpath, error);
+ if (error) {
+ LOG(ERROR) << "Failed to create directory: " << subpath;
+ return false;
}
if (!SetPackageDirectoryOwnerAndPermissions(subpath, uid, gid))
}
// TODO(jungh.yeon) : this is hotfix.
- for (auto& pair : kEntries) {
- bf::path subpath = path / pair.first;
+ for (auto& entry : kEntries) {
+ bf::path subpath = path / entry;
bf::create_directories(subpath, error);
std::string label = "User::Pkg::" + pkgid;
if (error) {