From 86a05866a86c766d7e19106e9e02dfd4f01b3a3e Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Thu, 3 Mar 2022 14:05:46 +0900 Subject: [PATCH] Keep system and update value for undo operation These value must be set for undo operation. Change-Id: I5d2896b82c535489bd8795b2357bf6a4cfa3153f Signed-off-by: Sangyoon Jang (cherry picked from commit f9c9291bdaf5cef264566cd48aa3f56be8a3fd04) --- .../step/configuration/step_parse_preload.cc | 34 ++++++++++++++++++++++ src/common/step/configuration/step_parse_preload.h | 1 + 2 files changed, 35 insertions(+) diff --git a/src/common/step/configuration/step_parse_preload.cc b/src/common/step/configuration/step_parse_preload.cc index a09e008..d926bdc 100644 --- a/src/common/step/configuration/step_parse_preload.cc +++ b/src/common/step/configuration/step_parse_preload.cc @@ -213,6 +213,36 @@ ci::Step::Status StepParsePreload::AdjustSystem() { return Status::OK; } +ci::Step::Status StepParsePreload::AdjustOldManifest() { + manifest_x* old_manifest = context_->old_manifest_data.get(); + if (!old_manifest) + return Status::OK; + + free(old_manifest->system); + // keep system value for undo operation + if (pkg_query_->IsSystemPackage()) + old_manifest->system = strdup("true"); + else + old_manifest->system = strdup("false"); + if (!old_manifest->system) { + LOG(ERROR) << "Out of memory"; + return Status::ERROR; + } + + free(old_manifest->update); + // keep update value for undo operation + if (pkg_query_->IsUpdatedPackage()) + old_manifest->update = strdup("true"); + else + old_manifest->update = strdup("false"); + if (!old_manifest->update) { + LOG(ERROR) << "Out of memory"; + return Status::ERROR; + } + + return Status::OK; +} + ci::Step::Status StepParsePreload::process() { req_type_ = context_->request_type.get(); pkg_query_.reset( @@ -241,6 +271,10 @@ ci::Step::Status StepParsePreload::process() { if (ret != Status::OK) return ret; + ret = AdjustOldManifest(); + if (ret != Status::OK) + return ret; + return Status::OK; } diff --git a/src/common/step/configuration/step_parse_preload.h b/src/common/step/configuration/step_parse_preload.h index 01d1541..21cae22 100644 --- a/src/common/step/configuration/step_parse_preload.h +++ b/src/common/step/configuration/step_parse_preload.h @@ -33,6 +33,7 @@ class StepParsePreload : public common_installer::Step { bool ValidateAttrs(); Status AdjustUpdate(); Status AdjustSystem(); + Status AdjustOldManifest(); common_installer::RequestType req_type_; std::unique_ptr pkg_query_; -- 2.7.4