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)
29 : config(
std::move(config_in)), primary_ecu(
Uptane::EcuSerial::Unknown(),
"") {
31 storage = INvStorage::newStorage(config.storage);
32 storage->importData(config.import);
34 EcuSerials ecu_serials;
35 if (!storage->loadEcuSerials(&ecu_serials)) {
37 std::string serial = config.provision.primary_ecu_serial;
38 std::string hwid = config.provision.primary_ecu_hardware_id;
40 hwid = Utils::getHostname();
43 boost::uuids::uuid tmp = boost::uuids::random_generator()();
44 serial = boost::uuids::to_string(tmp);
47 storage->storeEcuSerials(ecu_serials);
49 primary_ecu = ecu_serials[0];
51 auto http_client = std::make_shared<HttpClient>();
53 KeyManager keys(storage, config.keymanagerConfig());
54 keys.copyCertsToCurl(*http_client);
57 std::make_shared<SotaUptaneClient>(config, storage, http_client,
nullptr, primary_ecu.first, primary_ecu.second);
58 finalizeIfNeeded(*storage, config.pacman);
Configuration object for an aktualizr instance running on a Primary ECU.
Base data types that are used in The Update Framework (TUF), part of Uptane.