From d10c5c980c18216db3bb9fb1137866cfd4f836ec Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sat, 19 Apr 2025 14:48:02 +0200 Subject: Initial commit --- include/katja/database.hpp | 39 +++++++++++++++++++++++++++++++++++++++ include/katja/repository.hpp | 32 ++++++++++++++++++++++++++++++++ include/katja/sbo.hpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 include/katja/database.hpp create mode 100644 include/katja/repository.hpp create mode 100644 include/katja/sbo.hpp (limited to 'include') diff --git a/include/katja/database.hpp b/include/katja/database.hpp new file mode 100644 index 0000000..ca85ab1 --- /dev/null +++ b/include/katja/database.hpp @@ -0,0 +1,39 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +#pragma once + +#include +#include + +namespace katja +{ + constexpr const char *database = "/var/lib/pkgtools/packages"; + + class database_package + { + database_package(std::string&& name, std::string&& version, + std::string&& architecture, std::string&& build_tag); + + static database_package create_database_package(const std::string& fullname); + + public: + const std::string name; + const std::string version; + const std::string architecture; + const std::string build_tag; + + database_package(const std::string& fullname); + + bool operator<(const database_package& that) const; + bool operator>(const database_package& that) const; + + std::string to_string() const; + }; + + using package_database = std::multimap; + + package_database read_installed_database(); +} diff --git a/include/katja/repository.hpp b/include/katja/repository.hpp new file mode 100644 index 0000000..cde9ca0 --- /dev/null +++ b/include/katja/repository.hpp @@ -0,0 +1,32 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +#pragma once + +#include +#include + +#include "katja/database.hpp" + +namespace katja +{ + struct package_identifier + { + const std::string name; + const std::string version; + const std::string architecture; + const std::string data; + + std::string to_string() const; + }; + + class repository + { + public: + virtual std::vector get_updates(const package_database& database) = 0; + virtual std::vector search_names(const std::string& architecture, + const std::string& needle) = 0; + }; +} diff --git a/include/katja/sbo.hpp b/include/katja/sbo.hpp new file mode 100644 index 0000000..ba46509 --- /dev/null +++ b/include/katja/sbo.hpp @@ -0,0 +1,44 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +#pragma once + +#include +#include +#include +#include + +#include "katja/repository.hpp" + +namespace katja +{ + struct info_file + { + const std::string program_name; + const std::string version; + const std::string homepage; + const std::string email; + const std::string maintainer; + + info_file(const std::string& program_name, const std::string& version, + const std::string homepage, const std::string& email, const std::string& maintainer); + + package_identifier identifier_for(const std::string& architecture); + }; + + class sbo_repository final : public repository + { + std::map info_paths; + + public: + sbo_repository(const std::filesystem::path& repository_path); + + std::vector get_updates(const package_database& database) override; + std::vector search_names(const std::string& architecture, + const std::string& needle) override; + }; + + std::optional read_slackbuild_info(const std::filesystem::path& info_filepath); +} -- cgit v1.2.3