katja: Show only updates
This commit is contained in:
@ -3,6 +3,25 @@
|
||||
* 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/.
|
||||
*/
|
||||
#include "katja/repository.hpp"
|
||||
|
||||
namespace katja
|
||||
{
|
||||
std::string package_identifier::to_string() const
|
||||
{
|
||||
std::string identifier;
|
||||
const std::size_t total_size = this->name.size() + this->version.size()
|
||||
+ this->architecture.size() + this->data.size() + 3;
|
||||
|
||||
identifier.reserve(total_size);
|
||||
identifier.append(this->name);
|
||||
identifier.push_back(';');
|
||||
identifier.append(this->version);
|
||||
identifier.push_back(';');
|
||||
identifier.append(this->architecture);
|
||||
identifier.push_back(';');
|
||||
identifier.append(this->data);
|
||||
|
||||
return identifier;
|
||||
}
|
||||
}
|
||||
|
@ -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, "\""))
|
||||
@ -112,6 +141,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))
|
||||
{
|
||||
@ -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))
|
||||
{
|
||||
|
Reference in New Issue
Block a user