}
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) {
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
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);
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;
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)