From 34b10f41aa285e423cccb161342b68ae7275da4b Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sat, 15 Apr 2023 08:43:30 +0200 Subject: Retrieve updatable packages --- src/sbo.h | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/sbo.h (limited to 'src/sbo.h') diff --git a/src/sbo.h b/src/sbo.h new file mode 100644 index 0000000..95a1c53 --- /dev/null +++ b/src/sbo.h @@ -0,0 +1,73 @@ +#pragma once + +#include "package.h" +#include +#include +#include +#include +#include +#include + +namespace katja +{ + struct info + { + std::string prgnam; + std::string version; + std::string homepage; + std::vector download; + std::vector md5sum; + std::vector download_x86_64; + std::vector md5sum_x86_64; + std::vector requires; + std::string maintainer; + std::string email; + }; + + class sbo : public repository + { + using ordered_set = boost::multi_index_container< + std::string, + boost::multi_index::indexed_by< + boost::multi_index::ordered_unique>, + boost::multi_index::sequenced<> + > + >; + boost::filesystem::path git_binary; + std::filesystem::path cache_path; + + template + void git(const std::string& command, const std::filesystem::path& cwd, const Args&... args) const + { + if (cwd.empty()) + { + boost::process::system(git_binary, command, args...); + } + else + { + boost::process::system(git_binary, "-C", cwd.native(), command, args...); + } + } + + info parse_info_file(const std::filesystem::path& package_directory) const; + + /** + * Returns the list of packages in the repository. + * + * @return A map containing package names as key, and its category + * directory name as value. + */ + std::unordered_map collect_packages() const; + + void resolve_dependencies(const std::string& package_name, + const std::unordered_map& package_categories, + ordered_set& resolved) const; + + public: + explicit sbo(); + + virtual std::unordered_map list(const std::set& package_names) override; + virtual void refresh() override; + virtual std::forward_list check_dependencies(const std::string& package_name) override; + }; +} -- cgit v1.2.3