const char* target, int flags,
pakfire_execute_logging_callback logging_callback, void* data) {
PakfireParser makefile = NULL;
+ char buildroot[PATH_MAX];
struct pakfire_parser_error* error = NULL;
+ int r;
// Check for valid input
if (!path) {
pakfire_repo_unref(repo);
}
+ const char* root = pakfire_get_path(pakfire);
+
+ // Create BUILDROOT
+ pakfire_make_path(pakfire, buildroot, "/tmp/.buildroot.XXXXXX");
+ if (!pakfire_mkdtemp(buildroot))
+ return 1;
+
+ // Make relative BUILDROOT path
+ const char* buildroot_rel = pakfire_path_relpath(root, buildroot);
+ if (!buildroot_rel)
+ return 1;
+
// Read makefile
- int r = pakfire_read_makefile(&makefile, pakfire, path, &error);
+ r = pakfire_read_makefile(&makefile, pakfire, path, &error);
if (r) {
if (error) {
ERROR(pakfire, "Could not parse makefile %s: %s\n", path,
goto ERROR;
}
+ // Set BUILDROOT
+ pakfire_parser_set(makefile, NULL, "BUILDROOT", buildroot_rel);
+
// Run through all build stages
for (const char** stage = stages; *stage; stage++) {
int r = pakfire_build_stage(pakfire, makefile, *stage, logging_callback, data);
if (makefile)
pakfire_parser_unref(makefile);
+ // Remove buildroot
+ pakfire_rmtree(buildroot, 0);
+
return r;
}