aboutsummaryrefslogtreecommitdiff
path: root/katja/sbo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'katja/sbo.cpp')
-rw-r--r--katja/sbo.cpp53
1 files changed, 47 insertions, 6 deletions
diff --git a/katja/sbo.cpp b/katja/sbo.cpp
index 161e834..f358b03 100644
--- a/katja/sbo.cpp
+++ b/katja/sbo.cpp
@@ -17,6 +17,35 @@ namespace katja
{
}
+ sbo_repository::sbo_repository(const std::filesystem::path& repository_path)
+ {
+ search_for_slackbuilds(this->info_paths, repository_path);
+ }
+
+ std::vector<package_identifier> sbo_repository::get_updates(const package_database& database)
+ {
+ std::vector<package_identifier> identifiers;
+
+ for (const auto& [package_name, package] : database)
+ {
+ auto looked_up_info_path = this->info_paths.find(package_name);
+
+ if (looked_up_info_path != this->info_paths.cend())
+ {
+ auto slackbuild_info = read_slackbuild_info(looked_up_info_path->second);
+
+ if (slackbuild_info.has_value() && slackbuild_info.value().version != package.version)
+ {
+ identifiers.push_back({
+ slackbuild_info->program_name, slackbuild_info->version, package.architecture, "SBo"
+ });
+ }
+
+ }
+ }
+ return identifiers;
+ }
+
bool trim_info_line(std::string& info_value)
{
if (boost::algorithm::ends_with(info_value, "\""))
@@ -113,6 +142,23 @@ namespace katja
void search_for_slackbuilds(std::vector<info_file>& info_files, const std::filesystem::path& directory)
{
+ std::map<std::string, std::filesystem::path> info_paths;
+
+ search_for_slackbuilds(info_paths, directory);
+ for (const auto& [_, info_filepath] : info_paths)
+ {
+ auto slackbuild_info = read_slackbuild_info(info_filepath);
+
+ if (slackbuild_info.has_value())
+ {
+ info_files.emplace_back(std::move(slackbuild_info.value()));
+ }
+ }
+ }
+
+ void search_for_slackbuilds(std::map<std::string, std::filesystem::path>& info_files,
+ const std::filesystem::path& directory)
+ {
for (const auto& entry : std::filesystem::directory_iterator(directory))
{
std::filesystem::path entry_path = entry;
@@ -123,12 +169,7 @@ namespace katja
if (std::filesystem::exists(info_filepath))
{
- auto slackbuild_info = read_slackbuild_info(info_filepath);
-
- if (slackbuild_info.has_value())
- {
- info_files.emplace_back(std::move(slackbuild_info.value()));
- }
+ info_files.emplace(entry_path.filename(), info_filepath);
}
else if (std::filesystem::is_directory(entry_path))
{