Aktualizr
C++ SOTA Client
All Classes Namespaces Files Functions Variables Enumerations Enumerator Pages
packagemanagerconfig.h
1 #ifndef PACKAGE_MANAGER_PACKAGEMANAGERCONFIG_H_
2 #define PACKAGE_MANAGER_PACKAGEMANAGERCONFIG_H_
3 
4 #include <boost/filesystem.hpp>
5 #include <boost/property_tree/ptree_fwd.hpp>
6 #include <string>
7 
8 #include "utilities/config_utils.h"
9 
10 enum class PackageManager { kNone = 0, kOstree, kDebian, kAndroid, kOstreeDockerApp };
11 std::ostream& operator<<(std::ostream& os, PackageManager pm);
12 
13 struct PackageConfig {
14 #ifdef BUILD_OSTREE
15  PackageManager type{PackageManager::kOstree};
16 #else
17  PackageManager type{PackageManager::kNone};
18 #endif
19  std::string os;
20  boost::filesystem::path sysroot;
21  std::string ostree_server;
22  boost::filesystem::path packages_file{"/usr/package.manifest"};
23 
24 #ifdef BUILD_DOCKERAPP
25  std::vector<std::string> docker_apps;
26  boost::filesystem::path docker_apps_root;
27  boost::filesystem::path docker_app_params;
28  boost::filesystem::path docker_app_bin{"/usr/bin/docker-app"};
29  boost::filesystem::path docker_compose_bin{"/usr/bin/docker-compose"};
30 #endif
31 
32  // Options for simulation (to be used with kNone)
33  bool fake_need_reboot{false};
34 
35  void updateFromPropertyTree(const boost::property_tree::ptree& pt);
36  void writeToStream(std::ostream& out_stream) const;
37 };
38 
39 template <>
40 inline void CopyFromConfig(PackageManager& dest, const std::string& option_name,
41  const boost::property_tree::ptree& pt) {
42  boost::optional<std::string> value = pt.get_optional<std::string>(option_name);
43  if (value.is_initialized()) {
44  std::string pm_type{StripQuotesFromStrings(value.get())};
45  if (pm_type == "ostree") {
46  dest = PackageManager::kOstree;
47  } else if (pm_type == "debian") {
48  dest = PackageManager::kDebian;
49  } else if (pm_type == "android") {
50  dest = PackageManager::kAndroid;
51  } else if (pm_type == "ostree+docker-app") {
52  dest = PackageManager::kOstreeDockerApp;
53  } else {
54  dest = PackageManager::kNone;
55  }
56  }
57 }
58 
59 #endif // PACKAGE_MANAGER_PACKAGEMANAGERCONFIG_H_
PackageConfig
Definition: packagemanagerconfig.h:13