From 33997584fb8ce43bae79b4367b01b635dd38db36 Mon Sep 17 00:00:00 2001 From: Mykhaylo Sul Date: Wed, 11 Dec 2019 12:48:27 +0200 Subject: [PATCH] OLPSUP-8795: Import a hash of an initially installed version from the file prepared by the bitbake process Signed-off-by: Mykhaylo Sul --- src/aktualizr_secondary/aktualizr_secondary_common.cc | 2 ++ src/aktualizr_secondary/aktualizr_secondary_config.cc | 2 ++ src/aktualizr_secondary/aktualizr_secondary_config.h | 1 + src/libaktualizr/storage/invstorage.h | 2 +- 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/aktualizr_secondary/aktualizr_secondary_common.cc b/src/aktualizr_secondary/aktualizr_secondary_common.cc index 3121ebdea5..1bcde1cc81 100644 --- a/src/aktualizr_secondary/aktualizr_secondary_common.cc +++ b/src/aktualizr_secondary/aktualizr_secondary_common.cc @@ -57,5 +57,7 @@ bool AktualizrSecondaryCommon::uptaneInitialize() { ecu_serial_ = ecu_serials[0].first; hardware_id_ = ecu_serials[0].second; + storage_->importInstalledVersions(config_.import.base_path); + return true; } diff --git a/src/aktualizr_secondary/aktualizr_secondary_config.cc b/src/aktualizr_secondary/aktualizr_secondary_config.cc index c3ff1c109b..d6988af919 100644 --- a/src/aktualizr_secondary/aktualizr_secondary_config.cc +++ b/src/aktualizr_secondary/aktualizr_secondary_config.cc @@ -95,6 +95,7 @@ void AktualizrSecondaryConfig::updateFromPropertyTree(const boost::property_tree CopySubtreeFromConfig(p11, "p11", pt); CopySubtreeFromConfig(pacman, "pacman", pt); CopySubtreeFromConfig(storage, "storage", pt); + CopySubtreeFromConfig(import, "import", pt); } void AktualizrSecondaryConfig::writeToStream(std::ostream& sink) const { @@ -107,6 +108,7 @@ void AktualizrSecondaryConfig::writeToStream(std::ostream& sink) const { WriteSectionToStream(p11, "p11", sink); WriteSectionToStream(pacman, "pacman", sink); WriteSectionToStream(storage, "storage", sink); + WriteSectionToStream(import, "import", sink); } std::ostream& operator<<(std::ostream& os, const AktualizrSecondaryConfig& cfg) { diff --git a/src/aktualizr_secondary/aktualizr_secondary_config.h b/src/aktualizr_secondary/aktualizr_secondary_config.h index 028d2439f4..b360b97536 100644 --- a/src/aktualizr_secondary/aktualizr_secondary_config.h +++ b/src/aktualizr_secondary/aktualizr_secondary_config.h @@ -58,6 +58,7 @@ class AktualizrSecondaryConfig : public BaseConfig { PackageConfig pacman; BootloaderConfig bootloader; StorageConfig storage; + ImportConfig import; private: void updateFromCommandLine(const boost::program_options::variables_map& cmd); diff --git a/src/libaktualizr/storage/invstorage.h b/src/libaktualizr/storage/invstorage.h index 80c4d4ec36..119d25094f 100644 --- a/src/libaktualizr/storage/invstorage.h +++ b/src/libaktualizr/storage/invstorage.h @@ -214,6 +214,7 @@ class INvStorage { bool loadPrimaryInstallationLog(std::vector* log, bool only_installed) { return loadInstallationLog("", log, only_installed); } + void importInstalledVersions(const boost::filesystem::path& base_path); private: void importSimple(const boost::filesystem::path& base_path, store_data_t store_func, load_data_t load_func, @@ -222,7 +223,6 @@ class INvStorage { const BasedPath& imported_data_path); void importPrimaryKeys(const boost::filesystem::path& base_path, const BasedPath& import_pubkey_path, const BasedPath& import_privkey_path); - void importInstalledVersions(const boost::filesystem::path& base_path); protected: const StorageConfig config_;