]> git.ipfire.org Git - pakfire.git/commitdiff
build: Pass context to pakfire_build_makefile
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 8 Aug 2022 16:48:43 +0000 (16:48 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 8 Aug 2022 16:48:43 +0000 (16:48 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/build.c

index f765a80569cde5ba949970a1b42fd333c3c8b442..bb406e46c5282d5a611384a1e13d5890f8865564 100644 (file)
@@ -714,17 +714,16 @@ static int pakfire_build_run_post_build_scripts(struct pakfire* pakfire, const c
        return 0;
 }
 
-static int pakfire_build_makefile(struct pakfire* pakfire, const char* path, const char* target,
-               uuid_t* build_id, int flags) {
+static int pakfire_build_makefile(struct pakfire_build* build, const char* path) {
        struct pakfire_parser* makefile = NULL;
        char buildroot[PATH_MAX];
        struct pakfire_parser_error* error = NULL;
        int r = 1;
 
-       const char* root = pakfire_get_path(pakfire);
+       const char* root = pakfire_get_path(build->pakfire);
 
        // Create BUILDROOT
-       pakfire_make_path(pakfire, buildroot, "/tmp/.buildroot.XXXXXX");
+       pakfire_make_path(build->pakfire, buildroot, "/tmp/.buildroot.XXXXXX");
        if (!pakfire_mkdtemp(buildroot))
                goto ERROR;
 
@@ -734,14 +733,14 @@ static int pakfire_build_makefile(struct pakfire* pakfire, const char* path, con
                goto ERROR;
 
        // Read makefile
-       r = pakfire_read_makefile(&makefile, pakfire, path, &error);
+       r = pakfire_read_makefile(&makefile, build->pakfire, path, &error);
        if (r) {
                if (error) {
-                       ERROR(pakfire, "Could not parse makefile %s: %s\n", path,
+                       ERROR(build->pakfire, "Could not parse makefile %s: %s\n", path,
                                pakfire_parser_error_get_message(error));
                        pakfire_parser_error_unref(error);
                } else {
-                       ERROR(pakfire, "Could not parse makefile %s: %m\n", path);
+                       ERROR(build->pakfire, "Could not parse makefile %s: %m\n", path);
                }
 
                goto ERROR;
@@ -752,25 +751,26 @@ 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);
+               r = pakfire_build_stage(build->pakfire, makefile, *stage);
                if (r) {
                        // Drop to a shell for debugging
-                       if (pakfire_has_flag(pakfire, PAKFIRE_FLAGS_INTERACTIVE))
-                               pakfire_jail_shell(pakfire);
+                       if (pakfire_has_flag(build->pakfire, PAKFIRE_FLAGS_INTERACTIVE))
+                               pakfire_jail_shell(build->pakfire);
 
                        goto ERROR;
                }
        }
 
        // Run post build scripts
-       r = pakfire_build_run_post_build_scripts(pakfire, buildroot_rel);
+       r = pakfire_build_run_post_build_scripts(build->pakfire, buildroot_rel);
        if (r)
                goto ERROR;
 
        // Create the packages
-       r = pakfire_build_packages(pakfire, makefile, build_id, buildroot_rel, target);
+       r = pakfire_build_packages(build->pakfire, makefile, &build->id,
+                       buildroot_rel, build->target);
        if (r) {
-               ERROR(pakfire, "Could not create packages: %m\n");
+               ERROR(build->pakfire, "Could not create packages: %m\n");
                goto ERROR;
        }
 
@@ -1018,8 +1018,7 @@ PAKFIRE_EXPORT int pakfire_build_exec(struct pakfire_build* build, const char* p
        }
 
        // Run build
-       r = pakfire_build_makefile(build->pakfire, makefile, build->target,
-               &build->id, build->flags);
+       r = pakfire_build_makefile(build, makefile);
        if (r) {
                ERROR(build->pakfire, "Could not build %s: %m\n", nevra);
                goto ERROR;