diff options
Diffstat (limited to 'src/sbo.h')
| -rw-r--r-- | src/sbo.h | 73 |
1 files changed, 73 insertions, 0 deletions
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 <boost/process.hpp> +#include <filesystem> +#include <map> +#include <boost/multi_index_container.hpp> +#include <boost/multi_index/ordered_index.hpp> +#include <boost/multi_index/sequenced_index.hpp> + +namespace katja +{ + struct info + { + std::string prgnam; + std::string version; + std::string homepage; + std::vector<std::string> download; + std::vector<std::string> md5sum; + std::vector<std::string> download_x86_64; + std::vector<std::string> md5sum_x86_64; + std::vector<std::string> 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::identity<std::string>>, + boost::multi_index::sequenced<> + > + >; + boost::filesystem::path git_binary; + std::filesystem::path cache_path; + + template<typename... Args> + 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<std::string, std::filesystem::path> collect_packages() const; + + void resolve_dependencies(const std::string& package_name, + const std::unordered_map<std::string, std::filesystem::path>& package_categories, + ordered_set& resolved) const; + + public: + explicit sbo(); + + virtual std::unordered_map<std::string, package> list(const std::set<std::string>& package_names) override; + virtual void refresh() override; + virtual std::forward_list<std::string> check_dependencies(const std::string& package_name) override; + }; +} |
