Migrate Pkgtools char pointer fields to strings
This commit is contained in:
+1
-12
@@ -17,15 +17,4 @@ include_directories(${CMAKE_BINARY_DIR}/generated/)
|
|||||||
|
|
||||||
target_link_libraries(backend PkgConfig::deps CURL::libcurl)
|
target_link_libraries(backend PkgConfig::deps CURL::libcurl)
|
||||||
|
|
||||||
# configure_file(
|
file(COPY metadata.db DESTINATION ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LOCALSTATEDIR})
|
||||||
# input: 'Slackware.conf.in',
|
|
||||||
# output: 'Slackware.conf',
|
|
||||||
# configuration: slackware_config_data,
|
|
||||||
# install: true,
|
|
||||||
# install_dir: join_paths(get_option('sysconfdir'), 'PackageKit'),
|
|
||||||
# )
|
|
||||||
|
|
||||||
# install_data(
|
|
||||||
# 'metadata.db',
|
|
||||||
# install_dir: join_paths(get_option('localstatedir'), 'cache', 'PackageKit', 'metadata'),
|
|
||||||
# )
|
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* 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/.
|
||||||
|
*/
|
||||||
#ifndef CONFIG_H
|
#ifndef CONFIG_H
|
||||||
#define CONFIG_H
|
#define CONFIG_H
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -44,7 +44,7 @@ void pk_backend_initialize(GKeyFile *conf)
|
|||||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||||
|
|
||||||
/* Open the database. We will need it to save the time the configuration file was last modified. */
|
/* Open the database. We will need it to save the time the configuration file was last modified. */
|
||||||
path = g_build_filename(LOCALSTATEDIR, "cache", "PackageKit", "metadata", "metadata.db", nullptr);
|
path = g_build_filename(LOCALSTATEDIR, "cache", "katja", "metadata.db", nullptr);
|
||||||
if (sqlite3_open(path, &db) != SQLITE_OK)
|
if (sqlite3_open(path, &db) != SQLITE_OK)
|
||||||
{
|
{
|
||||||
g_error("%s: %s", path, sqlite3_errmsg(db));
|
g_error("%s: %s", path, sqlite3_errmsg(db));
|
||||||
@@ -137,7 +137,7 @@ JobData *pk_backend_start_job()
|
|||||||
char *db_filename = nullptr;
|
char *db_filename = nullptr;
|
||||||
JobData *job_data = g_new0(JobData, 1);
|
JobData *job_data = g_new0(JobData, 1);
|
||||||
|
|
||||||
db_filename = g_build_filename(LOCALSTATEDIR, "cache", "PackageKit", "metadata", "metadata.db", nullptr);
|
db_filename = g_build_filename(LOCALSTATEDIR, "cache", "katja", "metadata.db", nullptr);
|
||||||
if (sqlite3_open(db_filename, &job_data->db) == SQLITE_OK) { /* Some SQLite settings */
|
if (sqlite3_open(db_filename, &job_data->db) == SQLITE_OK) { /* Some SQLite settings */
|
||||||
sqlite3_exec(job_data->db, "PRAGMA foreign_keys = ON", nullptr, nullptr, nullptr);
|
sqlite3_exec(job_data->db, "PRAGMA foreign_keys = ON", nullptr, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
@@ -484,7 +484,7 @@ void pk_backend_install_packages(JobData *job_data, char **package_ids)
|
|||||||
percent_step = 100.0 / g_slist_length(install_list) / 2;
|
percent_step = 100.0 / g_slist_length(install_list) / 2;
|
||||||
|
|
||||||
/* Download the packages */
|
/* Download the packages */
|
||||||
dest_dir_name = g_build_filename(LOCALSTATEDIR, "cache", "PackageKit", "downloads", nullptr);
|
dest_dir_name = g_build_filename(LOCALSTATEDIR, "cache", "katja", "downloads", nullptr);
|
||||||
for (l = install_list, i = 0; l; l = g_slist_next(l), i++)
|
for (l = install_list, i = 0; l; l = g_slist_next(l), i++)
|
||||||
{
|
{
|
||||||
char **tokens;
|
char **tokens;
|
||||||
@@ -652,7 +652,7 @@ void pk_backend_update_packages(JobData *job_data, char **package_ids)
|
|||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
/* Download the packages */
|
/* Download the packages */
|
||||||
dest_dir_name = g_build_filename(LOCALSTATEDIR, "cache", "PackageKit", "downloads", nullptr);
|
dest_dir_name = g_build_filename(LOCALSTATEDIR, "cache", "katja", "downloads", nullptr);
|
||||||
for (i = 0; package_ids[i]; i++)
|
for (i = 0; package_ids[i]; i++)
|
||||||
{
|
{
|
||||||
char **tokens = g_strsplit(package_ids[i], ";", 4);
|
char **tokens = g_strsplit(package_ids[i], ";", 4);
|
||||||
@@ -691,7 +691,7 @@ void pk_backend_refresh_cache(JobData *job_data, bool force)
|
|||||||
sqlite3_stmt *stmt = nullptr;
|
sqlite3_stmt *stmt = nullptr;
|
||||||
|
|
||||||
/* Create temporary directory */
|
/* Create temporary directory */
|
||||||
tmp_dir_name = g_dir_make_tmp("PackageKit.XXXXXX", &err);
|
tmp_dir_name = g_dir_make_tmp("katja.XXXXXX", &err);
|
||||||
if (!tmp_dir_name)
|
if (!tmp_dir_name)
|
||||||
{
|
{
|
||||||
std::cerr << err->message << std::endl;
|
std::cerr << err->message << std::endl;
|
||||||
@@ -702,7 +702,7 @@ void pk_backend_refresh_cache(JobData *job_data, bool force)
|
|||||||
/* Force the complete cache refresh if the read configuration file is newer than the metadata cache */
|
/* Force the complete cache refresh if the read configuration file is newer than the metadata cache */
|
||||||
if (!force)
|
if (!force)
|
||||||
{
|
{
|
||||||
path = g_build_filename(LOCALSTATEDIR, "cache", "PackageKit", "metadata", "metadata.db", nullptr);
|
path = g_build_filename(LOCALSTATEDIR, "cache", "katja", "metadata.db", nullptr);
|
||||||
db_file = g_file_new_for_path(path);
|
db_file = g_file_new_for_path(path);
|
||||||
file_info = g_file_query_info(db_file, "time::modified-usec", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, nullptr, &err);
|
file_info = g_file_query_info(db_file, "time::modified-usec", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, nullptr, &err);
|
||||||
if (err)
|
if (err)
|
||||||
|
|||||||
+28
-40
@@ -10,6 +10,8 @@ module;
|
|||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
#include <string>
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
export module katja.pkgtools;
|
export module katja.pkgtools;
|
||||||
|
|
||||||
@@ -21,39 +23,29 @@ class Pkgtools
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* katja::Pkgtools::get_name:
|
* Repository name.
|
||||||
*
|
*/
|
||||||
* Retrieves the repository name.
|
const std::string name;
|
||||||
*
|
|
||||||
* Returns: Repository name.
|
|
||||||
**/
|
|
||||||
const char *get_name() const noexcept
|
|
||||||
{
|
|
||||||
return this->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* katja::Pkgtools::get_mirror:
|
* Repository mirror.
|
||||||
*
|
*/
|
||||||
* Retrieves the repository mirror.
|
const std::string mirror;
|
||||||
*
|
|
||||||
* Returns: Repository mirror.
|
|
||||||
**/
|
|
||||||
const char *get_mirror() const noexcept
|
|
||||||
{
|
|
||||||
return this->mirror;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* katja::Pkgtools::get_order:
|
* Repository order.
|
||||||
*
|
*/
|
||||||
* Retrieves the repository order.
|
const std::uint8_t order;
|
||||||
*
|
|
||||||
* Returns: Repository order.
|
/**
|
||||||
**/
|
* katja::Pkgtools::Pkgtools:
|
||||||
std::uint8_t get_order() const noexcept
|
* @name: Repository name.
|
||||||
|
* @mirror: Repository mirror.
|
||||||
|
* @order: Repository order.
|
||||||
|
*/
|
||||||
|
Pkgtools(const std::string& name, const std::string& mirror, std::uint8_t order)
|
||||||
|
: name(name), mirror(mirror), order(order)
|
||||||
{
|
{
|
||||||
return this->order;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,10 +56,9 @@ public:
|
|||||||
*
|
*
|
||||||
* Returns: %TRUE if the package is blacklisted, %FALSE otherwise.
|
* Returns: %TRUE if the package is blacklisted, %FALSE otherwise.
|
||||||
**/
|
**/
|
||||||
bool is_blacklisted(const char *pkg) const noexcept
|
bool is_blacklisted(const std::string_view& pkg) const noexcept
|
||||||
{
|
{
|
||||||
return this->blacklist
|
return std::regex_match(std::cbegin(pkg), std::cend(pkg), this->blacklist);
|
||||||
&& g_regex_match (this->blacklist, pkg, static_cast<GRegexMatchFlags>(0), nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~Pkgtools() noexcept
|
virtual ~Pkgtools() noexcept
|
||||||
@@ -101,12 +92,12 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
sqlite3_bind_text(statement, 1, pkg_name, -1, SQLITE_TRANSIENT);
|
sqlite3_bind_text(statement, 1, pkg_name, -1, SQLITE_TRANSIENT);
|
||||||
sqlite3_bind_int(statement, 2, this->get_order());
|
sqlite3_bind_int(statement, 2, this->order);
|
||||||
|
|
||||||
if (sqlite3_step(statement) == SQLITE_ROW)
|
if (sqlite3_step(statement) == SQLITE_ROW)
|
||||||
{
|
{
|
||||||
dest_filename = g_build_filename(dest_dir_name, sqlite3_column_text(statement, 1), nullptr);
|
dest_filename = g_build_filename(dest_dir_name, sqlite3_column_text(statement, 1), nullptr);
|
||||||
source_url = g_strconcat(this->get_mirror(),
|
source_url = g_strconcat(this->mirror.c_str(),
|
||||||
sqlite3_column_text(statement, 0),
|
sqlite3_column_text(statement, 0),
|
||||||
"/",
|
"/",
|
||||||
sqlite3_column_text(statement, 1),
|
sqlite3_column_text(statement, 1),
|
||||||
@@ -150,13 +141,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
sqlite3_bind_text(statement, 1, pkg_name, -1, SQLITE_TRANSIENT);
|
sqlite3_bind_text(statement, 1, pkg_name, -1, SQLITE_TRANSIENT);
|
||||||
sqlite3_bind_int(statement, 2, this->get_order());
|
sqlite3_bind_int(statement, 2, this->order);
|
||||||
|
|
||||||
if (sqlite3_step(statement) == SQLITE_ROW)
|
if (sqlite3_step(statement) == SQLITE_ROW)
|
||||||
{
|
{
|
||||||
pkg_filename = g_build_filename(LOCALSTATEDIR,
|
pkg_filename = g_build_filename(LOCALSTATEDIR,
|
||||||
"cache",
|
"cache",
|
||||||
"PackageKit",
|
"katja",
|
||||||
"downloads",
|
"downloads",
|
||||||
sqlite3_column_text(statement, 0),
|
sqlite3_column_text(statement, 0),
|
||||||
nullptr);
|
nullptr);
|
||||||
@@ -173,10 +164,7 @@ public:
|
|||||||
virtual void generate_cache(JobData *job_data, const char *tmpl) noexcept = 0;
|
virtual void generate_cache(JobData *job_data, const char *tmpl) noexcept = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
char *name = nullptr;
|
std::regex blacklist;
|
||||||
char *mirror = nullptr;
|
|
||||||
std::uint8_t order;
|
|
||||||
GRegex *blacklist = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -186,6 +174,6 @@ int cmp_repo(const void *a, const void *b)
|
|||||||
{
|
{
|
||||||
auto repo = static_cast<const Pkgtools *> (a);
|
auto repo = static_cast<const Pkgtools *> (a);
|
||||||
|
|
||||||
return g_strcmp0(repo->get_name(), (char *) b);
|
return g_strcmp0(repo->name.c_str(), (char *) b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+31
-58
@@ -13,6 +13,9 @@ module;
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
#include <string>
|
||||||
|
#include <regex>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
export module katja.slackpkg;
|
export module katja.slackpkg;
|
||||||
|
|
||||||
@@ -36,30 +39,18 @@ public:
|
|||||||
*
|
*
|
||||||
* Returns: New #katja::Slackpkg.
|
* Returns: New #katja::Slackpkg.
|
||||||
**/
|
**/
|
||||||
Slackpkg(const char *name, const char *mirror,
|
Slackpkg(const std::string& name, const std::string& mirror,
|
||||||
std::uint8_t order, const char *blacklist, char **priority) noexcept
|
std::uint8_t order, const char *blacklist, char **priority) noexcept
|
||||||
|
: Pkgtools(name, mirror, order)
|
||||||
{
|
{
|
||||||
GRegex *regex;
|
if (blacklist != nullptr)
|
||||||
|
|
||||||
if (blacklist)
|
|
||||||
{
|
{
|
||||||
regex = static_cast<GRegex *>(g_regex_new(blacklist,
|
this->blacklist = std::regex(blacklist);
|
||||||
G_REGEX_OPTIMIZE, static_cast<GRegexMatchFlags>(0), nullptr));
|
|
||||||
}
|
}
|
||||||
else
|
for (char **cur_priority = priority; *cur_priority; cur_priority++)
|
||||||
{
|
{
|
||||||
regex = nullptr;
|
this->priority.emplace_back(*cur_priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->name = g_strdup (name);
|
|
||||||
this->mirror = g_strdup (mirror);
|
|
||||||
|
|
||||||
this->order = order;
|
|
||||||
|
|
||||||
this->blacklist = regex;
|
|
||||||
|
|
||||||
this->priority = priority;
|
|
||||||
|
|
||||||
// Initialize category map
|
// Initialize category map
|
||||||
if (cat_map == nullptr)
|
if (cat_map == nullptr)
|
||||||
{
|
{
|
||||||
@@ -83,21 +74,6 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~Slackpkg() noexcept
|
|
||||||
{
|
|
||||||
if (this->blacklist)
|
|
||||||
{
|
|
||||||
g_regex_unref(this->blacklist);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free(this->name);
|
|
||||||
g_free(this->mirror);
|
|
||||||
if (this->priority)
|
|
||||||
{
|
|
||||||
g_strfreev(this->priority);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* katja::Slackpkg::collect_cache_info:
|
* katja::Slackpkg::collect_cache_info:
|
||||||
* @tmpl: temporary directory for downloading the files.
|
* @tmpl: temporary directory for downloading the files.
|
||||||
@@ -107,7 +83,7 @@ public:
|
|||||||
*
|
*
|
||||||
* Returns: List of files needed for building the cache.
|
* Returns: List of files needed for building the cache.
|
||||||
**/
|
**/
|
||||||
GSList *collect_cache_info(const char *tmpl) noexcept
|
GSList *collect_cache_info(const char *tmpl) noexcept
|
||||||
{
|
{
|
||||||
CURL *curl = nullptr;
|
CURL *curl = nullptr;
|
||||||
char **source_dest;
|
char **source_dest;
|
||||||
@@ -116,15 +92,15 @@ public:
|
|||||||
|
|
||||||
/* Create the temporary directory for the repository */
|
/* Create the temporary directory for the repository */
|
||||||
tmp_dir = g_file_new_for_path(tmpl);
|
tmp_dir = g_file_new_for_path(tmpl);
|
||||||
repo_tmp_dir = g_file_get_child(tmp_dir, this->get_name());
|
repo_tmp_dir = g_file_get_child(tmp_dir, this->name.c_str());
|
||||||
g_file_make_directory(repo_tmp_dir, nullptr, nullptr);
|
g_file_make_directory(repo_tmp_dir, nullptr, nullptr);
|
||||||
|
|
||||||
/* Download PACKAGES.TXT. These files are most important, break if some of them couldn't be found */
|
/* Download PACKAGES.TXT. These files are most important, break if some of them couldn't be found */
|
||||||
for (char **cur_priority = this->priority; *cur_priority; cur_priority++)
|
for (const std::string& current_priority : this->priority)
|
||||||
{
|
{
|
||||||
source_dest = static_cast<char **> (g_malloc_n(3, sizeof(char *)));
|
source_dest = static_cast<char **> (g_malloc_n(3, sizeof(char *)));
|
||||||
source_dest[0] = g_strconcat(this->get_mirror(), *cur_priority, "/PACKAGES.TXT", nullptr);
|
source_dest[0] = g_strconcat(this->mirror.c_str(), current_priority.c_str(), "/PACKAGES.TXT", nullptr);
|
||||||
source_dest[1] = g_build_filename(tmpl, this->get_name(), "PACKAGES.TXT", nullptr);
|
source_dest[1] = g_build_filename(tmpl, this->name.c_str(), "PACKAGES.TXT", nullptr);
|
||||||
source_dest[2] = nullptr;
|
source_dest[2] = nullptr;
|
||||||
|
|
||||||
if (get_file(&curl, source_dest[0], nullptr) == CURLE_OK)
|
if (get_file(&curl, source_dest[0], nullptr) == CURLE_OK)
|
||||||
@@ -140,8 +116,8 @@ public:
|
|||||||
|
|
||||||
/* Download file lists if available */
|
/* Download file lists if available */
|
||||||
source_dest = static_cast<char **> (g_malloc_n(3, sizeof(char *)));
|
source_dest = static_cast<char **> (g_malloc_n(3, sizeof(char *)));
|
||||||
source_dest[0] = g_strconcat(this->get_mirror(), *cur_priority, "/MANIFEST.bz2", nullptr);
|
source_dest[0] = g_strconcat(this->mirror.c_str(), current_priority.c_str(), "/MANIFEST.bz2", nullptr);
|
||||||
source_dest[1] = g_strconcat(tmpl, "/", this->get_name(), "/", *cur_priority, "-MANIFEST.bz2", nullptr);
|
source_dest[1] = g_strconcat(tmpl, "/", this->name.c_str(), "/", *current_priority.c_str(), "-MANIFEST.bz2", nullptr);
|
||||||
source_dest[2] = nullptr;
|
source_dest[2] = nullptr;
|
||||||
if (get_file(&curl, source_dest[0], nullptr) == CURLE_OK)
|
if (get_file(&curl, source_dest[0], nullptr) == CURLE_OK)
|
||||||
{
|
{
|
||||||
@@ -173,7 +149,7 @@ public:
|
|||||||
*
|
*
|
||||||
* Returns: List of files needed for building the cache.
|
* Returns: List of files needed for building the cache.
|
||||||
**/
|
**/
|
||||||
void generate_cache(JobData *job_data, const char *tmpl) noexcept
|
void generate_cache(JobData *job_data, const char *tmpl) noexcept
|
||||||
{
|
{
|
||||||
char **pkg_tokens = nullptr;
|
char **pkg_tokens = nullptr;
|
||||||
char *query = nullptr, *filename = nullptr, *location = nullptr, *summary = nullptr, *line, *packages_txt;
|
char *query = nullptr, *filename = nullptr, *location = nullptr, *summary = nullptr, *line, *packages_txt;
|
||||||
@@ -187,7 +163,7 @@ public:
|
|||||||
sqlite3_stmt *statement;
|
sqlite3_stmt *statement;
|
||||||
|
|
||||||
/* Check if the temporary directory for this repository exists, then the file metadata have to be generated */
|
/* Check if the temporary directory for this repository exists, then the file metadata have to be generated */
|
||||||
packages_txt = g_build_filename(tmpl, this->get_name(), "PACKAGES.TXT", nullptr);
|
packages_txt = g_build_filename(tmpl, this->name.c_str(), "PACKAGES.TXT", nullptr);
|
||||||
list_file = g_file_new_for_path(packages_txt);
|
list_file = g_file_new_for_path(packages_txt);
|
||||||
fin = g_file_read(list_file, nullptr, nullptr);
|
fin = g_file_read(list_file, nullptr, nullptr);
|
||||||
g_object_unref(list_file);
|
g_object_unref(list_file);
|
||||||
@@ -203,7 +179,7 @@ public:
|
|||||||
&statement,
|
&statement,
|
||||||
nullptr) == SQLITE_OK)
|
nullptr) == SQLITE_OK)
|
||||||
{
|
{
|
||||||
sqlite3_bind_text(statement, 1, this->get_name(), -1, SQLITE_TRANSIENT);
|
sqlite3_bind_text(statement, 1, this->name.c_str(), -1, SQLITE_TRANSIENT);
|
||||||
sqlite3_step(statement);
|
sqlite3_step(statement);
|
||||||
sqlite3_finalize(statement);
|
sqlite3_finalize(statement);
|
||||||
}
|
}
|
||||||
@@ -215,8 +191,8 @@ public:
|
|||||||
{
|
{
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
sqlite3_bind_int(statement, 1, this->get_order());
|
sqlite3_bind_int(statement, 1, this->order);
|
||||||
sqlite3_bind_text(statement, 2, this->get_name(), -1, SQLITE_TRANSIENT);
|
sqlite3_bind_text(statement, 2, this->name.c_str(), -1, SQLITE_TRANSIENT);
|
||||||
sqlite3_step(statement);
|
sqlite3_step(statement);
|
||||||
sqlite3_finalize(statement);
|
sqlite3_finalize(statement);
|
||||||
|
|
||||||
@@ -244,7 +220,7 @@ public:
|
|||||||
"ext = @ext, location = @location, summary = @summary, "
|
"ext = @ext, location = @location, summary = @summary, "
|
||||||
"desc = @desc, compressed = @compressed, uncompressed = @uncompressed "
|
"desc = @desc, compressed = @compressed, uncompressed = @uncompressed "
|
||||||
"WHERE name LIKE @name AND repo_order = %u",
|
"WHERE name LIKE @name AND repo_order = %u",
|
||||||
this->get_order());
|
this->order);
|
||||||
if (sqlite3_prepare_v2(job_data->db, query, -1, &update_statement, nullptr) != SQLITE_OK)
|
if (sqlite3_prepare_v2(job_data->db, query, -1, &update_statement, nullptr) != SQLITE_OK)
|
||||||
{
|
{
|
||||||
goto out;
|
goto out;
|
||||||
@@ -316,7 +292,7 @@ public:
|
|||||||
{
|
{
|
||||||
statement = insert_default_statement;
|
statement = insert_default_statement;
|
||||||
}
|
}
|
||||||
sqlite3_bind_int(statement, 11, this->get_order());
|
sqlite3_bind_int(statement, 11, this->order);
|
||||||
}
|
}
|
||||||
else /* Update package information if it is a patch */
|
else /* Update package information if it is a patch */
|
||||||
{
|
{
|
||||||
@@ -354,9 +330,9 @@ public:
|
|||||||
g_object_unref(data_in);
|
g_object_unref(data_in);
|
||||||
|
|
||||||
/* Parse MANIFEST.bz2 */
|
/* Parse MANIFEST.bz2 */
|
||||||
for (char **p = this->priority; *p; p++)
|
for (const std::string& current_priority : this->priority)
|
||||||
{
|
{
|
||||||
filename = g_strconcat(*p, "-MANIFEST.bz2", nullptr);
|
filename = g_strconcat(current_priority.c_str(), "-MANIFEST.bz2", nullptr);
|
||||||
manifest(job_data, tmpl, filename);
|
manifest(job_data, tmpl, filename);
|
||||||
g_free(filename);
|
g_free(filename);
|
||||||
}
|
}
|
||||||
@@ -373,9 +349,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static inline GHashTable *cat_map{ nullptr };
|
static inline GHashTable *cat_map{ nullptr };
|
||||||
static const std::size_t max_buf_size = 8192;
|
static const std::size_t max_buf_size = 8192;
|
||||||
char **priority = nullptr;
|
std::vector<std::string> priority;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* katja::Slackpkg::manifest:
|
* katja::Slackpkg::manifest:
|
||||||
@@ -386,7 +362,7 @@ private:
|
|||||||
* Parse the manifest file and save the file list in the database.
|
* Parse the manifest file and save the file list in the database.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void manifest(JobData *job_data, const char *tmpl, char *filename) noexcept
|
void manifest(JobData *job_data, const char *tmpl, char *filename) noexcept
|
||||||
{
|
{
|
||||||
FILE *manifest;
|
FILE *manifest;
|
||||||
int err, read_len;
|
int err, read_len;
|
||||||
@@ -399,10 +375,7 @@ private:
|
|||||||
GMatchInfo *match_info;
|
GMatchInfo *match_info;
|
||||||
sqlite3_stmt *statement = nullptr;
|
sqlite3_stmt *statement = nullptr;
|
||||||
|
|
||||||
path = g_build_filename(tmpl,
|
path = g_build_filename(tmpl, this->name.c_str(), filename, nullptr);
|
||||||
this->get_name(),
|
|
||||||
filename,
|
|
||||||
nullptr);
|
|
||||||
manifest = fopen(path, "rb");
|
manifest = fopen(path, "rb");
|
||||||
g_free(path);
|
g_free(path);
|
||||||
|
|
||||||
|
|||||||
@@ -1,98 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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/.
|
|
||||||
*/
|
|
||||||
#include <cstdint>
|
|
||||||
#include "pk-backend.h"
|
|
||||||
#include <pk-backend-job.h>
|
|
||||||
|
|
||||||
void *
|
|
||||||
pk_backend_job_get_user_data (PkBackendJob *job)
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
pk_backend_job_set_user_data (PkBackendJob *job, void *user_data)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
pk_backend_job_set_allow_cancel (PkBackendJob *job, bool allow_cancel)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
pk_backend_job_package (PkBackendJob *job,
|
|
||||||
PkInfoEnum info,
|
|
||||||
const char *package_id,
|
|
||||||
const char *summary)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
pk_backend_job_set_status (PkBackendJob *job, PkStatusEnum status)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
pk_backend_job_set_percentage (PkBackendJob *job, unsigned percentage)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
pk_backend_job_error_code (PkBackendJob *job,
|
|
||||||
PkErrorEnum error_code, const char *format, ...)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
pk_backend_job_files (PkBackendJob *job,
|
|
||||||
const char *package_id, char **files)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
pk_backend_job_details (PkBackendJob *job,
|
|
||||||
const char *package_id,
|
|
||||||
const char *summary,
|
|
||||||
const char *license,
|
|
||||||
PkGroupEnum group,
|
|
||||||
const char *description,
|
|
||||||
const char *url,
|
|
||||||
unsigned long size,
|
|
||||||
std::uint64_t download_size)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
pk_backend_job_update_detail (PkBackendJob *job,
|
|
||||||
const char *package_id,
|
|
||||||
char **updates,
|
|
||||||
char **obsoletes,
|
|
||||||
char **vendor_urls,
|
|
||||||
char **bugzilla_urls,
|
|
||||||
char **cve_urls,
|
|
||||||
PkRestartEnum restart,
|
|
||||||
const char *update_text,
|
|
||||||
const char *changelog,
|
|
||||||
PkUpdateStateEnum state,
|
|
||||||
const char *issued,
|
|
||||||
const char *updated)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
pk_backend_job_thread_create (PkBackendJob *job,
|
|
||||||
PkBackendJobThreadFunc func,
|
|
||||||
void *user_data,
|
|
||||||
GDestroyNotify destroy_func)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool pk_directory_remove_contents (const char *directory)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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/.
|
|
||||||
*/
|
|
||||||
#include "dl.h"
|
|
||||||
|
|
||||||
using namespace slack;
|
|
||||||
|
|
||||||
static void
|
|
||||||
slack_test_dl_construct()
|
|
||||||
{
|
|
||||||
auto dl = new Dl ("some", "mirror", 1, nullptr, nullptr);
|
|
||||||
|
|
||||||
g_assert_cmpstr (dl->get_name (), ==, "some");
|
|
||||||
g_assert_cmpstr (dl->get_mirror (), ==, "mirror");
|
|
||||||
g_assert_cmpuint (dl->get_order (), ==, 1);
|
|
||||||
g_assert_false (dl->is_blacklisted ("pattern"));
|
|
||||||
|
|
||||||
delete dl;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
g_test_init(&argc, &argv, nullptr);
|
|
||||||
|
|
||||||
g_test_add_func("/slack/dl/construct", slack_test_dl_construct);
|
|
||||||
|
|
||||||
return g_test_run();
|
|
||||||
}
|
|
||||||
@@ -3,28 +3,19 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/.
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
#include "slackpkg.h"
|
#define BOOST_TEST_MODULE slackpkg tests
|
||||||
|
|
||||||
using namespace slack;
|
#include <boost/test/unit_test.hpp>
|
||||||
|
import katja.slackpkg;
|
||||||
|
|
||||||
static void
|
BOOST_AUTO_TEST_CASE(slack_test_slackpkg_construct)
|
||||||
slack_test_slackpkg_construct()
|
|
||||||
{
|
{
|
||||||
auto slackpkg = new Slackpkg ("some", "mirror", 1, nullptr, nullptr);
|
auto slackpkg = new Slackpkg("some", "mirror", 1, nullptr, nullptr);
|
||||||
|
|
||||||
g_assert_cmpstr(slackpkg->get_name (), ==, "some");
|
BOOST_TEST(strcmp(slackpkg->get_name(), "some") == 0);
|
||||||
g_assert_cmpstr(slackpkg->get_mirror (), ==, "mirror");
|
BOOST_TEST(strcmp(slackpkg->get_mirror(), "mirror") == 0);
|
||||||
g_assert_cmpuint(slackpkg->get_order (), ==, 1);
|
BOOST_TEST(slackpkg->get_order() == 1);
|
||||||
g_assert_false (slackpkg->is_blacklisted ("pattern"));
|
BOOST_TEST(!slackpkg->is_blacklisted("pattern"));
|
||||||
|
|
||||||
delete slackpkg;
|
delete slackpkg;
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
g_test_init(&argc, &argv, nullptr);
|
|
||||||
|
|
||||||
g_test_add_func("/slack/slackpkg/construct", slack_test_slackpkg_construct);
|
|
||||||
|
|
||||||
return g_test_run();
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user