This repository was archived by the owner on May 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathostreemanager.h
75 lines (62 loc) · 2.98 KB
/
ostreemanager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef OSTREE_H_
#define OSTREE_H_
#include <memory>
#include <string>
#include <glib/gi18n.h>
#include <ostree.h>
#include "libaktualizr/packagemanagerinterface.h"
#include "crypto/keymanager.h"
#include "utilities/apiqueue.h"
constexpr const char *remote = "aktualizr-remote";
template <typename T>
struct GObjectFinalizer {
void operator()(T *e) const { g_object_unref(reinterpret_cast<gpointer>(e)); }
};
template <typename T>
using GObjectUniquePtr = std::unique_ptr<T, GObjectFinalizer<T>>;
using OstreeProgressCb = std::function<void(const Uptane::Target &, const std::string &, unsigned int)>;
struct PullMetaStruct {
PullMetaStruct(Uptane::Target target_in, const api::FlowControlToken *token_in, GCancellable *cancellable_in,
OstreeProgressCb progress_cb_in)
: target{std::move(target_in)},
percent_complete{0},
token{token_in},
cancellable{cancellable_in},
progress_cb{std::move(progress_cb_in)} {}
Uptane::Target target;
unsigned int percent_complete;
const api::FlowControlToken *token;
GObjectUniquePtr<GCancellable> cancellable;
OstreeProgressCb progress_cb;
};
class OstreeManager : public PackageManagerInterface {
public:
OstreeManager(const PackageConfig &pconfig, const BootloaderConfig &bconfig,
const std::shared_ptr<INvStorage> &storage, const std::shared_ptr<HttpInterface> &http);
~OstreeManager() override;
std::string name() const override { return "ostree"; }
Json::Value getInstalledPackages() const override;
virtual std::string getCurrentHash() const;
Uptane::Target getCurrent() const override;
bool imageUpdated();
data::InstallationResult install(const Uptane::Target &target) const override;
void completeInstall() const override;
data::InstallationResult finalizeInstall(const Uptane::Target &target) override;
void updateNotify() override;
bool fetchTarget(const Uptane::Target &target, Uptane::Fetcher &fetcher, const KeyManager &keys,
const FetcherProgressCb &progress_cb, const api::FlowControlToken *token) override;
TargetStatus verifyTarget(const Uptane::Target &target) const override;
GObjectUniquePtr<OstreeDeployment> getStagedDeployment() const;
static GObjectUniquePtr<OstreeSysroot> LoadSysroot(const boost::filesystem::path &path);
static GObjectUniquePtr<OstreeRepo> LoadRepo(OstreeSysroot *sysroot, GError **error);
static bool addRemote(OstreeRepo *repo, const std::string &url, const KeyManager &keys);
static data::InstallationResult pull(const boost::filesystem::path &sysroot_path, const std::string &ostree_server,
const KeyManager &keys, const Uptane::Target &target,
const api::FlowControlToken *token = nullptr,
OstreeProgressCb progress_cb = nullptr);
private:
TargetStatus verifyTargetInternal(const Uptane::Target &target) const;
private:
std::unique_ptr<Bootloader> bootloader_;
};
#endif // OSTREE_H_