Remove boost dependency
[platform/core/appfw/app-installers.git] / src / common / step / filesystem / step_delta_patch.h
1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache-2.0 license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMMON_STEP_FILESYSTEM_STEP_DELTA_PATCH_H_
6 #define COMMON_STEP_FILESYSTEM_STEP_DELTA_PATCH_H_
7
8 #include <manifest_parser/utils/logging.h>
9
10 #include <filesystem>
11 #include <string>
12
13 #include "common/installer_context.h"
14 #include "common/step/step.h"
15
16 namespace common_installer {
17 namespace filesystem {
18
19 /**
20  * @brief The StepDeltaPatch class
21  *        Patches the unpack directory content according to delta file so that
22  *        new package content is complete and no file is missing.
23  *
24  * Patching package files with delta is performed in unpacked_dir before all
25  * step that operates on widget's final location. That means that whole new
26  * package content is prepared before any files of package installation are
27  * touched.
28  *
29  * Flow goes as below:
30  *  1) `unpacked_dir` (where delta package is unpacked) is moved to
31  *     `unpacked_dir_patch` (PATCH DIR)
32  *  2) old package content is moved to `unpacked_dir` (it becomes APP_DIR)
33  *  3) `unpacked_dir` is being applied with patches (using xdelta3 tool)
34  *  4) `unpacked_dir_patch` is removed.
35  *  5) Normal update flow proceeds as if it it was normal update installation
36  *     (as the unpacked_dir contains full new version of package).
37  */
38 class StepDeltaPatch : public Step {
39  public:
40   explicit StepDeltaPatch(InstallerContext* context,
41                           const std::string& delta_root = "");
42
43   Status process() override;
44   Status clean() override { return Status::OK; }
45   Status undo() override;
46   Status precheck() override;
47
48  private:
49   std::filesystem::path patch_dir_;
50   std::string delta_root_;
51
52   STEP_NAME(DeltaPatch)
53 };
54
55 }  // namespace filesystem
56 }  // namespace common_installer
57
58 #endif  // COMMON_STEP_FILESYSTEM_STEP_DELTA_PATCH_H_