From: Michael Tremer Date: Tue, 2 Aug 2022 18:26:51 +0000 (+0000) Subject: build: Drop separate logging callback X-Git-Tag: 0.9.28~612 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=edcb40730f0ca12f61fb624f303c9427f9c292bd;p=pakfire.git build: Drop separate logging callback Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/pakfire.c b/src/_pakfire/pakfire.c index 134a06e2d..4ed49ffe2 100644 --- a/src/_pakfire/pakfire.c +++ b/src/_pakfire/pakfire.c @@ -1082,30 +1082,17 @@ static PyObject* Pakfire_build(PakfireObject* self, PyObject* args, PyObject* kw char* kwlist[] = { "path", "build_id", - "logging_callback", NULL, }; const char* path = NULL; const char* build_id = NULL; - PyObject* logging_callback = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|zO", kwlist, &path, - &build_id, &logging_callback)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|z", kwlist, &path, &build_id)) return NULL; - // 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, build_id, 0, - (logging_callback) ? __Pakfire_execute_logging_callback : NULL, NULL); + int r = pakfire_build(self->pakfire, path, NULL, build_id, 0); return execute_return_value(r); } diff --git a/src/libpakfire/build.c b/src/libpakfire/build.c index 480a7faa6..6762f8d93 100644 --- a/src/libpakfire/build.c +++ b/src/libpakfire/build.c @@ -581,8 +581,7 @@ ERROR: return r; } -static int pakfire_build_stage(struct pakfire* pakfire, struct pakfire_parser* makefile, const char* stage, - pakfire_execute_logging_callback logging_callback, void* data) { +static int pakfire_build_stage(struct pakfire* pakfire, struct pakfire_parser* makefile, const char* stage) { char template[1024]; // Prepare template for this stage @@ -602,8 +601,7 @@ static int pakfire_build_stage(struct pakfire* pakfire, struct pakfire_parser* m INFO(pakfire, "Running build stage '%s'\n", stage); - r = pakfire_execute_script(pakfire, script, strlen(script), NULL, envp, 0, - logging_callback, data); + r = pakfire_execute_script(pakfire, script, strlen(script), NULL, envp, 0, NULL, NULL); if (r) { ERROR(pakfire, "Build stage '%s' failed with status %d\n", stage, r); } @@ -636,8 +634,7 @@ static const char* post_build_scripts[] = { NULL, }; -static int pakfire_build_run_post_build_scripts(struct pakfire* pakfire, const char* buildroot, - pakfire_execute_logging_callback logging_callback, void* data) { +static int pakfire_build_run_post_build_scripts(struct pakfire* pakfire, const char* buildroot) { // Set default arguments for build scripts const char* args[] = { buildroot, NULL @@ -645,7 +642,7 @@ static int pakfire_build_run_post_build_scripts(struct pakfire* pakfire, const c // Run them one by one for (const char** script = post_build_scripts; *script; script++) { - int r = pakfire_build_run_script(pakfire, *script, args, logging_callback, data); + int r = pakfire_build_run_script(pakfire, *script, args, NULL, NULL); if (r) return r; } @@ -654,8 +651,7 @@ static int pakfire_build_run_post_build_scripts(struct pakfire* pakfire, const c } static int pakfire_build_makefile(struct pakfire* pakfire, const char* path, const char* target, - uuid_t* build_id, int flags, - pakfire_execute_logging_callback logging_callback, void* data) { + uuid_t* build_id, int flags) { struct pakfire_parser* makefile = NULL; char buildroot[PATH_MAX]; struct pakfire_parser_error* error = NULL; @@ -692,7 +688,7 @@ static int pakfire_build_makefile(struct pakfire* pakfire, const char* path, con // Run through all build stages for (const char** stage = stages; *stage; stage++) { - r = pakfire_build_stage(pakfire, makefile, *stage, logging_callback, data); + r = pakfire_build_stage(pakfire, makefile, *stage); if (r) { // Drop to a shell for debugging if (pakfire_has_flag(pakfire, PAKFIRE_FLAGS_INTERACTIVE)) @@ -703,7 +699,7 @@ static int pakfire_build_makefile(struct pakfire* pakfire, const char* path, con } // Run post build scripts - r = pakfire_build_run_post_build_scripts(pakfire, buildroot_rel, logging_callback, data); + r = pakfire_build_run_post_build_scripts(pakfire, buildroot_rel); if (r) goto ERROR; @@ -725,8 +721,7 @@ ERROR: } PAKFIRE_EXPORT int pakfire_build(struct pakfire* pakfire, const char* path, - const char* target, const char* id, int flags, - pakfire_execute_logging_callback logging_callback, void* data) { + const char* target, const char* id, int flags) { char makefiles[PATH_MAX]; char cwd[PATH_MAX]; uuid_t build_id; @@ -799,8 +794,7 @@ PAKFIRE_EXPORT int pakfire_build(struct pakfire* pakfire, const char* path, // Iterate over all makefiles for (unsigned int i = 0; i < buffer.gl_pathc; i++) { - r = pakfire_build_makefile(pakfire, buffer.gl_pathv[i], target, &build_id, flags, - logging_callback, data); + r = pakfire_build_makefile(pakfire, buffer.gl_pathv[i], target, &build_id, flags); if (r) { ERROR(pakfire, "Could not build %s: %m\n", buffer.gl_pathv[i]); globfree(&buffer); diff --git a/src/libpakfire/include/pakfire/build.h b/src/libpakfire/include/pakfire/build.h index 63018d5d1..1cfc425c1 100644 --- a/src/libpakfire/include/pakfire/build.h +++ b/src/libpakfire/include/pakfire/build.h @@ -25,7 +25,7 @@ #include int pakfire_build(struct pakfire* pakfire, const char* path, const char* target, - const char* id, int flags, pakfire_execute_logging_callback logging_callback, void* data); + const char* id, int flags); int pakfire_shell(struct pakfire* pakfire, const char** packages); int pakfire_build_clean(struct pakfire* pakfire, int flags);