free(buffer);
}
-static int result_callback(pakfire_ctx* ctx, struct pakfire* pakfire,
+static int result_callback(pakfire_ctx* ctx, pakfire_root* root,
pakfire_build* build, pakfire_archive* archive, void* data) {
const struct cli_local_args* local_args = data;
pakfire_package* pkg = NULL;
const char* nevra = pakfire_package_get_string(pkg, PAKFIRE_PKG_NEVRA);
// Fetch the local repository & import the archive
- local = pakfire_get_repo(pakfire, PAKFIRE_REPO_LOCAL);
+ local = pakfire_root_get_repo(root, PAKFIRE_REPO_LOCAL);
if (local) {
r = pakfire_repo_import_archive(local, archive, NULL);
if (r < 0) {
#include "check.h"
-int cli_check(struct pakfire* pakfire, int argc, char* argv[]) {
- return pakfire_check(pakfire, 0);
+int cli_check(pakfire_root* root, int argc, char* argv[]) {
+ return pakfire_root_check(root, 0);
}
#include <pakfire/pakfire.h>
-int cli_check(struct pakfire* pakfire, int argc, char* argv[]);
+int cli_check(pakfire_root* root, int argc, char* argv[]);
#endif /* PAKFIRE_CLI_CHECK_H */
int cli_clean(void* data, int argc, char* argv[]) {
struct cli_global_args* global_args = data;
- struct pakfire* pakfire = NULL;
+ pakfire_root* root = NULL;
int r;
// Parse the command line
if (r)
goto ERROR;
- // Setup Pakfire
- r = cli_setup_pakfire(&pakfire, global_args);
+ // Setup root
+ r = cli_setup_root(&root, global_args);
if (r)
goto ERROR;
// Clean!
- r = pakfire_clean(pakfire, 0);
+ r = pakfire_root_clean(root, 0);
ERROR:
- if (pakfire)
- pakfire_unref(pakfire);
+ if (root)
+ pakfire_root_unref(root);
return r;
}
return 0;
}
-static int do_dist(struct pakfire* pakfire, const char* makefile, const char* resultdir) {
+static int do_dist(pakfire_root* root, const char* makefile, const char* resultdir) {
pakfire_archive* archive = NULL;
const char* filename = NULL;
char path[PATH_MAX];
int r;
// Create the archive
- r = pakfire_dist(pakfire, makefile, &archive);
+ r = pakfire_dist(root, makefile, &archive);
if (r < 0)
goto ERROR;
int cli_dist(void* data, int argc, char* argv[]) {
struct cli_global_args* global_args = data;
struct cli_local_args local_args = {};
- struct pakfire* pakfire = NULL;
+ pakfire_root* root = NULL;
char cwd[PATH_MAX];
int r;
if (!local_args.resultdir)
local_args.resultdir = getcwd(cwd, sizeof(cwd));
- // Setup pakfire
- r = cli_setup_pakfire(&pakfire, global_args);
+ // Setup root
+ r = cli_setup_root(&root, global_args);
if (r)
goto ERROR;
// Process all packages
for (unsigned int i = 0; i < local_args.num_makefiles; i++) {
- r = do_dist(pakfire, local_args.makefiles[i], local_args.resultdir);
+ r = do_dist(root, local_args.makefiles[i], local_args.resultdir);
if (r < 0) {
fprintf(stderr, "Could not dist %s: %s\n", local_args.makefiles[i], strerror(-r));
goto ERROR;
}
ERROR:
- if (pakfire)
- pakfire_unref(pakfire);
+ if (root)
+ pakfire_root_unref(root);
return r;
}
struct cli_global_args* global_args = data;
struct cli_local_args local_args = {};
pakfire_build* build = NULL;
- struct pakfire* pakfire = NULL;
+ pakfire_root* root = NULL;
FILE* f = NULL;
int r;
// Handle OCI images separately
if (pakfire_string_equals(local_args.type, "oci")) {
- // Setup Pakfire
- r = cli_setup_pakfire(&pakfire, global_args);
+ // Setup root
+ r = cli_setup_root(&root, global_args);
if (r < 0)
goto ERROR;
// Install everything
- r = pakfire_install(pakfire, packages);
+ r = pakfire_root_install(root, packages);
if (r < 0)
goto ERROR;
// Create the image
- r = pakfire_oci_mkimage(pakfire, f);
+ r = pakfire_oci_mkimage(root, f);
if (r < 0)
goto ERROR;
ERROR:
if (build)
pakfire_build_unref(build);
- if (pakfire)
- pakfire_unref(pakfire);
+ if (root)
+ pakfire_root_unref(root);
if (f)
fclose(f);
int cli_info(void* data, int argc, char* argv[]) {
struct cli_global_args* global_args = data;
struct cli_local_args local_args = {};
- struct pakfire* pakfire = NULL;
pakfire_packagelist* list = NULL;
+ pakfire_root* root = NULL;
int r;
// Parse the command line
if (r)
goto ERROR;
- // Setup Pakfire
- r = cli_setup_pakfire(&pakfire, global_args);
+ // Setup root
+ r = cli_setup_root(&root, global_args);
if (r)
goto ERROR;
// Perform search
for (unsigned int i = 0; i < local_args.num_packages; i++) {
- r = pakfire_search(pakfire, local_args.packages[i], PAKFIRE_SEARCH_NAME_ONLY, list);
+ r = pakfire_root_search(root, local_args.packages[i], PAKFIRE_ROOT_SEARCH_NAME_ONLY, list);
if (r)
goto ERROR;
}
ERROR:
if (list)
pakfire_packagelist_unref(list);
- if (pakfire)
- pakfire_unref(pakfire);
+ if (root)
+ pakfire_root_unref(root);
return r;
}
int cli_install(void* data, int argc, char* argv[]) {
struct cli_global_args* global_args = data;
struct cli_local_args local_args = {};
- struct pakfire* pakfire = NULL;
+ pakfire_root* root = NULL;
int r;
// Parse the command line
if (r)
goto ERROR;
- // Setup Pakfire
- r = cli_setup_pakfire(&pakfire, global_args);
+ // Setup root
+ r = cli_setup_root(&root, global_args);
if (r)
goto ERROR;
- r = cli_transaction(pakfire, argc, argv, local_args.transaction_flags, __cli_install, &local_args);
+ r = cli_transaction(root, argc, argv, local_args.transaction_flags, __cli_install, &local_args);
ERROR:
- if (pakfire)
- pakfire_unref(pakfire);
+ if (root)
+ pakfire_root_unref(root);
return r;
}
return 0;
}
-static int do_lint(struct pakfire* pakfire, const char* path) {
+static int do_lint(pakfire_root* root, const char* path) {
pakfire_archive* archive = NULL;
int r;
// Open the archive
- r = pakfire_archive_open(&archive, pakfire, path);
+ r = pakfire_archive_open(&archive, root, path);
if (r < 0) {
fprintf(stderr, "Could not open %s: %s\n", path, strerror(-r));
goto ERROR;
int cli_lint(void* data, int argc, char* argv[]) {
struct cli_global_args* global_args = data;
struct cli_local_args local_args = {};
- struct pakfire* pakfire = NULL;
+ pakfire_root* root = NULL;
int r;
// Parse the command line
if (r)
goto ERROR;
- // Setup Pakfire
- r = cli_setup_pakfire(&pakfire, global_args);
+ // Setup root
+ r = cli_setup_root(&root, global_args);
if (r)
goto ERROR;
// Lint all archives
for (unsigned int i = 0; i < local_args.num_archives; i++) {
- r = do_lint(pakfire, local_args.archives[i]);
+ r = do_lint(root, local_args.archives[i]);
if (r < 0)
goto ERROR;
}
ERROR:
- if (pakfire)
- pakfire_unref(pakfire);
+ if (root)
+ pakfire_root_unref(root);
return r;
}
#include "config.h"
#include "pakfire.h"
-static void cli_set_repo_enabled(struct pakfire* pakfire, const char* name, int enabled) {
+static void cli_set_repo_enabled(pakfire_root* root, const char* name, int enabled) {
pakfire_repo* repo = NULL;
// Find the repository
- repo = pakfire_get_repo(pakfire, name);
+ repo = pakfire_root_get_repo(root, name);
// Ignore if the repository could not be found
if (!repo)
return r;
}
-int cli_setup_pakfire(struct pakfire** pakfire, struct cli_global_args* args) {
+int cli_setup_root(pakfire_root** root, struct cli_global_args* args) {
pakfire_config* config = NULL;
- struct pakfire* p = NULL;
+ pakfire_root* p = NULL;
int r;
// Setup the configuration
if (r < 0)
goto ERROR;
- // Initialize Pakfire
- r = pakfire_create(&p, args->ctx, config, args->root, args->arch, args->flags);
+ // Initialize root
+ r = pakfire_root_create(&p, args->ctx, config, args->root, args->arch, args->flags);
if (r < 0) {
fprintf(stderr, "Could not initialize Pakfire: %s\n", strerror(-r));
goto ERROR;
cli_set_repo_enabled(p, args->disable_repos[i], 0);
// Return pointer
- *pakfire = p;
+ *root = p;
ERROR:
if (config)
};
int cli_setup_config(pakfire_config** config, struct cli_global_args* args);
-int cli_setup_pakfire(struct pakfire** pakfire, struct cli_global_args* args);
+int cli_setup_root(pakfire_root** root, struct cli_global_args* args);
int cli_setup_build(pakfire_build** build, struct cli_global_args* args, int flags);
int cli_setup_client(pakfire_client** client, struct cli_global_args* args);
int cli_run_client(struct cli_global_args* args, pakfire_client_ready_callback callback, void* data);
int cli_provides(void* data, int argc, char* argv[]) {
struct cli_global_args* global_args = data;
struct cli_local_args local_args = {};
- struct pakfire* pakfire = NULL;
pakfire_packagelist* list = NULL;
+ pakfire_root* root = NULL;
int r;
// Parse the command line
if (r)
goto ERROR;
- // Setup pakfire
- r = cli_setup_pakfire(&pakfire, global_args);
+ // Setup root
+ r = cli_setup_root(&root, global_args);
if (r)
goto ERROR;
// Perform search
for (unsigned int i = 0; i < local_args.num_patterns; i++) {
- r = pakfire_whatprovides(pakfire, local_args.patterns[i], 0, list);
+ r = pakfire_root_whatprovides(root, local_args.patterns[i], 0, list);
if (r)
goto ERROR;
}
ERROR:
if (list)
pakfire_packagelist_unref(list);
- if (pakfire)
- pakfire_unref(pakfire);
+ if (root)
+ pakfire_root_unref(root);
return r;
}
int cli_remove(void* data, int argc, char* argv[]) {
struct cli_global_args* global_args = data;
struct cli_local_args local_args = {};
- struct pakfire* pakfire = NULL;
+ pakfire_root* root = NULL;
int r;
// Parse the command line
if (r)
goto ERROR;
- // Setup Pakfire
- r = cli_setup_pakfire(&pakfire, global_args);
+ // Setup root
+ r = cli_setup_root(&root, global_args);
if (r)
goto ERROR;
- r = cli_transaction(pakfire, argc, argv, 0, __cli_remove, &local_args);
+ r = cli_transaction(root, argc, argv, 0, __cli_remove, &local_args);
ERROR:
- if (pakfire)
- pakfire_unref(pakfire);
+ if (root)
+ pakfire_root_unref(root);
return r;
}
int cli_repo_compose(void* data, int argc, char* argv[]) {
struct cli_global_args* global_args = data;
struct cli_local_args local_args = {};
- struct pakfire* pakfire = NULL;
+ pakfire_root* root = NULL;
pakfire_key* key = NULL;
int r;
if (r)
goto ERROR;
- // Setup pakfire
- r = cli_setup_pakfire(&pakfire, global_args);
+ // Setup root
+ r = cli_setup_root(&root, global_args);
if (r)
goto ERROR;
}
// Write the repository
- r = pakfire_repo_compose(pakfire, local_args.path, key, (const char**)local_args.packages);
+ r = pakfire_repo_compose(root, local_args.path, key, (const char**)local_args.packages);
ERROR:
if (key)
pakfire_key_unref(key);
- if (pakfire)
- pakfire_unref(pakfire);
+ if (root)
+ pakfire_root_unref(root);
return r;
}
int cli_repolist(void* data, int argc, char* argv[]) {
struct cli_global_args* global_args = data;
- struct pakfire* pakfire = NULL;
pakfire_repolist* list = NULL;
+ pakfire_root* root = NULL;
int r;
// Parse the command line
if (r)
goto ERROR;
- // Setup Pakfire
- r = cli_setup_pakfire(&pakfire, global_args);
+ // Setup root
+ r = cli_setup_root(&root, global_args);
if (r)
goto ERROR;
// Fetch all repositories
- list = pakfire_get_repos(pakfire);
+ list = pakfire_root_get_repos(root);
if (!list) {
r = -errno;
goto ERROR;
ERROR:
if (list)
pakfire_repolist_unref(list);
- if (pakfire)
- pakfire_unref(pakfire);
+ if (root)
+ pakfire_root_unref(root);
return r;
}
int cli_requires(void* data, int argc, char* argv[]) {
struct cli_global_args* global_args = data;
struct cli_local_args local_args = {};
- struct pakfire* pakfire = NULL;
pakfire_packagelist* list = NULL;
+ pakfire_root* root = NULL;
int r;
// Parse the command line
if (r)
goto ERROR;
- // Setup pakfire
- r = cli_setup_pakfire(&pakfire, global_args);
+ // Setup root
+ r = cli_setup_root(&root, global_args);
if (r)
goto ERROR;
// Perform search
for (unsigned int i = 0; i < local_args.num_patterns; i++) {
- r = pakfire_whatrequires(pakfire, local_args.patterns[i], 0, list);
+ r = pakfire_root_whatrequires(root, local_args.patterns[i], 0, list);
if (r)
goto ERROR;
}
ERROR:
if (list)
pakfire_packagelist_unref(list);
- if (pakfire)
- pakfire_unref(pakfire);
+ if (root)
+ pakfire_root_unref(root);
return r;
}
int cli_search(void* data, int argc, char* argv[]) {
struct cli_global_args* global_args = data;
struct cli_local_args local_args = {};
- struct pakfire* pakfire = NULL;
pakfire_packagelist* list = NULL;
+ pakfire_root* root = NULL;
int r;
// Parse the command line
if (r)
goto ERROR;
- // Setup pakfire
- r = cli_setup_pakfire(&pakfire, global_args);
+ // Setup root
+ r = cli_setup_root(&root, global_args);
if (r)
goto ERROR;
// Perform search
for (unsigned int i = 0; i < local_args.num_patterns; i++) {
- r = pakfire_search(pakfire, local_args.patterns[i], 0, list);
+ r = pakfire_root_search(root, local_args.patterns[i], 0, list);
if (r)
goto ERROR;
}
ERROR:
if (list)
pakfire_packagelist_unref(list);
- if (pakfire)
- pakfire_unref(pakfire);
+ if (root)
+ pakfire_root_unref(root);
return r;
}
int cli_snapshot_update(void* data, int argc, char* argv[]) {
struct cli_global_args* global_args = data;
- struct pakfire* pakfire = NULL;
+ pakfire_root* root = NULL;
int r;
// Parse the command line
if (r)
goto ERROR;
- // Setup pakfire
- r = cli_setup_pakfire(&pakfire, global_args);
+ // Setup root
+ r = cli_setup_root(&root, global_args);
if (r)
goto ERROR;
// Make a new snapshot
- r = pakfire_update_snapshot(pakfire);
+ r = pakfire_root_update_snapshot(root);
ERROR:
- if (pakfire)
- pakfire_unref(pakfire);
+ if (root)
+ pakfire_root_unref(root);
return r;
}
int cli_sync(void* data, int argc, char* argv[]) {
struct cli_global_args* global_args = data;
struct cli_local_args local_args = {};
- struct pakfire* pakfire = NULL;
+ pakfire_root* root = NULL;
int r;
// Parse the command line
if (r)
goto ERROR;
- // Setup Pakfire
- r = cli_setup_pakfire(&pakfire, global_args);
+ // Setup root
+ r = cli_setup_root(&root, global_args);
if (r)
goto ERROR;
- r = cli_transaction(pakfire, argc, argv, 0, __cli_sync, &local_args);
+ r = cli_transaction(root, argc, argv, 0, __cli_sync, &local_args);
ERROR:
- if (pakfire)
- pakfire_unref(pakfire);
+ if (root)
+ pakfire_root_unref(root);
return r;
}
return isatty(STDIN_FILENO) && isatty(STDOUT_FILENO) && isatty(STDERR_FILENO);
}
-int cli_term_confirm(pakfire_ctx* ctx, struct pakfire* pakfire,
+int cli_term_confirm(pakfire_ctx* ctx, pakfire_root* root,
void* data, const char* message, const char* question) {
char* line = NULL;
size_t length = 0;
return r;
}
-int cli_term_confirm_yes(pakfire_ctx* ctx, struct pakfire* pakfire,
+int cli_term_confirm_yes(pakfire_ctx* ctx, pakfire_root* root,
void* data, const char* message, const char* question) {
return 0;
}
return selected_solution;
}
-int cli_term_pick_solution(pakfire_ctx* ctx, struct pakfire* pakfire, void* data,
+int cli_term_pick_solution(pakfire_ctx* ctx, pakfire_root* root, void* data,
pakfire_transaction* transaction) {
pakfire_problem** problems = NULL;
pakfire_solution* solution = NULL;
int cli_term_is_interactive(void);
-int cli_term_confirm(pakfire_ctx* ctx, struct pakfire* pakfire,
+int cli_term_confirm(pakfire_ctx* ctx, pakfire_root* root,
void* data, const char* message, const char* question);
-int cli_term_confirm_yes(pakfire_ctx* ctx, struct pakfire* pakfire,
+int cli_term_confirm_yes(pakfire_ctx* ctx, pakfire_root* root,
void* data, const char* message, const char* question);
-int cli_term_pick_solution(pakfire_ctx* ctx, struct pakfire* pakfire,
+int cli_term_pick_solution(pakfire_ctx* ctx, pakfire_root* root,
void* data, pakfire_transaction* transaction);
#endif /* PAKFIRE_CLI_TERMINAL_H */
The transaction is then solved and executed.
*/
-int cli_transaction(struct pakfire* pakfire, int argc, char* argv[], int flags,
+int cli_transaction(pakfire_root* root, int argc, char* argv[], int flags,
cli_transaction_callback callback, void* data) {
pakfire_transaction* transaction = NULL;
char* problems = NULL;
int r;
// Create a new transaction
- r = pakfire_transaction_create(&transaction, pakfire, flags);
+ r = pakfire_transaction_create(&transaction, root, flags);
if (r) {
fprintf(stderr, "Could not setup the transaction\n");
goto ERROR;
typedef int (*cli_transaction_callback)
(pakfire_transaction* transaction, int argc, char* argv[], void* data);
-int cli_transaction(struct pakfire* pakfire, int argc, char* argv[], int flags,
+int cli_transaction(pakfire_root* root, int argc, char* argv[], int flags,
cli_transaction_callback callback, void* data);
#endif /* PAKFIRE_CLI_TRANSACTION_H */
int cli_update(void* data, int argc, char* argv[]) {
struct cli_global_args* global_args = data;
struct cli_local_args local_args = {};
- struct pakfire* pakfire = NULL;
+ pakfire_root* root = NULL;
int r;
// Parse the command line
if (r)
goto ERROR;
- // Setup Pakfire
- r = cli_setup_pakfire(&pakfire, global_args);
+ // Setup root
+ r = cli_setup_root(&root, global_args);
if (r)
goto ERROR;
- r = cli_transaction(pakfire, argc, argv, local_args.transaction_flags, __cli_update, &local_args);
+ r = cli_transaction(root, argc, argv, local_args.transaction_flags, __cli_update, &local_args);
ERROR:
- if (pakfire)
- pakfire_unref(pakfire);
+ if (root)
+ pakfire_root_unref(root);
return r;
}
return 0;
}
-static int cli_confirm(pakfire_ctx* ctx, struct pakfire* pakfire,
+static int cli_confirm(pakfire_ctx* ctx, pakfire_root* root,
void* data, const char* message, const char* question) {
// Just print the message
if (message)
.ctx = ctx,
.distro = cli_get_default_distro(ctx),
.arch = NULL,
- .flags = PAKFIRE_FLAGS_BUILD,
+ .flags = PAKFIRE_ROOT_FLAGS_BUILD,
};
// Parse the command line and run any commands
struct pakfire_archive {
pakfire_ctx* ctx;
- struct pakfire* pakfire;
+ pakfire_root* root;
int nrefs;
char path[PATH_MAX];
pakfire_package_unref(archive->package);
if (archive->metadata)
json_object_put(archive->metadata);
- if (archive->pakfire)
- pakfire_unref(archive->pakfire);
+ if (archive->root)
+ pakfire_root_unref(archive->root);
if (archive->ctx)
pakfire_ctx_unref(archive->ctx);
free(archive);
return 0;
}
-int pakfire_archive_open(pakfire_archive** archive,
- struct pakfire* pakfire, const char* path) {
+int pakfire_archive_open(pakfire_archive** archive, pakfire_root* root, const char* path) {
pakfire_archive* a = NULL;
int r;
return -errno;
// Store a reference to the context
- a->ctx = pakfire_get_ctx(pakfire);
+ a->ctx = pakfire_root_get_ctx(root);
// Store a reference to pakfire
- a->pakfire = pakfire_ref(pakfire);
+ a->root = pakfire_root_ref(root);
// Initialize the reference counter
a->nrefs = 1;
}
// Generate a file object
- r = pakfire_file_create_from_archive_entry(&file, archive->pakfire, entry);
+ r = pakfire_file_create_from_archive_entry(&file, archive->root, entry);
if (r < 0)
goto ERROR;
goto ERROR;
// Setup the writer
- writer = pakfire_get_disk_writer(archive->pakfire);
+ writer = pakfire_root_get_disk_writer(archive->root);
if (!writer) {
r = -errno;
goto ERROR;
// Set prefix for source packages
} else if (pakfire_package_is_source(pkg)) {
- r = pakfire_path(archive->pakfire, prefix, "/usr/src/packages/%s", nevra);
+ r = pakfire_root_path(archive->root, prefix, "/usr/src/packages/%s", nevra);
if (r < 0)
goto ERROR;
// Otherwise extract relative to the pakfire root
} else {
- r = pakfire_path(archive->pakfire, prefix, "%s", "/");
+ r = pakfire_root_path(archive->root, prefix, "%s", "/");
if (r < 0)
goto ERROR;
}
int r;
// Generate a file object
- r = pakfire_file_create_from_archive_entry(&file, archive->pakfire, entry);
+ r = pakfire_file_create_from_archive_entry(&file, archive->root, entry);
if (r < 0)
goto ERROR;
int r;
// Create a new filelist
- r = pakfire_filelist_create(&filelist, self->pakfire);
+ r = pakfire_filelist_create(&filelist, self->root);
if (r < 0)
goto ERROR;
const char* arch = pakfire_archive_metadata_get(archive, "arch", NULL);
// Create a new package object
- r = pakfire_package_create(&pkg, archive->pakfire, repo, name, evr, arch);
+ r = pakfire_package_create(&pkg, archive->root, repo, name, evr, arch);
if (r)
return r;
// Use dummy repo if no repository was passed
if (!repo) {
- dummy = pakfire_get_repo(archive->pakfire, PAKFIRE_REPO_DUMMY);
+ dummy = pakfire_root_get_repo(archive->root, PAKFIRE_REPO_DUMMY);
if (!dummy)
return 1;
};
// Create a new jail
- r = pakfire_jail_create(&jail, archive->pakfire);
+ r = pakfire_jail_create(&jail, archive->root);
if (r)
goto ERROR;
int r;
// Create a new linter
- r = pakfire_linter_create(&linter, archive->pakfire, archive);
+ r = pakfire_linter_create(&linter, archive->root, archive);
if (r < 0)
goto ERROR;
#include <pakfire/repo.h>
#include <pakfire/scriptlet.h>
-int pakfire_archive_open(pakfire_archive** archive, struct pakfire* pakfire, const char* path);
+int pakfire_archive_open(pakfire_archive** archive, pakfire_root* root, const char* path);
pakfire_archive* pakfire_archive_ref(pakfire_archive* archive);
pakfire_archive* pakfire_archive_unref(pakfire_archive* archive);
pakfire_ctx* ctx;
int nrefs;
- // Pakfire
- struct pakfire* pakfire;
+ // Root
+ pakfire_root* root;
// Time Created
time_t time_created;
pakfire_progress_unref(self->progress);
if (self->archive)
archive_write_free(self->archive);
- if (self->pakfire)
- pakfire_unref(self->pakfire);
+ if (self->root)
+ pakfire_root_unref(self->root);
if (self->ctx)
pakfire_ctx_unref(self->ctx);
free(self);
}
int pakfire_archive_writer_create(pakfire_archive_writer** writer,
- struct pakfire* pakfire, pakfire_archive_writer_format format, FILE* f) {
+ pakfire_root* root, pakfire_archive_writer_format format, FILE* f) {
pakfire_archive_writer* self = NULL;
int r;
return -errno;
// Store a reference to the context
- self->ctx = pakfire_get_ctx(pakfire);
+ self->ctx = pakfire_root_get_ctx(root);
- // Store a reference to Pakfire
- self->pakfire = pakfire_ref(pakfire);
+ // Store a reference to the root
+ self->root = pakfire_root_ref(root);
// Initialize the reference counter
self->nrefs = 1;
int r;
// Create a new filelist
- r = pakfire_filelist_create(&files, self->pakfire);
+ r = pakfire_filelist_create(&files, self->root);
if (r < 0)
goto ERROR;
} pakfire_archive_writer_format;
int pakfire_archive_writer_create(pakfire_archive_writer** writer,
- struct pakfire* pakfire, pakfire_archive_writer_format format, FILE* f);
+ pakfire_root* root, pakfire_archive_writer_format format, FILE* f);
pakfire_archive_writer* pakfire_archive_writer_ref(pakfire_archive_writer* self);
pakfire_archive_writer* pakfire_archive_writer_unref(pakfire_archive_writer* self);
struct pakfire_build {
pakfire_ctx* ctx;
- struct pakfire* pakfire;
+ pakfire_root* root;
int nrefs;
// Flags
return 0;
}
-static int __pakfire_build_setup_repo(struct pakfire* pakfire,
- pakfire_repo* repo, void* p) {
+static int __pakfire_build_setup_repo(pakfire_root* root, pakfire_repo* repo, void* p) {
char path[PATH_MAX];
FILE* f = NULL;
int r;
DEBUG(build->ctx, "Exporting repository configuration for '%s'\n", name);
// Make path for configuration file
- r = pakfire_path(build->pakfire, path, PAKFIRE_CONFIG_DIR "/repos/%s.repo", name);
+ r = pakfire_root_path(root, path, PAKFIRE_CONFIG_DIR "/repos/%s.repo", name);
if (r) {
ERROR(build->ctx, "Could not make repository configuration path for %s: %m\n", name);
goto ERROR;
a pakfire instance running inside the chroot.
*/
static int pakfire_build_enable_repos(pakfire_build* build) {
- return pakfire_repo_walk(build->pakfire, __pakfire_build_setup_repo, build);
+ return pakfire_root_repo_walk(build->root, __pakfire_build_setup_repo, build);
}
static int pakfire_build_read_script(pakfire_build* build,
return 0;
// Create a new filelist
- r = pakfire_filelist_create(&perlfiles, build->pakfire);
+ r = pakfire_filelist_create(&perlfiles, build->root);
if (r < 0)
goto ERROR;
goto ERROR;
// Allocate a new filelist
- r = pakfire_filelist_create(&filelist, build->pakfire);
+ r = pakfire_filelist_create(&filelist, build->root);
if (r)
goto ERROR;
// Otherwise, we will have to resolve the command
} else {
- r = pakfire_which(deps->build->pakfire, path, command);
+ r = pakfire_which(deps->build->root, path, command);
if (r < 0)
return r;
DEBUG(build->ctx, " buildroot = %s\n", buildroot);
// Fetch build architecture
- const char* arch = pakfire_get_arch(build->pakfire);
+ const char* arch = pakfire_root_get_arch(build->root);
if (!arch)
goto ERROR;
goto ERROR;
// Create a packager
- r = pakfire_packager_create(&packager, build->pakfire, pkg);
+ r = pakfire_packager_create(&packager, build->root, pkg);
if (r)
goto ERROR;
int r;
// Create a filelist with objects that need to be removed
- r = pakfire_filelist_create(&removees, build->pakfire);
+ r = pakfire_filelist_create(&removees, build->root);
if (r)
goto ERROR;
int r;
// Create a filelist of all files in the build
- r = pakfire_filelist_create(&filelist, build->pakfire);
+ r = pakfire_filelist_create(&filelist, build->root);
if (r) {
ERROR(build->ctx, "Could not create filelist: %m\n");
goto ERROR;
int r;
// Create a new stripper
- r = pakfire_stripper_create(&stripper, build->pakfire, build->jail, build->buildroot);
+ r = pakfire_stripper_create(&stripper, build->root, build->jail, build->buildroot);
if (r < 0)
goto ERROR;
if (*build->buildroot)
pakfire_rmtree(build->buildroot, 0);
- if (build->pakfire)
- pakfire_unref(build->pakfire);
+ if (build->root)
+ pakfire_root_unref(build->root);
if (build->ctx)
pakfire_ctx_unref(build->ctx);
free(build);
}
// Fetch config
- config = pakfire_get_config(build->pakfire);
+ config = pakfire_root_get_config(build->root);
if (!config)
goto ERROR;
int r;
// Create a new jail
- r = pakfire_jail_create(&build->jail, build->pakfire);
+ r = pakfire_jail_create(&build->jail, build->root);
if (r) {
ERROR(build->ctx, "Could not create jail for build %s: %m\n", build->_id);
return r;
}
// Set a default path
- r = pakfire_cache_path(build->pakfire, build->ccache_path, "%s", "ccache");
+ r = pakfire_root_cache_path(build->root, build->ccache_path, "%s", "ccache");
if (r)
return r;
int r;
// Create a new repository
- r = pakfire_repo_create(&build->repo, build->pakfire, PAKFIRE_REPO_RESULT);
+ r = pakfire_repo_create(&build->repo, build->root, PAKFIRE_REPO_RESULT);
if (r) {
ERROR(build->ctx, "Could not create repository %s: %m", PAKFIRE_REPO_RESULT);
return r;
return r;
}
-static int pakfire_build_setup_pakfire(
+static int pakfire_build_setup_root(
pakfire_build* build, pakfire_config* config, const char* arch) {
- int flags = PAKFIRE_FLAGS_BUILD;
+ int flags = PAKFIRE_ROOT_FLAGS_BUILD;
int r;
// Is this a local build?
if (build->flags & PAKFIRE_BUILD_LOCAL)
- flags |= PAKFIRE_FLAGS_BUILD_LOCAL | PAKFIRE_USE_TMPFS;
+ flags |= PAKFIRE_ROOT_FLAGS_BUILD_LOCAL | PAKFIRE_ROOT_USE_TMPFS;
// Enable snapshot?
if (build->flags & PAKFIRE_BUILD_ENABLE_SNAPSHOT)
- flags |= PAKFIRE_USE_SNAPSHOT;
+ flags |= PAKFIRE_ROOT_USE_SNAPSHOT;
- // Create a new Pakfire instance
- r = pakfire_create(&build->pakfire, build->ctx, config, NULL, arch, flags);
+ // Create a new root
+ r = pakfire_root_create(&build->root, build->ctx, config, NULL, arch, flags);
if (r < 0)
return r;
if (r)
goto ERROR;
- // Setup Pakfire
- r = pakfire_build_setup_pakfire(b, config, arch);
+ // Setup root
+ r = pakfire_build_setup_root(b, config, arch);
if (r < 0)
goto ERROR;
const char* name = pakfire_package_get_string(package, PAKFIRE_PKG_NAME);
// Compose path to makefile
- r = pakfire_path(build->pakfire, path, "/usr/src/packages/%s/%s.nm", nevra, name);
+ r = pakfire_root_path(build->root, path, "/usr/src/packages/%s/%s.nm", nevra, name);
if (r < 0)
return 1;
// Read makefile
- r = pakfire_read_makefile(parser, build->pakfire, path, &error);
+ r = pakfire_read_makefile(parser, build->root, path, &error);
if (r) {
if (error) {
ERROR(build->ctx, "Could not parse makefile %s: %s\n", path,
int r;
// Create a new filelist
- r = pakfire_filelist_create(&filelist, build->pakfire);
+ r = pakfire_filelist_create(&filelist, build->root);
if (r)
goto ERROR;
int r;
// Create a new transaction
- r = pakfire_transaction_create(&transaction, build->pakfire,
+ r = pakfire_transaction_create(&transaction, build->root,
PAKFIRE_TRANSACTION_ALLOW_UNINSTALL);
if (r < 0)
goto ERROR;
int r;
// Create a new transaction
- r = pakfire_transaction_create(&transaction, build->pakfire,
+ r = pakfire_transaction_create(&transaction, build->root,
PAKFIRE_TRANSACTION_ALLOW_DOWNGRADE|PAKFIRE_TRANSACTION_ALLOW_UNINSTALL);
if (r)
goto ERROR;
int r;
// Call the callback
- r = result->callback(ctx, build->pakfire, build, archive, result->data);
+ r = result->callback(ctx, build->root, build, archive, result->data);
if (r) {
ERROR(ctx, "Result callback returned %d\n", r);
return r;
int r;
// Fetch architecture
- const char* arch = pakfire_get_arch(build->pakfire);
+ const char* arch = pakfire_root_get_arch(build->root);
// Open the source package
- r = pakfire_commandline_add(build->pakfire, path, &package);
+ r = pakfire_root_commandline_add(build->root, path, &package);
if (r)
goto ERROR;
goto ERROR;
// Create a new transaction
- r = pakfire_transaction_create(&transaction, build->pakfire, 0);
+ r = pakfire_transaction_create(&transaction, build->root, 0);
if (r) {
ERROR(build->ctx, "Could not create transaction: %m\n");
goto ERROR;
int r;
// Create a new transaction
- r = pakfire_transaction_create(&transaction, build->pakfire, 0);
+ r = pakfire_transaction_create(&transaction, build->root, 0);
if (r) {
ERROR(build->ctx, "Could not create transaction: %m\n");
goto ERROR;
return -EINVAL;
// Create a path inside the build environment
- r = pakfire_path(build->pakfire, path, "%s",
- PAKFIRE_TMP_DIR "/pakfire-image.XXXXXX");
- if (r)
+ r = pakfire_root_path(build->root, path, "%s", PAKFIRE_TMP_DIR "/pakfire-image.XXXXXX");
+ if (r < 0)
goto ERROR;
// Allocate a temporary file
}
// Create a path for all packages
- r = pakfire_path(build->pakfire, packagesdir, "%s",
- PAKFIRE_TMP_DIR "/pakfire-packages.XXXXXX");
+ r = pakfire_root_path(build->root, packagesdir, "%s", PAKFIRE_TMP_DIR "/pakfire-packages.XXXXXX");
if (r)
goto ERROR;
const char* args[] = {
type,
- pakfire_relpath(build->pakfire, path),
- pakfire_relpath(build->pakfire, packagesdir),
+ pakfire_root_relpath(build->root, path),
+ pakfire_root_relpath(build->root, packagesdir),
NULL,
};
return r;
}
-int pakfire_build_clean(struct pakfire* pakfire, int flags) {
+int pakfire_build_clean(pakfire_root* root, int flags) {
pakfire_repo* local = NULL;
int r = 0;
- pakfire_ctx* ctx = pakfire_get_ctx(pakfire);
+ pakfire_ctx* ctx = pakfire_root_get_ctx(root);
// Fetch local repository
- local = pakfire_get_repo(pakfire, PAKFIRE_REPO_LOCAL);
+ local = pakfire_root_get_repo(root, PAKFIRE_REPO_LOCAL);
if (!local) {
ERROR(ctx, "Could not find repository %s: %m\n", PAKFIRE_REPO_LOCAL);
goto ERROR;
PAKFIRE_BUILD_LOCAL = (1 << 4),
};
-typedef int (*pakfire_build_result_callback)(pakfire_ctx* ctx, struct pakfire* pakfire,
+typedef int (*pakfire_build_result_callback)(pakfire_ctx* ctx, pakfire_root* root,
pakfire_build* build, pakfire_archive* archive, void* data);
int pakfire_build_create(pakfire_build** build, pakfire_ctx* ctx,
int pakfire_build_mkimage(pakfire_build* build,
const char* type, FILE* f);
-int pakfire_build_clean(struct pakfire* pakfire, int flags);
+int pakfire_build_clean(pakfire_root* root, int flags);
#endif /* PAKFIRE_BUILD_H */
}
static int pakfire_ctx_default_confirm_callback(pakfire_ctx* self,
- struct pakfire* pakfire, void* data, const char* message, const char* question) {
+ pakfire_root* root, void* data, const char* message, const char* question) {
// Just log the message
INFO(self, "%s\n", message);
self->confirm.data = data;
}
-int pakfire_ctx_confirm(pakfire_ctx* self, struct pakfire* pakfire,
+int pakfire_ctx_confirm(pakfire_ctx* self, pakfire_root* root,
const char* message, const char* question) {
// Run callback
if (!self->confirm.callback)
return 0;
- return self->confirm.callback(self, pakfire, self->confirm.data, message, question);
+ return self->confirm.callback(self, root, self->confirm.data, message, question);
}
// Progress
self->pick_solution.data = data;
}
-int pakfire_ctx_pick_solution(pakfire_ctx* self, struct pakfire* pakfire,
+int pakfire_ctx_pick_solution(pakfire_ctx* self, pakfire_root* root,
pakfire_transaction* transaction) {
if (!self->pick_solution.callback)
return 1;
- return self->pick_solution.callback(self, pakfire, self->pick_solution.data, transaction);
+ return self->pick_solution.callback(self, root, self->pick_solution.data, transaction);
}
// Event Loop
// Confirm
-typedef int (*pakfire_confirm_callback)(pakfire_ctx* self, struct pakfire* pakfire,
+typedef int (*pakfire_confirm_callback)(pakfire_ctx* self, pakfire_root* root,
void* data, const char* message, const char* question);
void pakfire_ctx_set_confirm_callback(pakfire_ctx* self,
// Pick Solution
typedef int (*pakfire_pick_solution_callback)(pakfire_ctx* self,
- struct pakfire* pakfire, void* data, pakfire_transaction* transaction);
+ pakfire_root* root, void* data, pakfire_transaction* transaction);
void pakfire_ctx_set_pick_solution_callback(pakfire_ctx* self,
pakfire_pick_solution_callback callback, void* data);
// Confirm
-int pakfire_ctx_confirm(pakfire_ctx* self, struct pakfire* pakfire,
+int pakfire_ctx_confirm(pakfire_ctx* self, pakfire_root* root,
const char* message, const char* question);
// Progress
// Pick Solution
-int pakfire_ctx_pick_solution(pakfire_ctx* self, struct pakfire* pakfire,
+int pakfire_ctx_pick_solution(pakfire_ctx* self, pakfire_root* root,
pakfire_transaction* transaction);
// Event Loop
struct pakfire_db {
pakfire_ctx* ctx;
- struct pakfire* pakfire;
+ pakfire_root* root;
int nrefs;
char path[PATH_MAX];
}
}
- if (db->pakfire)
- pakfire_unref(db->pakfire);
+ if (db->root)
+ pakfire_root_unref(db->root);
if (db->ctx)
pakfire_ctx_unref(db->ctx);
free(db);
if (r)
return 1;
- const char* arch = pakfire_get_effective_arch(db->pakfire);
+ const char* arch = pakfire_root_get_effective_arch(db->root);
// Set architecture
r = pakfire_db_set_string(db, "arch", arch);
}
// Fetch the running architecture
- arch = pakfire_get_effective_arch(db->pakfire);
+ arch = pakfire_root_get_effective_arch(db->root);
if (!arch) {
r = -EINVAL;
goto ERROR;
return 0;
}
-int pakfire_db_open(pakfire_db** db, struct pakfire* pakfire, int flags) {
+int pakfire_db_open(pakfire_db** db, pakfire_root* root, int flags) {
pakfire_db* self = NULL;
int sqlite3_flags = 0;
int r;
return -errno;
// Store a reference to the context
- self->ctx = pakfire_get_ctx(pakfire);
+ self->ctx = pakfire_root_get_ctx(root);
- // Store a reference to pakfire
- self->pakfire = pakfire_ref(pakfire);
+ // Store a reference to the root
+ self->root = pakfire_root_ref(root);
// Initialize the reference counter
self->nrefs = 1;
}
// Make the filename
- r = pakfire_path(self->pakfire, self->path, "%s", DATABASE_PATH);
+ r = pakfire_root_path(self->root, self->path, "%s", DATABASE_PATH);
if (r < 0)
goto ERROR;
return packages;
}
-static void pakfire_db_add_userinstalled(struct pakfire* pakfire, const char* name) {
- Pool* pool = pakfire_get_solv_pool(pakfire);
+static void pakfire_db_add_userinstalled(pakfire_root* root, const char* name) {
+ Pool* pool = pakfire_root_get_solv_pool(root);
// Convert name to ID
Id id = pool_str2id(pool, name, 1);
}
// Create package
- r = pakfire_package_create(&pkg, db->pakfire, repo, name, evr, arch);
+ r = pakfire_package_create(&pkg, db->root, repo, name, evr, arch);
if (r) {
ERROR(db->ctx, "Could not create package '%s-%s.%s': %m\n", name, evr, arch);
goto ERROR;
// installed by user?
int userinstalled = sqlite3_column_int(stmt, 18);
if (userinstalled)
- pakfire_db_add_userinstalled(db->pakfire, name);
+ pakfire_db_add_userinstalled(db->root, name);
// Files
const char* files = (const char*)sqlite3_column_text(stmt, 19);
for (const struct dependency* deps = dependencies; deps->field; deps++) {
const char* relations = (const char*)sqlite3_column_text(stmt, deps->field);
if (relations) {
- r = pakfire_str2deps(db->pakfire, pkg, deps->key, relations);
+ r = pakfire_str2deps(db->root, pkg, deps->key, relations);
if (r)
goto ERROR;
}
}
// Create a new file object
- r = pakfire_file_create(&file, db->pakfire, path);
+ r = pakfire_file_create(&file, db->root, path);
if (r < 0)
goto ERROR;
}
// Create a new filelist
- r = pakfire_filelist_create(&list, db->pakfire);
+ r = pakfire_filelist_create(&list, db->root);
if (r)
goto ERROR;
}
// Create a new filelist
- r = pakfire_filelist_create(&fl, db->pakfire);
+ r = pakfire_filelist_create(&fl, db->root);
if (r) {
ERROR(db->ctx, "Could not create filelist: %m\n");
goto ERROR;
PAKFIRE_DB_READWRITE = (1 << 0),
};
-int pakfire_db_open(pakfire_db** db, struct pakfire* pakfire, int flags);
+int pakfire_db_open(pakfire_db** db, pakfire_root* root, int flags);
pakfire_db* pakfire_db_ref(pakfire_db* db);
pakfire_db* pakfire_db_unref(pakfire_db* db);
return pool_evrcmp_str(pool, evr1, evr2, EVRCMP_COMPARE);
}
-const char* pakfire_dep2str(struct pakfire* pakfire, Id id) {
- Pool* pool = pakfire_get_solv_pool(pakfire);
+const char* pakfire_dep2str(pakfire_root* root, Id id) {
+ Pool* pool = pakfire_root_get_solv_pool(root);
return pool_dep2str(pool, id);
}
/*
This function parses any namespaced dependencies
*/
-static Id pakfire_parse_namespace(struct pakfire* pakfire, const char* s) {
+static Id pakfire_parse_namespace(pakfire_root* root, const char* s) {
const char* p = strchr(s, '(');
if (!p)
return 0;
// Fetch the pool
- Pool* pool = pakfire_get_solv_pool(pakfire);
+ Pool* pool = pakfire_root_get_solv_pool(root);
// Store the namespace ID
Id namespace = pool_strn2id(pool, s, p - s, 1);
/*
This function parses a simple dependency like "foo = 1.2.3"
*/
-static Id pakfire_parse_dep(struct pakfire* pakfire, const char** s) {
+static Id pakfire_parse_dep(pakfire_root* root, const char** s) {
Id id = ID_NULL;
if (!s) {
return ID_NULL;
// Fetch the pool
- Pool* pool = pakfire_get_solv_pool(pakfire);
+ Pool* pool = pakfire_root_get_solv_pool(root);
// Consume any leading space
while (isspace(*p))
// Add name to pool
if (pakfire_string_startswith(n, "pakfire(") || pakfire_string_startswith(n, "arch(")) {
- id = pakfire_parse_namespace(pakfire, n);
+ id = pakfire_parse_namespace(root, n);
} else {
id = pool_strn2id(pool, n, l, 1);
}
/*
This function parses any rich dependencies
*/
-static Id pakfire_parse_rich_dep(struct pakfire* pakfire, const char** dep, int flags) {
+static Id pakfire_parse_rich_dep(pakfire_root* root, const char** dep, int flags) {
const char* p = *dep;
Id id;
switch (*p) {
// A new rich dependency
case '(':
- id = pakfire_parse_rich_dep(pakfire, &p, 0);
+ id = pakfire_parse_rich_dep(root, &p, 0);
if (!id)
return id;
break;
// Parse a regular dependency
default:
- id = pakfire_parse_dep(pakfire, &p);
+ id = pakfire_parse_dep(root, &p);
if (!id)
return id;
break;
return ID_NULL;
// Parse the next bit
- Id evr = pakfire_parse_rich_dep(pakfire, &p, flags);
+ Id evr = pakfire_parse_rich_dep(root, &p, flags);
// Abort if there was a problem
if (!evr)
return ID_NULL;
// Fetch pool
- Pool* pool = pakfire_get_solv_pool(pakfire);
+ Pool* pool = pakfire_root_get_solv_pool(root);
// Store until where we have parsed the string
*dep = p;
return pool_rel2id(pool, id, evr, flags, 1);
}
-Id pakfire_str2dep(struct pakfire* pakfire, const char* dep) {
+Id pakfire_str2dep(pakfire_root* root, const char* dep) {
Id id = ID_NULL;
// Invalid input
// Parse any rich dependencies
if (*s == '(')
- id = pakfire_parse_rich_dep(pakfire, &s, 0);
+ id = pakfire_parse_rich_dep(root, &s, 0);
else
- id = pakfire_parse_dep(pakfire, &s);
+ id = pakfire_parse_dep(root, &s);
// Return nothing if we could not parse the entire string
if (id && *s)
return id;
}
-int pakfire_str2deps(struct pakfire* pakfire, pakfire_package* pkg,
+int pakfire_str2deps(pakfire_root* root, pakfire_package* pkg,
const enum pakfire_package_key key, const char* deps) {
char* p = NULL;
int r = 0;
int pakfire_static_version_compare(const char* evr1, const char* evr2);
-const char* pakfire_dep2str(struct pakfire* pakfire, Id id);
-Id pakfire_str2dep(struct pakfire* pakfire, const char* s);
+const char* pakfire_dep2str(pakfire_root* root, Id id);
+Id pakfire_str2dep(pakfire_root* root, const char* s);
-int pakfire_str2deps(struct pakfire* pakfire, pakfire_package* pkg,
+int pakfire_str2deps(pakfire_root* root, pakfire_package* pkg,
const enum pakfire_package_key key, const char* deps);
#endif /* PAKFIRE_DEPENDENCIES_H */
NULL,
};
-static int pakfire_makefile_set_defaults(struct pakfire* pakfire,
+static int pakfire_makefile_set_defaults(pakfire_root* root,
pakfire_parser* parser, const char* path) {
char dirname[PATH_MAX];
char buffer[1024];
pakfire_parser_set(parser, NULL, "vendor", "%{DISTRO_VENDOR}", 0);
// Set arch
- const char* arch = pakfire_get_arch(pakfire);
+ const char* arch = pakfire_root_get_arch(root);
if (arch) {
r = pakfire_parser_set(parser, NULL, "arch", arch, 0);
if (r)
}
// Set DISTRO_NAME
- const char* name = pakfire_get_distro_name(pakfire);
+ const char* name = pakfire_root_get_distro_name(root);
if (name)
pakfire_parser_set(parser, NULL, "DISTRO_NAME", name, 0);
// Set DISTRO_SNAME
- const char* id = pakfire_get_distro_id(pakfire);
+ const char* id = pakfire_root_get_distro_id(root);
if (id)
pakfire_parser_set(parser, NULL, "DISTRO_SNAME", name, 0);
// Set DISTRO_RELEASE
- const char* version_id = pakfire_get_distro_version_id(pakfire);
+ const char* version_id = pakfire_root_get_distro_version_id(root);
if (version_id)
pakfire_parser_set(parser, NULL, "DISTRO_RELEASE", version_id, 0);
// Set DISTRO_DISTTAG
- const char* tag = pakfire_get_distro_tag(pakfire);
+ const char* tag = pakfire_root_get_distro_tag(root);
if (tag)
pakfire_parser_set(parser, NULL, "DISTRO_DISTTAG", tag, 0);
// Set DISTRO_VENDOR
- const char* vendor = pakfire_get_distro_vendor(pakfire);
+ const char* vendor = pakfire_root_get_distro_vendor(root);
if (vendor)
pakfire_parser_set(parser, NULL, "DISTRO_VENDOR", vendor, 0);
// Set DISTRO_ARCH
- const char* effective_arch = pakfire_get_effective_arch(pakfire);
+ const char* effective_arch = pakfire_root_get_effective_arch(root);
if (effective_arch) {
pakfire_parser_set(parser, NULL, "DISTRO_ARCH", effective_arch, 0);
return r;
if (*dirname) {
- const char* root = pakfire_get_path(pakfire);
+ const char* p = pakfire_root_get_path(root);
pakfire_parser_set(parser, NULL, "BASEDIR",
- pakfire_path_relpath(root, dirname), 0);
+ pakfire_path_relpath(p, dirname), 0);
}
long processors_online = sysconf(_SC_NPROCESSORS_ONLN);
return 0;
}
-int pakfire_read_makefile(pakfire_parser** parser, struct pakfire* pakfire,
+int pakfire_read_makefile(pakfire_parser** parser, pakfire_root* root,
const char* path, pakfire_parser_error** error) {
int r;
// Fetch context
- pakfire_ctx* ctx = pakfire_get_ctx(pakfire);
+ pakfire_ctx* ctx = pakfire_root_get_ctx(root);
// Create a new parser
- r = pakfire_parser_create(parser, pakfire, NULL, NULL, PAKFIRE_PARSER_FLAGS_EXPAND_COMMANDS);
+ r = pakfire_parser_create(parser, root, NULL, NULL, PAKFIRE_PARSER_FLAGS_EXPAND_COMMANDS);
if (r < 0)
goto ERROR;
// Set defaults
- r = pakfire_makefile_set_defaults(pakfire, *parser, path);
+ r = pakfire_makefile_set_defaults(root, *parser, path);
if (r < 0)
goto ERROR;
return r;
}
-static int pakfire_dist_get_mirrorlist(pakfire_ctx* ctx, struct pakfire* pakfire,
+static int pakfire_dist_get_mirrorlist(pakfire_ctx* ctx, pakfire_root* root,
pakfire_parser* makefile, pakfire_mirrorlist** list) {
pakfire_mirrorlist* m = NULL;
pakfire_mirror* mirror = NULL;
return r;
}
-static int pakfire_dist_add_source(struct pakfire* pakfire, pakfire_packager* packager,
+static int pakfire_dist_add_source(pakfire_root* root, pakfire_packager* packager,
pakfire_package* pkg, pakfire_ctx* ctx,
pakfire_mirrorlist* mirrorlist, const char* filename) {
char archive_path[PATH_MAX];
const char* name = pakfire_package_get_string(pkg, PAKFIRE_PKG_NAME);
// Compose path
- r = pakfire_cache_path(pakfire, cache_path, "sources/%s/%s", name, filename);
+ r = pakfire_root_cache_path(root, cache_path, "sources/%s/%s", name, filename);
if (r)
return r;
return pakfire_packager_add(packager, cache_path, archive_path);
}
-static int pakfire_dist_add_sources(pakfire_ctx* ctx, struct pakfire* pakfire,
+static int pakfire_dist_add_sources(pakfire_ctx* ctx, pakfire_root* root,
pakfire_packager* packager, pakfire_package* pkg, pakfire_parser* makefile) {
pakfire_mirrorlist* mirrorlist = NULL;
char* sources = NULL;
return 0;
// Fetch the mirrorlist
- r = pakfire_dist_get_mirrorlist(ctx, pakfire, makefile, &mirrorlist);
+ r = pakfire_dist_get_mirrorlist(ctx, root, makefile, &mirrorlist);
if (r)
goto ERROR;
while (source) {
DEBUG(ctx, "Adding source file %s\n", source);
- r = pakfire_dist_add_source(pakfire, packager, pkg, ctx, mirrorlist, source);
+ r = pakfire_dist_add_source(root, packager, pkg, ctx, mirrorlist, source);
if (r) {
ERROR(ctx, "Could not add '%s' to package: %m\n", source);
goto ERROR;
return __pakfire_path_dirname(root, length, p);
}
-static int pakfire_dist_add_files(pakfire_ctx* ctx, struct pakfire* pakfire,
+static int pakfire_dist_add_files(pakfire_ctx* ctx, pakfire_root* root,
pakfire_packager* packager, const char* file) {
pakfire_filelist* filelist = NULL;
- char root[PATH_MAX];
+ char path[PATH_MAX];
int r;
// Find the package directory
- r = pakfire_dist_find_root(root, file);
+ r = pakfire_dist_find_root(path, file);
if (r) {
ERROR(ctx, "Could not find package root directory: %s\n", strerror(r));
return r;
}
- DEBUG(ctx, "Adding all files in '%s' to package...\n", root);
+ DEBUG(ctx, "Adding all files in '%s' to package...\n", path);
// Create a new filelist
- r = pakfire_filelist_create(&filelist, pakfire);
+ r = pakfire_filelist_create(&filelist, root);
if (r)
goto ERROR;
// Scan for any files
- r = pakfire_filelist_scan(filelist, root, NULL, pakfire_dist_excludes,
+ r = pakfire_filelist_scan(filelist, path, NULL, pakfire_dist_excludes,
PAKFIRE_FILELIST_NO_DIRECTORIES);
if (r)
goto ERROR;
return r;
}
-int pakfire_dist(struct pakfire* pakfire,
- const char* path, pakfire_archive** archive) {
+int pakfire_dist(pakfire_root* root, const char* path, pakfire_archive** archive) {
pakfire_packager* packager = NULL;
pakfire_package* pkg = NULL;
pakfire_parser* makefile = NULL;
int r;
// Fetch context
- pakfire_ctx* ctx = pakfire_get_ctx(pakfire);
+ pakfire_ctx* ctx = pakfire_root_get_ctx(root);
// Load makefile
- r = pakfire_read_makefile(&makefile, pakfire, path, &error);
+ r = pakfire_read_makefile(&makefile, root, path, &error);
if (r < 0) {
if (error)
pakfire_parser_error_unref(error);
goto ERROR;
// Create a packager
- r = pakfire_packager_create(&packager, pakfire, pkg);
+ r = pakfire_packager_create(&packager, root, pkg);
if (r)
goto ERROR;
// Add all files in the directory
- r = pakfire_dist_add_files(ctx, pakfire, packager, path);
+ r = pakfire_dist_add_files(ctx, root, packager, path);
if (r)
goto ERROR;
// Add all source files (which might need to be downloaded)
- r = pakfire_dist_add_sources(ctx, pakfire, packager, pkg, makefile);
+ r = pakfire_dist_add_sources(ctx, root, packager, pkg, makefile);
if (r)
goto ERROR;
#include <pakfire/pakfire.h>
#include <pakfire/parser.h>
-int pakfire_dist(struct pakfire* pakfire,
- const char* path, pakfire_archive** archive);
+int pakfire_dist(pakfire_root* root, const char* path, pakfire_archive** archive);
-int pakfire_read_makefile(pakfire_parser** parser, struct pakfire* pakfire,
+int pakfire_read_makefile(pakfire_parser** parser, pakfire_root* root,
const char* path, pakfire_parser_error** error);
#endif /* PAKFIRE_DIST_H */
struct pakfire_file {
pakfire_ctx* ctx;
- struct pakfire* pakfire;
+ pakfire_root* root;
int nrefs;
// Use the libarchive entry to store common attributes
return r;
}
-int pakfire_file_create(pakfire_file** file,
- struct pakfire* pakfire, const char* path) {
+int pakfire_file_create(pakfire_file** file, pakfire_root* root, const char* path) {
pakfire_file* f = NULL;
int r = 0;
return -errno;
// Store a reference to the context
- f->ctx = pakfire_get_ctx(pakfire);
+ f->ctx = pakfire_root_get_ctx(root);
- // Store reference to Pakfire
- f->pakfire = pakfire_ref(pakfire);
+ // Store reference to the root
+ f->root = pakfire_root_ref(root);
// Initialize reference counter
f->nrefs = 1;
return r;
}
-int pakfire_file_create_from_archive_entry(pakfire_file** file, struct pakfire* pakfire,
+int pakfire_file_create_from_archive_entry(pakfire_file** file, pakfire_root* root,
struct archive_entry* entry) {
pakfire_file* f = NULL;
int r;
- r = pakfire_file_create(&f, pakfire, NULL);
+ r = pakfire_file_create(&f, root, NULL);
if (r < 0)
goto ERROR;
cap_free(file->caps);
if (file->entry)
archive_entry_free(file->entry);
- if (file->pakfire)
- pakfire_unref(file->pakfire);
+ if (file->root)
+ pakfire_root_unref(file->root);
if (file->ctx)
pakfire_ctx_unref(file->ctx);
free(file);
archive_entry_set_pathname(file->entry, buffer);
// Store the absolute path only when not in stub mode
- if (!pakfire_has_flag(file->pakfire, PAKFIRE_FLAGS_STUB)) {
+ if (!pakfire_root_has_flag(file->root, PAKFIRE_ROOT_FLAGS_STUB)) {
// Make the absolute path
- r = pakfire_path(file->pakfire, buffer, "%s", buffer);
+ r = pakfire_root_path(file->root, buffer, "%s", buffer);
if (r < 0)
return r;
// Fix the path if we have entered the jail
if (pakfire_ctx_has_flag(file->ctx, PAKFIRE_CTX_IN_JAIL)) {
- path = pakfire_relpath(file->pakfire, path);
+ path = pakfire_root_relpath(file->root, path);
if (!path)
return -EBADF;
}
static int pakfire_file_verify_ownership(pakfire_file* file, const struct stat* st) {
// Fetch UID/GID
#if 0
- const uid_t uid = pakfire_unmap_id(file->pakfire, st->st_uid);
- const gid_t gid = pakfire_unmap_id(file->pakfire, st->st_gid);
+ const uid_t uid = pakfire_unmap_id(file->root, st->st_uid);
+ const gid_t gid = pakfire_unmap_id(file->root, st->st_gid);
#else
const uid_t uid = st->st_uid;
const gid_t gid = st->st_gid;
const char* gname = pakfire_file_get_gname(file);
// Fetch owner & group
- struct passwd* owner = pakfire_getpwnam(file->pakfire, uname);
- struct group* group = pakfire_getgrnam(file->pakfire, gname);
+ struct passwd* owner = pakfire_getpwnam(file->root, uname);
+ struct group* group = pakfire_getgrnam(file->root, gname);
// Check if owner matches
if (!owner || owner->pw_uid != uid) {
DEBUG(file->ctx, "%s: Found command %s (%s)\n", path, interpreter, args);
// Find the real path
- r = pakfire_which(file->pakfire, command, interpreter);
+ r = pakfire_which(file->root, command, interpreter);
if (r < 0) {
ERROR(file->ctx, "%s: Could not resolve %s: %m\n", path, interpreter);
goto ERROR;
PAKFIRE_FILE_CONFIG = (1 << 0),
};
-int pakfire_file_create(pakfire_file** file, struct pakfire* pakfire, const char* path);
+int pakfire_file_create(pakfire_file** file, pakfire_root* root, const char* path);
pakfire_file* pakfire_file_ref(pakfire_file* file);
pakfire_file* pakfire_file_unref(pakfire_file* file);
int pakfire_file_write_fcaps(pakfire_file* file, struct vfs_cap_data* cap_data);
-int pakfire_file_create_from_archive_entry(pakfire_file** file, struct pakfire* pakfire,
- struct archive_entry* entry);
+int pakfire_file_create_from_archive_entry(pakfire_file** file,
+ pakfire_root* root, struct archive_entry* entry);
struct archive_entry* pakfire_file_archive_entry(pakfire_file* file, const enum pakfire_hash_type hashes);
enum pakfire_file_dump_flags {
struct pakfire_filelist {
pakfire_ctx* ctx;
- struct pakfire* pakfire;
+ pakfire_root* root;
int nrefs;
pakfire_file** files;
unsigned int num_files;
};
-int pakfire_filelist_create(pakfire_filelist** list, struct pakfire* pakfire) {
+int pakfire_filelist_create(pakfire_filelist** list, pakfire_root* root) {
pakfire_filelist* l = NULL;
// Allocate a new object
return -errno;
// Store a reference to the context
- l->ctx = pakfire_get_ctx(pakfire);
+ l->ctx = pakfire_root_get_ctx(root);
- // Store a reference to Pakfire
- l->pakfire = pakfire_ref(pakfire);
+ // Store a reference to the root
+ l->root = pakfire_root_ref(root);
// Initialize the reference counter
l->nrefs = 1;
static void pakfire_filelist_free(pakfire_filelist* list) {
pakfire_filelist_clear(list);
- if (list->pakfire)
- pakfire_unref(list->pakfire);
+ if (list->root)
+ pakfire_root_unref(list->root);
if (list->ctx)
pakfire_ctx_unref(list->ctx);
free(list);
}
// Create a new disk reader
- reader = pakfire_get_disk_reader(list->pakfire);
+ reader = pakfire_root_get_disk_reader(list->root);
if (!reader)
goto ERROR;
}
// Create file
- r = pakfire_file_create_from_archive_entry(&file, list->pakfire, entry);
+ r = pakfire_file_create_from_archive_entry(&file, list->root, entry);
if (r)
goto ERROR;
#include <pakfire/file.h>
#include <pakfire/pakfire.h>
-int pakfire_filelist_create(pakfire_filelist** list, struct pakfire* pakfire);
+int pakfire_filelist_create(pakfire_filelist** list, pakfire_root* root);
pakfire_filelist* pakfire_filelist_ref(pakfire_filelist* list);
pakfire_filelist* pakfire_filelist_unref(pakfire_filelist* list);
struct pakfire_jail {
pakfire_ctx* ctx;
- struct pakfire* pakfire;
+ pakfire_root* root;
int nrefs;
// A unique ID for each jail
static void pakfire_jail_free(pakfire_jail* jail) {
if (jail->cgroup)
pakfire_cgroup_unref(jail->cgroup);
- if (jail->pakfire)
- pakfire_unref(jail->pakfire);
+ if (jail->root)
+ pakfire_root_unref(jail->root);
if (jail->env)
pakfire_env_unref(jail->env);
if (jail->ctx)
return jail->__uuid;
}
-int pakfire_jail_create(pakfire_jail** jail, struct pakfire* pakfire) {
+int pakfire_jail_create(pakfire_jail** jail, pakfire_root* root) {
pakfire_jail* self = NULL;
int r;
return -errno;
// Reference context
- self->ctx = pakfire_get_ctx(pakfire);
+ self->ctx = pakfire_root_get_ctx(root);
- // Reference Pakfire
- self->pakfire = pakfire_ref(pakfire);
+ // Reference to the root
+ self->root = pakfire_root_ref(root);
// Initialize reference counter
self->nrefs = 1;
}
// Fetch the architecture
- const char* arch = pakfire_get_effective_arch(pakfire);
+ const char* arch = pakfire_root_get_effective_arch(root);
// Enable all CPU features that CPU has to offer
if (!pakfire_arch_is_supported_by_host(arch)) {
goto ERROR;
// Disable systemctl to talk to systemd
- if (!pakfire_on_root(self->pakfire)) {
+ if (!pakfire_root_on_root(self->root)) {
r = pakfire_env_set(self->env, "SYSTEMD_OFFLINE", "1");
if (r < 0)
goto ERROR;
// Bind-mount all paths read-only
for (const char** path = paths; *path; path++) {
- r = pakfire_bind(jail->ctx, jail->pakfire, *path, NULL, MS_RDONLY);
+ r = pakfire_bind(jail->ctx, jail->root, *path, NULL, MS_RDONLY);
if (r) {
switch (errno) {
// Ignore if we don't have permission
flags |= PAKFIRE_MOUNT_LOOP_DEVICES;
// Mount all default stuff
- r = pakfire_mount_all(jail->ctx, jail->pakfire, PAKFIRE_MNTNS_OUTER, flags);
+ r = pakfire_mount_all(jail->ctx, jail->root, PAKFIRE_MNTNS_OUTER, flags);
if (r)
return r;
// Populate /dev
- r = pakfire_populate_dev(jail->ctx, jail->pakfire, flags);
+ r = pakfire_populate_dev(jail->ctx, jail->root, flags);
if (r)
return r;
// Mount the interpreter (if needed)
- r = pakfire_mount_interpreter(jail->ctx, jail->pakfire);
+ r = pakfire_mount_interpreter(jail->ctx, jail->root);
if (r)
return r;
mp = &jail->mountpoints[i];
// Mount it
- r = pakfire_bind(jail->ctx, jail->pakfire, mp->source, mp->target, mp->flags);
+ r = pakfire_bind(jail->ctx, jail->root, mp->source, mp->target, mp->flags);
if (r)
return r;
}
return r;
// Fetch UID
- const uid_t uid = pakfire_uid(jail->pakfire);
+ const uid_t uid = pakfire_root_uid(jail->root);
// Fetch SUBUID
- const struct pakfire_subid* subuid = pakfire_subuid(jail->pakfire);
+ const struct pakfire_subid* subuid = pakfire_root_subuid(jail->root);
if (!subuid)
return 1;
int r;
// Fetch GID
- const gid_t gid = pakfire_gid(jail->pakfire);
+ const gid_t gid = pakfire_root_gid(jail->root);
// Fetch SUBGID
- const struct pakfire_subid* subgid = pakfire_subgid(jail->pakfire);
+ const struct pakfire_subid* subgid = pakfire_root_subgid(jail->root);
if (!subgid)
return 1;
}
// Mount all default stuff
- r = pakfire_mount_all(jail->ctx, jail->pakfire, PAKFIRE_MNTNS_INNER, 0);
+ r = pakfire_mount_all(jail->ctx, jail->root, PAKFIRE_MNTNS_INNER, 0);
if (r)
return 126;
- const char* root = pakfire_get_path(jail->pakfire);
- const char* arch = pakfire_get_effective_arch(jail->pakfire);
+ const char* path = pakfire_root_get_path(jail->root);
+ const char* arch = pakfire_root_get_effective_arch(jail->root);
// Change mount propagation to slave to receive anything from the parent namespace
r = pakfire_mount_change_propagation(jail->ctx, "/", MS_SLAVE);
return r;
// Make root a mountpoint in the new mount namespace
- r = pakfire_mount_make_mounpoint(jail->ctx, root);
+ r = pakfire_mount_make_mounpoint(jail->ctx, path);
if (r)
return r;
// Change mount propagation to private
- r = pakfire_mount_change_propagation(jail->ctx, root, MS_PRIVATE);
+ r = pakfire_mount_change_propagation(jail->ctx, path, MS_PRIVATE);
if (r)
return r;
// Change root (unless root is /)
- if (!pakfire_on_root(jail->pakfire)) {
+ if (!pakfire_root_on_root(jail->root)) {
// Mount everything
r = pakfire_jail_mount(jail, ctx);
if (r)
return r;
// chroot()
- r = pakfire_jail_switch_root(jail, root);
+ r = pakfire_jail_switch_root(jail, path);
if (r)
return r;
}
FILE* f = NULL;
int r;
- const char* root = pakfire_get_path(jail->pakfire);
+ const char* root = pakfire_root_get_path(jail->root);
// Write the scriptlet to disk
r = pakfire_path_append(path, root, PAKFIRE_TMP_DIR "/pakfire-script.XXXXXX");
A convenience function that creates a new jail, runs the given command and destroys
the jail again.
*/
-int pakfire_jail_run(struct pakfire* pakfire, const char* argv[], pakfire_env* env,
+int pakfire_jail_run(pakfire_root* root, const char* argv[], pakfire_env* env,
int flags, char** output, size_t* output_length) {
pakfire_jail* jail = NULL;
int r;
// Create a new jail
- r = pakfire_jail_create(&jail, pakfire);
+ r = pakfire_jail_create(&jail, root);
if (r)
goto ERROR;
return r;
}
-int pakfire_jail_run_script(struct pakfire* pakfire, const char* script, const size_t length,
+int pakfire_jail_run_script(pakfire_root* root, const char* script, const size_t length,
const char* argv[], pakfire_env* env, int flags) {
pakfire_jail* jail = NULL;
int r;
// Create a new jail
- r = pakfire_jail_create(&jail, pakfire);
+ r = pakfire_jail_create(&jail, root);
if (r)
goto ERROR;
return r;
}
-static int pakfire_jail_run_if_possible(struct pakfire* pakfire, const char** argv) {
+static int pakfire_jail_run_if_possible(pakfire_root* root, const char** argv) {
char path[PATH_MAX];
int r;
// Fetch the context
- pakfire_ctx* ctx = pakfire_get_ctx(pakfire);
+ pakfire_ctx* ctx = pakfire_root_get_ctx(root);
- r = pakfire_path(pakfire, path, "%s", *argv);
+ r = pakfire_root_path(root, path, "%s", *argv);
if (r)
goto ERROR;
goto ERROR;
}
- r = pakfire_jail_run(pakfire, argv, NULL, 0, NULL, NULL);
+ r = pakfire_jail_run(root, argv, NULL, 0, NULL, NULL);
ERROR:
if (ctx)
return r;
}
-int pakfire_jail_ldconfig(struct pakfire* pakfire) {
+int pakfire_jail_ldconfig(pakfire_root* root) {
const char* argv[] = {
"/sbin/ldconfig",
NULL,
};
- return pakfire_jail_run_if_possible(pakfire, argv);
+ return pakfire_jail_run_if_possible(root, argv);
}
-int pakfire_jail_run_systemd_tmpfiles(struct pakfire* pakfire) {
+int pakfire_jail_run_systemd_tmpfiles(pakfire_root* root) {
const char* argv[] = {
"/usr/bin/systemd-tmpfiles",
"--create",
NULL,
};
- return pakfire_jail_run_if_possible(pakfire, argv);
+ return pakfire_jail_run_if_possible(root, argv);
}
ssize_t pakfire_jail_send_buffer(pakfire_ctx* ctx,
typedef int (*pakfire_jail_output_callback)(pakfire_ctx* ctx, void* data,
const enum pakfire_jail_output_stream stream, const char* line, size_t length);
-int pakfire_jail_create(pakfire_jail** jail, struct pakfire* pakfire);
+int pakfire_jail_create(pakfire_jail** jail, pakfire_root* root);
pakfire_jail* pakfire_jail_ref(pakfire_jail* jail);
pakfire_jail* pakfire_jail_unref(pakfire_jail* jail);
pakfire_jail_output_callback output_callback, void* output_data);
// Convenience functions
-int pakfire_jail_run(struct pakfire* pakfire,
+int pakfire_jail_run(pakfire_root* root,
const char* argv[], pakfire_env* env, int flags, char** output, size_t* output_length);
-int pakfire_jail_run_script(struct pakfire* pakfire,
+int pakfire_jail_run_script(pakfire_root* root,
const char* script, const size_t length, const char* argv[], pakfire_env* env, int flags);
int pakfire_jail_execute_script(pakfire_jail* jail,
pakfire_jail_output_callback output_callback, void* output_data);
int pakfire_jail_shell(pakfire_jail* jail, pakfire_env* env);
-int pakfire_jail_ldconfig(struct pakfire* pakfire);
-int pakfire_jail_run_systemd_tmpfiles(struct pakfire* pakfire);
+int pakfire_jail_ldconfig(pakfire_root* root);
+int pakfire_jail_run_systemd_tmpfiles(pakfire_root* root);
// Streaming functions
struct pakfire_input_buffer {
return pakfire_job_upload_packages(self);
}
-static int pakfire_job_result(pakfire_ctx* ctx, struct pakfire* pakfire,
+static int pakfire_job_result(pakfire_ctx* ctx, pakfire_root* root,
pakfire_build* build, pakfire_archive* archive, void* data) {
pakfire_job* self = data;
pakfire_package* pkg = NULL;
pakfire_ctx* ctx;
int nrefs;
- // Pakfire
- struct pakfire* pakfire;
+ // Root
+ pakfire_root* root;
// Archive
pakfire_archive* archive;
}
int pakfire_linter_create(pakfire_linter** linter,
- struct pakfire* pakfire, pakfire_archive* archive) {
+ pakfire_root* root, pakfire_archive* archive) {
pakfire_linter* l = NULL;
int r;
return -errno;
// Reference the context
- l->ctx = pakfire_get_ctx(pakfire);
+ l->ctx = pakfire_root_get_ctx(root);
- // Reference Pakfire
- l->pakfire = pakfire_ref(pakfire);
+ // Reference the root
+ l->root = pakfire_root_ref(root);
// Initialize reference counter
l->nrefs = 1;
}
// Create a filelist
- r = pakfire_filelist_create(&l->filelist, l->pakfire);
+ r = pakfire_filelist_create(&l->filelist, l->root);
if (r < 0)
goto ERROR;
pakfire_archive_unref(linter->archive);
if (linter->pkg)
pakfire_package_unref(linter->pkg);
- if (linter->pakfire)
- pakfire_unref(linter->pakfire);
+ if (linter->root)
+ pakfire_root_unref(linter->root);
if (linter->ctx)
pakfire_ctx_unref(linter->ctx);
free(linter);
int r;
// Fetch a file object
- r = pakfire_file_create_from_archive_entry(&file, linter->pakfire, e);
+ r = pakfire_file_create_from_archive_entry(&file, linter->root, e);
if (r < 0)
goto ERROR;
typedef struct pakfire_linter pakfire_linter;
int pakfire_linter_create(pakfire_linter** linter,
- struct pakfire* pakfire, pakfire_archive* archive);
+ pakfire_root* root, pakfire_archive* archive);
pakfire_linter* pakfire_linter_ref(pakfire_linter* linter);
pakfire_linter* pakfire_linter_unref(pakfire_linter* linter);
return pakfire_parse_file("/proc/self/mounts", __pakfire_mount_list, ctx);
}
-int pakfire_populate_dev(pakfire_ctx* ctx, struct pakfire* pakfire, int flags) {
+int pakfire_populate_dev(pakfire_ctx* ctx, pakfire_root* root, int flags) {
char path[PATH_MAX];
// Create device nodes
if (devnode->flags && !(flags & devnode->flags))
continue;
- int r = pakfire_path(pakfire, path, "%s", devnode->path);
+ int r = pakfire_root_path(root, path, "%s", devnode->path);
if (r)
return r;
for (const struct pakfire_symlink* s = symlinks; s->target; s++) {
DEBUG(ctx, "Creating symlink %s -> %s\n", s->path, s->target);
- int r = pakfire_path(pakfire, path, "%s", s->path);
+ int r = pakfire_root_path(root, path, "%s", s->path);
if (r)
return r;
return 0;
}
-int pakfire_mount_interpreter(pakfire_ctx* ctx, struct pakfire* pakfire) {
+int pakfire_mount_interpreter(pakfire_ctx* ctx, pakfire_root* root) {
char target[PATH_MAX];
// Fetch the target architecture
- const char* arch = pakfire_get_effective_arch(pakfire);
+ const char* arch = pakfire_root_get_effective_arch(root);
// Can we emulate this architecture?
char* interpreter = pakfire_arch_find_interpreter(arch);
DEBUG(ctx, "Mounting interpreter %s for %s\n", interpreter, arch);
// Where to mount this?
- int r = pakfire_path(pakfire, target, "%s", interpreter);
+ int r = pakfire_root_path(root, target, "%s", interpreter);
if (r)
return r;
return r;
}
-int pakfire_mount_all(pakfire_ctx* ctx, struct pakfire* pakfire, pakfire_mntns_t ns, int flags) {
+int pakfire_mount_all(pakfire_ctx* ctx, pakfire_root* root, pakfire_mntns_t ns, int flags) {
char target[PATH_MAX];
int r;
- const char* root = "/";
+ const char* path = "/";
// Fetch Pakfire's root directory
if (ns == PAKFIRE_MNTNS_OUTER)
- root = pakfire_get_path(pakfire);
+ path = pakfire_root_get_path(root);
for (const struct pakfire_mountpoint* mp = mountpoints; mp->source; mp++) {
if (!(mp->ns & ns))
continue;
// Figure out where to mount
- r = pakfire_path_append(target, root, mp->target);
+ r = pakfire_path_append(target, path, mp->target);
if (r)
return r;
return 0;
}
-int pakfire_bind(pakfire_ctx* ctx, struct pakfire* pakfire,
+int pakfire_bind(pakfire_ctx* ctx, pakfire_root* root,
const char* src, const char* dst, int flags) {
struct stat st;
char mountpoint[PATH_MAX];
if (!dst)
dst = src;
- int r = pakfire_path(pakfire, mountpoint, "%s", dst);
+ int r = pakfire_root_path(root, mountpoint, "%s", dst);
if (r)
return r;
int pakfire_mount_make_mounpoint(pakfire_ctx* ctx, const char* path);
-int pakfire_bind(pakfire_ctx* ctx, struct pakfire* pakfire,
+int pakfire_bind(pakfire_ctx* ctx, pakfire_root* root,
const char* src, const char* dst, int flags);
int pakfire_mount_list(pakfire_ctx* ctx);
-int pakfire_populate_dev(pakfire_ctx* ctx, struct pakfire* pakfire, int flags);
+int pakfire_populate_dev(pakfire_ctx* ctx, pakfire_root* root, int flags);
-int pakfire_mount_interpreter(pakfire_ctx* ctx, struct pakfire* pakfire);
+int pakfire_mount_interpreter(pakfire_ctx* ctx, pakfire_root* root);
enum pakfire_mount_flags {
PAKFIRE_MOUNT_LOOP_DEVICES = (1 << 0),
};
-int pakfire_mount_all(pakfire_ctx* ctx, struct pakfire* pakfire,
+int pakfire_mount_all(pakfire_ctx* ctx, pakfire_root* root,
pakfire_mntns_t ns, int flags);
#endif /* PAKFIRE_MOUNT_H */
// Context
pakfire_ctx* ctx;
- // Pakfire
- struct pakfire* pakfire;
+ // Root
+ pakfire_root* root;
// Image writer
pakfire_archive_writer* image;
json_object* manifests;
};
-static const char* pakfire_oci_arch(struct pakfire* pakfire) {
- const char* arch = pakfire_get_arch(pakfire);
+static const char* pakfire_oci_arch(pakfire_root* root) {
+ const char* arch = pakfire_root_get_arch(root);
// aarch64
if (pakfire_string_equals(arch, "aarch64"))
goto ERROR;
// Add author
- const char* vendor = pakfire_get_distro_vendor(self->pakfire);
+ const char* vendor = pakfire_root_get_distro_vendor(self->root);
if (vendor) {
r = pakfire_json_add_string(o, "author", vendor);
if (r < 0)
goto ERROR;
// Fetch OS version
- const char* version_id = pakfire_get_distro_version_id(self->pakfire);
+ const char* version_id = pakfire_root_get_distro_version_id(self->root);
// Add OS version
if (version_id) {
}
// Fetch arch
- const char* arch = pakfire_oci_arch(self->pakfire);
+ const char* arch = pakfire_oci_arch(self->root);
// Add arch
r = pakfire_json_add_string(o, "architecture", arch);
goto ERROR;
// Fetch architecture
- const char* arch = pakfire_oci_arch(self->pakfire);
+ const char* arch = pakfire_oci_arch(self->root);
// Add architecture
r = pakfire_json_add_string(platform, "architecture", arch);
int r;
// Fetch the pakfire root
- const char* root = pakfire_get_path(self->pakfire);
+ const char* root = pakfire_root_get_path(self->root);
// Make a new temporary file
f = pakfire_mktemp(path, 0);
unlink(path);
// Make a new archive writer
- r = pakfire_archive_writer_create(&layer, self->pakfire, PAKFIRE_FORMAT_OCI_LAYER, f);
+ r = pakfire_archive_writer_create(&layer, self->root, PAKFIRE_FORMAT_OCI_LAYER, f);
if (r < 0)
goto ERROR;
return r;
}
-int pakfire_oci_mkimage(struct pakfire* pakfire, FILE* f) {
+int pakfire_oci_mkimage(pakfire_root* root, FILE* f) {
struct pakfire_oci_writer writer = {
- .ctx = pakfire_get_ctx(pakfire),
- .pakfire = pakfire,
+ .ctx = pakfire_root_get_ctx(root),
+ .root = root,
};
int r;
}
// Make a new archive writer
- r = pakfire_archive_writer_create(&writer.image, pakfire, PAKFIRE_FORMAT_OCI, f);
+ r = pakfire_archive_writer_create(&writer.image, root, PAKFIRE_FORMAT_OCI, f);
if (r < 0)
goto ERROR;
#include <pakfire/pakfire.h>
-int pakfire_oci_mkimage(struct pakfire* pakfire, FILE* f);
+int pakfire_oci_mkimage(pakfire_root* root, FILE* f);
#endif /* PAKFIRE_OCI_H */
struct pakfire_package {
pakfire_ctx* ctx;
- struct pakfire* pakfire;
+ pakfire_root* root;
int nrefs;
// Reference to this package in the SOLV pool
};
static Solvable* get_solvable(pakfire_package* pkg) {
- Pool* pool = pakfire_get_solv_pool(pkg->pakfire);
+ Pool* pool = pakfire_root_get_solv_pool(pkg->root);
return pool_id2solvable(pool, pkg->id);
}
}
int pakfire_package_create_from_solvable(pakfire_package** package,
- struct pakfire* pakfire, pakfire_repo* repo, Id id) {
+ pakfire_root* root, pakfire_repo* repo, Id id) {
pakfire_package* pkg = NULL;
// Allocate some memory
return -errno;
// Store a reference to the context
- pkg->ctx = pakfire_get_ctx(pakfire);
+ pkg->ctx = pakfire_root_get_ctx(root);
- // Store a reference to Pakfire
- pkg->pakfire = pakfire_ref(pakfire);
+ // Store a reference to the root
+ pkg->root = pakfire_root_ref(root);
// Initialize the reference counter
pkg->nrefs = 1;
return 0;
}
-int pakfire_package_create(pakfire_package** package,
- struct pakfire* pakfire, pakfire_repo* repo,
- const char* name, const char* evr, const char* arch) {
+int pakfire_package_create(pakfire_package** package, pakfire_root* root,
+ pakfire_repo* repo, const char* name, const char* evr, const char* arch) {
pakfire_repo* dummy = NULL;
int r;
// Default to dummy repository
if (!repo) {
- dummy = pakfire_get_repo(pakfire, PAKFIRE_REPO_DUMMY);
+ dummy = pakfire_root_get_repo(root, PAKFIRE_REPO_DUMMY);
if (!dummy) {
errno = ENOENT;
return 1;
}
// Fetch the context
- pakfire_ctx* ctx = pakfire_get_ctx(pakfire);
+ pakfire_ctx* ctx = pakfire_root_get_ctx(root);
// Allocate a new solvable
Id id = pakfire_repo_add_solvable(repo);
}
// Create a new package object
- r = pakfire_package_create_from_solvable(package, pakfire, repo, id);
+ r = pakfire_package_create_from_solvable(package, root, repo, id);
if (r)
goto ERROR;
pcre2_code_free(pkg->filters.provides);
if (pkg->repo)
pakfire_repo_unref(pkg->repo);
- if (pkg->pakfire)
- pakfire_unref(pkg->pakfire);
+ if (pkg->root)
+ pakfire_root_unref(pkg->root);
if (pkg->ctx)
pakfire_ctx_unref(pkg->ctx);
free(pkg);
}
int pakfire_package_cmp(pakfire_package* pkg1, pakfire_package* pkg2) {
- Pool* pool = pakfire_get_solv_pool(pkg1->pakfire);
+ Pool* pool = pakfire_root_get_solv_pool(pkg1->root);
Solvable* s1 = get_solvable(pkg1);
Solvable* s2 = get_solvable(pkg2);
}
int pakfire_package_evr_cmp(pakfire_package* pkg1, pakfire_package* pkg2) {
- Pool* pool = pakfire_get_solv_pool(pkg1->pakfire);
+ Pool* pool = pakfire_root_get_solv_pool(pkg1->root);
Solvable* s1 = get_solvable(pkg1);
Solvable* s2 = get_solvable(pkg2);
return 1;
}
- return pakfire_cache_path(pkg->pakfire, pkg->cache_path, "%s/%s", uuid, filename);
+ return pakfire_root_cache_path(pkg->root, pkg->cache_path, "%s/%s", uuid, filename);
}
void pakfire_package_unset(pakfire_package* pkg,
pakfire_package_internalize_repo(pkg);
- Pool* pool = pakfire_get_solv_pool(pkg->pakfire);
+ Pool* pool = pakfire_root_get_solv_pool(pkg->root);
Solvable* s = get_solvable(pkg);
switch (key) {
pakfire_package_internalize_repo(pkg);
- Pool* pool = pakfire_get_solv_pool(pkg->pakfire);
+ Pool* pool = pakfire_root_get_solv_pool(pkg->root);
Solvable* s = get_solvable(pkg);
switch (key) {
Id id = ID_NULL;
int r;
- Pool* pool = pakfire_get_solv_pool(pkg->pakfire);
+ Pool* pool = pakfire_root_get_solv_pool(pkg->root);
Solvable* s = get_solvable(pkg);
switch (key) {
Id key_id = ID_NULL;
Id value_id = ID_NULL;
- Pool* pool = pakfire_get_solv_pool(pkg->pakfire);
+ Pool* pool = pakfire_root_get_solv_pool(pkg->root);
Solvable* s = get_solvable(pkg);
switch (key) {
}
int pakfire_package_is_installed(pakfire_package* pkg) {
- Pool* pool = pakfire_get_solv_pool(pkg->pakfire);
+ Pool* pool = pakfire_root_get_solv_pool(pkg->root);
Solvable* s = get_solvable(pkg);
return pool->installed == s->repo;
goto ERROR;
for (int i = 0; i < q.count; i++) {
- dep = pakfire_dep2str(pkg->pakfire, q.elements[i]);
+ dep = pakfire_dep2str(pkg->root, q.elements[i]);
if (!dep)
goto ERROR;
}
// Parse the dependency
- Id id = pakfire_str2dep(pkg->pakfire, buffer);
+ Id id = pakfire_str2dep(pkg->root, buffer);
if (!id) {
ERROR(pkg->ctx, "Could not add dependency '%s' to %s\n",
buffer, pakfire_package_get_string(pkg, PAKFIRE_PKG_NEVRA));
goto ERROR;
// Get the pool ready
- pakfire_pool_internalize(pkg->pakfire);
+ pakfire_root_pool_internalize(pkg->root);
- Pool* pool = pakfire_get_solv_pool(pkg->pakfire);
+ Pool* pool = pakfire_root_get_solv_pool(pkg->root);
// Search for any matches
pool_whatmatchessolvable(pool, SOLVABLE_REQUIRES, pkg->id, &matches, 0);
// Import the result to the package list
- r = pakfire_packagelist_import_solvables(list, pkg->pakfire, &matches);
+ r = pakfire_packagelist_import_solvables(list, pkg->root, &matches);
if (r < 0)
goto ERROR;
goto ERROR;
for (int i = 0; i < q.count; i++) {
- const char* dep = pakfire_dep2str(pkg->pakfire, q.elements[i]);
+ const char* dep = pakfire_dep2str(pkg->root, q.elements[i]);
// Is this a rich dependency?
if (dep && *dep == '(') {
int pakfire_package_matches_dep(pakfire_package* pkg,
const enum pakfire_package_key key, const char* dep) {
// Get the dependency
- Id id = pakfire_str2dep(pkg->pakfire, dep);
+ Id id = pakfire_str2dep(pkg->root, dep);
if (!id)
return -EINVAL;
if (!pkg->repo) {
Solvable* s = get_solvable(pkg);
- r = pakfire_repo_open(&pkg->repo, pkg->pakfire, s->repo);
+ r = pakfire_repo_open(&pkg->repo, pkg->root, s->repo);
if (r < 0)
return NULL;
}
return -errno;
// Open archive
- r = pakfire_archive_open(archive, pkg->pakfire, path);
+ r = pakfire_archive_open(archive, pkg->root, path);
if (r < 0) {
ERROR(pkg->ctx, "Could not open archive for %s (at %s): %s\n",
pakfire_package_get_string(pkg, PAKFIRE_PKG_NEVRA), path, strerror(-r));
}
typedef struct pakfire_package_filelist_search {
- struct pakfire* pakfire;
+ pakfire_root* root;
pakfire_filelist* filelist;
int r;
} pakfire_package_filelist_search;
}
// Create a new file entry
- r = pakfire_file_create(&file, search->pakfire, path);
+ r = pakfire_file_create(&file, search->root, path);
if (r < 0)
goto ERROR;
static int pakfire_package_fetch_filelist(pakfire_package* pkg, pakfire_filelist* filelist) {
pakfire_package_filelist_search search = {
- .pakfire = pkg->pakfire,
+ .root = pkg->root,
.filelist = filelist,
.r = 0,
};
pakfire_filelist* filelist = NULL;
// Create a new filelist
- int r = pakfire_filelist_create(&filelist, pkg->pakfire);
+ int r = pakfire_filelist_create(&filelist, pkg->root);
if (r)
goto ERROR;
}
// Fetch the installed repository
- repo = pakfire_get_installed_repo(pkg->pakfire);
+ repo = pakfire_root_get_installed_repo(pkg->root);
if (!repo) {
ERROR(pkg->ctx, "Could not fetch the installed repository: %m\n");
r = -EINVAL;
const char* nevra = pakfire_package_get_string(pkg, PAKFIRE_PKG_NEVRA);
// Create a new transaction
- r = pakfire_transaction_create(&transaction, pkg->pakfire, flags);
+ r = pakfire_transaction_create(&transaction, pkg->root, flags);
if (r)
goto ERROR;
PAKFIRE_PKG_ENHANCES,
};
-int pakfire_package_create(pakfire_package** package, struct pakfire* pakfire,
+int pakfire_package_create(pakfire_package** package, pakfire_root* root,
pakfire_repo* repo, const char* name, const char* evr, const char* arch);
pakfire_package* pakfire_package_ref(pakfire_package* pkg);
int pakfire_package_installcheck(pakfire_package* pkg, char** problem, int flags);
int pakfire_package_create_from_solvable(pakfire_package** package,
- struct pakfire* pakfire, pakfire_repo* repo, Id id);
+ pakfire_root* root, pakfire_repo* repo, Id id);
int pakfire_package_set_strings_from_string(pakfire_package* pkg,
const enum pakfire_package_key key, const char* value);
}
int pakfire_packagelist_import_solvables(pakfire_packagelist* self,
- struct pakfire* pakfire, Queue* q) {
+ pakfire_root* root, Queue* q) {
pakfire_package* pkg = NULL;
int r;
// Walk through all elements on the queue
for (int i = 0; i < q->count; i++) {
- r = pakfire_package_create_from_solvable(&pkg, pakfire, NULL, q->elements[i]);
+ r = pakfire_package_create_from_solvable(&pkg, root, NULL, q->elements[i]);
if (r)
return r;
pakfire_packagelist_walk_callback callback, void* p, int flags);
int pakfire_packagelist_import_solvables(pakfire_packagelist* list,
- struct pakfire* pakfire, Queue* q);
+ pakfire_root* root, Queue* q);
int pakfire_packagelist_has_path(pakfire_packagelist* self, const char* path);
struct pakfire_packager {
pakfire_ctx* ctx;
- struct pakfire* pakfire;
+ pakfire_root* root;
int nrefs;
time_t time_created;
pakfire_filelist_unref(packager->filelist);
if (packager->pkg)
pakfire_package_unref(packager->pkg);
- if (packager->pakfire)
- pakfire_unref(packager->pakfire);
+ if (packager->root)
+ pakfire_root_unref(packager->root);
if (packager->ctx)
pakfire_ctx_unref(packager->ctx);
free(packager);
}
int pakfire_packager_create(pakfire_packager** packager,
- struct pakfire* pakfire, pakfire_package* pkg) {
+ pakfire_root* root, pakfire_package* pkg) {
pakfire_packager* p = NULL;
char hostname[HOST_NAME_MAX];
int r = 1;
p->nrefs = 1;
// Store a reference to the context
- p->ctx = pakfire_get_ctx(pakfire);
+ p->ctx = pakfire_root_get_ctx(root);
// Store a reference to Pakfire
- p->pakfire = pakfire_ref(pakfire);
+ p->root = pakfire_root_ref(root);
// Store a reference to the package
p->pkg = pakfire_package_ref(pkg);
p->digests = PAKFIRE_PACKAGER_HASHES;
// Set distribution
- const char* tag = pakfire_get_distro_tag(p->pakfire);
+ const char* tag = pakfire_root_get_distro_tag(p->root);
if (!tag) {
ERROR(p->ctx, "Distribution tag is not configured: %m\n");
goto ERROR;
pakfire_package_set_num(pkg, PAKFIRE_PKG_BUILD_TIME, p->time_created);
// Create reader
- p->reader = pakfire_get_disk_reader(p->pakfire);
+ p->reader = pakfire_root_get_disk_reader(p->root);
if (!p->reader)
goto ERROR;
// Create filelist
- r = pakfire_filelist_create(&p->filelist, p->pakfire);
+ r = pakfire_filelist_create(&p->filelist, p->root);
if (r)
goto ERROR;
goto ERROR;
// Create a new archive writer
- r = pakfire_archive_writer_create(&writer, packager->pakfire,
- PAKFIRE_FORMAT_SOURCE_ARCHIVE, f);
+ r = pakfire_archive_writer_create(&writer, packager->root, PAKFIRE_FORMAT_SOURCE_ARCHIVE, f);
if (r < 0)
goto ERROR;
f = NULL;
// Open the archive
- r = pakfire_archive_open(archive, self->pakfire, path);
+ r = pakfire_archive_open(archive, self->root, path);
if (r < 0) {
ERROR(self->ctx, "Could not open the generated archive at %s: %s\n",
path, strerror(-r));
}
// Create a new file object from the archive entry
- r = pakfire_file_create_from_archive_entry(&file, packager->pakfire, entry);
+ r = pakfire_file_create_from_archive_entry(&file, packager->root, entry);
if (r < 0) {
ERROR(packager->ctx, "Could not create file object: %s\n", strerror(-r));
goto ERROR;
typedef struct pakfire_packager pakfire_packager;
int pakfire_packager_create(pakfire_packager** packager,
- struct pakfire* pakfire, pakfire_package* pkg);
+ pakfire_root* root, pakfire_package* pkg);
pakfire_packager* pakfire_packager_ref(pakfire_packager* packager);
pakfire_packager* pakfire_packager_unref(pakfire_packager* packager);
#include <pakfire/transaction.h>
#include <pakfire/util.h>
-struct pakfire {
+struct pakfire_root {
pakfire_ctx* ctx;
int nrefs;
char cache_path[PATH_MAX];
- struct pakfire_arches {
+ struct pakfire_root_arches {
char nominal[ARCH_MAX];
const char* effective;
} arches;
int flags;
// Keep some internal state
- enum pakfire_internal_flags {
- PAKFIRE_HAS_PATH = (1 << 0),
- PAKFIRE_DESTROY_ON_FREE = (1 << 1),
- PAKFIRE_UMOUNT_PATH = (1 << 2),
- PAKFIRE_POOL_READY = (1 << 3),
+ enum pakfire_root_internal_flags {
+ PAKFIRE_ROOT_HAS_PATH = (1 << 0),
+ PAKFIRE_ROOT_DESTROY_ON_FREE = (1 << 1),
+ PAKFIRE_ROOT_UMOUNT_PATH = (1 << 2),
+ PAKFIRE_ROOT_POOL_READY = (1 << 3),
} internal_flags;
// UID/GID of running user
- struct pakfire_user {
+ struct pakfire_root_user {
uid_t uid;
char name[NAME_MAX];
char home[PATH_MAX];
struct pakfire_subid subuids;
} user;
- struct pakfire_group {
+ struct pakfire_root_group {
gid_t gid;
char name[NAME_MAX];
struct pakfire_subid subgids;
NULL,
};
-int pakfire_on_root(struct pakfire* pakfire) {
- return (strcmp(pakfire->path, "/") == 0);
+int pakfire_root_on_root(pakfire_root* self) {
+ return (strcmp(self->path, "/") == 0);
}
-uid_t pakfire_uid(struct pakfire* pakfire) {
- return pakfire->user.uid;
+uid_t pakfire_root_uid(pakfire_root* self) {
+ return self->user.uid;
}
-gid_t pakfire_gid(struct pakfire* pakfire) {
- return pakfire->group.gid;
+gid_t pakfire_root_gid(pakfire_root* self) {
+ return self->group.gid;
}
-const struct pakfire_subid* pakfire_subuid(struct pakfire* pakfire) {
- return &pakfire->user.subuids;
+const struct pakfire_subid* pakfire_root_subuid(pakfire_root* self) {
+ return &self->user.subuids;
}
-const struct pakfire_subid* pakfire_subgid(struct pakfire* pakfire) {
- return &pakfire->group.subgids;
+const struct pakfire_subid* pakfire_root_subgid(pakfire_root* self) {
+ return &self->group.subgids;
}
/*
Maps any UID/GIDs to the SUBUID/SUBGIDs so that we can transparently
copy files in and out of the jail environment.
*/
-static unsigned int pakfire_map_id(struct pakfire* pakfire,
+static unsigned int pakfire_root_map_id(pakfire_root* self,
const struct pakfire_subid* subid, const unsigned int id) {
// Nothing to do if we are running on root
- if (pakfire_on_root(pakfire))
+ if (pakfire_root_on_root(self))
return id;
// Map the ID
// Check if the ID is in range
if (id > subid->length) {
- ERROR(pakfire->ctx, "Mapped ID is out of range. Setting to %u\n", subid->id);
+ ERROR(self->ctx, "Mapped ID is out of range. Setting to %u\n", subid->id);
mapped_id = subid->id;
}
return mapped_id;
}
-static unsigned int pakfire_unmap_id(struct pakfire* pakfire,
+static unsigned int pakfire_root_unmap_id(pakfire_root* self,
const struct pakfire_subid* subid, const unsigned int id) {
// Nothing to do if we are running on root
- if (pakfire_on_root(pakfire))
+ if (pakfire_root_on_root(self))
return id;
// Unmap the ID
// Check if the ID is in range
if (unmapped_id < 0) {
- ERROR(pakfire->ctx, "Mapped ID is out of range. Setting to %u\n", subid->id);
+ ERROR(self->ctx, "Mapped ID is out of range. Setting to %u\n", subid->id);
unmapped_id = subid->id;
}
}
static void pool_log(Pool* pool, void* data, int type, const char* s) {
- struct pakfire* pakfire = (struct pakfire*)data;
+ pakfire_root* self = data;
- DEBUG(pakfire->ctx, "pool: %s", s);
+ DEBUG(self->ctx, "pool: %s", s);
}
-static Id pakfire_handle_ns_pakfire(struct pakfire* pakfire, const char* name) {
+static Id pakfire_root_handle_ns_pakfire(pakfire_root* self, const char* name) {
// Find all supported features
for (const char** feature = features; *feature; feature++) {
if (strcmp(*feature, name) == 0)
return 0;
}
-static Id pakfire_handle_ns_arch(struct pakfire* pakfire, const char* name) {
- const char* arch = pakfire_get_arch(pakfire);
+static Id pakfire_root_handle_ns_arch(pakfire_root* self, const char* name) {
+ const char* arch = pakfire_root_get_arch(self);
return strcmp(arch, name) == 0;
}
-static Id pakfire_namespace_callback(Pool* pool, void* data, Id ns, Id id) {
- struct pakfire* pakfire = (struct pakfire*)data;
+static Id pakfire_root_namespace_callback(Pool* pool, void* data, Id ns, Id id) {
+ pakfire_root* self = data;
const char* namespace = pool_id2str(pool, ns);
- const char* name = pakfire_dep2str(pakfire, id);
+ const char* name = pakfire_dep2str(self, id);
- DEBUG(pakfire->ctx, "Namespace callback called for %s(%s)\n", namespace, name);
+ DEBUG(self->ctx, "Namespace callback called for %s(%s)\n", namespace, name);
// Handle the pakfire() namespace
if (strcmp(namespace, "pakfire") == 0)
- return pakfire_handle_ns_pakfire(pakfire, name);
+ return pakfire_root_handle_ns_pakfire(self, name);
// Handle the arch() namespace
else if (strcmp(namespace, "arch") == 0)
- return pakfire_handle_ns_arch(pakfire, name);
+ return pakfire_root_handle_ns_arch(self, name);
// Not handled here
else
return 0;
}
-static int pakfire_setup_path(struct pakfire* self, const char* path) {
+static int pakfire_root_setup_path(pakfire_root* self, const char* path) {
int r;
// Template when running Pakfire in a temporary environment
char tmppath[PATH_MAX] = PAKFIRE_TMP_DIR "/pakfire-root-XXXXXX";
// Don't do any of this when in stub mode
- if (pakfire_has_flag(self, PAKFIRE_FLAGS_STUB))
+ if (pakfire_root_has_flag(self, PAKFIRE_ROOT_FLAGS_STUB))
return 0;
// If we don't have a path, create something temporary...
return -errno;
// Destroy the temporary directory afterwards
- self->internal_flags |= PAKFIRE_DESTROY_ON_FREE;
+ self->internal_flags |= PAKFIRE_ROOT_DESTROY_ON_FREE;
// Mount the snapshot
if (self->snapshot) {
}
// Mount a tmpfs
- } else if (pakfire_has_flag(self, PAKFIRE_USE_TMPFS)) {
+ } else if (pakfire_root_has_flag(self, PAKFIRE_ROOT_USE_TMPFS)) {
r = mount("pakfire_root", path, "tmpfs", 0, NULL);
if (r) {
ERROR(self->ctx, "Could not mount tmpfs: %m\n");
}
// Umount path later
- self->internal_flags |= PAKFIRE_UMOUNT_PATH;
+ self->internal_flags |= PAKFIRE_ROOT_UMOUNT_PATH;
}
}
return 0;
}
-static int pakfire_lock_running_kernel(struct pakfire* pakfire) {
+static int pakfire_root_lock_running_kernel(pakfire_root* self) {
struct utsname utsname;
char buffer[NAME_MAX];
// Call uname()
int r = uname(&utsname);
if (r) {
- ERROR(pakfire->ctx, "uname() failed: %m\n");
+ ERROR(self->ctx, "uname() failed: %m\n");
return r;
}
- DEBUG(pakfire->ctx, "Locking running kernel %s\n", utsname.release);
+ DEBUG(self->ctx, "Locking running kernel %s\n", utsname.release);
r = pakfire_string_format(buffer, "kernel(%s)", utsname.release);
if (r)
return r;
// Add a locking pool job
- Id id = pool_str2id(pakfire->pool, buffer, 1);
+ Id id = pool_str2id(self->pool, buffer, 1);
if (id)
- queue_push2(&pakfire->pool->pooljobs, SOLVER_LOCK|SOLVER_SOLVABLE_PROVIDES, id);
+ queue_push2(&self->pool->pooljobs, SOLVER_LOCK|SOLVER_SOLVABLE_PROVIDES, id);
return 0;
}
-static int pakfire_setup_pool(struct pakfire* pakfire) {
+static int pakfire_root_setup_pool(pakfire_root* self) {
int r;
// Initialize the pool
- Pool* pool = pakfire->pool = pool_create();
+ Pool* pool = self->pool = pool_create();
pool_setdisttype(pool, DISTTYPE_RPM);
// Don't replace source packages with binary packages
#endif
// Set architecture of the pool
- pool_setarchpolicy(pool, pakfire_get_effective_arch(pakfire));
+ pool_setarchpolicy(pool, pakfire_root_get_effective_arch(self));
// Set path
- pool_set_rootdir(pool, pakfire->path);
+ pool_set_rootdir(pool, self->path);
// Set debug callback
- pool_setdebugcallback(pool, pool_log, pakfire);
+ pool_setdebugcallback(pool, pool_log, self);
// Install namespace callback
- pool_setnamespacecallback(pool, pakfire_namespace_callback, pakfire);
+ pool_setnamespacecallback(pool, pakfire_root_namespace_callback, self);
// These packages can be installed multiple times simultaneously
- static const char* pakfire_multiinstall_packages[] = {
+ static const char* pakfire_root_multiinstall_packages[] = {
"kernel",
"kernel-devel",
NULL,
};
- for (const char** package = pakfire_multiinstall_packages; *package; package++) {
- Id id = pakfire_str2dep(pakfire, *package);
+ for (const char** package = pakfire_root_multiinstall_packages; *package; package++) {
+ Id id = pakfire_str2dep(self, *package);
if (!id)
continue;
}
// Lock the running kernel
- if (pakfire_on_root(pakfire)) {
- r = pakfire_lock_running_kernel(pakfire);
+ if (pakfire_root_on_root(self)) {
+ r = pakfire_root_lock_running_kernel(self);
if (r < 0)
return r;
}
return 0;
}
-static int pakfire_load_installed_packages(struct pakfire* self) {
+static int pakfire_root_load_installed_packages(pakfire_root* self) {
pakfire_repo* repo = NULL;
pakfire_db* db = NULL;
int r;
// Fetch the system repository
- repo = pakfire_get_repo(self, PAKFIRE_REPO_SYSTEM);
+ repo = pakfire_root_get_repo(self, PAKFIRE_REPO_SYSTEM);
// Open the database (or create a new one)
r = pakfire_db_open(&db, self, PAKFIRE_DB_READWRITE);
return r;
}
-static int pakfire_setup_default_repos(struct pakfire* self) {
+static int pakfire_root_setup_default_repos(pakfire_root* self) {
pakfire_repo* commandline = NULL;
pakfire_repo* dummy = NULL;
pakfire_repo* system = NULL;
return r;
}
-static void pakfire_free(struct pakfire* pakfire) {
+static void pakfire_root_free(pakfire_root* self) {
pakfire_repo* repo = NULL;
int r;
// Avoid recursive free
- if (pakfire->in_free)
+ if (self->in_free)
return;
- pakfire->in_free = 1;
+ self->in_free = 1;
// Destroy the commandline repository
- repo = pakfire_get_repo(pakfire, PAKFIRE_REPO_COMMANDLINE);
+ repo = pakfire_root_get_repo(self, PAKFIRE_REPO_COMMANDLINE);
if (repo) {
r = pakfire_repo_clean(repo, PAKFIRE_REPO_CLEAN_FLAGS_DESTROY);
if (r)
- ERROR(pakfire->ctx, "Could not cleanup %s repository: %m\n", PAKFIRE_REPO_COMMANDLINE);
+ ERROR(self->ctx, "Could not cleanup %s repository: %m\n", PAKFIRE_REPO_COMMANDLINE);
pakfire_repo_unref(repo);
}
// Write back the local repository
- repo = pakfire_get_repo(pakfire, PAKFIRE_REPO_LOCAL);
+ repo = pakfire_root_get_repo(self, PAKFIRE_REPO_LOCAL);
if (repo) {
// Write back the local repository metadata
r = pakfire_repo_write_metadata(repo, NULL);
if (r)
- ERROR(pakfire->ctx, "Could not write the local repository: %s. Ignoring.\n", strerror(-r));
+ ERROR(self->ctx, "Could not write the local repository: %s. Ignoring.\n", strerror(-r));
pakfire_repo_unref(repo);
}
// Close the path
- if (pakfire->fd >= 0)
- close(pakfire->fd);
+ if (self->fd >= 0)
+ close(self->fd);
// Umount the snapshot
- if (pakfire->snapshot) {
- r = pakfire_snapshot_umount(pakfire->snapshot);
+ if (self->snapshot) {
+ r = pakfire_snapshot_umount(self->snapshot);
if (r)
- ERROR(pakfire->ctx, "Could not umount the snapshot: %s\n", strerror(-r));
+ ERROR(self->ctx, "Could not umount the snapshot: %s\n", strerror(-r));
- pakfire_snapshot_unref(pakfire->snapshot);
+ pakfire_snapshot_unref(self->snapshot);
}
// Umount path
- if (pakfire->internal_flags & PAKFIRE_UMOUNT_PATH) {
- r = umount2(pakfire->path, 0);
+ if (self->internal_flags & PAKFIRE_ROOT_UMOUNT_PATH) {
+ r = umount2(self->path, 0);
if (r)
- ERROR(pakfire->ctx, "Could not umount ramdisk at %s: %m\n", pakfire->path);
+ ERROR(self->ctx, "Could not umount ramdisk at %s: %m\n", self->path);
}
// Destroy path
- if (pakfire->internal_flags & PAKFIRE_DESTROY_ON_FREE) {
- DEBUG(pakfire->ctx, "Destroying %s\n", pakfire->path);
+ if (self->internal_flags & PAKFIRE_ROOT_DESTROY_ON_FREE) {
+ DEBUG(self->ctx, "Destroying %s\n", self->path);
// Destroy the temporary directory
- r = pakfire_rmtree(pakfire->path, 0);
+ r = pakfire_rmtree(self->path, 0);
if (r)
- ERROR(pakfire->ctx, "Could not destroy %s: %s\n", pakfire->path, strerror(-r));
+ ERROR(self->ctx, "Could not destroy %s: %s\n", self->path, strerror(-r));
}
- pakfire_repo_free_all(pakfire);
+ pakfire_repo_free_all(self);
- if (pakfire->pool)
- pool_free(pakfire->pool);
- if (pakfire->writer)
- archive_write_free(pakfire->writer);
- if (pakfire->config)
- pakfire_config_unref(pakfire->config);
- if (pakfire->ctx)
- pakfire_ctx_unref(pakfire->ctx);
-
- free(pakfire);
+ if (self->pool)
+ pool_free(self->pool);
+ if (self->writer)
+ archive_write_free(self->writer);
+ if (self->config)
+ pakfire_config_unref(self->config);
+ if (self->ctx)
+ pakfire_ctx_unref(self->ctx);
+ free(self);
}
// Safety check in case this is being launched on the host system
-static int pakfire_safety_checks(struct pakfire* pakfire) {
+static int pakfire_root_safety_checks(pakfire_root* self) {
// Nothing to do if we are not working on root
- if (!pakfire_on_root(pakfire))
+ if (!pakfire_root_on_root(self))
return 0;
// We must be root in order to operate in /
- if (pakfire->user.uid) {
- ERROR(pakfire->ctx, "Must be running as root on /\n");
+ if (self->user.uid) {
+ ERROR(self->ctx, "Must be running as root on /\n");
return -EPERM;
}
return 0;
}
-static int pakfire_read_one_repo_config(struct pakfire* pakfire, DIR* dir, const char* path) {
+static int pakfire_root_read_one_repo_config(pakfire_root* self, DIR* dir, const char* path) {
FILE* f = NULL;
int fd = -1;
int r;
return -errno;
// Read the configuration
- r = pakfire_config_read(pakfire->config, f);
+ r = pakfire_config_read(self->config, f);
// Cleanup
fclose(f);
return r;
}
-static int pakfire_read_repo_config(struct pakfire* pakfire) {
+static int pakfire_root_read_repo_config(pakfire_root* self) {
struct dirent* entry = NULL;
char path[PATH_MAX];
int r;
// Make path absolute
- r = pakfire_path(pakfire, path, "%s", PAKFIRE_CONFIG_DIR "/repos");
+ r = pakfire_root_path(self, path, "%s", PAKFIRE_CONFIG_DIR "/repos");
if (r)
return r;
- DEBUG(pakfire->ctx, "Reading repository configuration from %s\n", path);
+ DEBUG(self->ctx, "Reading repository configuration from %s\n", path);
// Open path
DIR* dir = opendir(path);
return 0;
default:
- ERROR(pakfire->ctx, "Could not open %s: %m\n", path);
+ ERROR(self->ctx, "Could not open %s: %m\n", path);
return -errno;
}
}
continue;
// Read the configuration
- r = pakfire_read_one_repo_config(pakfire, dir, entry->d_name);
+ r = pakfire_root_read_one_repo_config(self, dir, entry->d_name);
if (r)
goto ERROR;
}
return r;
}
-static int pakfire_setup_local_repo(struct pakfire* self) {
+static int pakfire_root_setup_local_repo(pakfire_root* self) {
pakfire_repo* local = NULL;
char path[PATH_MAX];
char url[PATH_MAX];
int r;
// Fetch distro ID
- const char* distro_id = pakfire_get_distro_id(self);
+ const char* distro_id = pakfire_root_get_distro_id(self);
if (!distro_id) {
ERROR(self->ctx, "Could not fetch the distro ID\n");
return -EINVAL;
}
// Fetch the distro version ID
- const char* version_id = pakfire_get_distro_version_id(self);
+ const char* version_id = pakfire_root_get_distro_version_id(self);
if (!version_id) {
ERROR(self->ctx, "Could not fetch the distro version ID\n");
return -EINVAL;
}
// Make the repository path
- r = pakfire_string_format(path,
- "~/.local/share/%s/local/%s/%s", PACKAGE_NAME, distro_id, version_id);
+ r = pakfire_string_format(path, "~/.local/share/%s/local/%s/%s",
+ PACKAGE_NAME, distro_id, version_id);
if (r < 0) {
ERROR(self->ctx, "Could not compose the local repository path: %s\n", strerror(-r));
goto ERROR;
return r;
}
-static int pakfire_refresh_repo(struct pakfire* pakfire, pakfire_repo* repo, void* data) {
+static int pakfire_root_refresh_repo(pakfire_root* self, pakfire_repo* repo, void* data) {
return pakfire_repo_refresh(repo, 0);
}
-const char* pakfire_get_distro_name(struct pakfire* pakfire) {
- if (*pakfire->distro.name)
- return pakfire->distro.name;
+const char* pakfire_root_get_distro_name(pakfire_root* self) {
+ if (*self->distro.name)
+ return self->distro.name;
return NULL;
}
-const char* pakfire_get_distro_id(struct pakfire* pakfire) {
- if (*pakfire->distro.id)
- return pakfire->distro.id;
+const char* pakfire_root_get_distro_id(pakfire_root* self) {
+ if (*self->distro.id)
+ return self->distro.id;
return NULL;
}
-const char* pakfire_get_distro_vendor(struct pakfire* pakfire) {
- if (*pakfire->distro.vendor)
- return pakfire->distro.vendor;
+const char* pakfire_root_get_distro_vendor(pakfire_root* self) {
+ if (*self->distro.vendor)
+ return self->distro.vendor;
return NULL;
}
-const char* pakfire_get_distro_version(struct pakfire* pakfire) {
- if (*pakfire->distro.version)
- return pakfire->distro.version;
+const char* pakfire_root_get_distro_version(pakfire_root* self) {
+ if (*self->distro.version)
+ return self->distro.version;
return NULL;
}
-const char* pakfire_get_distro_version_id(struct pakfire* pakfire) {
- if (*pakfire->distro.version_id)
- return pakfire->distro.version_id;
+const char* pakfire_root_get_distro_version_id(pakfire_root* self) {
+ if (*self->distro.version_id)
+ return self->distro.version_id;
return NULL;
}
-const char* pakfire_get_distro_tag(struct pakfire* pakfire) {
+const char* pakfire_root_get_distro_tag(pakfire_root* self) {
int r;
// Generate the tag
- if (!*pakfire->distro.tag) {
- r = pakfire_string_format(pakfire->distro.tag,
- "%s%s", pakfire->distro.id, pakfire->distro.version_id);
+ if (!*self->distro.tag) {
+ r = pakfire_string_format(self->distro.tag, "%s%s",
+ self->distro.id, self->distro.version_id);
if (r < 0) {
errno = -r;
return NULL;
}
}
- return pakfire->distro.tag;
+ return self->distro.tag;
}
-static int pakfire_config_import_distro(struct pakfire* pakfire) {
+static int pakfire_root_config_import_distro(pakfire_root* self) {
int r;
// Nothing to do if there is no distro section
- if (!pakfire_config_has_section(pakfire->config, "distro"))
+ if (!pakfire_config_has_section(self->config, "distro"))
return 0;
// Name
- const char* name = pakfire_config_get(pakfire->config, "distro", "name", NULL);
+ const char* name = pakfire_config_get(self->config, "distro", "name", NULL);
if (name) {
- r = pakfire_string_set(pakfire->distro.name, name);
+ r = pakfire_string_set(self->distro.name, name);
if (r < 0) {
- ERROR(pakfire->ctx, "Could not set distro name: %s\n", strerror(-r));
+ ERROR(self->ctx, "Could not set distro name: %s\n", strerror(-r));
return r;
}
}
// ID
- const char* id = pakfire_config_get(pakfire->config, "distro", "id", NULL);
+ const char* id = pakfire_config_get(self->config, "distro", "id", NULL);
if (id) {
- r = pakfire_string_set(pakfire->distro.id, id);
+ r = pakfire_string_set(self->distro.id, id);
if (r < 0) {
- ERROR(pakfire->ctx, "Could not set distro ID: %s\n", strerror(-r));
+ ERROR(self->ctx, "Could not set distro ID: %s\n", strerror(-r));
return r;
}
}
// Version ID
- const char* version_id = pakfire_config_get(pakfire->config, "distro", "version_id", NULL);
+ const char* version_id = pakfire_config_get(self->config, "distro", "version_id", NULL);
if (version_id) {
- r = pakfire_string_set(pakfire->distro.version_id, version_id);
+ r = pakfire_string_set(self->distro.version_id, version_id);
if (r < 0) {
- ERROR(pakfire->ctx, "Could not set distro version ID: %s\n", strerror(-r));
+ ERROR(self->ctx, "Could not set distro version ID: %s\n", strerror(-r));
return r;
}
}
// Codename
- const char* codename = pakfire_config_get(pakfire->config, "distro", "codename", NULL);
+ const char* codename = pakfire_config_get(self->config, "distro", "codename", NULL);
if (codename) {
- r = pakfire_string_set(pakfire->distro.version_codename, codename);
+ r = pakfire_string_set(self->distro.version_codename, codename);
if (r < 0) {
- ERROR(pakfire->ctx, "Could not set distro codename: %s\n", strerror(-r));
+ ERROR(self->ctx, "Could not set distro codename: %s\n", strerror(-r));
return r;
}
}
// Fill in version
- if (*pakfire->distro.version_codename) {
- r = pakfire_string_format(pakfire->distro.version, "%s (%s)",
- pakfire->distro.version_id, pakfire->distro.version_codename);
+ if (*self->distro.version_codename) {
+ r = pakfire_string_format(self->distro.version, "%s (%s)",
+ self->distro.version_id, self->distro.version_codename);
if (r < 0) {
- ERROR(pakfire->ctx, "Could not set distro version: %s\n", strerror(-r));
+ ERROR(self->ctx, "Could not set distro version: %s\n", strerror(-r));
return r;
}
} else {
- r = pakfire_string_set(pakfire->distro.version, pakfire->distro.version_id);
+ r = pakfire_string_set(self->distro.version, self->distro.version_id);
if (r < 0) {
- ERROR(pakfire->ctx, "Could not set distro version: %s\n", strerror(-r));
+ ERROR(self->ctx, "Could not set distro version: %s\n", strerror(-r));
return r;
}
}
// Fill in pretty name
- r = pakfire_string_format(pakfire->distro.pretty_name, "%s %s",
- pakfire->distro.name, pakfire->distro.version);
+ r = pakfire_string_format(self->distro.pretty_name, "%s %s",
+ self->distro.name, self->distro.version);
if (r < 0) {
- ERROR(pakfire->ctx, "Could not set distro pretty name: %s\n", strerror(-r));
+ ERROR(self->ctx, "Could not set distro pretty name: %s\n", strerror(-r));
return r;
}
// Vendor
- const char* vendor = pakfire_config_get(pakfire->config, "distro", "vendor", NULL);
+ const char* vendor = pakfire_config_get(self->config, "distro", "vendor", NULL);
if (vendor) {
- r = pakfire_string_set(pakfire->distro.vendor, vendor);
+ r = pakfire_string_set(self->distro.vendor, vendor);
if (r < 0) {
- ERROR(pakfire->ctx, "Could not set distro vendor: %s\n", strerror(-r));
+ ERROR(self->ctx, "Could not set distro vendor: %s\n", strerror(-r));
return r;
}
}
// Slogan
- const char* slogan = pakfire_config_get(pakfire->config, "distro", "slogan", NULL);
+ const char* slogan = pakfire_config_get(self->config, "distro", "slogan", NULL);
if (slogan) {
- r = pakfire_string_set(pakfire->distro.slogan, slogan);
+ r = pakfire_string_set(self->distro.slogan, slogan);
if (r < 0) {
- ERROR(pakfire->ctx, "Could not set distro slogan: %s\n", strerror(-r));
+ ERROR(self->ctx, "Could not set distro slogan: %s\n", strerror(-r));
return r;
}
}
return 0;
}
-static int pakfire_read_os_release(struct pakfire* pakfire, const char* path) {
+static int pakfire_root_read_os_release(pakfire_root* self, const char* path) {
char file[PATH_MAX];
int r;
return r;
// Read the distro
- r = pakfire_distro(&pakfire->distro, file);
+ r = pakfire_distro(&self->distro, file);
if (r < 0) {
switch (-r) {
case ENOENT:
return 0;
default:
- ERROR(pakfire->ctx, "Could not read /etc/os-release: %s\n", strerror(-r));
+ ERROR(self->ctx, "Could not read /etc/os-release: %s\n", strerror(-r));
break;
}
}
return r;
}
-static int pakfire_set_cache_path(struct pakfire* pakfire) {
- const char* cache_path = pakfire_ctx_get_cache_path(pakfire->ctx);
- const char* arch = pakfire_get_effective_arch(pakfire);
+static int pakfire_root_set_cache_path(pakfire_root* self) {
+ const char* cache_path = pakfire_ctx_get_cache_path(self->ctx);
+ const char* arch = pakfire_root_get_effective_arch(self);
// Format the final path
- return pakfire_string_format(pakfire->cache_path, "%s/%s/%s/%s",
- cache_path, pakfire->distro.id, pakfire->distro.version_id, arch);
+ return pakfire_string_format(self->cache_path, "%s/%s/%s/%s",
+ cache_path, self->distro.id, self->distro.version_id, arch);
}
-static int pakfire_setup_user(struct pakfire* pakfire) {
+static int pakfire_root_setup_user(pakfire_root* self) {
struct passwd user;
struct passwd* u = NULL;
struct group group;
goto ERROR;
// Store UID
- pakfire->user.uid = pakfire->user.subuids.id = uid;
+ self->user.uid = self->user.subuids.id = uid;
// Store username
- r = pakfire_string_set(pakfire->user.name, user.pw_name);
+ r = pakfire_string_set(self->user.name, user.pw_name);
if (r)
goto ERROR;
// Store home directory
- r = pakfire_string_set(pakfire->user.home, user.pw_dir);
+ r = pakfire_string_set(self->user.home, user.pw_dir);
if (r)
goto ERROR;
goto ERROR;
// Store GID
- pakfire->group.gid = pakfire->group.subgids.id = gid;
+ self->group.gid = self->group.subgids.id = gid;
// Store name
- r = pakfire_string_set(pakfire->group.name, group.gr_name);
+ r = pakfire_string_set(self->group.name, group.gr_name);
if (r)
goto ERROR;
from /etc/sub{u,g}id.
*/
if (uid == 0)
- pakfire->user.subuids.length = pakfire->group.subgids.length = 0xffffffff - 1;
+ self->user.subuids.length = self->group.subgids.length = 0xffffffff - 1;
else
- pakfire->user.subuids.length = pakfire->group.subgids.length = 1;
+ self->user.subuids.length = self->group.subgids.length = 1;
// Read SUBUID/SUBGIDs from file
- if (!pakfire_on_root(pakfire)) {
+ if (!pakfire_root_on_root(self)) {
// Fetch SUBUIDs
- r = pakfire_getsubuid(pakfire, pakfire->user.name, &pakfire->user.subuids);
+ r = pakfire_getsubuid(self, self->user.name, &self->user.subuids);
switch (r) {
case 0:
case 1:
}
// Fetch SUBGIDs
- r = pakfire_getsubgid(pakfire, pakfire->user.name, &pakfire->group.subgids);
+ r = pakfire_getsubgid(self, self->user.name, &self->group.subgids);
switch (r) {
case 0:
case 1:
return r;
}
-int pakfire_create(struct pakfire** pakfire, pakfire_ctx* ctx,
+int pakfire_root_create(pakfire_root** root, pakfire_ctx* ctx,
pakfire_config* config, const char* path, const char* arch, int flags) {
- struct pakfire* p = NULL;
+ pakfire_root* self = NULL;
int r;
// Always require a configuration
// Check path
if (path) {
// Check that we don't have a path in stub mode
- if (flags & PAKFIRE_FLAGS_STUB) {
+ if (flags & PAKFIRE_ROOT_FLAGS_STUB) {
ERROR(ctx, "Cannot use path in stub mode\n");
r = -EINVAL;
goto ERROR;
}
// Check that we don't have path set when using snapshots
- if (flags & PAKFIRE_USE_SNAPSHOT) {
+ if (flags & PAKFIRE_ROOT_USE_SNAPSHOT) {
ERROR(ctx, "Cannot use path with snapshots\n");
r = -EINVAL;
goto ERROR;
}
// Allocate a new object
- p = calloc(1, sizeof(*p));
- if (!p)
+ self = calloc(1, sizeof(*self));
+ if (!self)
return -errno;
// Reference the context
- p->ctx = pakfire_ctx_ref(ctx);
+ self->ctx = pakfire_ctx_ref(ctx);
// Initialize the reference counter
- p->nrefs = 1;
+ self->nrefs = 1;
// Store the flags
- p->flags = flags;
+ self->flags = flags;
// Store a reference to the configuration
- p->config = pakfire_config_ref(config);
+ self->config = pakfire_config_ref(config);
// Initialize file descriptors
- p->fd = -EBADF;
+ self->fd = -EBADF;
// Store the nominal architecture
- r = pakfire_string_set(p->arches.nominal, arch);
+ r = pakfire_string_set(self->arches.nominal, arch);
if (r < 0)
goto ERROR;
// Determine the effective architecture
- p->arches.effective = pakfire_arch_is_supported_by_host(arch);
- if (!p->arches.effective) {
- ERROR(p->ctx, "Unsupported architecture: %s\n", arch);
+ self->arches.effective = pakfire_arch_is_supported_by_host(arch);
+ if (!self->arches.effective) {
+ ERROR(self->ctx, "Unsupported architecture: %s\n", arch);
r = -ENOTSUP;
goto ERROR;
}
// Setup user/group
- r = pakfire_setup_user(p);
+ r = pakfire_root_setup_user(self);
if (r < 0) {
- ERROR(p->ctx, "Could not parse user information: %s\n", strerror(-r));
+ ERROR(self->ctx, "Could not parse user information: %s\n", strerror(-r));
goto ERROR;
}
// Store if we have a path
if (path)
- p->internal_flags |= PAKFIRE_HAS_PATH;
+ self->internal_flags |= PAKFIRE_ROOT_HAS_PATH;
// Import distro configuration
- r = pakfire_config_import_distro(p);
+ r = pakfire_root_config_import_distro(self);
if (r < 0) {
- ERROR(p->ctx, "Could not parse distribution from configuration: %s\n", strerror(-r));
+ ERROR(self->ctx, "Could not parse distribution from configuration: %s\n", strerror(-r));
goto ERROR;
}
// Read /etc/os-release
- if (p->internal_flags & PAKFIRE_HAS_PATH) {
- r = pakfire_read_os_release(p, path);
+ if (self->internal_flags & PAKFIRE_ROOT_HAS_PATH) {
+ r = pakfire_root_read_os_release(self, path);
if (r < 0)
goto ERROR;
// Perform some safety checks
- r = pakfire_safety_checks(p);
+ r = pakfire_root_safety_checks(self);
if (r < 0)
goto ERROR;
}
// Set cache path
- r = pakfire_set_cache_path(p);
+ r = pakfire_root_set_cache_path(self);
if (r < 0) {
- ERROR(p->ctx, "Could not set cache path: %m\n");
+ ERROR(self->ctx, "Could not set cache path: %m\n");
goto ERROR;
}
// Are we using a snapshot?
- if (p->flags & PAKFIRE_USE_SNAPSHOT) {
+ if (self->flags & PAKFIRE_ROOT_USE_SNAPSHOT) {
// Find the most recent snapshot
- r = pakfire_snapshot_find(&p->snapshot, p);
+ r = pakfire_snapshot_find(&self->snapshot, self);
if (r < 0) {
- ERROR(p->ctx, "Could not find a snapshot: %s\n", strerror(-r));
+ ERROR(self->ctx, "Could not find a snapshot: %s\n", strerror(-r));
goto ERROR;
}
}
// Setup path
- r = pakfire_setup_path(p, path);
+ r = pakfire_root_setup_path(self, path);
if (r < 0)
goto ERROR;
// Setup the pool
- r = pakfire_setup_pool(p);
+ r = pakfire_root_setup_pool(self);
if (r < 0)
goto ERROR;
// Create the default repositories
- r = pakfire_setup_default_repos(p);
+ r = pakfire_root_setup_default_repos(self);
if (r < 0)
goto ERROR;
// Create repositories
- r = pakfire_repo_import(p, p->config);
+ r = pakfire_repo_import(self, self->config);
if (r < 0)
goto ERROR;
// Skip a couple of steps when in stub mode
- if (!pakfire_has_flag(p, PAKFIRE_FLAGS_STUB)) {
+ if (!pakfire_root_has_flag(self, PAKFIRE_ROOT_FLAGS_STUB)) {
// Setup the local repository
- if (p->flags & (PAKFIRE_FLAGS_BUILD|PAKFIRE_FLAGS_BUILD_LOCAL)) {
- r = pakfire_setup_local_repo(p);
+ if (self->flags & (PAKFIRE_ROOT_FLAGS_BUILD|PAKFIRE_ROOT_FLAGS_BUILD_LOCAL)) {
+ r = pakfire_root_setup_local_repo(self);
if (r < 0)
goto ERROR;
}
// Read repository configuration
- if (p->internal_flags & PAKFIRE_HAS_PATH) {
- r = pakfire_read_repo_config(p);
+ if (self->internal_flags & PAKFIRE_ROOT_HAS_PATH) {
+ r = pakfire_root_read_repo_config(self);
if (r < 0)
goto ERROR;
}
}
// Load installed packages
- if (!pakfire_has_flag(p, PAKFIRE_FLAGS_STUB)) {
- r = pakfire_load_installed_packages(p);
+ if (!pakfire_root_has_flag(self, PAKFIRE_ROOT_FLAGS_STUB)) {
+ r = pakfire_root_load_installed_packages(self);
if (r < 0)
goto ERROR;
}
// Refresh repositories
- r = pakfire_repo_walk(p, pakfire_refresh_repo, NULL);
+ r = pakfire_root_repo_walk(self, pakfire_root_refresh_repo, NULL);
if (r < 0)
goto ERROR;
- DEBUG(p->ctx, "Pakfire initialized at %p\n", p);
- DEBUG(p->ctx, " user = %s (%u)\n", p->user.name, p->user.uid);
- DEBUG(p->ctx, " group = %s (%u)\n", p->group.name, p->group.gid);
- DEBUG(p->ctx, " arch = %s (%s)\n", pakfire_get_arch(p), pakfire_get_effective_arch(p));
- DEBUG(p->ctx, " path = %s\n", pakfire_get_path(p));
- if (p->user.subuids.id)
- DEBUG(p->ctx, " subuid = %u (%zu)\n", p->user.subuids.id, p->user.subuids.length);
- if (p->group.subgids.id)
- DEBUG(p->ctx, " subgid = %u (%zu)\n", p->group.subgids.id, p->group.subgids.length);
+ DEBUG(self->ctx, "Pakfire initialized at %p\n", self);
+ DEBUG(self->ctx, " user = %s (%u)\n", self->user.name, self->user.uid);
+ DEBUG(self->ctx, " group = %s (%u)\n", self->group.name, self->group.gid);
+ DEBUG(self->ctx, " arch = %s (%s)\n",
+ pakfire_root_get_arch(self), pakfire_root_get_effective_arch(self));
+ DEBUG(self->ctx, " path = %s\n", pakfire_root_get_path(self));
+ if (self->user.subuids.id)
+ DEBUG(self->ctx, " subuid = %u (%zu)\n",
+ self->user.subuids.id, self->user.subuids.length);
+ if (self->group.subgids.id)
+ DEBUG(self->ctx, " subgid = %u (%zu)\n",
+ self->group.subgids.id, self->group.subgids.length);
// Dump distribution configuration
- DEBUG(p->ctx, " Distribution: %s\n", p->distro.pretty_name);
- DEBUG(p->ctx, " name = %s\n", p->distro.name);
- DEBUG(p->ctx, " id = %s\n", p->distro.id);
- DEBUG(p->ctx, " version = %s\n", p->distro.version);
- DEBUG(p->ctx, " version_id = %s\n", p->distro.version_id);
- if (*p->distro.version_codename)
- DEBUG(p->ctx, " codename = %s\n", p->distro.version_codename);
- if (*p->distro.vendor)
- DEBUG(p->ctx, " vendor = %s\n", p->distro.vendor);
- if (*p->distro.slogan)
- DEBUG(p->ctx, " slogan = %s\n", p->distro.slogan);
+ DEBUG(self->ctx, " Distribution: %s\n", self->distro.pretty_name);
+ DEBUG(self->ctx, " name = %s\n", self->distro.name);
+ DEBUG(self->ctx, " id = %s\n", self->distro.id);
+ DEBUG(self->ctx, " version = %s\n", self->distro.version);
+ DEBUG(self->ctx, " version_id = %s\n", self->distro.version_id);
+ if (*self->distro.version_codename)
+ DEBUG(self->ctx, " codename = %s\n", self->distro.version_codename);
+ if (*self->distro.vendor)
+ DEBUG(self->ctx, " vendor = %s\n", self->distro.vendor);
+ if (*self->distro.slogan)
+ DEBUG(self->ctx, " slogan = %s\n", self->distro.slogan);
// Return the pointer
- *pakfire = pakfire_ref(p);
+ *root = pakfire_root_ref(self);
ERROR:
- if (p)
- pakfire_unref(p);
+ if (self)
+ pakfire_root_unref(self);
return r;
}
-struct pakfire* pakfire_ref(struct pakfire* pakfire) {
- ++pakfire->nrefs;
+pakfire_root* pakfire_root_ref(pakfire_root* self) {
+ ++self->nrefs;
- return pakfire;
+ return self;
}
-struct pakfire* pakfire_unref(struct pakfire* pakfire) {
- if (--pakfire->nrefs > 0)
- return pakfire;
+pakfire_root* pakfire_root_unref(pakfire_root* self) {
+ if (--self->nrefs > 0)
+ return self;
- pakfire_free(pakfire);
+ pakfire_root_free(self);
return NULL;
}
-pakfire_ctx* pakfire_get_ctx(struct pakfire* pakfire) {
- return pakfire_ctx_ref(pakfire->ctx);
+pakfire_ctx* pakfire_root_get_ctx(pakfire_root* self) {
+ return pakfire_ctx_ref(self->ctx);
}
-int pakfire_has_flag(struct pakfire* pakfire, const int flag) {
- return pakfire->flags & flag;
+int pakfire_root_has_flag(pakfire_root* self, const int flag) {
+ return self->flags & flag;
}
-pakfire_config* pakfire_get_config(struct pakfire* pakfire) {
- if (!pakfire->config)
+pakfire_config* pakfire_root_get_config(pakfire_root* self) {
+ if (!self->config)
return NULL;
- return pakfire_config_ref(pakfire->config);
+ return pakfire_config_ref(self->config);
}
-const char* pakfire_get_path(struct pakfire* pakfire) {
- return pakfire->path;
+const char* pakfire_root_get_path(pakfire_root* self) {
+ return self->path;
}
-int pakfire_openat(struct pakfire* pakfire, const char* path, int flags) {
+int pakfire_root_openat(pakfire_root* self, const char* path, int flags) {
// Make paths relative
while (*path == '/')
path++;
- return openat(pakfire->fd, path, flags);
+ return openat(self->fd, path, flags);
}
-int __pakfire_path(struct pakfire* pakfire, char* path, const size_t length,
- const char* format, ...) {
+int __pakfire_root_path(pakfire_root* self, char* path, const size_t length, const char* format, ...) {
char buffer[PATH_MAX];
va_list args;
int r;
// Check if path is set
- if (!*pakfire->path) {
- ERROR(pakfire->ctx, "pakfire_path() called without path being set\n");
+ if (!*self->path) {
+ ERROR(self->ctx, "pakfire_path() called without path being set\n");
return -ENOTSUP;
}
return r;
// Join paths together
- return __pakfire_path_append(path, length, pakfire->path, buffer);
+ return __pakfire_path_append(path, length, self->path, buffer);
}
-const char* pakfire_relpath(struct pakfire* pakfire, const char* path) {
- return pakfire_path_relpath(pakfire->path, path);
+const char* pakfire_root_relpath(pakfire_root* self, const char* path) {
+ return pakfire_path_relpath(self->path, path);
}
-int __pakfire_cache_path(struct pakfire* pakfire, char* path, size_t length,
+int __pakfire_root_cache_path(pakfire_root* self, char* path, size_t length,
const char* format, ...) {
char buffer[PATH_MAX];
va_list args;
return r;
// Join paths together
- return __pakfire_path_append(path, length, pakfire->cache_path, buffer);
+ return __pakfire_path_append(path, length, self->cache_path, buffer);
}
-int pakfire_repo_walk(struct pakfire* pakfire,
- pakfire_repo_walk_callback callback, void* p) {
+int pakfire_root_repo_walk(pakfire_root* self,
+ pakfire_root_repo_walk_callback callback, void* p) {
pakfire_repo* repo = NULL;
Repo* solv_repo = NULL;
int i = 0;
int r;
- Pool* pool = pakfire->pool;
+ Pool* pool = self->pool;
// Run func for every repository
FOR_REPOS(i, solv_repo) {
- r = pakfire_repo_open(&repo, pakfire, solv_repo);
+ r = pakfire_repo_open(&repo, self, solv_repo);
if (r < 0)
return r;
// Run callback
- r = callback(pakfire, repo, p);
+ r = callback(self, repo, p);
pakfire_repo_unref(repo);
// Raise any errors
return 0;
}
-static int __pakfire_repo_clean(struct pakfire* pakfire, pakfire_repo* repo,
- void* p) {
+static int __pakfire_root_repo_clean(pakfire_root* self, pakfire_repo* repo, void* p) {
int flags = *(int*)p;
return pakfire_repo_clean(repo, flags);
}
-int pakfire_clean(struct pakfire* pakfire, int flags) {
+int pakfire_root_clean(pakfire_root* self, int flags) {
int r;
// Clean all repositories
- r = pakfire_repo_walk(pakfire, __pakfire_repo_clean, &flags);
+ r = pakfire_root_repo_walk(self, __pakfire_root_repo_clean, &flags);
if (r)
return r;
// Clean all snapshots
- r = pakfire_snapshot_clean(pakfire);
+ r = pakfire_snapshot_clean(self);
if (r < 0)
return r;
// Clean build environments
- r = pakfire_build_clean(pakfire, flags);
+ r = pakfire_build_clean(self, flags);
if (r)
return r;
return pakfire_rmtree(PAKFIRE_CACHE_DIR, 0);
}
-const char* pakfire_get_arch(struct pakfire* pakfire) {
- return pakfire->arches.nominal;
+const char* pakfire_root_get_arch(pakfire_root* self) {
+ return self->arches.nominal;
}
-const char* pakfire_get_effective_arch(struct pakfire* pakfire) {
- return pakfire->arches.effective;
+const char* pakfire_root_get_effective_arch(pakfire_root* self) {
+ return self->arches.effective;
}
-int pakfire_version_compare(struct pakfire* pakfire, const char* evr1, const char* evr2) {
- return pool_evrcmp_str(pakfire->pool, evr1, evr2, EVRCMP_COMPARE);
+int pakfire_root_version_compare(pakfire_root* self, const char* evr1, const char* evr2) {
+ return pool_evrcmp_str(self->pool, evr1, evr2, EVRCMP_COMPARE);
}
-Pool* pakfire_get_solv_pool(struct pakfire* pakfire) {
- return pakfire->pool;
+Pool* pakfire_root_get_solv_pool(pakfire_root* self) {
+ return self->pool;
}
-void pakfire_pool_has_changed(struct pakfire* pakfire) {
- pakfire->internal_flags &= ~PAKFIRE_POOL_READY;
+void pakfire_root_pool_has_changed(pakfire_root* self) {
+ self->internal_flags &= ~PAKFIRE_ROOT_POOL_READY;
}
-static int __pakfire_repo_internalize(struct pakfire* pakfire, pakfire_repo* repo,
- void* p) {
+static int __pakfire_root_repo_internalize(pakfire_root* self, pakfire_repo* repo, void* p) {
int flags = *(int*)p;
return pakfire_repo_internalize(repo, flags);
}
-void pakfire_pool_internalize(struct pakfire* pakfire) {
+void pakfire_root_pool_internalize(pakfire_root* self) {
int flags = 0;
// Nothing to do if the pool is ready
- if (pakfire->internal_flags & PAKFIRE_POOL_READY)
+ if (self->internal_flags & PAKFIRE_ROOT_POOL_READY)
return;
// Internalize all repositories
- pakfire_repo_walk(pakfire, __pakfire_repo_internalize, &flags);
+ pakfire_root_repo_walk(self, __pakfire_root_repo_internalize, &flags);
// Create fileprovides
- pool_addfileprovides(pakfire->pool);
+ pool_addfileprovides(self->pool);
// Create whatprovides index
- pool_createwhatprovides(pakfire->pool);
+ pool_createwhatprovides(self->pool);
// Mark the pool as ready
- pakfire->internal_flags |= PAKFIRE_POOL_READY;
+ self->internal_flags |= PAKFIRE_ROOT_POOL_READY;
}
-pakfire_repolist* pakfire_get_repos(struct pakfire* pakfire) {
+pakfire_repolist* pakfire_root_get_repos(pakfire_root* self) {
pakfire_repo* repo = NULL;
pakfire_repolist* list;
if (r)
return NULL;
- Pool* pool = pakfire_get_solv_pool(pakfire);
+ Pool* pool = pakfire_root_get_solv_pool(self);
Repo* solv_repo;
int i;
continue;
// Create repository
- r = pakfire_repo_open(&repo, pakfire, solv_repo);
+ r = pakfire_repo_open(&repo, self, solv_repo);
if (r < 0)
goto ERROR;
return NULL;
}
-pakfire_repo* pakfire_get_repo(struct pakfire* pakfire, const char* name) {
+pakfire_repo* pakfire_root_get_repo(pakfire_root* self, const char* name) {
pakfire_repo* repo = NULL;
Repo* solv_repo = NULL;
int r;
int i;
- Pool* pool = pakfire_get_solv_pool(pakfire);
+ Pool* pool = pakfire_root_get_solv_pool(self);
if (!pool)
return NULL;
FOR_REPOS(i, solv_repo) {
if (strcmp(solv_repo->name, name) == 0) {
- r = pakfire_repo_open(&repo, pakfire, solv_repo);
+ r = pakfire_repo_open(&repo, self, solv_repo);
if (r < 0)
return NULL;
return NULL;
}
-pakfire_repo* pakfire_get_installed_repo(struct pakfire* pakfire) {
+pakfire_repo* pakfire_root_get_installed_repo(pakfire_root* self) {
pakfire_repo* repo = NULL;
int r;
- if (!pakfire->pool->installed)
+ if (!self->pool->installed)
return NULL;
// Open the repository
- r = pakfire_repo_open(&repo, pakfire, pakfire->pool->installed);
+ r = pakfire_repo_open(&repo, self, self->pool->installed);
if (r < 0)
return NULL;
/*
Convenience function to dist() a package on the fly
*/
-static int pakfire_commandline_dist(struct pakfire* pakfire, pakfire_repo* repo,
- const char* path, pakfire_package** pkg) {
+static int pakfire_root_commandline_dist(pakfire_root* self,
+ pakfire_repo* repo, const char* path, pakfire_package** pkg) {
pakfire_archive* archive = NULL;
int r;
// Run dist()
- r = pakfire_dist(pakfire, path, &archive);
+ r = pakfire_dist(self, path, &archive);
if (r < 0)
goto ERROR;
/*
Convenience function to add a package to the @commandline repository
*/
-int pakfire_commandline_add(struct pakfire* pakfire, const char* path,
- pakfire_package** package) {
+int pakfire_root_commandline_add(pakfire_root* self,
+ const char* path, pakfire_package** package) {
pakfire_repo* repo = NULL;
int r;
// Find the commandline repository
- repo = pakfire_get_repo(pakfire, PAKFIRE_REPO_COMMANDLINE);
+ repo = pakfire_root_get_repo(self, PAKFIRE_REPO_COMMANDLINE);
if (!repo) {
- ERROR(pakfire->ctx, "Could not find the commandline repository: %m\n");
+ ERROR(self->ctx, "Could not find the commandline repository: %m\n");
return 1;
}
r = pakfire_repo_add(repo, path, package);
switch (-r) {
case ENOMSG:
- r = pakfire_commandline_dist(pakfire, repo, path, package);
+ r = pakfire_root_commandline_dist(self, repo, path, package);
break;
default:
return r;
}
-static int __pakfire_search(struct pakfire* pakfire, pakfire_packagelist* list,
+static int __pakfire_root_search(pakfire_root* self, pakfire_packagelist* list,
const Id* keys, const char* what, int flags) {
Dataiterator di;
Queue matches;
int r;
// Get the pool ready
- pakfire_pool_internalize(pakfire);
+ pakfire_root_pool_internalize(self);
// Initialize the result queue
queue_init(&matches);
// Setup the data interator
- dataiterator_init(&di, pakfire->pool, 0, 0, 0, what, flags);
+ dataiterator_init(&di, self->pool, 0, 0, 0, what, flags);
// Search through these keys and add matches to the queue
for (const Id* key = keys; *key; key++) {
}
// Import matches into the package list
- r = pakfire_packagelist_import_solvables(list, pakfire, &matches);
+ r = pakfire_packagelist_import_solvables(list, self, &matches);
if (r)
goto ERROR;
return r;
}
-static int pakfire_search_filelist(struct pakfire* pakfire, const char* what, int flags,
+static int pakfire_root_search_filelist(pakfire_root* self, const char* what, int flags,
pakfire_packagelist* list) {
const Id keys[] = {
SOLVABLE_FILELIST,
ID_NULL,
};
- return __pakfire_search(pakfire, list, keys, what, SEARCH_FILES|SEARCH_GLOB);
+ return __pakfire_root_search(self, list, keys, what, SEARCH_FILES|SEARCH_GLOB);
}
-static int pakfire_search_dep(struct pakfire* pakfire, Id type, const char* what, int flags,
+static int pakfire_root_search_dep(pakfire_root* self, Id type, const char* what, int flags,
pakfire_packagelist* list) {
int r;
// Get the pool ready
- pakfire_pool_internalize(pakfire);
+ pakfire_root_pool_internalize(self);
// Translate dependency to ID
- Id dep = pakfire_str2dep(pakfire, what);
+ Id dep = pakfire_str2dep(self, what);
if (!dep) {
errno = EINVAL;
return 1;
queue_init(&matches);
// Search for anything that matches
- pool_whatmatchesdep(pakfire->pool, type, dep, &matches, 0);
+ pool_whatmatchesdep(self->pool, type, dep, &matches, 0);
// Add the result to the packagelist
- r = pakfire_packagelist_import_solvables(list, pakfire, &matches);
+ r = pakfire_packagelist_import_solvables(list, self, &matches);
if (r)
goto ERROR;
return r;
}
-int pakfire_whatprovides(struct pakfire* pakfire, const char* what, int flags,
+int pakfire_root_whatprovides(pakfire_root* self, const char* what, int flags,
pakfire_packagelist* list) {
int r;
}
// Search for all packages that match this dependency
- r = pakfire_search_dep(pakfire, SOLVABLE_PROVIDES, what, flags, list);
+ r = pakfire_root_search_dep(self, SOLVABLE_PROVIDES, what, flags, list);
if (r)
return r;
// Search the filelist
if (*what == '/') {
- r = pakfire_search_filelist(pakfire, what, flags, list);
+ r = pakfire_root_search_filelist(self, what, flags, list);
if (r)
return r;
}
return 0;
}
-static int __pakfire_whatrequires(pakfire_ctx* ctx, pakfire_package* pkg, void* data) {
+static int __pakfire_root_whatrequires(pakfire_ctx* ctx, pakfire_package* pkg, void* data) {
pakfire_packagelist* reverse = NULL;
pakfire_packagelist* list = data;
int r;
return r;
}
-int pakfire_whatrequires(struct pakfire* pakfire, const char* what, int flags,
+int pakfire_root_whatrequires(pakfire_root* self, const char* what, int flags,
pakfire_packagelist* list) {
pakfire_packagelist* packages = NULL;
int r;
};
// Create a new package list
- r = pakfire_packagelist_create(&packages, pakfire->ctx);
+ r = pakfire_packagelist_create(&packages, self->ctx);
if (r)
goto ERROR;
// Find any packages that match the name
- r = __pakfire_search(pakfire, packages, keys, what, SEARCH_STRING);
+ r = __pakfire_root_search(self, packages, keys, what, SEARCH_STRING);
if (r)
goto ERROR;
// Find everything for all packages
- r = pakfire_packagelist_walk(packages, __pakfire_whatrequires, list, 0);
+ r = pakfire_packagelist_walk(packages, __pakfire_root_whatrequires, list, 0);
if (r)
goto ERROR;
// Append any simple dependencies
- r = pakfire_search_dep(pakfire, SOLVABLE_REQUIRES, what, flags, list);
+ r = pakfire_root_search_dep(self, SOLVABLE_REQUIRES, what, flags, list);
if (r)
goto ERROR;
return r;
}
-int pakfire_search(struct pakfire* pakfire, const char* what, int flags,
+int pakfire_root_search(pakfire_root* self, const char* what, int flags,
pakfire_packagelist* list) {
const Id keys[] = {
SOLVABLE_NAME,
ID_NULL
};
- return __pakfire_search(pakfire,
+ return __pakfire_root_search(self,
list,
- (flags & PAKFIRE_SEARCH_NAME_ONLY) ? keys_name_only : keys,
+ (flags & PAKFIRE_ROOT_SEARCH_NAME_ONLY) ? keys_name_only : keys,
what,
SEARCH_SUBSTRING|SEARCH_NOCASE);
}
-static const char* pakfire_user_lookup(void* data, la_int64_t uid) {
- struct pakfire* pakfire = (struct pakfire*)data;
+static const char* pakfire_root_user_lookup(void* data, la_int64_t uid) {
+ pakfire_root* self = data;
// Unmap the UID first
- uid = pakfire_unmap_id(pakfire, &pakfire->user.subuids, uid);
+ uid = pakfire_root_unmap_id(self, &self->user.subuids, uid);
// Fast path for "root"
if (uid == 0)
return "root";
- DEBUG(pakfire->ctx, "Looking up name for UID %ld\n", uid);
+ DEBUG(self->ctx, "Looking up name for UID %ld\n", uid);
// Find a matching entry in /etc/passwd
- struct passwd* entry = pakfire_getpwuid(pakfire, uid);
+ struct passwd* entry = pakfire_getpwuid(self, uid);
if (!entry) {
- ERROR(pakfire->ctx, "Could not retrieve uname for %ld: %m\n", uid);
+ ERROR(self->ctx, "Could not retrieve uname for %ld: %m\n", uid);
return 0;
}
- DEBUG(pakfire->ctx, "Mapping UID %ld to %s\n", uid, entry->pw_name);
+ DEBUG(self->ctx, "Mapping UID %ld to %s\n", uid, entry->pw_name);
return entry->pw_name;
}
-static const char* pakfire_group_lookup(void* data, la_int64_t gid) {
- struct pakfire* pakfire = (struct pakfire*)data;
+static const char* pakfire_root_group_lookup(void* data, la_int64_t gid) {
+ pakfire_root* self = data;
// Unmap the GID first
- gid = pakfire_unmap_id(pakfire, &pakfire->group.subgids, gid);
+ gid = pakfire_root_unmap_id(self, &self->group.subgids, gid);
// Fast path for "root"
if (gid == 0)
return "root";
- DEBUG(pakfire->ctx, "Looking up name for GID %ld\n", gid);
+ DEBUG(self->ctx, "Looking up name for GID %ld\n", gid);
// Find a matching entry in /etc/group
- struct group* entry = pakfire_getgrgid(pakfire, gid);
+ struct group* entry = pakfire_getgrgid(self, gid);
if (!entry) {
- ERROR(pakfire->ctx, "Could not retrieve gname for %ld: %m\n", gid);
+ ERROR(self->ctx, "Could not retrieve gname for %ld: %m\n", gid);
return 0;
}
- DEBUG(pakfire->ctx, "Mapping GID %ld to %s\n", gid, entry->gr_name);
+ DEBUG(self->ctx, "Mapping GID %ld to %s\n", gid, entry->gr_name);
return entry->gr_name;
}
-struct archive* pakfire_get_disk_reader(struct pakfire* pakfire) {
+struct archive* pakfire_root_get_disk_reader(pakfire_root* self) {
struct archive* reader = NULL;
int r;
// Create a new reader
reader = archive_read_disk_new();
if (!reader) {
- ERROR(pakfire->ctx, "Could not set up reader: %m\n");
+ ERROR(self->ctx, "Could not set up reader: %m\n");
return NULL;
}
// Do not read fflags
r = archive_read_disk_set_behavior(reader, ARCHIVE_READDISK_NO_FFLAGS);
if (r) {
- ERROR(pakfire->ctx, "Could not change behavior of reader: %s\n",
+ ERROR(self->ctx, "Could not change behavior of reader: %s\n",
archive_error_string(reader));
goto ERROR;
}
// Install user/group lookups
- archive_read_disk_set_uname_lookup(reader, pakfire, pakfire_user_lookup, NULL);
- archive_read_disk_set_gname_lookup(reader, pakfire, pakfire_group_lookup, NULL);
+ archive_read_disk_set_uname_lookup(reader, self, pakfire_root_user_lookup, NULL);
+ archive_read_disk_set_gname_lookup(reader, self, pakfire_root_group_lookup, NULL);
return reader;
return NULL;
}
-static la_int64_t pakfire_uid_lookup(void* data, const char* name, la_int64_t uid) {
- struct pakfire* pakfire = (struct pakfire*)data;
+static la_int64_t pakfire_root_uid_lookup(void* data, const char* name, la_int64_t uid) {
+ pakfire_root* self = data;
// Cannot handle empty names
if (!*name)
if (strcmp(name, "root") == 0)
goto ERROR;
- DEBUG(pakfire->ctx, "Looking up UID for '%s' (%ld)\n", name, uid);
+ DEBUG(self->ctx, "Looking up UID for '%s' (%ld)\n", name, uid);
// Find a matching entry in /etc/passwd
- struct passwd* entry = pakfire_getpwnam(pakfire, name);
+ struct passwd* entry = pakfire_getpwnam(self, name);
if (!entry) {
- ERROR(pakfire->ctx, "Could not retrieve UID for '%s': %m\n", name);
+ ERROR(self->ctx, "Could not retrieve UID for '%s': %m\n", name);
goto ERROR;
}
- DEBUG(pakfire->ctx, "Mapping %s to UID %u\n", name, entry->pw_uid);
+ DEBUG(self->ctx, "Mapping %s to UID %u\n", name, entry->pw_uid);
- return pakfire_map_id(pakfire, &pakfire->user.subuids, entry->pw_uid);
+ return pakfire_root_map_id(self, &self->user.subuids, entry->pw_uid);
ERROR:
// Return root on error
- return pakfire_map_id(pakfire, &pakfire->user.subuids, 0);
+ return pakfire_root_map_id(self, &self->user.subuids, 0);
}
-static la_int64_t pakfire_gid_lookup(void* data, const char* name, la_int64_t gid) {
- struct pakfire* pakfire = (struct pakfire*)data;
+static la_int64_t pakfire_root_gid_lookup(void* data, const char* name, la_int64_t gid) {
+ pakfire_root* self = data;
// Cannot handle empty names
if (!*name)
if (strcmp(name, "root") == 0)
goto ERROR;
- DEBUG(pakfire->ctx, "Looking up GID for '%s' (%ld)\n", name, gid);
+ DEBUG(self->ctx, "Looking up GID for '%s' (%ld)\n", name, gid);
// Find a matching entry in /etc/group
- struct group* entry = pakfire_getgrnam(pakfire, name);
+ struct group* entry = pakfire_getgrnam(self, name);
if (!entry) {
- ERROR(pakfire->ctx, "Could not retrieve GID for '%s': %m\n", name);
+ ERROR(self->ctx, "Could not retrieve GID for '%s': %m\n", name);
goto ERROR;
}
- DEBUG(pakfire->ctx, "Mapping %s to GID %u\n", name, entry->gr_gid);
+ DEBUG(self->ctx, "Mapping %s to GID %u\n", name, entry->gr_gid);
- return pakfire_map_id(pakfire, &pakfire->group.subgids, entry->gr_gid);
+ return pakfire_root_map_id(self, &self->group.subgids, entry->gr_gid);
ERROR:
// Return root on error
- return pakfire_map_id(pakfire, &pakfire->group.subgids, 0);
+ return pakfire_root_map_id(self, &self->group.subgids, 0);
}
-struct archive* pakfire_get_disk_writer(struct pakfire* pakfire) {
+struct archive* pakfire_root_get_disk_writer(pakfire_root* self) {
// Set flags for extracting files
const int flags =
ARCHIVE_EXTRACT_ACL |
ARCHIVE_EXTRACT_UNLINK |
ARCHIVE_EXTRACT_XATTR;
- if (!pakfire->writer) {
+ if (!self->writer) {
// Create a new writer
- pakfire->writer = archive_write_disk_new();
- if (!pakfire->writer) {
- ERROR(pakfire->ctx, "Could not set up writer: %m\n");
+ self->writer = archive_write_disk_new();
+ if (!self->writer) {
+ ERROR(self->ctx, "Could not set up writer: %m\n");
return NULL;
}
- archive_write_disk_set_options(pakfire->writer, flags);
+ archive_write_disk_set_options(self->writer, flags);
// Install our own routine for user/group lookups
- archive_write_disk_set_user_lookup(pakfire->writer,
- pakfire, pakfire_uid_lookup, NULL);
- archive_write_disk_set_group_lookup(pakfire->writer,
- pakfire, pakfire_gid_lookup, NULL);
+ archive_write_disk_set_user_lookup(self->writer,
+ self, pakfire_root_uid_lookup, NULL);
+ archive_write_disk_set_group_lookup(self->writer,
+ self, pakfire_root_gid_lookup, NULL);
}
- return pakfire->writer;
+ return self->writer;
}
// Convenience functions to install/erase/update packages
-static int pakfire_verify(struct pakfire* pakfire, int *changed) {
+static int pakfire_root_verify(pakfire_root* self, int *changed) {
#if 0
- return pakfire_perform_transaction_simple(pakfire, 0, PAKFIRE_JOB_VERIFY,
+ return pakfire_root_perform_transaction_simple(self, 0, pakfire_root_JOB_VERIFY,
0, changed, NULL, NULL);
#endif
#warning TODO
return 0;
}
-static int pakfire_check_files(struct pakfire* pakfire,
- pakfire_db* db, pakfire_filelist* errors) {
+static int pakfire_root_check_files(pakfire_root* self, pakfire_db* db, pakfire_filelist* errors) {
pakfire_filelist* filelist = NULL;
int r;
return r;
}
-int pakfire_check(struct pakfire* pakfire, pakfire_filelist* errors) {
+int pakfire_root_check(pakfire_root* self, pakfire_filelist* errors) {
pakfire_db* db = NULL;
int r;
// Open database in read-only mode and try to load all installed packages
- r = pakfire_db_open(&db, pakfire, PAKFIRE_DB_READWRITE);
+ r = pakfire_db_open(&db, self, PAKFIRE_DB_READWRITE);
if (r)
goto ERROR;
goto ERROR;
// Check if all dependencies are intact
- r = pakfire_verify(pakfire, NULL);
+ r = pakfire_root_verify(self, NULL);
if (r)
goto ERROR;
// Check files
- r = pakfire_check_files(pakfire, db, errors);
+ r = pakfire_root_check_files(self, db, errors);
if (r)
goto ERROR;
return r;
}
-int pakfire_update_snapshot(struct pakfire* pakfire) {
+int pakfire_root_update_snapshot(pakfire_root* self) {
pakfire_snapshot* snapshot = NULL;
int r;
// Make a new snapshot
- r = pakfire_snapshot_make(&snapshot, pakfire);
+ r = pakfire_snapshot_make(&snapshot, self);
if (r < 0)
goto ERROR;
/*
* Convenience function to install a couple of packages. Simple.
*/
-int pakfire_install(struct pakfire* self, const char** packages) {
+int pakfire_root_install(pakfire_root* self, const char** packages) {
pakfire_transaction* transaction = NULL;
char* problems = NULL;
int r;
# #
#############################################################################*/
-#ifndef PAKFIRE_PAKFIRE_H
-#define PAKFIRE_PAKFIRE_H
+#ifndef PAKFIRE_ROOT_H
+#define PAKFIRE_ROOT_H
#include <stdarg.h>
#include <stddef.h>
// libsolv
#include <solv/pool.h>
-struct pakfire;
+typedef struct pakfire_root pakfire_root;
#include <pakfire/config.h>
#include <pakfire/ctx.h>
#include <pakfire/repolist.h>
#include <pakfire/transaction.h>
-enum pakfire_flags {
- PAKFIRE_FLAGS_STUB = (1 << 0),
- PAKFIRE_FLAGS_BUILD = (1 << 1),
- PAKFIRE_FLAGS_BUILD_LOCAL = (1 << 2),
- PAKFIRE_USE_TMPFS = (1 << 3),
- PAKFIRE_USE_SNAPSHOT = (1 << 4),
+enum pakfire_rootflags {
+ PAKFIRE_ROOT_FLAGS_STUB = (1 << 0),
+ PAKFIRE_ROOT_FLAGS_BUILD = (1 << 1),
+ PAKFIRE_ROOT_FLAGS_BUILD_LOCAL = (1 << 2),
+ PAKFIRE_ROOT_USE_TMPFS = (1 << 3),
+ PAKFIRE_ROOT_USE_SNAPSHOT = (1 << 4),
};
-int pakfire_create(struct pakfire** pakfire, pakfire_ctx* ctx,
+int pakfire_root_create(pakfire_root** pakfire, pakfire_ctx* ctx,
pakfire_config* config, const char* path, const char* arch, int flags);
-struct pakfire* pakfire_ref(struct pakfire* pakfire);
-struct pakfire* pakfire_unref(struct pakfire* pakfire);
+pakfire_root* pakfire_root_ref(pakfire_root* pakfire);
+pakfire_root* pakfire_root_unref(pakfire_root* pakfire);
-int pakfire_has_flag(struct pakfire* pakfire, const int flag);
+int pakfire_root_has_flag(pakfire_root* pakfire, const int flag);
-const char* pakfire_get_path(struct pakfire* pakfire);
+const char* pakfire_root_get_path(pakfire_root* pakfire);
-int pakfire_clean(struct pakfire* pakfire, int flags);
+int pakfire_root_clean(pakfire_root* pakfire, int flags);
-const char* pakfire_get_arch(struct pakfire* pakfire);
+const char* pakfire_root_get_arch(pakfire_root* pakfire);
-int pakfire_version_compare(struct pakfire* pakfire, const char* evr1, const char* evr2);
+int pakfire_root_version_compare(pakfire_root* pakfire, const char* evr1, const char* evr2);
-pakfire_repolist* pakfire_get_repos(struct pakfire* pakfire);
-pakfire_repo* pakfire_get_repo(struct pakfire* pakfire, const char* name);
+pakfire_repolist* pakfire_root_get_repos(pakfire_root* pakfire);
+pakfire_repo* pakfire_root_get_repo(pakfire_root* pakfire, const char* name);
-int pakfire_whatprovides(struct pakfire* pakfire, const char* what, int flags,
+int pakfire_root_whatprovides(pakfire_root* pakfire, const char* what, int flags,
pakfire_packagelist* list);
-int pakfire_whatrequires(struct pakfire* pakfire, const char* what, int flags,
+int pakfire_root_whatrequires(pakfire_root* pakfire, const char* what, int flags,
pakfire_packagelist* list);
// Search
-enum pakfire_search_flags {
- PAKFIRE_SEARCH_NAME_ONLY = (1 << 0),
+enum pakfire_rootsearch_flags {
+ PAKFIRE_ROOT_SEARCH_NAME_ONLY = (1 << 0),
};
-int pakfire_search(struct pakfire* pakfire, const char* what, int flags,
+int pakfire_root_search(pakfire_root* pakfire, const char* what, int flags,
pakfire_packagelist* list);
// Check
-int pakfire_check(struct pakfire* pakfire, pakfire_filelist* errors);
+int pakfire_root_check(pakfire_root* pakfire, pakfire_filelist* errors);
// Snapshots
-int pakfire_update_snapshot(struct pakfire* pakfire);
+int pakfire_root_update_snapshot(pakfire_root* pakfire);
-pakfire_ctx* pakfire_get_ctx(struct pakfire* pakfire);
+pakfire_ctx* pakfire_root_get_ctx(pakfire_root* pakfire);
-const char* pakfire_get_effective_arch(struct pakfire* pakfire);
+const char* pakfire_root_get_effective_arch(pakfire_root* pakfire);
-int pakfire_on_root(struct pakfire* pakfire);
+int pakfire_root_on_root(pakfire_root* pakfire);
-uid_t pakfire_uid(struct pakfire* pakfire);
-gid_t pakfire_gid(struct pakfire* pakfire);
+uid_t pakfire_root_uid(pakfire_root* pakfire);
+gid_t pakfire_root_gid(pakfire_root* pakfire);
-const struct pakfire_subid* pakfire_subuid(struct pakfire* pakfire);
-const struct pakfire_subid* pakfire_subgid(struct pakfire* pakfire);
+const struct pakfire_subid* pakfire_root_subuid(pakfire_root* pakfire);
+const struct pakfire_subid* pakfire_root_subgid(pakfire_root* pakfire);
-pakfire_config* pakfire_get_config(struct pakfire* pakfire);
+pakfire_config* pakfire_root_get_config(pakfire_root* pakfire);
-int pakfire_confirm(struct pakfire* pakfire, const char* message, const char* question);
-int pakfire_pick_solution(struct pakfire* pakfire, pakfire_transaction* transaction);
-int pakfire_setup_progress(struct pakfire* pakfire, pakfire_progress* progress);
+const char* pakfire_root_get_distro_name(pakfire_root* pakfire);
+const char* pakfire_root_get_distro_id(pakfire_root* pakfire);
+const char* pakfire_root_get_distro_vendor(pakfire_root* pakfire);
+const char* pakfire_root_get_distro_version(pakfire_root* pakfire);
+const char* pakfire_root_get_distro_version_id(pakfire_root* pakfire);
+const char* pakfire_root_get_distro_tag(pakfire_root* pakfire);
-const char* pakfire_get_distro_name(struct pakfire* pakfire);
-const char* pakfire_get_distro_id(struct pakfire* pakfire);
-const char* pakfire_get_distro_vendor(struct pakfire* pakfire);
-const char* pakfire_get_distro_version(struct pakfire* pakfire);
-const char* pakfire_get_distro_version_id(struct pakfire* pakfire);
-const char* pakfire_get_distro_tag(struct pakfire* pakfire);
+int pakfire_root_openat(pakfire_root* pakfire, const char* path, int flags) __nonnull((2));
-int pakfire_openat(struct pakfire* pakfire, const char* path, int flags) __nonnull((2));
-
-#define pakfire_path(pakfire, path, format, ...) \
- __pakfire_path(pakfire, path, sizeof(path), format, __VA_ARGS__)
-int __pakfire_path(struct pakfire* pakfire, char* path, const size_t length,
+#define pakfire_root_path(pakfire, path, format, ...) \
+ __pakfire_root_path(pakfire, path, sizeof(path), format, __VA_ARGS__)
+int __pakfire_root_path(pakfire_root* pakfire, char* path, const size_t length,
const char* format, ...) __attribute__((format(printf, 4, 5)));
-const char* pakfire_relpath(struct pakfire* pakfire, const char* path);
+const char* pakfire_root_relpath(pakfire_root* pakfire, const char* path);
-#define pakfire_cache_path(pakfire, path, format, ...) \
- __pakfire_cache_path(pakfire, path, sizeof(path), format, __VA_ARGS__)
-int __pakfire_cache_path(struct pakfire* pakfire, char* path, size_t length,
+#define pakfire_root_cache_path(pakfire, path, format, ...) \
+ __pakfire_root_cache_path(pakfire, path, sizeof(path), format, __VA_ARGS__)
+int __pakfire_root_cache_path(pakfire_root* pakfire, char* path, size_t length,
const char* format, ...) __attribute__((format(printf, 4, 5)));
-void pakfire_pool_has_changed(struct pakfire* pakfire);
-void pakfire_pool_internalize(struct pakfire* pakfire);
+void pakfire_root_pool_has_changed(pakfire_root* pakfire);
+void pakfire_root_pool_internalize(pakfire_root* pakfire);
-Pool* pakfire_get_solv_pool(struct pakfire* pakfire);
+Pool* pakfire_root_get_solv_pool(pakfire_root* pakfire);
-pakfire_repo* pakfire_get_installed_repo(struct pakfire* pakfire);
+pakfire_repo* pakfire_root_get_installed_repo(pakfire_root* pakfire);
-int pakfire_commandline_add(struct pakfire* pakfire, const char* path,
+int pakfire_root_commandline_add(pakfire_root* pakfire, const char* path,
pakfire_package** package);
-typedef int (*pakfire_repo_walk_callback)
- (struct pakfire* pakfire, pakfire_repo* repo, void* p);
-int pakfire_repo_walk(struct pakfire* pakfire,
- pakfire_repo_walk_callback callback, void* p);
+typedef int (*pakfire_root_repo_walk_callback)
+ (pakfire_root* pakfire, pakfire_repo* repo, void* p);
+int pakfire_root_repo_walk(pakfire_root* pakfire,
+ pakfire_root_repo_walk_callback callback, void* p);
// Archive helpers
-struct archive* pakfire_get_disk_reader(struct pakfire* pakfire);
-struct archive* pakfire_get_disk_writer(struct pakfire* pakfire);
+struct archive* pakfire_root_get_disk_reader(pakfire_root* pakfire);
+struct archive* pakfire_root_get_disk_writer(pakfire_root* pakfire);
-int pakfire_install(struct pakfire* self, const char** packages);
+int pakfire_root_install(pakfire_root* self, const char** packages);
-#endif /* PAKFIRE_PAKFIRE_H */
+#endif /* pakfire_rootPAKFIRE_H */
struct pakfire_parser {
pakfire_ctx* ctx;
- struct pakfire* pakfire;
+ pakfire_root* root;
int nrefs;
pakfire_parser* parent;
if (parser->parent)
pakfire_parser_unref(parser->parent);
- if (parser->pakfire)
- pakfire_unref(parser->pakfire);
+ if (parser->root)
+ pakfire_root_unref(parser->root);
if (parser->ctx)
pakfire_ctx_unref(parser->ctx);
free(parser);
}
int pakfire_parser_create(pakfire_parser** parser,
- struct pakfire* pakfire, pakfire_parser* parent, const char* namespace, int flags) {
+ pakfire_root* root, pakfire_parser* parent, const char* namespace, int flags) {
pakfire_parser* self = NULL;
int r;
return -errno;
// Store a reference to the context
- self->ctx = pakfire_get_ctx(pakfire);
+ self->ctx = pakfire_root_get_ctx(root);
- // Store a reference to Pakfire
- self->pakfire = pakfire_ref(pakfire);
+ // Store a reference to the root
+ self->root = pakfire_root_ref(root);
// Initialize the reference counter
self->nrefs = 1;
int r;
// Create the parser
- r = pakfire_parser_create(&child, parser->pakfire, parser, namespace, parser->flags);
+ r = pakfire_parser_create(&child, parser->root, parser, namespace, parser->flags);
if (r < 0)
return NULL;
return parser;
}
-struct pakfire* pakfire_parser_get_pakfire(pakfire_parser* parser) {
- return pakfire_ref(parser->pakfire);
+pakfire_root* pakfire_parser_get_root(pakfire_parser* parser) {
+ return pakfire_root_ref(parser->root);
}
pakfire_parser* pakfire_parser_unref(pakfire_parser* parser) {
size_t length = 0;
// Execute the command inside the Pakfire environment
- r = pakfire_jail_run(parser->pakfire, argv, NULL, 0, &output, &length);
+ r = pakfire_jail_run(parser->root, argv, NULL, 0, &output, &length);
if (r) {
// Just log this and continue
DEBUG(parser->ctx, "Command '%s' failed with return code %d\n", command, r);
}
// Create a new package object
- r = pakfire_package_create(pkg, parser->pakfire, repo, name, evr, (arch) ? arch : default_arch);
+ r = pakfire_package_create(pkg, parser->root, repo, name, evr, (arch) ? arch : default_arch);
if (r < 0) {
ERROR(parser->ctx, "Could not create package: %m\n");
goto CLEANUP;
if (is_source) {
deps = pakfire_parser_get(parser, "build", "requires");
if (deps) {
- r = pakfire_str2deps(parser->pakfire, *pkg, PAKFIRE_PKG_REQUIRES, deps);
+ r = pakfire_str2deps(parser->root, *pkg, PAKFIRE_PKG_REQUIRES, deps);
if (r)
goto CLEANUP;
}
for (const struct pakfire_dep* dep = pakfire_deps; dep->key; dep++) {
deps = pakfire_parser_get(parser, namespace, dep->name);
if (deps) {
- r = pakfire_str2deps(parser->pakfire, *pkg, dep->key, deps);
+ r = pakfire_str2deps(parser->root, *pkg, dep->key, deps);
if (r)
goto CLEANUP;
}
typedef struct pakfire_parser_error pakfire_parser_error;
-int pakfire_parser_create(pakfire_parser** parser, struct pakfire* pakfire,
+int pakfire_parser_create(pakfire_parser** parser, pakfire_root* root,
pakfire_parser* parent, const char* namespace, int flags);
pakfire_parser* pakfire_parser_create_child(pakfire_parser* parser,
const char* namespace);
int pakfire_parser_error_get_line(pakfire_parser_error* error);
const char* pakfire_parser_error_get_message(pakfire_parser_error* error);
-struct pakfire* pakfire_parser_get_pakfire(pakfire_parser* parser);
+pakfire_root* pakfire_parser_get_root(pakfire_parser* parser);
typedef struct pakfire_parser_state {
unsigned int lineno;
%parse-param
{yyscan_t* scanner}
{pakfire_ctx* ctx}
- {struct pakfire* pakfire}
+ {pakfire_root* root}
{pakfire_parser** parser}
{pakfire_parser* parent}
{pakfire_parser_error** error}
OP_EQUALS = 0,
};
-static void yyerror(yyscan_t* scanner, pakfire_ctx* ctx, struct pakfire* pakfire,
+static void yyerror(yyscan_t* scanner, pakfire_ctx* ctx, pakfire_root* root,
pakfire_parser** parser, pakfire_parser* parent,
pakfire_parser_error** error, const char* s) {
const pakfire_parser_state* state = yyget_extra(scanner);
}
%initial-action {
- int r = pakfire_parser_create(parser, pakfire, parent, NULL, 0);
+ int r = pakfire_parser_create(parser, root, parent, NULL, 0);
if (r < 0)
ABORT;
};
grammar : %empty
{
- int r = pakfire_parser_create(&$$, pakfire, *parser, NULL, 0);
+ int r = pakfire_parser_create(&$$, root, *parser, NULL, 0);
if (r < 0)
ABORT;
int r;
// Create a new parser
- r = pakfire_parser_create(&$$, pakfire, *parser, NULL, 0);
+ r = pakfire_parser_create(&$$, root, *parser, NULL, 0);
if (r < 0)
ABORT;
int pakfire_parser_parse_data(pakfire_parser* parent, const char* data, size_t len,
pakfire_parser_error** error) {
- struct pakfire* pakfire = pakfire_parser_get_pakfire(parent);
+ pakfire_root* root = pakfire_parser_get_root(parent);
yyscan_t scanner;
int r;
};
// Fetch context
- pakfire_ctx* ctx = pakfire_get_ctx(pakfire);
+ pakfire_ctx* ctx = pakfire_root_get_ctx(root);
#ifdef ENABLE_DEBUG
DEBUG(ctx, "Parsing the following data (%zu):\n%.*s\n", len, (int)len, data);
pakfire_parser* parser = NULL;
YY_BUFFER_STATE buffer = yy_scan_bytes(data, len, scanner);
- r = yyparse(scanner, ctx, pakfire, &parser, parent, error);
+ r = yyparse(scanner, ctx, root, &parser, parent, error);
yy_delete_buffer(buffer, scanner);
// Deal with the return code of the parser
ERROR:
if (parser)
pakfire_parser_unref(parser);
- if (pakfire)
- pakfire_unref(pakfire);
+ if (root)
+ pakfire_root_unref(root);
if (ctx)
pakfire_ctx_unref(ctx);
yylex_destroy(scanner);
struct pakfire_problem {
pakfire_ctx* ctx;
- struct pakfire* pakfire;
+ pakfire_root* root;
int nrefs;
pakfire_transaction* transaction;
case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
r = asprintf(&s, _("nothing provides requested %s"),
- pakfire_dep2str(problem->pakfire, dep));
+ pakfire_dep2str(problem->root, dep));
break;
case SOLVER_RULE_JOB_UNKNOWN_PACKAGE:
r = asprintf(&s, _("package %s does not exist"),
- pakfire_dep2str(problem->pakfire, dep));
+ pakfire_dep2str(problem->root, dep));
break;
case SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM:
r = asprintf(&s, _("%s is provided by the system"),
- pakfire_dep2str(problem->pakfire, dep));
+ pakfire_dep2str(problem->root, dep));
break;
case SOLVER_RULE_RPM:
case SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP:
r = asprintf(&s, _("nothing provides %s needed by %s"),
- pakfire_dep2str(problem->pakfire, dep), pool_solvid2str(pool, source));
+ pakfire_dep2str(problem->root, dep), pool_solvid2str(pool, source));
break;
case SOLVER_RULE_RPM_SAME_NAME:
case SOLVER_RULE_RPM_PACKAGE_CONFLICT:
r = asprintf(&s, _("package %s conflicts with %s provided by %s"),
- pool_solvid2str(pool, source), pakfire_dep2str(problem->pakfire, dep),
+ pool_solvid2str(pool, source), pakfire_dep2str(problem->root, dep),
pool_solvid2str(pool, target));
break;
case SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
r = asprintf(&s, _("package %s obsoletes %s provided by %s"),
- pool_solvid2str(pool, source), pakfire_dep2str(problem->pakfire, dep),
+ pool_solvid2str(pool, source), pakfire_dep2str(problem->root, dep),
pool_solvid2str(pool, target));
break;
case SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES:
r = asprintf(&s, _("installed package %s obsoletes %s provided by %s"),
- pool_solvid2str(pool, source), pakfire_dep2str(problem->pakfire, dep),
+ pool_solvid2str(pool, source), pakfire_dep2str(problem->root, dep),
pool_solvid2str(pool, target));
break;
case SOLVER_RULE_RPM_IMPLICIT_OBSOLETES:
r = asprintf(&s, _("package %s implicitely obsoletes %s provided by %s"),
- pool_solvid2str(pool, source), pakfire_dep2str(problem->pakfire, dep),
+ pool_solvid2str(pool, source), pakfire_dep2str(problem->root, dep),
pool_solvid2str(pool, target));
break;
case SOLVER_RULE_RPM_PACKAGE_REQUIRES:
r = asprintf(&s, _("package %s requires %s, but none of the providers can be installed"),
- pool_solvid2str(pool, source), pakfire_dep2str(problem->pakfire, dep));
+ pool_solvid2str(pool, source), pakfire_dep2str(problem->root, dep));
break;
case SOLVER_RULE_RPM_SELF_CONFLICT:
r = asprintf(&s, _("package %s conflicts with %s provided by itself"),
- pool_solvid2str(pool, source), pakfire_dep2str(problem->pakfire, dep));
+ pool_solvid2str(pool, source), pakfire_dep2str(problem->root, dep));
break;
case SOLVER_RULE_YUMOBS:
r = asprintf(&s, _("both package %s and %s obsolete %s"),
pool_solvid2str(pool, source), pool_solvid2str(pool, target),
- pakfire_dep2str(problem->pakfire, dep));
+ pakfire_dep2str(problem->root, dep));
break;
case SOLVER_RULE_BLACK:
case SOLVER_RULE_PKG_CONSTRAINS:
r = asprintf(&s, _("package %s has constraint %s conflicting with %s"),
- pool_solvid2str(pool, source), pakfire_dep2str(problem->pakfire, dep),
+ pool_solvid2str(pool, source), pakfire_dep2str(problem->root, dep),
pool_solvid2str(pool, target));
break;
}
int pakfire_problem_create(pakfire_problem** problem,
- struct pakfire* pakfire, pakfire_transaction* transaction, Id id) {
+ pakfire_root* root, pakfire_transaction* transaction, Id id) {
pakfire_problem* p = NULL;
// Allocate some memory
return -errno;
// Store a reference to the context
- p->ctx = pakfire_get_ctx(pakfire);
+ p->ctx = pakfire_root_get_ctx(root);
- // Store a reference to Pakfire
- p->pakfire = pakfire_ref(pakfire);
+ // Store a reference to the root
+ p->root = pakfire_root_ref(root);
// Initialize the reference counter
p->nrefs = 1;
pakfire_transaction_unref(problem->transaction);
if (problem->string)
free(problem->string);
- if (problem->pakfire)
- pakfire_unref(problem->pakfire);
+ if (problem->root)
+ pakfire_root_unref(problem->root);
if (problem->ctx)
pakfire_ctx_unref(problem->ctx);
free(problem);
break;
// Create a new solution
- r = pakfire_solution_create(&solution, problem->pakfire, problem, id);
+ r = pakfire_solution_create(&solution, problem->root, problem, id);
if (r)
goto ERROR;
pakfire_solution** pakfire_problem_get_solutions(
pakfire_problem* problem);
-int pakfire_problem_create(pakfire_problem** problem, struct pakfire* pakfire,
+int pakfire_problem_create(pakfire_problem** problem, pakfire_root* root,
pakfire_transaction* transaction, Id id);
pakfire_transaction* pakfire_problem_get_transaction(pakfire_problem* problem);
#define ETC_SUBUID "/etc/subuid"
#define ETC_SUBGID "/etc/subgid"
-static struct passwd* pakfire_getpwent(struct pakfire* pakfire,
+static struct passwd* pakfire_getpwent(pakfire_root* root,
int(*cmp)(struct passwd* entry, const void* value), const void* value) {
struct passwd* entry = NULL;
char path[PATH_MAX];
int r;
// This cannot be performed in stub mode
- if (pakfire_has_flag(pakfire, PAKFIRE_FLAGS_STUB))
+ if (pakfire_root_has_flag(root, PAKFIRE_ROOT_FLAGS_STUB))
return NULL;
// Get path to /etc/passwd
- r = pakfire_path(pakfire, path, "%s", "/etc/passwd");
+ r = pakfire_root_path(root, path, "%s", "/etc/passwd");
if (r < 0)
return NULL;
return 0;
}
-struct passwd* pakfire_getpwnam(struct pakfire* pakfire, const char* name) {
- return pakfire_getpwent(pakfire, __pakfire_getpwnam, name);
+struct passwd* pakfire_getpwnam(pakfire_root* root, const char* name) {
+ return pakfire_getpwent(root, __pakfire_getpwnam, name);
}
static int __pakfire_getpwuid(struct passwd* entry, const void* value) {
return 0;
}
-struct passwd* pakfire_getpwuid(struct pakfire* pakfire, uid_t uid) {
- return pakfire_getpwent(pakfire, __pakfire_getpwuid, &uid);
+struct passwd* pakfire_getpwuid(pakfire_root* root, uid_t uid) {
+ return pakfire_getpwent(root, __pakfire_getpwuid, &uid);
}
-static struct group* pakfire_getgrent(struct pakfire* pakfire,
+static struct group* pakfire_getgrent(pakfire_root* root,
int(*cmp)(struct group* entry, const void* value), const void* value) {
struct group* entry = NULL;
char path[PATH_MAX];
int r;
// This cannot be performed in stub mode
- if (pakfire_has_flag(pakfire, PAKFIRE_FLAGS_STUB))
+ if (pakfire_root_has_flag(root, PAKFIRE_ROOT_FLAGS_STUB))
return NULL;
// Get path to /etc/group
- r = pakfire_path(pakfire, path, "%s", "/etc/group");
+ r = pakfire_root_path(root, path, "%s", "/etc/group");
if (r < 0)
return NULL;
return 0;
}
-struct group* pakfire_getgrnam(struct pakfire* pakfire, const char* name) {
- return pakfire_getgrent(pakfire, __pakfire_getgrnam, name);
+struct group* pakfire_getgrnam(pakfire_root* root, const char* name) {
+ return pakfire_getgrent(root, __pakfire_getgrnam, name);
}
static int __pakfire_getgrgid(struct group* entry, const void* value) {
return 0;
}
-struct group* pakfire_getgrgid(struct pakfire* pakfire, gid_t gid) {
- return pakfire_getgrent(pakfire, __pakfire_getgrgid, &gid);
+struct group* pakfire_getgrgid(pakfire_root* root, gid_t gid) {
+ return pakfire_getgrent(root, __pakfire_getgrgid, &gid);
}
// SUBUID/SUBGID
#ifdef HAVE_SUBID
-static int pakfire_getsubid(struct pakfire* pakfire, const char* owner,
+static int pakfire_getsubid(pakfire_root* root, const char* owner,
struct pakfire_subid* subid, int (callback)(const char* owner, struct subid_range** ranges)) {
struct subid_range* ranges = NULL;
int count;
int r = -1;
- pakfire_ctx* ctx = pakfire_get_ctx(pakfire);
+ pakfire_ctx* ctx = pakfire_root_get_ctx(root);
r = subid_init(PACKAGE_NAME, stderr);
if (r) {
return r;
}
-int pakfire_getsubuid(struct pakfire* pakfire, const char* owner, struct pakfire_subid* subid) {
- return pakfire_getsubid(pakfire, owner, subid, subid_get_uid_ranges);
+int pakfire_getsubuid(pakfire_root* root, const char* owner, struct pakfire_subid* subid) {
+ return pakfire_getsubid(root, owner, subid, subid_get_uid_ranges);
}
-int pakfire_getsubgid(struct pakfire* pakfire, const char* owner, struct pakfire_subid* subid) {
- return pakfire_getsubid(pakfire, owner, subid, subid_get_gid_ranges);
+int pakfire_getsubgid(pakfire_root* root, const char* owner, struct pakfire_subid* subid) {
+ return pakfire_getsubid(root, owner, subid, subid_get_gid_ranges);
}
# else /* Our own implementation */
-static int pakfire_fgetsubid(struct pakfire* pakfire, struct pakfire_subid* subid, FILE* f) {
+static int pakfire_fgetsubid(pakfire_root* root, struct pakfire_subid* subid, FILE* f) {
int r;
char* line = NULL;
size_t length = 0;
char* p = NULL;
- pakfire_ctx* ctx = pakfire_get_ctx(pakfire);
+ pakfire_ctx* ctx = pakfire_root_get_ctx(root);
// Read the next line
while (1) {
If nothing was found, the function returns 1.
If there was an error, the function may return something else.
*/
-static int pakfire_getsubid(struct pakfire* pakfire, const char* path, const char* owner,
+static int pakfire_getsubid(pakfire_root* root, const char* path, const char* owner,
struct pakfire_subid* subid) {
struct pakfire_subid entry = {};
int r;
if (!owner)
return 1;
- pakfire_ctx* ctx = pakfire_get_ctx(pakfire);
+ pakfire_ctx* ctx = pakfire_root_get_ctx(root);
DEBUG(ctx, "Fetching SUBID from %s for %s\n", path, owner);
// Walk through all entries
while (1) {
- r = pakfire_fgetsubid(pakfire, &entry, f);
+ r = pakfire_fgetsubid(root, &entry, f);
switch (r) {
case 0:
break;
return r;
}
-int pakfire_getsubuid(struct pakfire* pakfire, const char* owner, struct pakfire_subid* subid) {
- return pakfire_getsubid(pakfire, ETC_SUBUID, owner, subid);
+int pakfire_getsubuid(pakfire_root* root, const char* owner, struct pakfire_subid* subid) {
+ return pakfire_getsubid(root, ETC_SUBUID, owner, subid);
}
-int pakfire_getsubgid(struct pakfire* pakfire, const char* owner, struct pakfire_subid* subid) {
- return pakfire_getsubid(pakfire, ETC_SUBGID, owner, subid);
+int pakfire_getsubgid(pakfire_root* root, const char* owner, struct pakfire_subid* subid) {
+ return pakfire_getsubid(root, ETC_SUBGID, owner, subid);
}
#endif
size_t length;
};
-struct passwd* pakfire_getpwnam(struct pakfire* pakfire, const char* name);
-struct passwd* pakfire_getpwuid(struct pakfire* pakfire, uid_t uid);
+struct passwd* pakfire_getpwnam(pakfire_root* root, const char* name);
+struct passwd* pakfire_getpwuid(pakfire_root* root, uid_t uid);
-struct group* pakfire_getgrnam(struct pakfire* pakfire, const char* name);
-struct group* pakfire_getgrgid(struct pakfire* pakfire, gid_t gid);
+struct group* pakfire_getgrnam(pakfire_root* root, const char* name);
+struct group* pakfire_getgrgid(pakfire_root* root, gid_t gid);
-int pakfire_getsubuid(struct pakfire* pakfire, const char* owner, struct pakfire_subid* subid);
-int pakfire_getsubgid(struct pakfire* pakfire, const char* owner, struct pakfire_subid* subid);
+int pakfire_getsubuid(pakfire_root* root, const char* owner, struct pakfire_subid* subid);
+int pakfire_getsubgid(pakfire_root* root, const char* owner, struct pakfire_subid* subid);
#endif /* PAKFIRE_PWD_H */
struct pakfire_repo {
pakfire_ctx* ctx;
- struct pakfire* pakfire;
+ pakfire_root* root;
int nrefs;
Repo* repo;
const char* replacement;
} replacements[] = {
{ "%{name}", pakfire_repo_get_name(repo) },
- { "%{arch}", pakfire_get_effective_arch(repo->pakfire) },
- { "%{distro}", pakfire_get_distro_id(repo->pakfire) },
- { "%{version}", pakfire_get_distro_version_id(repo->pakfire) },
+ { "%{arch}", pakfire_root_get_effective_arch(repo->root) },
+ { "%{distro}", pakfire_root_get_distro_id(repo->root) },
+ { "%{version}", pakfire_root_get_distro_version_id(repo->root) },
{ NULL },
};
const char* name = pakfire_repo_get_name(repo);
// Otherwise return the cached path
- return __pakfire_cache_path(repo->pakfire, path, length, "%s/%s", name, buffer);
+ return __pakfire_root_cache_path(repo->root, path, length, "%s/%s", name, buffer);
}
static int pakfire_repo_xfer_create(pakfire_xfer** xfer, pakfire_repo* repo,
static int __pakfire_repo_import(pakfire_config* config, const char* section, void* data) {
pakfire_repo* self = NULL;
- struct pakfire* pakfire = data;
+ pakfire_root* root = data;
int r;
// Ignore if the section does not start with "repo:"
return 0;
// Create a new repository
- r = pakfire_repo_create(&self, pakfire, name);
+ r = pakfire_repo_create(&self, root, name);
if (r < 0)
goto ERROR;
return r;
}
-int pakfire_repo_import(struct pakfire* pakfire, pakfire_config* config) {
+int pakfire_repo_import(pakfire_root* root, pakfire_config* config) {
int r;
// Import all repositories from the configuration
- r = pakfire_config_walk_sections(config, __pakfire_repo_import, pakfire);
+ r = pakfire_config_walk_sections(config, __pakfire_repo_import, root);
if (r)
return r;
id = pool_solvable2id(self->repo->pool, s);
// Create a new package
- r = pakfire_package_create_from_solvable(&pkg, self->pakfire, self, id);
+ r = pakfire_package_create_from_solvable(&pkg, self->root, self, id);
if (r < 0)
goto ERROR;
}
// Open archive
- r = pakfire_archive_open(&archive, repo->pakfire, entry->fts_path);
+ r = pakfire_archive_open(&archive, repo->root, entry->fts_path);
if (r < 0)
goto ERROR;
const char* name = pakfire_repo_get_name(self);
// Make path to mirrorlist
- r = pakfire_cache_path(self->pakfire, path, "repodata/%s/mirrorlist", name);
+ r = pakfire_root_cache_path(self->root, path, "repodata/%s/mirrorlist", name);
if (r < 0)
goto ERROR;
static void pakfire_repo_free(pakfire_repo* self) {
if (self->appdata)
pakfire_repo_free_appdata(self->appdata);
- if (self->pakfire)
- pakfire_unref(self->pakfire);
+ if (self->root)
+ pakfire_root_unref(self->root);
if (self->ctx)
pakfire_ctx_unref(self->ctx);
free(self);
}
-void pakfire_repo_free_all(struct pakfire* pakfire) {
+void pakfire_repo_free_all(pakfire_root* root) {
Repo* repo = NULL;
int i;
// Fetch the pool
- Pool* pool = pakfire_get_solv_pool(pakfire);
+ Pool* pool = pakfire_root_get_solv_pool(root);
if (!pool)
return;
return 0;
}
-int pakfire_repo_create(pakfire_repo** repo,
- struct pakfire* pakfire, const char* name) {
+int pakfire_repo_create(pakfire_repo** repo, pakfire_root* root, const char* name) {
pakfire_repo* self = NULL;
int r;
return -errno;
// Store a reference to the context
- self->ctx = pakfire_get_ctx(pakfire);
+ self->ctx = pakfire_root_get_ctx(root);
- // Store a reference to Pakfire
- self->pakfire = pakfire_ref(pakfire);
+ // Store a reference to the root
+ self->root = pakfire_root_ref(root);
// Initialize the reference counter
self->nrefs = 1;
// Fetch the pool
- Pool* pool = pakfire_get_solv_pool(pakfire);
+ Pool* pool = pakfire_root_get_solv_pool(root);
// Allocate a libsolv repository
self->repo = repo_create(pool, name);
return r;
}
-int pakfire_repo_open(pakfire_repo** repo, struct pakfire* pakfire, Repo* _repo) {
+int pakfire_repo_open(pakfire_repo** repo, pakfire_root* root, Repo* _repo) {
pakfire_repo* self = NULL;
// Allocate some memory
return -errno;
// Store a reference to the context
- self->ctx = pakfire_get_ctx(pakfire);
+ self->ctx = pakfire_root_get_ctx(root);
- // Store a reference to Pakfire
- self->pakfire = pakfire_ref(pakfire);
+ // Store a reference to the root
+ self->root = pakfire_root_ref(root);
// Initialize the reference counter
self->nrefs = 1;
}
int pakfire_repo_count(pakfire_repo* repo) {
- Pool* pool = pakfire_get_solv_pool(repo->pakfire);
+ Pool* pool = pakfire_root_get_solv_pool(repo->root);
int cnt = 0;
for (int i = 2; i < pool->nsolvables; i++) {
repo->appdata->ready = 0;
// Mark pool as changed, too
- pakfire_pool_has_changed(repo->pakfire);
+ pakfire_root_pool_has_changed(repo->root);
}
int pakfire_repo_internalize(pakfire_repo* repo, int flags) {
}
// Try to open the archive
- r = pakfire_archive_open(&archive, repo->pakfire, path);
+ r = pakfire_archive_open(&archive, repo->root, path);
if (r < 0)
goto ERROR;
Queue addedfileprovides;
int r;
- pakfire_pool_internalize(repo->pakfire);
+ pakfire_root_pool_internalize(repo->root);
// Initialize file provides
queue_init(&addedfileprovides);
Id id = pool_solvable2id(pool, s);
// Allocate package
- r = pakfire_package_create_from_solvable(&pkg, repo->pakfire, repo, id);
+ r = pakfire_package_create_from_solvable(&pkg, repo->root, repo, id);
if (r)
return 1;
}
// Destroy all files in the cache directory
- r = pakfire_cache_path(repo->pakfire, cache_path,
- "repodata/%s", pakfire_repo_get_name(repo));
- if (r)
+ r = pakfire_root_cache_path(repo->root, cache_path,
+ "repodata/%s", pakfire_repo_get_name(repo));
+ if (r < 0)
return r;
return pakfire_rmtree(cache_path, 0);
return r;
}
-int pakfire_repo_compose(struct pakfire* pakfire, const char* path,
+int pakfire_repo_compose(pakfire_root* root, const char* path,
pakfire_key* key, const char** files) {
pakfire_archive* archive = NULL;
pakfire_repo* repo = NULL;
}
// Fetch context
- pakfire_ctx* ctx = pakfire_get_ctx(pakfire);
+ pakfire_ctx* ctx = pakfire_root_get_ctx(root);
// XXX Check if the key is a secret key
goto ERROR;
// Create a new temporary repository at path
- r = pakfire_repo_create(&repo, pakfire, "tmp");
+ r = pakfire_repo_create(&repo, root, "tmp");
if (r) {
ERROR(ctx, "Could not create a temporary repository: %m\n");
goto ERROR;
DEBUG(ctx, "Adding %s to repository...\n", *file);
// Open source archive
- r = pakfire_archive_open(&archive, pakfire, *file);
+ r = pakfire_archive_open(&archive, root, *file);
if (r) {
ERROR(ctx, "Could not open %s: %m\n", *file);
goto OUT;
#include <pakfire/pakfire.h>
#include <pakfire/xfer.h>
-int pakfire_repo_create(pakfire_repo** repo, struct pakfire* pakfire, const char* name);
-int pakfire_repo_open(pakfire_repo** repo, struct pakfire* pakfire, Repo* _repo);
+int pakfire_repo_create(pakfire_repo** repo, pakfire_root* root, const char* name);
+int pakfire_repo_open(pakfire_repo** repo, pakfire_root* root, Repo* _repo);
pakfire_repo* pakfire_repo_ref(pakfire_repo* repo);
pakfire_repo* pakfire_repo_unref(pakfire_repo* repo);
int pakfire_repo_write_metadata(pakfire_repo* repo, pakfire_key* key);
-int pakfire_repo_compose(struct pakfire* pakfire, const char* path,
+int pakfire_repo_compose(pakfire_root* root, const char* path,
pakfire_key* key, const char** files);
#define PAKFIRE_REPO_COMMANDLINE "@commandline"
char* pakfire_repo_url_replace(pakfire_repo* repo, const char* url);
-int pakfire_repo_import(struct pakfire* pakfire, pakfire_config* config);
+int pakfire_repo_import(pakfire_root* root, pakfire_config* config);
const char* pakfire_repo_get_path(pakfire_repo* repo);
void pakfire_repo_has_changed(pakfire_repo* repo);
int pakfire_repo_add(pakfire_repo* repo, const char* path,
pakfire_package** package);
-void pakfire_repo_free_all(struct pakfire* pakfire);
+void pakfire_repo_free_all(pakfire_root* root);
Repo* pakfire_repo_get_repo(pakfire_repo* repo);
Repodata* pakfire_repo_get_repodata(pakfire_repo* repo);
return 0;
}
-int pakfire_scriptlet_execute(pakfire_scriptlet* scriptlet, struct pakfire* pakfire) {
+int pakfire_scriptlet_execute(pakfire_scriptlet* scriptlet, pakfire_root* root) {
// Detect what kind of script this is and run it
if (pakfire_scriptlet_is_shell_script(scriptlet))
- return pakfire_jail_run_script(pakfire, scriptlet->data, scriptlet->size, NULL, NULL, 0);
+ return pakfire_jail_run_script(root, scriptlet->data, scriptlet->size, NULL, NULL, 0);
ERROR(scriptlet->ctx, "Scriptlet is of an unknown kind\n");
return -ENOTSUP;
const char* pakfire_scriptlet_get_type(pakfire_scriptlet* scriptlet);
const char* pakfire_scriptlet_get_data(pakfire_scriptlet* scriptlet, size_t* size);
-int pakfire_scriptlet_execute(pakfire_scriptlet* scriptlet, struct pakfire* pakfire);
+int pakfire_scriptlet_execute(pakfire_scriptlet* scriptlet, pakfire_root* root);
#endif /* PAKFIRE_SCRIPTLET_H */
/*
Finds and returns the latest snapshot
*/
-int pakfire_snapshot_find(pakfire_snapshot** snapshot, struct pakfire* pakfire) {
+int pakfire_snapshot_find(pakfire_snapshot** snapshot, pakfire_root* root) {
struct dirent** paths = NULL;
int num_paths = 0;
char path[PATH_MAX];
int fd = -EBADF;
int r;
- pakfire_ctx* ctx = pakfire_get_ctx(pakfire);
+ pakfire_ctx* ctx = pakfire_root_get_ctx(root);
// Make the path
- r = pakfire_cache_path(pakfire, path, "%s", "snapshots");
+ r = pakfire_root_cache_path(root, path, "%s", "snapshots");
if (r < 0)
return r;
switch (errno) {
// If the directory does not exist, we will make a new snapshot
case ENOENT:
- r = pakfire_snapshot_make(snapshot, pakfire);
+ r = pakfire_snapshot_make(snapshot, root);
if (r < 0)
goto ERROR;
// Create a new snapshot if none was found
} else if (num_paths == 0) {
- r = pakfire_snapshot_make(snapshot, pakfire);
+ r = pakfire_snapshot_make(snapshot, root);
if (r < 0)
goto ERROR;
return 0;
}
-static int pakfire_snapshot_install_packages(struct pakfire* pakfire, const char** packages) {
+static int pakfire_snapshot_install_packages(pakfire_root* root, const char** packages) {
pakfire_transaction* transaction = NULL;
int r;
// Create a new transaction
- r = pakfire_transaction_create(&transaction, pakfire, 0);
+ r = pakfire_transaction_create(&transaction, root, 0);
if (r)
goto ERROR;
/*
Creates a new snapshot
*/
-int pakfire_snapshot_make(pakfire_snapshot** snapshot, struct pakfire* pakfire) {
+int pakfire_snapshot_make(pakfire_snapshot** snapshot, pakfire_root* root) {
pakfire_config* config = NULL;
- struct pakfire* p = NULL;
+ pakfire_root* p = NULL;
char snapshot_path[PATH_MAX];
char tmp[PATH_MAX];
const char* arch = NULL;
const char* path = NULL;
char time[1024];
- int flags = PAKFIRE_FLAGS_BUILD|PAKFIRE_FLAGS_BUILD_LOCAL;
+ int flags = PAKFIRE_ROOT_FLAGS_BUILD|PAKFIRE_ROOT_FLAGS_BUILD_LOCAL;
int r;
const char* packages[] = {
NULL,
};
- pakfire_ctx* ctx = pakfire_get_ctx(pakfire);
+ pakfire_ctx* ctx = pakfire_root_get_ctx(root);
// Fetch the configuration
- config = pakfire_get_config(pakfire);
+ config = pakfire_root_get_config(root);
// Fetch the architecture
- arch = pakfire_get_arch(pakfire);
+ arch = pakfire_root_get_arch(root);
// Store the current time
r = pakfire_strftime_now(time, PAKFIRE_SNAPSHOT_TIMESTAMP_FORMAT);
goto ERROR;
// Make the final snapshot path
- r = pakfire_cache_path(pakfire, snapshot_path, "snapshots/%s", time);
+ r = pakfire_root_cache_path(root, snapshot_path, "snapshots/%s", time);
if (r < 0)
goto ERROR;
// Make a new temporary path
- r = pakfire_cache_path(pakfire, tmp, "%s", "snapshots/.XXXXXXX");
+ r = pakfire_root_cache_path(root, tmp, "%s", "snapshots/.XXXXXXX");
if (r < 0)
goto ERROR;
goto ERROR;
}
- // Create a new pakfire instance
- r = pakfire_create(&p, ctx, config, tmp, arch, flags);
+ // Create a new root instance
+ r = pakfire_root_create(&p, ctx, config, tmp, arch, flags);
if (r < 0) {
- ERROR(ctx, "Could not clone pakfire: %s\n", strerror(-r));
+ ERROR(ctx, "Could not clone root: %s\n", strerror(-r));
goto ERROR;
}
if (r < 0)
goto ERROR;
- // Close the pakfire instance
- pakfire_unref(p);
+ // Close the root instance
+ pakfire_root_unref(p);
p = NULL;
// Move the snapshot to its final place
goto ERROR;
// Cleanup any older snapshots (and ignore if something goes wrong)
- pakfire_snapshot_clean(pakfire);
+ pakfire_snapshot_clean(root);
ERROR:
- if (p)
- pakfire_unref(p);
if (config)
pakfire_config_unref(config);
if (ctx)
pakfire_ctx_unref(ctx);
+ if (p)
+ pakfire_root_unref(p);
// Cleanup the temporary directory
if (r)
/*
Cleans up any unused snapshots
*/
-int pakfire_snapshot_clean(struct pakfire* pakfire) {
+int pakfire_snapshot_clean(pakfire_root* root) {
pakfire_snapshot* snapshot = NULL;
char path[PATH_MAX];
FTS* f = NULL;
int r;
- pakfire_ctx* ctx = pakfire_get_ctx(pakfire);
+ pakfire_ctx* ctx = pakfire_root_get_ctx(root);
DEBUG(ctx, "Cleaning up snapshots...\n");
// Make the path
- r = pakfire_cache_path(pakfire, path, "%s", "snapshots");
+ r = pakfire_root_cache_path(root, path, "%s", "snapshots");
if (r < 0)
return r;
pakfire_snapshot* pakfire_snapshot_ref(pakfire_snapshot* self);
pakfire_snapshot* pakfire_snapshot_unref(pakfire_snapshot* self);
-int pakfire_snapshot_find(pakfire_snapshot** snapshot, struct pakfire* pakfire);
+int pakfire_snapshot_find(pakfire_snapshot** snapshot, pakfire_root* root);
const char* pakfire_snapshot_path(pakfire_snapshot* self);
int pakfire_snapshot_mount(pakfire_snapshot* self, const char* path);
int pakfire_snapshot_umount(pakfire_snapshot* self);
-int pakfire_snapshot_make(pakfire_snapshot** snapshot, struct pakfire* pakfire);
+int pakfire_snapshot_make(pakfire_snapshot** snapshot, pakfire_root* root);
-int pakfire_snapshot_clean(struct pakfire* pakfire);
+int pakfire_snapshot_clean(pakfire_root* root);
#endif /* PAKFIRE_SNAPSHOT_H */
#include <pakfire/util.h>
struct pakfire_solution {
- struct pakfire* pakfire;
+ pakfire_root* root;
int nrefs;
pakfire_problem* problem;
};
int pakfire_solution_create(pakfire_solution** solution,
- struct pakfire* pakfire, pakfire_problem* problem, Id id) {
+ pakfire_root* root, pakfire_problem* problem, Id id) {
pakfire_solution* s = calloc(1, sizeof(*s));
if (!s)
return -errno;
- // Store a reference to pakfire
- s->pakfire = pakfire_ref(pakfire);
+ // Store a reference to the root
+ s->root = pakfire_root_ref(root);
// Initialize the ref counter
s->nrefs = 1;
if (solution->string)
free(solution->string);
- pakfire_unref(solution->pakfire);
+ if (solution->root)
+ pakfire_root_unref(solution->root);
free(solution);
}
const char* pakfire_solution_to_string(pakfire_solution* solution);
-int pakfire_solution_create(pakfire_solution** solution, struct pakfire* pakfire,
+int pakfire_solution_create(pakfire_solution** solution, pakfire_root* root,
pakfire_problem* problem, Id id);
pakfire_problem* pakfire_solution_get_problem(pakfire_solution* solution);
Id pakfire_solution_get_id(pakfire_solution* solution);
pakfire_ctx* ctx;
int nrefs;
- // Pakfire
- struct pakfire* pakfire;
+ // Root
+ pakfire_root* root;
// Jail
pakfire_jail* jail;
static int pakfire_stripper_open_sources(pakfire_stripper* self) {
// Open the source directory
- self->sourcesfd = pakfire_openat(self->pakfire, BUILD_SRC_DIR, O_DIRECTORY|O_PATH);
+ self->sourcesfd = pakfire_root_openat(self->root, BUILD_SRC_DIR, O_DIRECTORY|O_PATH);
if (self->sourcesfd < 0) {
switch (errno) {
case ENOENT:
}
int pakfire_stripper_create(pakfire_stripper** stripper,
- struct pakfire* pakfire, pakfire_jail* jail, const char* path) {
+ pakfire_root* root, pakfire_jail* jail, const char* path) {
pakfire_stripper* self = NULL;
int r;
return -errno;
// Store a reference to the context
- self->ctx = pakfire_get_ctx(pakfire);
+ self->ctx = pakfire_root_get_ctx(root);
- // Store a reference to Pakfire
- self->pakfire = pakfire_ref(pakfire);
+ // Store a reference to the root
+ self->root = pakfire_root_ref(root);
// Store a reference to the jail
self->jail = pakfire_jail_ref(jail);
goto ERROR;
// Create a filelist
- r = pakfire_filelist_create(&self->filelist, self->pakfire);
+ r = pakfire_filelist_create(&self->filelist, self->root);
if (r < 0)
goto ERROR;
// Create a list for the sources
- r = pakfire_filelist_create(&self->sources, self->pakfire);
+ r = pakfire_filelist_create(&self->sources, self->root);
if (r < 0)
goto ERROR;
close(self->sourcesfd);
if (self->filelist)
pakfire_filelist_unref(self->filelist);
- if (self->pakfire)
- pakfire_unref(self->pakfire);
+ if (self->root)
+ pakfire_root_unref(self->root);
if (self->jail)
pakfire_jail_unref(self->jail);
if (self->ctx)
int r;
// Create a new filelist
- r = pakfire_filelist_create(&filelist, self->pakfire);
+ r = pakfire_filelist_create(&filelist, self->root);
if (r < 0)
goto ERROR;
return 0;
// Create a new file object
- r = pakfire_file_create(&file, self->pakfire, filename);
+ r = pakfire_file_create(&file, self->root, filename);
if (r < 0)
goto ERROR;
}
// Make a path for a new temporary file
- r = pakfire_path(self->pakfire, tmppath, "%s", PAKFIRE_TMP_DIR "/.pakfire-strip.XXXXXXX");
+ r = pakfire_root_path(self->root, tmppath, "%s", PAKFIRE_TMP_DIR "/.pakfire-strip.XXXXXXX");
if (r < 0)
goto ERROR;
path,
// The stripped output
- pakfire_relpath(self->pakfire, tmppath),
+ pakfire_root_relpath(self->root, tmppath),
NULL,
};
#include <pakfire/pakfire.h>
int pakfire_stripper_create(pakfire_stripper** stripper,
- struct pakfire* pakfire, pakfire_jail* jail, const char* path);
+ pakfire_root* root, pakfire_jail* jail, const char* path);
pakfire_stripper* pakfire_stripper_ref(pakfire_stripper* self);
pakfire_stripper* pakfire_stripper_unref(pakfire_stripper* self);
struct pakfire_transaction {
pakfire_ctx* ctx;
- struct pakfire* pakfire;
+ pakfire_root* root;
int nrefs;
// Flags
// Create all packages
for (unsigned int i = 0; i < transaction->num; i++) {
r = pakfire_package_create_from_solvable(&transaction->packages[i],
- transaction->pakfire, NULL, transaction->transaction->steps.elements[i]);
+ transaction->root, NULL, transaction->transaction->steps.elements[i]);
if (r < 0)
goto ERROR;
}
// Store all newly installed and overall all installed packages
for (int i = 0; i < pkgs.count; i++) {
r = pakfire_package_create_from_solvable(&pkg,
- transaction->pakfire, NULL, pkgs.elements[i]);
+ transaction->root, NULL, pkgs.elements[i]);
if (r < 0)
goto ERROR;
goto ERROR;
}
- Pool* pool = pakfire_get_solv_pool(transaction->pakfire);
+ Pool* pool = pakfire_root_get_solv_pool(transaction->root);
// Store the names of all userinstalled packages
for (int i = 0; i < userinstalled.count; i++) {
}
static int pakfire_transaction_setup_solver(pakfire_transaction* transaction) {
- Pool* pool = pakfire_get_solv_pool(transaction->pakfire);
+ Pool* pool = pakfire_root_get_solv_pool(transaction->root);
// Allocate a new solver
transaction->solver = solver_create(pool);
#endif
// In build mode, we want to install the best versions
- if (pakfire_has_flag(transaction->pakfire, PAKFIRE_FLAGS_BUILD))
+ if (pakfire_root_has_flag(transaction->root, PAKFIRE_ROOT_FLAGS_BUILD))
solver_set_flag(transaction->solver, SOLVER_FLAG_FOCUS_BEST, 1);
// Can the solver downgrade packages?
transaction_free(transaction->transaction);
if (transaction->solver)
solver_free(transaction->solver);
- if (transaction->pakfire)
- pakfire_unref(transaction->pakfire);
+ if (transaction->root)
+ pakfire_root_unref(transaction->root);
if (transaction->ctx)
pakfire_ctx_unref(transaction->ctx);
queue_free(&transaction->jobs);
}
int pakfire_transaction_create(pakfire_transaction** transaction,
- struct pakfire* pakfire, int flags) {
+ pakfire_root* root, int flags) {
int r;
// Allocate the transaction
return -errno;
// Store a reference to the context
- t->ctx = pakfire_get_ctx(pakfire);
+ t->ctx = pakfire_root_get_ctx(root);
// Store reference to Pakfire
- t->pakfire = pakfire_ref(pakfire);
+ t->root = pakfire_root_ref(root);
// Initialize the reference counter
t->nrefs = 1;
break;
// Create a new problem
- r = pakfire_problem_create(&problem, transaction->pakfire, transaction, id);
+ r = pakfire_problem_create(&problem, transaction->root, transaction, id);
if (r)
goto ERROR;
// XXX halt if the request has already been solved
// Prepare pool
- pakfire_pool_internalize(transaction->pakfire);
+ pakfire_root_pool_internalize(transaction->root);
- Pool* pool = pakfire_get_solv_pool(transaction->pakfire);
+ Pool* pool = pakfire_root_get_solv_pool(transaction->root);
const char* selection = pool_selection2str(pool, &transaction->jobs, 0);
if (selection)
}
// Ask the user to pick a solution
- r = pakfire_ctx_pick_solution(transaction->ctx, transaction->pakfire, transaction);
+ r = pakfire_ctx_pick_solution(transaction->ctx, transaction->root, transaction);
switch (r) {
case 0:
continue;
Queue jobs;
int r;
- Pool* pool = pakfire_get_solv_pool(transaction->pakfire);
+ Pool* pool = pakfire_root_get_solv_pool(transaction->root);
// Make the pool ready
- pakfire_pool_internalize(transaction->pakfire);
+ pakfire_root_pool_internalize(transaction->root);
// Initialize jobs
queue_init(&jobs);
// Did we find anything?
if (jobs.count == 0) {
- Id id = pakfire_str2dep(transaction->pakfire, what);
+ Id id = pakfire_str2dep(transaction->root, what);
if (!id) {
r = -errno;
goto ERROR;
// Check if we got given a URL or some file
} else if (pakfire_string_is_url(what) || pakfire_transaction_is_file(what)) {
// Add them to the commandline repository
- r = pakfire_commandline_add(transaction->pakfire, what, &package);
+ r = pakfire_root_commandline_add(transaction->root, what, &package);
if (r)
goto ERROR;
pakfire_package* old_pkg = NULL;
pakfire_package* new_pkg = NULL;
- r = pakfire_package_create_from_solvable(&old_pkg, transaction->pakfire,
+ r = pakfire_package_create_from_solvable(&old_pkg, transaction->root,
NULL, pkgs.elements[j]);
if (r)
continue;
switch (class) {
case SOLVER_TRANSACTION_UPGRADED:
case SOLVER_TRANSACTION_DOWNGRADED:
- r = pakfire_package_create_from_solvable(&new_pkg, transaction->pakfire,
+ r = pakfire_package_create_from_solvable(&new_pkg, transaction->root,
NULL, transaction_obs_pkg(transaction->transaction, pkgs.elements[j]));
if (r)
continue;
return 0;
// Execute the scriptlet
- pakfire_scriptlet_execute(scriptlet, transaction->pakfire);
+ pakfire_scriptlet_execute(scriptlet, transaction->root);
pakfire_scriptlet_unref(scriptlet);
// Update the runtime linker cache
if (pakfire_filelist_contains(filelist, "*/lib*.so.?"))
- pakfire_jail_ldconfig(transaction->pakfire);
+ pakfire_jail_ldconfig(transaction->root);
if (filelist)
pakfire_filelist_unref(filelist);
goto ERROR;
// Update the runtime linker cache after all files have been removed
- pakfire_jail_ldconfig(transaction->pakfire);
+ pakfire_jail_ldconfig(transaction->root);
ERROR:
pakfire_progress_pop_status(transaction->progress);
pakfire_transaction* transaction, pakfire_package* pkg) {
// Apply any tmpfiles (ignore any errors)
if (pakfire_package_matches_dep(pkg, PAKFIRE_PKG_REQUIRES, "pakfire(systemd-tmpfiles)"))
- pakfire_jail_run_systemd_tmpfiles(transaction->pakfire);
+ pakfire_jail_run_systemd_tmpfiles(transaction->root);
return 0;
}
return 0;
}
-static int pakfire_usrmove_symlink(pakfire_ctx* ctx, struct pakfire* pakfire,
+static int pakfire_usrmove_symlink(pakfire_ctx* ctx, pakfire_root* root,
const char* src, const char* dst) {
char link[PATH_MAX];
char path[PATH_MAX];
int r;
// Compose the link path
- r = pakfire_path(pakfire, link, "%s", src);
+ r = pakfire_root_path(root, link, "%s", src);
if (r)
return r;
return 0;
// Compose the destination path
- r = pakfire_path(pakfire, path, "%s", dst);
+ r = pakfire_root_path(root, path, "%s", dst);
if (r)
return r;
that /bin, /sbin, /lib and /lib64 are symlinks to their
corresponding path in /usr.
*/
-static int pakfire_usrmove(pakfire_ctx* ctx, struct pakfire* pakfire) {
+static int pakfire_usrmove(pakfire_ctx* ctx, pakfire_root* root) {
int r;
- r = pakfire_usrmove_symlink(ctx, pakfire, "/bin", "usr/bin");
+ r = pakfire_usrmove_symlink(ctx, root, "/bin", "usr/bin");
if (r)
return r;
- r = pakfire_usrmove_symlink(ctx, pakfire, "/sbin", "usr/sbin");
+ r = pakfire_usrmove_symlink(ctx, root, "/sbin", "usr/sbin");
if (r)
return r;
- r = pakfire_usrmove_symlink(ctx, pakfire, "/lib", "usr/lib");
+ r = pakfire_usrmove_symlink(ctx, root, "/lib", "usr/lib");
if (r)
return r;
- r = pakfire_usrmove_symlink(ctx, pakfire, "/lib64", "usr/lib64");
+ r = pakfire_usrmove_symlink(ctx, root, "/lib64", "usr/lib64");
if (r)
return r;
return r;
// Open the database
- r = pakfire_db_open(&db, transaction->pakfire, PAKFIRE_DB_READWRITE);
+ r = pakfire_db_open(&db, transaction->root, PAKFIRE_DB_READWRITE);
if (r) {
ERROR(transaction->ctx, "Could not open the database\n");
return r;
goto ERROR;
// Make sure /usr-move is working
- r = pakfire_usrmove(transaction->ctx, transaction->pakfire);
+ r = pakfire_usrmove(transaction->ctx, transaction->root);
if (r)
goto ERROR;
// Reload database for next transaction
- repo = pakfire_get_installed_repo(transaction->pakfire);
+ repo = pakfire_root_get_installed_repo(transaction->root);
if (!repo)
goto ERROR;
dump = pakfire_transaction_dump(transaction, 80);
// Check if we should continue
- r = pakfire_ctx_confirm(transaction->ctx, transaction->pakfire, dump, _("Is this okay?"));
+ r = pakfire_ctx_confirm(transaction->ctx, transaction->root, dump, _("Is this okay?"));
if (r) {
ERROR(transaction->ctx, "Transaction aborted upon user request\n");
goto ERROR;
files[num] = NULL;
// Create the repository
- return pakfire_repo_compose(transaction->pakfire, path, key, files);
+ return pakfire_repo_compose(transaction->root, path, key, files);
}
PAKFIRE_JOB_BEST = 1 << 3,
};
-int pakfire_transaction_create(pakfire_transaction** transaction,
- struct pakfire* pakfire, int flags);
+int pakfire_transaction_create(pakfire_transaction** transaction, pakfire_root* root, int flags);
pakfire_transaction* pakfire_transaction_ref(pakfire_transaction* transaction);
pakfire_transaction* pakfire_transaction_unref(pakfire_transaction* transaction);
return r;
}
-int __pakfire_which(struct pakfire* pakfire, char* path, const size_t length,
+int __pakfire_which(pakfire_root* root, char* path, const size_t length,
const char* what) {
char buffer[PATH_MAX];
int r;
for (const char** p = paths; *p; p++) {
// Compose path
- r = pakfire_path(pakfire, buffer, "%s/%s", *p, what);
+ r = pakfire_root_path(root, buffer, "%s/%s", *p, what);
if (r)
return r;
// If the path exists and is executable we are done
if (access(buffer, X_OK) == 0) {
- const char* relpath = pakfire_relpath(pakfire, buffer);
+ const char* relpath = pakfire_root_relpath(root, buffer);
// Store the result in path
return __pakfire_string_set(path, length, relpath);
int pakfire_symlink(pakfire_ctx* ctx, const char* target, const char* linkpath);
int pakfire_rmtree(const char* path, int flags);
-#define pakfire_which(pakfire, path, what) \
- __pakfire_which(pakfire, path, sizeof(path), what)
-int __pakfire_which(struct pakfire* pakfire, char* path, const size_t length, const char* what);
+#define pakfire_which(root, path, what) \
+ __pakfire_which(root, path, sizeof(path), what)
+int __pakfire_which(pakfire_root* root, char* path, const size_t length, const char* what);
// UUID Stuff
if (!PyArg_ParseTuple(args, "O!s", &PakfireType, &pakfire, &filename))
return -1;
- errno = -pakfire_archive_open(&self->archive, pakfire->pakfire, filename);
+ errno = -pakfire_archive_open(&self->archive, pakfire->root, filename);
if (errno) {
PyErr_SetFromErrno(PyExc_OSError);
return -1;
// Confirm Callback
-static int Ctx_confirm_callback(pakfire_ctx* ctx, struct pakfire* pakfire,
+static int Ctx_confirm_callback(pakfire_ctx* ctx, pakfire_root* root,
void* data, const char* message, const char* question) {
PyObject* callback = data;
PyObject* ret = NULL;
return -1;
// Create the package object
- r = pakfire_package_create(&self->package, pakfire->pakfire, repo->repo, name, evr, arch);
+ r = pakfire_package_create(&self->package, pakfire->root, repo->repo, name, evr, arch);
if (r < 0) {
errno = -r;
PyErr_SetFromErrno(PyExc_OSError);
PakfireObject* self = (PakfireObject *)type->tp_alloc(type, 0);
if (self) {
self->ctx = NULL;
- self->pakfire = NULL;
+ self->root = NULL;
}
return (PyObject *)self;
// Setup flags
if (stub)
- flags |= PAKFIRE_FLAGS_STUB;
+ flags |= PAKFIRE_ROOT_FLAGS_STUB;
// Create a new configuration object
r = pakfire_config_create(&c);
Py_BEGIN_ALLOW_THREADS
- // Create a new Pakfire instance
- r = pakfire_create(&self->pakfire, self->ctx->ctx, c, path, arch, flags);
+ // Create a new root
+ r = pakfire_root_create(&self->root, self->ctx->ctx, c, path, arch, flags);
if (r < 0) {
Py_BLOCK_THREADS
errno = -r;
static void Pakfire_dealloc(PakfireObject* self) {
Py_BEGIN_ALLOW_THREADS
- if (self->pakfire)
- pakfire_unref(self->pakfire);
+ if (self->root)
+ pakfire_root_unref(self->root);
Py_END_ALLOW_THREADS
}
static PyObject* Pakfire_repr(PakfireObject* self) {
- const char* path = pakfire_get_path(self->pakfire);
- const char* arch = pakfire_get_arch(self->pakfire);
+ const char* path = pakfire_root_get_path(self->root);
+ const char* arch = pakfire_root_get_arch(self->root);
return PyUnicode_FromFormat("<_pakfire.Pakfire %s (%s)>", path, arch);
}
static PyObject* Pakfire_get_path(PakfireObject* self) {
- const char* path = pakfire_get_path(self->pakfire);
+ const char* path = pakfire_root_get_path(self->root);
return PyUnicode_FromString(path);
}
static PyObject* Pakfire_get_arch(PakfireObject* self) {
- const char* arch = pakfire_get_arch(self->pakfire);
+ const char* arch = pakfire_root_get_arch(self->root);
return PyUnicode_FromString(arch);
}
if (!PyArg_ParseTuple(args, "s", &name))
return NULL;
- pakfire_repo* repo = pakfire_get_repo(self->pakfire, name);
+ pakfire_repo* repo = pakfire_root_get_repo(self->root, name);
if (!repo)
Py_RETURN_NONE;
goto ERROR;
}
- r = pakfire_whatprovides(self->pakfire, provides, 0, list);
+ r = pakfire_root_whatprovides(self->root, provides, 0, list);
if (r < 0) {
errno = -r;
PyErr_SetFromErrno(PyExc_OSError);
goto ERROR;
}
- r = pakfire_whatrequires(self->pakfire, requires, 0, list);
+ r = pakfire_root_whatrequires(self->root, requires, 0, list);
if (r < 0) {
Py_BLOCK_THREADS
errno = -r;
// Search for package names only
if (name_only)
- flags |= PAKFIRE_SEARCH_NAME_ONLY;
+ flags |= PAKFIRE_ROOT_SEARCH_NAME_ONLY;
r = pakfire_packagelist_create(&list, self->ctx->ctx);
if (r < 0) {
goto ERROR;
}
- r = pakfire_search(self->pakfire, pattern, flags, list);
+ r = pakfire_root_search(self->root, pattern, flags, list);
if (r < 0) {
errno = -r;
PyErr_SetFromErrno(PyExc_OSError);
if (!PyArg_ParseTuple(args, "ss", &evr1, &evr2))
return NULL;
- int cmp = pakfire_version_compare(self->pakfire, evr1, evr2);
+ int cmp = pakfire_root_version_compare(self->root, evr1, evr2);
return PyLong_FromLong(cmp);
}
Py_BEGIN_ALLOW_THREADS
- r = pakfire_dist(self->pakfire, path, &archive);
+ r = pakfire_dist(self->root, path, &archive);
if (r) {
Py_BLOCK_THREADS
PyErr_SetFromErrno(PyExc_OSError);
}
static PyObject* Pakfire_get_repos(PakfireObject* self) {
- pakfire_repolist* repos = pakfire_get_repos(self->pakfire);
+ pakfire_repolist* repos = pakfire_root_get_repos(self->root);
if (!repos) {
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
Py_BEGIN_ALLOW_THREADS
- r = pakfire_clean(self->pakfire, 0);
+ r = pakfire_root_clean(self->root, 0);
if (r) {
Py_BLOCK_THREADS
PyErr_SetFromErrno(PyExc_OSError);
Py_BEGIN_ALLOW_THREADS
- int r = pakfire_archive_open(&archive, self->pakfire, path);
+ int r = pakfire_archive_open(&archive, self->root, path);
if (r) {
Py_BLOCK_THREADS
PyErr_SetFromErrno(PyExc_OSError);
Py_BEGIN_ALLOW_THREADS
- int r = pakfire_repo_compose(self->pakfire, path, (key) ? key->key : NULL, files);
+ int r = pakfire_repo_compose(self->root, path, (key) ? key->key : NULL, files);
if (r) {
Py_BLOCK_THREADS
PyErr_SetFromErrno(PyExc_OSError);
input_callback = pakfire_jail_send_buffer;
// Create a new jail
- r = pakfire_jail_create(&jail, self->pakfire);
+ r = pakfire_jail_create(&jail, self->root);
if (r < 0) {
errno = -r;
PyErr_SetFromErrno(PyExc_OSError);
// The Python context object
CtxObject* ctx;
- // Pakfire
- struct pakfire* pakfire;
+ // Root
+ pakfire_root* root;
} PakfireObject;
extern PyTypeObject PakfireType;
return -1;
// Create a new repository
- int r = pakfire_repo_create(&self->repo, pakfire->pakfire, name);
+ int r = pakfire_repo_create(&self->repo, pakfire->root, name);
if (r) {
PyErr_SetFromErrno(PyExc_OSError);
return -1;
flags |= PAKFIRE_TRANSACTION_WITHOUT_RECOMMENDED;
// Create a new transaction
- r = pakfire_transaction_create(&self->transaction, pakfire->pakfire, flags);
+ r = pakfire_transaction_create(&self->transaction, pakfire->root, flags);
if (r < 0) {
errno = -r;
PyErr_SetFromErrno(PyExc_OSError);
int r = EXIT_FAILURE;
// Open the archive
- ASSERT_SUCCESS(pakfire_archive_open(&archive, t->pakfire, TEST_SRC_PATH TEST_PKG1_PATH));
+ ASSERT_SUCCESS(pakfire_archive_open(&archive, t->root, TEST_SRC_PATH TEST_PKG1_PATH));
// Check if path was set correctly
ASSERT_STRING_EQUALS(pakfire_archive_get_path(archive), TEST_SRC_PATH TEST_PKG1_PATH);
int r = EXIT_FAILURE;
// Open the archive
- ASSERT_ERROR(pakfire_archive_open(&archive, t->pakfire, TEST_SRC_PATH), EISDIR);
+ ASSERT_ERROR(pakfire_archive_open(&archive, t->root, TEST_SRC_PATH), EISDIR);
ASSERT_NULL(archive);
// Everything passed
};
// Open the archive
- ASSERT_SUCCESS(pakfire_archive_open(&archive, t->pakfire, TEST_SRC_PATH TEST_PKG1_PATH));
+ ASSERT_SUCCESS(pakfire_archive_open(&archive, t->root, TEST_SRC_PATH TEST_PKG1_PATH));
// Read a file
ASSERT(f = pakfire_archive_read(archive, "/usr/bin/beep", 0));
ASSERT(f && path);
// Open the archive
- ASSERT_SUCCESS(pakfire_archive_open(&archive, t->pakfire, TEST_SRC_PATH TEST_PKG1_PATH));
+ ASSERT_SUCCESS(pakfire_archive_open(&archive, t->root, TEST_SRC_PATH TEST_PKG1_PATH));
// Copy archive
ASSERT_SUCCESS(pakfire_archive_copy(archive, path));
int r = EXIT_FAILURE;
// Open the archive
- ASSERT_SUCCESS(pakfire_archive_open(&archive, t->pakfire, TEST_SRC_PATH TEST_PKG1_PATH));
+ ASSERT_SUCCESS(pakfire_archive_open(&archive, t->root, TEST_SRC_PATH TEST_PKG1_PATH));
// Fetch the filelist
ASSERT_SUCCESS(pakfire_archive_get_filelist(archive, &list));
char path[PATH_MAX];
int r = EXIT_FAILURE;
- ASSERT_SUCCESS(pakfire_archive_open(&archive, t->pakfire, TEST_SRC_PATH TEST_PKG1_PATH));
+ ASSERT_SUCCESS(pakfire_archive_open(&archive, t->root, TEST_SRC_PATH TEST_PKG1_PATH));
// Extract the archive payload
ASSERT_SUCCESS(pakfire_archive_extract(archive, NULL, 0, NULL));
// Check if test file from the archive exists
- pakfire_path(t->pakfire, path, "%s", "/usr/bin/beep");
+ pakfire_root_path(t->root, path, "%s", "/usr/bin/beep");
ASSERT_SUCCESS(access(path, F_OK));
r = EXIT_SUCCESS;
pakfire_package* package = NULL;
// Open archive
- ASSERT_SUCCESS(pakfire_archive_open(&archive, t->pakfire, path));
+ ASSERT_SUCCESS(pakfire_archive_open(&archive, t->root, path));
ASSERT(archive);
// Create a new repository
- ASSERT_SUCCESS(pakfire_repo_create(&repo, t->pakfire, "@tmp"));
+ ASSERT_SUCCESS(pakfire_repo_create(&repo, t->root, "@tmp"));
ASSERT(repo);
// Add the package to the repository
}
int main(int argc, const char* argv[]) {
- testsuite_add_test(test_open, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_open_directory, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_read, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_copy, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_filelist, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_extract, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_import, TEST_WANTS_PAKFIRE);
+ testsuite_add_test(test_open, TEST_WANTS_ROOT);
+ testsuite_add_test(test_open_directory, TEST_WANTS_ROOT);
+ testsuite_add_test(test_read, TEST_WANTS_ROOT);
+ testsuite_add_test(test_copy, TEST_WANTS_ROOT);
+ testsuite_add_test(test_filelist, TEST_WANTS_ROOT);
+ testsuite_add_test(test_extract, TEST_WANTS_ROOT);
+ testsuite_add_test(test_import, TEST_WANTS_ROOT);
return testsuite_run(argc, argv);
}
ASSERT_SUCCESS(pakfire_cgroup_create(&cgroup, t->ctx, NULL, "pakfire-test", 0));
// Create a new jail
- ASSERT_SUCCESS(pakfire_jail_create(&jail, t->pakfire));
+ ASSERT_SUCCESS(pakfire_jail_create(&jail, t->root));
// Connect jail to the cgroup
ASSERT_SUCCESS(pakfire_jail_set_cgroup(jail, cgroup));
testsuite_add_test(test_create_and_destroy, 0);
testsuite_add_test(test_recursive, 0);
testsuite_add_test(test_child, 0);
- testsuite_add_test(test_stats, TEST_WANTS_PAKFIRE);
+ testsuite_add_test(test_stats, TEST_WANTS_ROOT);
return testsuite_run(argc, argv);
}
pakfire_db* db = NULL;
int r = EXIT_FAILURE;
- ASSERT_SUCCESS(pakfire_db_open(&db, t->pakfire, PAKFIRE_DB_READONLY));
+ ASSERT_SUCCESS(pakfire_db_open(&db, t->root, PAKFIRE_DB_READONLY));
// Everything passed
r = EXIT_SUCCESS;
pakfire_db* db = NULL;
int r = EXIT_FAILURE;
- ASSERT_SUCCESS(pakfire_db_open(&db, t->pakfire, PAKFIRE_DB_READWRITE));
+ ASSERT_SUCCESS(pakfire_db_open(&db, t->root, PAKFIRE_DB_READWRITE));
// Everything passed
r = EXIT_SUCCESS;
pakfire_db* db = NULL;
int r = EXIT_FAILURE;
- ASSERT_SUCCESS(pakfire_db_open(&db, t->pakfire, PAKFIRE_DB_READWRITE));
+ ASSERT_SUCCESS(pakfire_db_open(&db, t->root, PAKFIRE_DB_READWRITE));
// Perform check
ASSERT_SUCCESS(pakfire_db_check(db));
pakfire_archive* archive = NULL;
int r = EXIT_FAILURE;
- ASSERT(repo = pakfire_get_repo(t->pakfire, PAKFIRE_REPO_DUMMY));
+ ASSERT(repo = pakfire_root_get_repo(t->root, PAKFIRE_REPO_DUMMY));
- ASSERT_SUCCESS(pakfire_db_open(&db, t->pakfire, PAKFIRE_DB_READWRITE));
+ ASSERT_SUCCESS(pakfire_db_open(&db, t->root, PAKFIRE_DB_READWRITE));
// There must be no packages installed
ssize_t packages = pakfire_db_packages(db);
const char* path = TEST_SRC_PATH "/data/beep-1.3-2.ip3.x86_64.pfm";
// Open archive
- ASSERT_SUCCESS(pakfire_archive_open(&archive, t->pakfire, path));
+ ASSERT_SUCCESS(pakfire_archive_open(&archive, t->root, path));
ASSERT(archive);
// Get package
}
int main(int argc, const char* argv[]) {
- testsuite_add_test(test_open_ro, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_open_rw, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_check, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_add_package, TEST_WANTS_PAKFIRE);
+ testsuite_add_test(test_open_ro, TEST_WANTS_ROOT);
+ testsuite_add_test(test_open_rw, TEST_WANTS_ROOT);
+ testsuite_add_test(test_check, TEST_WANTS_ROOT);
+ testsuite_add_test(test_add_package, TEST_WANTS_ROOT);
return testsuite_run(argc, argv);
}
const char* result = NULL;
// Check some invalid inputs
- ASSERT(pakfire_str2dep(t->pakfire, NULL) == ID_NULL);
- ASSERT(pakfire_str2dep(t->pakfire, "") == ID_NULL);
+ ASSERT(pakfire_str2dep(t->root, NULL) == ID_NULL);
+ ASSERT(pakfire_str2dep(t->root, "") == ID_NULL);
// Check some valid inputs
for (const char** relation = relations; *relation; relation++) {
printf("Parsing '%s'...\n", *relation);
// Parse relation
- dep = pakfire_str2dep(t->pakfire, *relation);
+ dep = pakfire_str2dep(t->root, *relation);
// Convert it back to string
- result = pakfire_dep2str(t->pakfire, dep);
+ result = pakfire_dep2str(t->root, dep);
ASSERT(result);
// Check if the output matches the input
printf("Parsing '%s'...\n", *relation);
// Parse relation
- dep = pakfire_str2dep(t->pakfire, *relation);
+ dep = pakfire_str2dep(t->root, *relation);
// The return value must be ID_NULL
ASSERT(dep == ID_NULL);
printf("Parsing '%s'...\n", *relation);
// Parse relation
- ASSERT(dep = pakfire_str2dep(t->pakfire, *relation));
+ ASSERT(dep = pakfire_str2dep(t->root, *relation));
// Convert it back to string
- ASSERT(result = pakfire_dep2str(t->pakfire, dep));
+ ASSERT(result = pakfire_dep2str(t->root, dep));
printf(" as '%s'\n", result);
}
pakfire_package* pkg = NULL;
int r = EXIT_FAILURE;
- ASSERT_SUCCESS(pakfire_package_create(&pkg, t->pakfire, NULL,
+ ASSERT_SUCCESS(pakfire_package_create(&pkg, t->root, NULL,
"test", "1.0-1", "x86_64"));
// Check if the package matches itself
}
int main(int argc, const char* argv[]) {
- testsuite_add_test(test_dependencies, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_dep_match, TEST_WANTS_PAKFIRE);
+ testsuite_add_test(test_dependencies, TEST_WANTS_ROOT);
+ testsuite_add_test(test_dep_match, TEST_WANTS_ROOT);
return testsuite_run(argc, argv);
}
pakfire_file* file = NULL;
// Create a new file
- ASSERT_SUCCESS(pakfire_file_create(&file, t->pakfire, NULL));
+ ASSERT_SUCCESS(pakfire_file_create(&file, t->root, NULL));
// Set path & check
ASSERT_SUCCESS(pakfire_file_set_path(file, "/abc"));
pakfire_file* file = NULL;
// Create a new file
- ASSERT_SUCCESS(pakfire_file_create(&file, t->pakfire, NULL));
+ ASSERT_SUCCESS(pakfire_file_create(&file, t->root, NULL));
// Set path
ASSERT(pakfire_file_set_path(file, NULL) == -EINVAL);
int r = EXIT_FAILURE;
// Create a new filelist
- ASSERT_SUCCESS(pakfire_filelist_create(&list, t->pakfire));
+ ASSERT_SUCCESS(pakfire_filelist_create(&list, t->root));
// Create some files
- ASSERT_SUCCESS(pakfire_file_create(&file1, t->pakfire, "/1"));
- ASSERT_SUCCESS(pakfire_file_create(&file2, t->pakfire, "/2"));
- ASSERT_SUCCESS(pakfire_file_create(&file3, t->pakfire, "/3"));
+ ASSERT_SUCCESS(pakfire_file_create(&file1, t->root, "/1"));
+ ASSERT_SUCCESS(pakfire_file_create(&file2, t->root, "/2"));
+ ASSERT_SUCCESS(pakfire_file_create(&file3, t->root, "/3"));
// Add the files to the list
ASSERT_SUCCESS(pakfire_filelist_add(list, file1));
int main(int argc, const char* argv[]) {
- testsuite_add_test(test_create, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_create_invalid, TEST_WANTS_PAKFIRE);
+ testsuite_add_test(test_create, TEST_WANTS_ROOT);
+ testsuite_add_test(test_create_invalid, TEST_WANTS_ROOT);
- testsuite_add_test(test_create_filelist, TEST_WANTS_PAKFIRE);
+ testsuite_add_test(test_create_filelist, TEST_WANTS_ROOT);
return testsuite_run(argc, argv);
}
pakfire_jail* jail = NULL;
// Create a new jail
- ASSERT_SUCCESS(pakfire_jail_create(&jail, t->pakfire));
+ ASSERT_SUCCESS(pakfire_jail_create(&jail, t->root));
// Destroy it
ASSERT_NULL(pakfire_jail_unref(jail));
};
// Create a new jail
- ASSERT_SUCCESS(pakfire_jail_create(&jail, t->pakfire));
+ ASSERT_SUCCESS(pakfire_jail_create(&jail, t->root));
// Check if we receive the correct exit code
ASSERT_EQUALS(pakfire_jail_execute_command(jail, argv, NULL, 0), 123);
};
// Create a new jail
- ASSERT_SUCCESS(pakfire_jail_create(&jail, t->pakfire));
+ ASSERT_SUCCESS(pakfire_jail_create(&jail, t->root));
// Check if we receive the correct exit code
ASSERT(pakfire_jail_execute_command(jail, argv, NULL, 0) == 139);
size_t length = 0;
// Create a new jail
- ASSERT_SUCCESS(pakfire_jail_create(&jail, t->pakfire));
+ ASSERT_SUCCESS(pakfire_jail_create(&jail, t->root));
// Try to execute something
ASSERT_SUCCESS(pakfire_jail_execute_capture_output(jail, cmd_hello_world, NULL, 0, &output, &length));
ASSERT_SUCCESS(pakfire_cgroup_create(&cgroup, t->ctx, NULL, "pakfire-test", 0));
// Create a new jail
- ASSERT_SUCCESS(pakfire_jail_create(&jail, t->pakfire));
+ ASSERT_SUCCESS(pakfire_jail_create(&jail, t->root));
// Connect jail to the cgroup
ASSERT_SUCCESS(pakfire_jail_set_cgroup(jail, cgroup));
};
// Create a new jail
- ASSERT_SUCCESS(pakfire_jail_create(&jail, t->pakfire));
+ ASSERT_SUCCESS(pakfire_jail_create(&jail, t->root));
// Set invalid nice levels
ASSERT_ERROR(pakfire_jail_nice(jail, 100), EINVAL);
ASSERT_SUCCESS(pakfire_cgroup_create(&cgroup, t->ctx, NULL, "pakfire-test", 0));
// Create jail
- ASSERT_SUCCESS(pakfire_jail_create(&jail, t->pakfire));
+ ASSERT_SUCCESS(pakfire_jail_create(&jail, t->root));
// Connect jail to the cgroup
ASSERT_SUCCESS(pakfire_jail_set_cgroup(jail, cgroup));
ASSERT_SUCCESS(pakfire_cgroup_create(&cgroup, t->ctx, NULL, "pakfire-test", 0));
// Create jail
- ASSERT_SUCCESS(pakfire_jail_create(&jail, t->pakfire));
+ ASSERT_SUCCESS(pakfire_jail_create(&jail, t->root));
// Connect jail to the cgroup
ASSERT_SUCCESS(pakfire_jail_set_cgroup(jail, cgroup));
char* output = NULL;
// Execute a simple command
- ASSERT_SUCCESS(pakfire_jail_run(t->pakfire, cmd_stat_ownership, NULL, 0, &output, NULL));
+ ASSERT_SUCCESS(pakfire_jail_run(t->root, cmd_stat_ownership, NULL, 0, &output, NULL));
// Check if the file has been mapped to root/root
ASSERT_STRING_EQUALS(output, "uid=0 gid=0\n");
};
// Create a new jail
- ASSERT_SUCCESS(pakfire_jail_create(&jail, t->pakfire));
+ ASSERT_SUCCESS(pakfire_jail_create(&jail, t->root));
// Bind-mount nonsense
ASSERT_ERROR(pakfire_jail_bind(jail, NULL, target, 0), EINVAL);
};
// Create a new jail
- ASSERT_SUCCESS(pakfire_jail_create(&jail, t->pakfire));
+ ASSERT_SUCCESS(pakfire_jail_create(&jail, t->root));
// Check if the mount actually works
ASSERT_SUCCESS(pakfire_jail_communicate(jail, argv, NULL, 0,
int r = EXIT_FAILURE;
// Create a new jail
- ASSERT_SUCCESS(pakfire_jail_create(&jail, t->pakfire));
+ ASSERT_SUCCESS(pakfire_jail_create(&jail, t->root));
// Sending SIGTERM to ourselves
ASSERT(test_send_one_signal(t, jail, "15") == 0);
};
// Create a new jail
- ASSERT_SUCCESS(pakfire_jail_create(&jail, t->pakfire));
+ ASSERT_SUCCESS(pakfire_jail_create(&jail, t->root));
// Set a timeout of one second
ASSERT_SUCCESS(pakfire_jail_set_timeout(jail, 1));
int i = 123;
// Create a new jail
- ASSERT_SUCCESS(pakfire_jail_create(&jail, t->pakfire));
+ ASSERT_SUCCESS(pakfire_jail_create(&jail, t->root));
// Check if we receive the correct exit code
ASSERT(pakfire_jail_execute(jail, __callback, &i, 0) == 123);
}
int main(int argc, const char* argv[]) {
- testsuite_add_test(test_create, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_exit_code, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_segv, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_exec, TEST_WANTS_PAKFIRE);
+ testsuite_add_test(test_create, TEST_WANTS_ROOT);
+ testsuite_add_test(test_exit_code, TEST_WANTS_ROOT);
+ testsuite_add_test(test_segv, TEST_WANTS_ROOT);
+ testsuite_add_test(test_exec, TEST_WANTS_ROOT);
#if 0
- testsuite_add_test(test_launch_into_cgroup, TEST_WANTS_PAKFIRE);
+ testsuite_add_test(test_launch_into_cgroup, TEST_WANTS_ROOT);
#endif
- testsuite_add_test(test_nice, TEST_WANTS_PAKFIRE);
+ testsuite_add_test(test_nice, TEST_WANTS_ROOT);
#if 0
- testsuite_add_test(test_memory_limit, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_pid_limit, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_file_ownership, TEST_WANTS_PAKFIRE);
+ testsuite_add_test(test_memory_limit, TEST_WANTS_ROOT);
+ testsuite_add_test(test_pid_limit, TEST_WANTS_ROOT);
+ testsuite_add_test(test_file_ownership, TEST_WANTS_ROOT);
#endif
- testsuite_add_test(test_bind, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_communicate, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_send_signal, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_timeout, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_callback, TEST_WANTS_PAKFIRE);
+ testsuite_add_test(test_bind, TEST_WANTS_ROOT);
+ testsuite_add_test(test_communicate, TEST_WANTS_ROOT);
+ testsuite_add_test(test_send_signal, TEST_WANTS_ROOT);
+ testsuite_add_test(test_timeout, TEST_WANTS_ROOT);
+ testsuite_add_test(test_callback, TEST_WANTS_ROOT);
return testsuite_run(argc, argv);
}
#include "../testsuite.h"
static int test_init(const struct test* t) {
- LOG("Allocated at %p\n", t->pakfire);
+ LOG("Allocated at %p\n", t->root);
// Check if the path matches
- ASSERT_STRING_EQUALS(pakfire_get_path(t->pakfire), TEST_STUB_ROOT);
+ ASSERT_STRING_EQUALS(pakfire_root_get_path(t->root), TEST_STUB_ROOT);
return EXIT_SUCCESS;
}
static int test_stub(const struct test* t) {
- struct pakfire* pakfire = NULL;
+ pakfire_root* root = NULL;
int r = EXIT_FAILURE;
// Have some illegal calls
- ASSERT_ERROR(pakfire_create(&pakfire, t->ctx, t->config, "PATH", NULL, PAKFIRE_FLAGS_STUB), EINVAL);
+ ASSERT_ERROR(pakfire_root_create(&root, t->ctx, t->config, "PATH", NULL, PAKFIRE_ROOT_FLAGS_STUB), EINVAL);
// Have a success call
- ASSERT_SUCCESS(pakfire_create(&pakfire, t->ctx, t->config, NULL, NULL, PAKFIRE_FLAGS_STUB));
+ ASSERT_SUCCESS(pakfire_root_create(&root, t->ctx, t->config, NULL, NULL, PAKFIRE_ROOT_FLAGS_STUB));
r = EXIT_SUCCESS;
FAIL:
- if (pakfire)
- pakfire_unref(pakfire);
+ if (root)
+ pakfire_root_unref(root);
return r;
}
static int test_fail(const struct test* t) {
pakfire_config* config = NULL;
- struct pakfire* pakfire = NULL;
+ pakfire_root* root = NULL;
int r = EXIT_FAILURE;
// Create a configuration
ASSERT_SUCCESS(pakfire_config_create(&config));
// Init without anything
- ASSERT_ERROR(pakfire_create(&pakfire, t->ctx, NULL, NULL, NULL, 0), EINVAL);
+ ASSERT_ERROR(pakfire_root_create(&root, t->ctx, NULL, NULL, NULL, 0), EINVAL);
// Invalid architecture
- ASSERT_ERROR(pakfire_create(&pakfire, t->ctx, config, NULL, "arch", 0), ENOTSUP);
+ ASSERT_ERROR(pakfire_root_create(&root, t->ctx, config, NULL, "arch", 0), ENOTSUP);
// Invalid path (must be absolute)
- ASSERT_ERROR(pakfire_create(&pakfire, t->ctx, config, "path", NULL, 0), EINVAL);
+ ASSERT_ERROR(pakfire_root_create(&root, t->ctx, config, "path", NULL, 0), EINVAL);
// Cannot use snapshots with a path
- ASSERT_ERROR(pakfire_create(&pakfire, t->ctx, NULL, PAKFIRE_TMP_DIR "/test",
- NULL, PAKFIRE_USE_SNAPSHOT), EINVAL);
+ ASSERT_ERROR(pakfire_root_create(&root, t->ctx, NULL, PAKFIRE_TMP_DIR "/test",
+ NULL, PAKFIRE_ROOT_USE_SNAPSHOT), EINVAL);
r = EXIT_SUCCESS;
}
int main(int argc, const char* argv[]) {
- testsuite_add_test(test_init, TEST_WANTS_PAKFIRE);
+ testsuite_add_test(test_init, TEST_WANTS_ROOT);
testsuite_add_test(test_stub, 0);
testsuite_add_test(test_fail, 0);
FILE* f = fopen(path, "r");
ASSERT(f);
- ASSERT_SUCCESS(pakfire_parser_create(&parser, t->pakfire, NULL, NULL, 0));
+ ASSERT_SUCCESS(pakfire_parser_create(&parser, t->root, NULL, NULL, 0));
ASSERT_SUCCESS(pakfire_parser_read(parser, f, NULL));
pakfire_parser* parser = NULL;
int r = EXIT_FAILURE;
- ASSERT_SUCCESS(pakfire_parser_create(&parser, t->pakfire, NULL, NULL, 0));
+ ASSERT_SUCCESS(pakfire_parser_create(&parser, t->root, NULL, NULL, 0));
// Load 'em all
ASSERT_SUCCESS(load_macros(parser));
char* s = NULL;
int r = EXIT_FAILURE;
- ASSERT_SUCCESS(pakfire_repo_create(&repo, t->pakfire, "test"));
+ ASSERT_SUCCESS(pakfire_repo_create(&repo, t->root, "test"));
ASSERT(repo);
- ASSERT_SUCCESS(pakfire_parser_create(&parser, t->pakfire, NULL, NULL,
+ ASSERT_SUCCESS(pakfire_parser_create(&parser, t->root, NULL, NULL,
PAKFIRE_PARSER_FLAGS_EXPAND_COMMANDS));
// Set some architecture
ASSERT(tmp);
// Attempt to dist the dummy package
- ASSERT_SUCCESS(pakfire_dist(t->pakfire,
+ ASSERT_SUCCESS(pakfire_dist(t->root,
TEST_SRC_PATH "data/packages/dummy/dummy.nm", &archive));
// Extract all package metadata
// Check vendor
const char* vendor = pakfire_package_get_string(package, PAKFIRE_PKG_VENDOR);
- ASSERT_STRING_EQUALS(vendor, pakfire_get_distro_vendor(t->pakfire));
+ ASSERT_STRING_EQUALS(vendor, pakfire_root_get_distro_vendor(t->root));
// Check UUID
const char* uuid = pakfire_package_get_string(package, PAKFIRE_PKG_UUID);
}
int main(int argc, const char* argv[]) {
- testsuite_add_test(test_macros, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_parse, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_packages, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_dist_dummy, TEST_WANTS_PAKFIRE);
+ testsuite_add_test(test_macros, TEST_WANTS_ROOT);
+ testsuite_add_test(test_parse, TEST_WANTS_ROOT);
+ testsuite_add_test(test_packages, TEST_WANTS_ROOT);
+ testsuite_add_test(test_dist_dummy, TEST_WANTS_ROOT);
return testsuite_run(argc, argv);
}
char** groups = NULL;
int r = EXIT_FAILURE;
- ASSERT_SUCCESS(pakfire_package_create(&pkg, t->pakfire, NULL, "test", "1.0-1", "x86_64"));
+ ASSERT_SUCCESS(pakfire_package_create(&pkg, t->root, NULL, "test", "1.0-1", "x86_64"));
ASSERT_STRING_EQUALS(pakfire_package_get_string(pkg, PAKFIRE_PKG_NAME), "test");
ASSERT_STRING_EQUALS(pakfire_package_get_string(pkg, PAKFIRE_PKG_EVR), "1.0-1");
int r = EXIT_FAILURE;
// Try to create a package with some values missing
- ASSERT_ERRNO(pakfire_package_create(&pkg, t->pakfire, NULL, NULL, "1.0-1", "src"), EINVAL);
- ASSERT_ERRNO(pakfire_package_create(&pkg, t->pakfire, NULL, "test", NULL, "src"), EINVAL);
- ASSERT_ERRNO(pakfire_package_create(&pkg, t->pakfire, NULL, "test", "1.0-1", NULL), EINVAL);
+ ASSERT_ERRNO(pakfire_package_create(&pkg, t->root, NULL, NULL, "1.0-1", "src"), EINVAL);
+ ASSERT_ERRNO(pakfire_package_create(&pkg, t->root, NULL, "test", NULL, "src"), EINVAL);
+ ASSERT_ERRNO(pakfire_package_create(&pkg, t->root, NULL, "test", "1.0-1", NULL), EINVAL);
// Finally create a package
- ASSERT_SUCCESS(pakfire_package_create(&pkg, t->pakfire, NULL, "test", "1.0-1", "x86_64"));
+ ASSERT_SUCCESS(pakfire_package_create(&pkg, t->root, NULL, "test", "1.0-1", "x86_64"));
// Try to set non-sense for strings
ASSERT_ERRNO(pakfire_package_set_string(pkg, PAKFIRE_PKG_INSTALLTIME, "today"), EINVAL);
uuid_unparse(uuid, uuid_string);
// Create a new package
- ASSERT_SUCCESS(pakfire_package_create(&pkg, t->pakfire, NULL, "test", "1.0-1", "src"));
+ ASSERT_SUCCESS(pakfire_package_create(&pkg, t->root, NULL, "test", "1.0-1", "src"));
// Set the UUID
ASSERT_SUCCESS(pakfire_package_set_uuid(pkg, PAKFIRE_PKG_UUID, uuid));
char** deps = NULL;
int r = EXIT_FAILURE;
- ASSERT_SUCCESS(pakfire_package_create(&pkg, t->pakfire, NULL, "test", "1.0-1", "src"));
+ ASSERT_SUCCESS(pakfire_package_create(&pkg, t->root, NULL, "test", "1.0-1", "src"));
// Add a "provides"
ASSERT_SUCCESS(pakfire_package_add_dep(pkg, PAKFIRE_PKG_PROVIDES, "a"));
int r = EXIT_FAILURE;
// Create a filelist
- ASSERT_SUCCESS(pakfire_filelist_create(&filelist, t->pakfire));
+ ASSERT_SUCCESS(pakfire_filelist_create(&filelist, t->root));
// Create a file
- ASSERT_SUCCESS(pakfire_file_create(&file, t->pakfire, "/bin/bash"));
+ ASSERT_SUCCESS(pakfire_file_create(&file, t->root, "/bin/bash"));
// Append the file to the filelist
ASSERT_SUCCESS(pakfire_filelist_add(filelist, file));
ASSERT_EQUALS(pakfire_filelist_length(filelist), 1);
// Create a new package
- ASSERT_SUCCESS(pakfire_package_create(&pkg, t->pakfire, NULL,
+ ASSERT_SUCCESS(pakfire_package_create(&pkg, t->root, NULL,
"bash", "1.0-1", "i386"));
// Set filelist
}
int main(int argc, const char* argv[]) {
- testsuite_add_test(test_create, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_invalid_inputs, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_uuid, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_deps, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_filelist, TEST_WANTS_PAKFIRE);
+ testsuite_add_test(test_create, TEST_WANTS_ROOT);
+ testsuite_add_test(test_invalid_inputs, TEST_WANTS_ROOT);
+ testsuite_add_test(test_uuid, TEST_WANTS_ROOT);
+ testsuite_add_test(test_deps, TEST_WANTS_ROOT);
+ testsuite_add_test(test_filelist, TEST_WANTS_ROOT);
return testsuite_run(argc, argv);
}
pakfire_repo* repo = NULL;
int r = EXIT_FAILURE;
- ASSERT_SUCCESS(pakfire_repo_create(&repo, t->pakfire, "test"));
+ ASSERT_SUCCESS(pakfire_repo_create(&repo, t->root, "test"));
ASSERT(repo);
- ASSERT_SUCCESS(pakfire_package_create(&pkg, t->pakfire, repo, "test", "1.0-1", "src"));
+ ASSERT_SUCCESS(pakfire_package_create(&pkg, t->root, repo, "test", "1.0-1", "src"));
// Create packager
- ASSERT_SUCCESS(pakfire_packager_create(&packager, t->pakfire, pkg));
+ ASSERT_SUCCESS(pakfire_packager_create(&packager, t->root, pkg));
// Add a file to the package
const char* path = TEST_SRC_PATH "data/beep-1.3-2.ip3.x86_64.pfm";
int r = EXIT_FAILURE;
// Fetch the dummy repository
- pakfire_repo* repo = pakfire_get_repo(t->pakfire, PAKFIRE_REPO_DUMMY);
+ pakfire_repo* repo = pakfire_root_get_repo(t->root, PAKFIRE_REPO_DUMMY);
ASSERT(repo);
- ASSERT_SUCCESS(pakfire_package_create(&pkg1, t->pakfire, repo,
+ ASSERT_SUCCESS(pakfire_package_create(&pkg1, t->root, repo,
"test", "1.0-1", "x86_64"));
// Set all metadata
pakfire_package_set_string(pkg1, PAKFIRE_PKG_DESCRIPTION, "DESCRIPTION");
// Create packager
- ASSERT_SUCCESS(pakfire_packager_create(&packager, t->pakfire, pkg1));
+ ASSERT_SUCCESS(pakfire_packager_create(&packager, t->root, pkg1));
// Write archive
FILE* f = test_mktemp(&path);
printf("Archive written to %s\n", path);
// Try to open the archive
- ASSERT_SUCCESS(pakfire_archive_open(&archive, t->pakfire, path));
+ ASSERT_SUCCESS(pakfire_archive_open(&archive, t->root, path));
// Parse package from archive
ASSERT_SUCCESS(pakfire_archive_make_package(archive, repo, &pkg2));
}
int main(int argc, const char* argv[]) {
- testsuite_add_test(test_create, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_compare_metadata, TEST_WANTS_PAKFIRE);
+ testsuite_add_test(test_create, TEST_WANTS_ROOT);
+ testsuite_add_test(test_compare_metadata, TEST_WANTS_ROOT);
return testsuite_run(argc, argv);
}
char* s = NULL;
// Create a new parser
- ASSERT_SUCCESS(pakfire_parser_create(&parser, t->pakfire, NULL, NULL, 0));
+ ASSERT_SUCCESS(pakfire_parser_create(&parser, t->root, NULL, NULL, 0));
// Retrieve a value that does not exist
ASSERT_NULL(pakfire_parser_get(parser, NULL, "null"));
ASSERT_SUCCESS(pakfire_string_format(path, "%s/%s", TEST_SRC_PATH, *file));
// Create a new parser
- ASSERT_SUCCESS(pakfire_parser_create(&parser, t->pakfire, NULL, NULL, 0));
+ ASSERT_SUCCESS(pakfire_parser_create(&parser, t->root, NULL, NULL, 0));
FILE* f = fopen(path, "r");
ASSERT(f);
char* s = NULL;
// Create a new parser
- ASSERT_SUCCESS(pakfire_parser_create(&parser, t->pakfire, NULL, NULL, 0));
+ ASSERT_SUCCESS(pakfire_parser_create(&parser, t->root, NULL, NULL, 0));
const char* str1 =
"a = 1\n"
pakfire_parser* parser = NULL;
int r = EXIT_FAILURE;
- ASSERT_SUCCESS(pakfire_parser_create(&parser, t->pakfire, NULL, NULL, PAKFIRE_PARSER_FLAGS_EXPAND_COMMANDS));
+ ASSERT_SUCCESS(pakfire_parser_create(&parser, t->root, NULL, NULL, PAKFIRE_PARSER_FLAGS_EXPAND_COMMANDS));
ASSERT_SUCCESS(pakfire_parser_set(parser, NULL, "command", command, 0));
#endif
int main(int argc, const char* argv[]) {
- testsuite_add_test(test_parser, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_parser_files, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_append, TEST_WANTS_PAKFIRE);
+ testsuite_add_test(test_parser, TEST_WANTS_ROOT);
+ testsuite_add_test(test_parser_files, TEST_WANTS_ROOT);
+ testsuite_add_test(test_append, TEST_WANTS_ROOT);
#if 0
- testsuite_add_test(test_parser_command, TEST_WANTS_PAKFIRE);
+ testsuite_add_test(test_parser_command, TEST_WANTS_ROOT);
#endif
return testsuite_run(argc, argv);
pakfire_string_format(baseurl, "file://%s/data", TEST_SRC_PATH);
- ASSERT_SUCCESS(pakfire_repo_create(&repo, t->pakfire, "test"));
+ ASSERT_SUCCESS(pakfire_repo_create(&repo, t->root, "test"));
ASSERT(repo);
// Set the base URL (where to scan for files)
// Compose the repository
ASSERT_SUCCESS(
- pakfire_repo_compose(t->pakfire, path, NULL, files)
+ pakfire_repo_compose(t->root, path, NULL, files)
);
// Everything passed
}
int main(int argc, const char* argv[]) {
- testsuite_add_test(test_scan, TEST_WANTS_PAKFIRE);
- testsuite_add_test(test_compose, TEST_WANTS_PAKFIRE);
+ testsuite_add_test(test_scan, TEST_WANTS_ROOT);
+ testsuite_add_test(test_compose, TEST_WANTS_ROOT);
return testsuite_run(argc, argv);
}
char path[PATH_MAX];
// Create some random path
- ASSERT_SUCCESS(pakfire_path(t->pakfire, path, "%s", "/a/b/c/d/e"));
+ ASSERT_SUCCESS(pakfire_root_path(t->root, path, "%s", "/a/b/c/d/e"));
// Create this directory
ASSERT_SUCCESS(pakfire_mkdir(path, 0755));
}
int main(int argc, const char* argv[]) {
- testsuite_add_test(test_mkdir, TEST_WANTS_PAKFIRE);
+ testsuite_add_test(test_mkdir, TEST_WANTS_ROOT);
testsuite_add_test(test_base64, 0);
return testsuite_run(argc, argv);
int main(int argc, const char* argv[]) {
pakfire_config* config = NULL;
pakfire_ctx* ctx = NULL;
- struct pakfire* pakfire = NULL;
+ pakfire_root* root = NULL;
pakfire_parser* parser = NULL;
pakfire_parser_error* error = NULL;
const char* message = NULL;
FILE* f = NULL;
int r = 1;
- char root[PATH_MAX] = "/tmp/pakfire-parser-test.XXXXXX";
+ char path[PATH_MAX] = "/tmp/pakfire-parser-test.XXXXXX";
// Create test root directory
- char* tmp = pakfire_mkdtemp(root);
+ char* tmp = pakfire_mkdtemp(path);
if (!tmp) {
- fprintf(stderr, "Could not create temporary directory %s: %m\n", root);
+ fprintf(stderr, "Could not create temporary directory %s: %m\n", path);
goto ERROR;
}
if (r < 0)
goto ERROR;
- // Create a pakfire instance
- r = pakfire_create(&pakfire, ctx, config, root, NULL, 0);
+ // Create a new root
+ r = pakfire_root_create(&root, ctx, config, path, NULL, 0);
if (r) {
fprintf(stderr, "Could not create Pakfire: %m\n");
goto ERROR;
}
// Create a new parser
- r = pakfire_parser_create(&parser, pakfire, NULL, NULL, 0);
+ r = pakfire_parser_create(&parser, root, NULL, NULL, 0);
if (r < 0) {
fprintf(stderr, "Could not create a parser: %s\n", strerror(-r));
goto ERROR;
pakfire_parser_error_unref(error);
if (parser)
pakfire_parser_unref(parser);
- if (pakfire)
- pakfire_unref(pakfire);
+ if (root)
+ pakfire_root_unref(root);
if (config)
pakfire_config_unref(config);
if (ctx) {
static int test_run(int i, struct test* t) {
pakfire_ctx* ctx = NULL;
- struct pakfire* p = NULL;
+ pakfire_root* p = NULL;
int r;
LOG("running %s\n", t->name);
goto ERROR;
}
- // Create a pakfire instance (if requested)
- if (t->flags & TEST_WANTS_PAKFIRE) {
- r = pakfire_create(&t->pakfire, t->ctx, t->config, TEST_STUB_ROOT, NULL, 0);
+ // Create a root instance (if requested)
+ if (t->flags & TEST_WANTS_ROOT) {
+ r = pakfire_root_create(&t->root, t->ctx, t->config, TEST_STUB_ROOT, NULL, 0);
if (r < 0) {
- LOG("ERROR: Could not initialize pakfire: %s\n", strerror(-r));
+ LOG("ERROR: Could not initialize root: %s\n", strerror(-r));
goto ERROR;
}
// Check if the instance was created properly
- if (r == 0 && !t->pakfire) {
- LOG("ERROR: Pakfire was not initialized, but no error was raised: %m\n");
+ if (r == 0 && !t->root) {
+ LOG("ERROR: Root was not initialized, but no error was raised: %m\n");
goto ERROR;
}
}
if (t->httpclient)
pakfire_httpclient_unref(t->httpclient);
- // Release pakfire
- if (t->pakfire) {
- p = pakfire_unref(t->pakfire);
+ // Release root
+ if (t->root) {
+ p = pakfire_root_unref(t->root);
// Check if Pakfire was actually released
if (p) {
- LOG("Error: Pakfire instance was not released in test %d\n", i);
+ LOG("Error: Root instance was not released in test %d\n", i);
r = 1;
}
// Reset pointer (just in case)
- t->pakfire = NULL;
+ t->root = NULL;
}
// Release context
#define TEST_SRC_PATH ABS_TOP_SRCDIR "/tests/"
enum test_flags {
- TEST_WANTS_PAKFIRE = (1 << 0),
+ TEST_WANTS_ROOT = (1 << 0),
TEST_WANTS_HTTPCLIENT = (1 << 1),
};
// Config
pakfire_config* config;
- // Pakfire Context
+ // Context
pakfire_ctx* ctx;
- // Pakfire
- struct pakfire* pakfire;
+ // Root
+ pakfire_root* root;
// HTTP Client
pakfire_httpclient* httpclient;