3bb36884ac1bed007d4a338a2b8d317cb4ae5578
[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 <string>
11
12 #include "common/installer_context.h"
13 #include "common/step/step.h"
14
15 namespace common_installer {
16 namespace filesystem {
17
18 /**
19  * @brief The StepDeltaPatch class
20  *        Patches the unpack directory content according to delta file so that
21  *        new package content is complete and no file is missing.
22  *
23  * Patching package files with delta is performed in unpacked_dir before all
24  * step that operates on widget's final location. That means that whole new
25  * package content is prepared before any files of package installation are
26  * touched.
27  *
28  * Flow goes as below:
29  *  1) `unpacked_dir` (where delta package is unpacked) is moved to
30  *     `unpacked_dir_patch` (PATCH DIR)
31  *  2) old package content is moved to `unpacked_dir` (it becomes APP_DIR)
32  *  3) `unpacked_dir` is being applied with patches (using xdelta3 tool)
33  *  4) `unpacked_dir_patch` is removed.
34  *  5) Normal update flow proceeds as if it it was normal update installation
35  *     (as the unpacked_dir contains full new version of package).
36  */
37 class StepDeltaPatch : public Step {
38  public:
39   explicit StepDeltaPatch(InstallerContext* context,
40                           const std::string& delta_root = "");
41
42   Status process() override;
43   Status clean() override { return Status::OK; }
44   Status undo() override;
45   Status precheck() override;
46
47  private:
48   boost::filesystem::path patch_dir_;
49   std::string delta_root_;
50
51   STEP_NAME(DeltaPatch)
52 };
53
54 }  // namespace filesystem
55 }  // namespace common_installer
56
57 #endif  // COMMON_STEP_FILESYSTEM_STEP_DELTA_PATCH_H_