[OldManifest] Added step for update installation 13/38513/1
authorTomasz Iwanek <t.iwanek@samsung.com>
Tue, 24 Mar 2015 15:35:34 +0000 (16:35 +0100)
committerTomasz Iwanek <t.iwanek@samsung.com>
Tue, 21 Apr 2015 13:30:43 +0000 (15:30 +0200)
Tizen-JIRA: TC-2482

Change-Id: I37848449f6a6e199d796c2f01edbee422471591c

src/common/CMakeLists.txt
src/common/step/step_old_manifest.cc [new file with mode: 0644]
src/common/step/step_old_manifest.h [new file with mode: 0644]

index 30ac543..7596b10 100644 (file)
@@ -11,6 +11,7 @@ SET(SRCS
   step/step_copy.cc
   step/step_generate_xml.cc
   step/step_register_app.cc
+  step/step_old_manifest.cc
   step/step_parse.cc
   step/step_remove_files.cc
   step/step_revoke_security.cc
diff --git a/src/common/step/step_old_manifest.cc b/src/common/step/step_old_manifest.cc
new file mode 100644 (file)
index 0000000..4a6c43c
--- /dev/null
@@ -0,0 +1,49 @@
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#include "common/step/step_old_manifest.h"
+
+#include <boost/filesystem.hpp>
+#include <pkgmgr-info.h>
+#include <string>
+
+#include "utils/logging.h"
+
+namespace common_installer {
+namespace old_manifest {
+
+namespace bf = boost::filesystem;
+
+Step::Status StepOldManifest::process() {
+  // TODO(t.iwanek): refactor -> this is set in StepGenerateXml too
+  // but for update installation, it is too late
+  // set xml file path
+  bf::path xml_path = bf::path(getUserManifestPath(context_->uid.get()))
+      / bf::path(context_->pkgid.get());
+  xml_path += ".xml";
+  context_->xml_path.set(xml_path);
+
+  if (!bf::exists(context_->xml_path.get())) {
+    LOG(ERROR) << "Missing old platform manifest file";
+    return Status::ERROR;
+  }
+
+  xmlInitParser();
+  manifest_x* mfx = pkgmgr_parser_usr_process_manifest_xml(
+      context_->xml_path.get().c_str(), context_->uid.get());
+  if (!mfx) {
+    LOG(ERROR) << "Failed to parse old tizen manifest xml "
+               << context_->xml_path.get();
+    return Step::Status::ERROR;
+  }
+
+  context_->old_manifest_data.set(mfx);
+
+  LOG(DEBUG) << "Successfully parse old tizen manifest xml for update";
+
+  return Status::OK;
+}
+
+}  // namespace old_manifest
+}  // namespace common_installer
diff --git a/src/common/step/step_old_manifest.h b/src/common/step/step_old_manifest.h
new file mode 100644 (file)
index 0000000..5b25aab
--- /dev/null
@@ -0,0 +1,31 @@
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef COMMON_STEP_STEP_OLD_MANIFEST_H_
+#define COMMON_STEP_STEP_OLD_MANIFEST_H_
+
+#include "common/context_installer.h"
+
+#include "common/step/step.h"
+#include "utils/logging.h"
+
+namespace common_installer {
+namespace old_manifest {
+
+class StepOldManifest : public 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; }
+
+  SCOPE_LOG_TAG(OldManifest)
+};
+
+}  // namespace old_manifest
+}  // namespace common_installer
+
+#endif  // COMMON_STEP_STEP_OLD_MANIFEST_H_