}
static PyObject* Pakfire_build(PakfireObject* self, PyObject* args, PyObject* kwargs) {
- char* kwlist[] = {"path", "interactive", NULL};
+ char* kwlist[] = {"path", "logging_callback", "interactive", NULL};
const char* path = NULL;
+ PyObject* logging_callback = NULL;
int interactive = 0;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|p", kwlist, &path, &interactive))
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|Op", kwlist, &path,
+ &logging_callback, &interactive))
return NULL;
int flags = 0;
if (interactive)
flags |= PAKFIRE_BUILD_INTERACTIVE;
+ // Check if logging_callback is
+ if (logging_callback && !PyCallable_Check(logging_callback)) {
+ PyErr_SetString(PyExc_TypeError, "logging_callback must be callable\n");
+ return NULL;
+ }
+
+ // Set logging callback
+ Pakfire_execute_logging_callback = logging_callback;
+
// Run build
- int r = pakfire_build(self->pakfire, path, NULL, flags);
+ int r = pakfire_build(self->pakfire, path, NULL, flags,
+ (logging_callback) ? __Pakfire_execute_logging_callback : NULL, NULL);
return execute_return_value(r);
}
"\n" \
"exit 0\n"
-static int pakfire_build_stage(Pakfire pakfire, PakfireParser makefile, const char* stage) {
+static int pakfire_build_stage(Pakfire pakfire, PakfireParser makefile, const char* stage,
+ pakfire_execute_logging_callback logging_callback, void* data) {
char template[1024];
// Prepare template for this stage
INFO(pakfire, "Running build stage '%s'\n", stage);
- r = pakfire_execute_script(pakfire, script, strlen(script), NULL, 0, NULL, NULL);
+ r = pakfire_execute_script(pakfire, script, strlen(script), NULL, 0,
+ logging_callback, data);
if (r) {
ERROR(pakfire, "Build stage '%s' failed with status %d\n", stage, r);
}
}
PAKFIRE_EXPORT int pakfire_build(Pakfire pakfire, const char* path,
- const char* target, int flags) {
+ const char* target, int flags,
+ pakfire_execute_logging_callback logging_callback, void* data) {
PakfireParser makefile = NULL;
struct pakfire_parser_error* error = NULL;
// Run through all build stages
for (const char** stage = stages; *stage; stage++) {
- int r = pakfire_build_stage(pakfire, makefile, *stage);
+ int r = pakfire_build_stage(pakfire, makefile, *stage, logging_callback, data);
if (r) {
// Drop to a shell for debugging
if (flags & PAKFIRE_BUILD_INTERACTIVE)
#ifndef PAKFIRE_BUILD_H
#define PAKFIRE_BUILD_H
+#include <pakfire/execute.h>
#include <pakfire/types.h>
enum pakfire_build_flags {
PAKFIRE_BUILD_INTERACTIVE = (1 << 0),
};
-int pakfire_build(Pakfire pakfire, const char* path, const char* target, int flags);
+int pakfire_build(Pakfire pakfire, const char* path, const char* target, int flags,
+ pakfire_execute_logging_callback logging_callback, void* data);
int pakfire_shell(Pakfire pakfire);
#endif /* PAKFIRE_BUILD_H */
self._install([path])
for makefile in glob.glob("%s/usr/src/packages/*/*.nm" % self.pakfire.path):
- self.pakfire.build(makefile, interactive=shell)
+ self.pakfire.build(makefile, logging_callback=self.log.log, interactive=shell)
def shell(self, packages=[], install=None):
# Setup the environment