From: Michael Tremer Date: Wed, 17 Aug 2022 21:34:25 +0000 (+0000) Subject: build: Actually perform the build again X-Git-Tag: 0.9.28~458 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=03dc1d52bc39d1f4264a4c95e1714b4c2e4f246e;p=pakfire.git build: Actually perform the build again Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/build.c b/src/libpakfire/build.c index b17afe003..c30ee1208 100644 --- a/src/libpakfire/build.c +++ b/src/libpakfire/build.c @@ -630,10 +630,12 @@ ERROR: } static int pakfire_build_packages(struct pakfire_build* build, - struct pakfire_parser* makefile, const char* buildroot) { + struct pakfire_parser* makefile) { DEBUG(build->pakfire, "Creating packages..."); int r = 1; + const char* buildroot = pakfire_relpath(build->pakfire, build->buildroot); + // Fetch a list all all packages char** packages = pakfire_parser_list_namespaces(makefile, "packages.package:*"); if (!packages) { @@ -730,8 +732,10 @@ static const char* post_build_scripts[] = { NULL, }; -static int pakfire_build_run_post_build_scripts( - struct pakfire_build* build, const char* buildroot) { +static int pakfire_build_run_post_build_scripts(struct pakfire_build* build) { + // Fetch buildroot + const char* buildroot = pakfire_relpath(build->pakfire, build->buildroot); + // Set default arguments for build scripts const char* args[] = { buildroot, NULL @@ -747,75 +751,6 @@ static int pakfire_build_run_post_build_scripts( return 0; } -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(build->pakfire); - - // Create BUILDROOT - pakfire_make_path(build->pakfire, buildroot, "/tmp/.buildroot.XXXXXX"); - if (!pakfire_mkdtemp(buildroot)) - goto ERROR; - - // Make relative BUILDROOT path - const char* buildroot_rel = pakfire_path_relpath(root, buildroot); - if (!buildroot_rel) - goto ERROR; - - // Read makefile - r = pakfire_read_makefile(&makefile, build->pakfire, path, &error); - if (r) { - if (error) { - ERROR(build->pakfire, "Could not parse makefile %s: %s\n", path, - pakfire_parser_error_get_message(error)); - pakfire_parser_error_unref(error); - } else { - ERROR(build->pakfire, "Could not parse makefile %s: %m\n", path); - } - - goto ERROR; - } - - // Set BUILDROOT - pakfire_parser_set(makefile, NULL, "BUILDROOT", buildroot_rel, 0); - - // Run through all build stages - for (const char** stage = stages; *stage; stage++) { - r = pakfire_build_stage(build, makefile, *stage); - if (r) { - // Drop to a shell for debugging - if (pakfire_has_flag(build->pakfire, PAKFIRE_BUILD_INTERACTIVE)) - pakfire_build_shell(build); - - goto ERROR; - } - } - - // Run post build scripts - r = pakfire_build_run_post_build_scripts(build, buildroot_rel); - if (r) - goto ERROR; - - // Create the packages - r = pakfire_build_packages(build, makefile, buildroot_rel); - if (r) { - ERROR(build->pakfire, "Could not create packages: %m\n"); - goto ERROR; - } - -ERROR: - if (makefile) - pakfire_parser_unref(makefile); - - // Remove buildroot - pakfire_rmtree(buildroot, 0); - - return r; -} - static void pakfire_build_free(struct pakfire_build* build) { if (build->repo) pakfire_repo_unref(build->repo); @@ -1260,6 +1195,26 @@ ERROR: return r; } +static int pakfire_build_perform(struct pakfire_build* build, + struct pakfire_parser* makefile) { + int r; + + // Run through all build stages + for (const char** stage = stages; *stage; stage++) { + r = pakfire_build_stage(build, makefile, *stage); + if (r) { + // Drop to a shell for debugging + if (pakfire_has_flag(build->pakfire, PAKFIRE_BUILD_INTERACTIVE)) + pakfire_build_shell(build); + + return r; + } + } + + // Run post build scripts + return pakfire_build_run_post_build_scripts(build); +} + PAKFIRE_EXPORT int pakfire_build_exec(struct pakfire_build* build, const char* path) { struct pakfire_archive* archive = NULL; struct pakfire_package* package = NULL; @@ -1317,14 +1272,17 @@ PAKFIRE_EXPORT int pakfire_build_exec(struct pakfire_build* build, const char* p if (r) goto ERROR; -#if 0 - // Run build - r = pakfire_build_makefile(build, makefile); + // Perform the actual build + r = pakfire_build_perform(build, makefile); + if (r) + goto ERROR; + + // Create the packages + r = pakfire_build_packages(build, makefile); if (r) { - ERROR(build->pakfire, "Could not build %s: %m\n", nevra); + ERROR(build->pakfire, "Could not create packages: %m\n"); goto ERROR; } -#endif ERROR: if (makefile)