blob: 8bed632210e077c43c40b20d5c48dee59530a903 [file] [log] [blame]
adlr@google.com3defe6a2009-12-04 20:57:17 +00001// Copyright (c) 2009 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_INSTALL_ACTION_H__
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_INSTALL_ACTION_H__
7
8#include "base/scoped_ptr.h"
9#include "update_engine/action.h"
10#include "update_engine/delta_diff_parser.h"
11#include "update_engine/install_plan.h"
12#include "update_engine/update_metadata.pb.h"
13
14// The Install Action is responsible for ensuring the update that's been
15// downloaded has been installed. This may be a no-op in the case of a full
16// update, since those will be downloaded directly into the destination
17// partition. However, for a delta update some work is required.
18
19// An InstallPlan struct must be passed to this action before PerformAction()
20// is called so that this action knows if it's a delta update, and if so,
21// what the paths are.
22
23// TODO(adlr): At the moment, InstallAction is synchronous. It should be
24// updated to be asynchronous at some point.
25
26namespace chromeos_update_engine {
27
28class InstallAction;
29class NoneType;
30
31template<>
32class ActionTraits<InstallAction> {
33 public:
34 // Takes the InstallPlan for input
35 typedef InstallPlan InputObjectType;
36 // On success, puts the output device path on output
37 typedef std::string OutputObjectType;
38};
39
40class InstallAction : public Action<InstallAction> {
41 public:
42 InstallAction() {}
43 typedef ActionTraits<InstallAction>::InputObjectType InputObjectType;
44 typedef ActionTraits<InstallAction>::OutputObjectType OutputObjectType;
45 void PerformAction();
46
47 // This action is synchronous for now.
48 void TerminateProcessing() { CHECK(false); }
49
50 // Debugging/logging
51 static std::string StaticType() { return "InstallAction"; }
52 std::string Type() const { return StaticType(); }
53
54 private:
55 // Installs 'file' into mountpoint. 'path' is the path that 'file'
56 // should have when we reboot and mountpoint is root.
57 bool InstallFile(const std::string& mountpoint,
58 const DeltaArchiveManifest_File& file,
59 const std::string& path,
60 const DeltaDiffParser& parser) const;
61 // These are helpers for InstallFile. They focus on specific file types:
62 // Regular data files:
63 bool InstallFileRegularFile(const std::string& mountpoint,
64 const DeltaArchiveManifest_File& file,
65 const std::string& path,
66 const DeltaDiffParser& parser,
67 const bool exists) const;
68 // char/block devices, fifos, and sockets:
69 bool InstallFileSpecialFile(const std::string& mountpoint,
70 const DeltaArchiveManifest_File& file,
71 const std::string& path,
72 const DeltaDiffParser& parser,
73 const bool exists) const;
74 // symlinks:
75 bool InstallFileSymlink(const std::string& mountpoint,
76 const DeltaArchiveManifest_File& file,
77 const std::string& path,
78 const DeltaDiffParser& parser,
79 const bool exists) const;
80
81 DISALLOW_COPY_AND_ASSIGN(InstallAction);
82};
83
84} // namespace chromeos_update_engine
85
86#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_INSTALL_ACTION_H__