3 #include <boost/uuid/uuid_generators.hpp>
4 #include <boost/uuid/uuid_io.hpp>
6 #include "package_manager/ostreemanager.h"
9 boost::optional<Uptane::Target> pending_version;
10 storage.loadInstalledVersions(
"",
nullptr, &pending_version);
12 if (!!pending_version) {
13 GObjectUniquePtr<OstreeSysroot> sysroot_smart = OstreeManager::LoadSysroot(config.sysroot);
14 OstreeDeployment *booted_deployment = ostree_sysroot_get_booted_deployment(sysroot_smart.get());
15 if (booted_deployment ==
nullptr) {
16 throw std::runtime_error(
"Could not get booted deployment in " + config.sysroot.string());
18 std::string current_hash = ostree_deployment_get_csum(booted_deployment);
21 if (current_hash == target.sha256Hash()) {
22 LOG_INFO <<
"Marking target install complete for: " << target;
23 storage.saveInstalledVersion(
"", target, InstalledVersionUpdateMode::kCurrent);
28 LiteClient::LiteClient(
Config &config_in) : config(std::move(config_in)) {
30 storage = INvStorage::newStorage(config.storage);
31 storage->importData(config.import);
33 EcuSerials ecu_serials;
34 if (!storage->loadEcuSerials(&ecu_serials)) {
36 std::string serial = config.provision.primary_ecu_serial;
37 std::string hwid = config.provision.primary_ecu_hardware_id;
39 hwid = Utils::getHostname();
42 boost::uuids::uuid tmp = boost::uuids::random_generator()();
43 serial = boost::uuids::to_string(tmp);
46 storage->storeEcuSerials(ecu_serials);
49 auto http_client = std::make_shared<HttpClient>();
51 KeyManager keys(storage, config.keymanagerConfig());
52 keys.copyCertsToCurl(*http_client);
54 primary = std::make_shared<SotaUptaneClient>(config, storage, http_client);
55 finalizeIfNeeded(*storage, config.pacman);