#############################################################################*/
#include <errno.h>
+#include <glob.h>
#include <stdlib.h>
#include <sys/mount.h>
return 0;
}
-PAKFIRE_EXPORT int pakfire_build(Pakfire pakfire, const char* path,
- const char* target, const char* id, int flags,
- pakfire_execute_logging_callback logging_callback, void* data) {
+static int pakfire_build_makefile(Pakfire pakfire, const char* path, const char* target,
+ const char* id, int flags, pakfire_execute_logging_callback logging_callback, void* data) {
PakfireParser makefile = NULL;
char buildroot[PATH_MAX];
struct pakfire_parser_error* error = NULL;
- char* generated_id = NULL;
- int r;
-
- // Check for valid input
- if (!path) {
- errno = EINVAL;
- return 1;
- }
-
- // The default target is the local repository path
- if (!target) {
- PakfireRepo repo = pakfire_get_repo(pakfire, "local");
- if (!repo) {
- errno = EINVAL;
- return 1;
- }
-
- target = pakfire_repo_get_path(repo);
- pakfire_repo_unref(repo);
- }
-
- const char* packages[] = {
- path, NULL
- };
-
- // Install the package into the build environment
- r = pakfire_install(pakfire, packages, 0, NULL);
- if (r) {
- ERROR(pakfire, "Could not install %s\n", path);
- goto ERROR;
- }
+ int r = 1;
const char* root = pakfire_get_path(pakfire);
goto ERROR;
}
- // If no build ID was passed, we generate a random one
- if (!id) {
- generated_id = pakfire_generate_uuid();
- if (!generated_id)
- goto ERROR;
-
- id = generated_id;
- }
-
// Set BUILDROOT
pakfire_parser_set(makefile, NULL, "BUILDROOT", buildroot_rel, 0);
}
ERROR:
- if (generated_id)
- free(generated_id);
if (makefile)
pakfire_parser_unref(makefile);
return r;
}
+PAKFIRE_EXPORT int pakfire_build(Pakfire pakfire, const char* path,
+ const char* target, const char* id, int flags,
+ pakfire_execute_logging_callback logging_callback, void* data) {
+ char makefiles[PATH_MAX];
+ char* generated_id = NULL;
+ glob_t buffer;
+ int r = 1;
+
+ // Check for valid input
+ if (!path) {
+ errno = EINVAL;
+ return 1;
+ }
+
+ // The default target is the local repository path
+ if (!target) {
+ PakfireRepo repo = pakfire_get_repo(pakfire, "local");
+ if (!repo) {
+ errno = EINVAL;
+ return 1;
+ }
+
+ target = pakfire_repo_get_path(repo);
+ pakfire_repo_unref(repo);
+ }
+
+ // If no build ID was passed, we generate a random one
+ if (!id) {
+ generated_id = pakfire_generate_uuid();
+ if (!generated_id)
+ goto ERROR;
+
+ id = generated_id;
+ }
+
+ const char* packages[] = {
+ path, NULL
+ };
+
+ // Install the package into the build environment
+ r = pakfire_install(pakfire, packages, 0, NULL);
+ if (r) {
+ ERROR(pakfire, "Could not install %s\n", path);
+ goto ERROR;
+ }
+
+ // Where are the makefiles located?
+ r = pakfire_make_path(pakfire, makefiles, "/usr/src/packages/*/*.nm");
+ if (r < 0)
+ goto ERROR;
+
+ // Find all makefiles
+ r = glob(makefiles, 0, NULL, &buffer);
+ if (r) {
+ ERROR(pakfire, "glob() on %s failed: %m\n", makefiles);
+ goto ERROR;
+ }
+
+ // Iterate over all makefiles
+ for (unsigned int i = 0; i < buffer.gl_pathc; i++) {
+ r = pakfire_build_makefile(pakfire, buffer.gl_pathv[i], target, id, flags,
+ logging_callback, data);
+ if (r)
+ goto ERROR;
+ }
+
+ERROR:
+ if (generated_id)
+ free(generated_id);
+ globfree(&buffer);
+
+ return r;
+}
+
PAKFIRE_EXPORT int pakfire_shell(Pakfire pakfire) {
const char* argv[] = {
"/bin/bash", "--login", NULL,