return 0;
}
-static int do_dist(pakfire_root* root, const char* makefile, const char* resultdir) {
+static int do_dist(pakfire_ctx* ctx, 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(root, makefile, &archive);
+ r = pakfire_dist(ctx, root, makefile, &archive);
if (r < 0)
goto ERROR;
// Process all packages
for (unsigned int i = 0; i < local_args.num_makefiles; i++) {
- r = do_dist(root, local_args.makefiles[i], local_args.resultdir);
+ r = do_dist(global_args->ctx, 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;
return 1;
// Read makefile
- r = pakfire_read_makefile(parser, build->root, path, &error);
+ r = pakfire_read_makefile(parser, build->ctx, build->root, path, &error);
if (r) {
if (error) {
ERROR(build->ctx, "Could not parse makefile %s: %s\n", path,
return 0;
}
-int pakfire_read_makefile(pakfire_parser** parser, pakfire_root* root,
+int pakfire_read_makefile(pakfire_parser** parser, pakfire_ctx* ctx, pakfire_root* root,
const char* path, pakfire_parser_error** error) {
int r;
- // Fetch context
- pakfire_ctx* ctx = pakfire_root_get_ctx(root);
-
// Create a new parser
r = pakfire_parser_create(parser, root, NULL, NULL, PAKFIRE_PARSER_FLAGS_EXPAND_COMMANDS);
if (r < 0)
goto ERROR;
}
- if (ctx)
- pakfire_ctx_unref(ctx);
-
return 0;
ERROR:
*parser = NULL;
}
- if (ctx)
- pakfire_ctx_unref(ctx);
-
return r;
}
return r;
}
-int pakfire_dist(pakfire_root* root, const char* path, pakfire_archive** archive) {
+int pakfire_dist(pakfire_ctx* ctx, pakfire_root* root, const char* path, pakfire_archive** archive) {
pakfire_packager* packager = NULL;
pakfire_package* pkg = NULL;
pakfire_parser* makefile = NULL;
pakfire_archive* a = NULL;
int r;
- // Fetch context
- pakfire_ctx* ctx = pakfire_root_get_ctx(root);
-
// Load makefile
- r = pakfire_read_makefile(&makefile, root, path, &error);
+ r = pakfire_read_makefile(&makefile, ctx, root, path, &error);
if (r < 0) {
if (error)
pakfire_parser_error_unref(error);
pakfire_parser_unref(makefile);
if (a)
pakfire_archive_unref(a);
- if (ctx)
- pakfire_ctx_unref(ctx);
return r;
}
#define PAKFIRE_DIST_H
#include <pakfire/archive.h>
+#include <pakfire/ctx.h>
#include <pakfire/root.h>
#include <pakfire/parser.h>
-int pakfire_dist(pakfire_root* root, const char* path, pakfire_archive** archive);
+int pakfire_dist(pakfire_ctx* ctx, pakfire_root* root,
+ const char* path, pakfire_archive** archive);
-int pakfire_read_makefile(pakfire_parser** parser, pakfire_root* root,
- const char* path, pakfire_parser_error** error);
+int pakfire_read_makefile(pakfire_parser** parser,
+ pakfire_ctx* ctx, pakfire_root* root, const char* path, pakfire_parser_error** error);
#endif /* PAKFIRE_DIST_H */
int r;
// Run dist()
- r = pakfire_dist(self, path, &archive);
+ r = pakfire_dist(self->ctx, self, path, &archive);
if (r < 0)
goto ERROR;
Py_BEGIN_ALLOW_THREADS
- r = pakfire_dist(self->root, path, &archive);
+ r = pakfire_dist(self->ctx->ctx, self->root, path, &archive);
if (r) {
Py_BLOCK_THREADS
PyErr_SetFromErrno(PyExc_OSError);
ASSERT(tmp);
// Attempt to dist the dummy package
- ASSERT_SUCCESS(pakfire_dist(t->root,
+ ASSERT_SUCCESS(pakfire_dist(t->ctx, t->root,
TEST_SRC_PATH "data/packages/dummy/dummy.nm", &archive));
// Extract all package metadata