]> git.ipfire.org Git - pakfire.git/commitdiff
build: Use CWD if no local repository could be found
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 22 Jun 2021 13:49:56 +0000 (13:49 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 22 Jun 2021 13:49:56 +0000 (13:49 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/build.c

index df08545b7bb1f8f2aac2166c6880f5071b959637..1ddff8a215ba24d93697ec5dbd257053bff92d1f 100644 (file)
@@ -22,6 +22,7 @@
 #include <glob.h>
 #include <stdlib.h>
 #include <sys/mount.h>
+#include <unistd.h>
 
 #include <pakfire/build.h>
 #include <pakfire/execute.h>
@@ -844,6 +845,7 @@ 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 cwd[PATH_MAX];
        char* generated_id = NULL;
        glob_t buffer;
        int r = 1;
@@ -857,13 +859,14 @@ PAKFIRE_EXPORT int pakfire_build(Pakfire pakfire, const char* path,
        // The default target is the local repository path
        if (!target) {
                PakfireRepo repo = pakfire_get_repo(pakfire, "@local");
-               if (!repo) {
-                       errno = EINVAL;
-                       return 1;
-               }
+               if (repo) {
+                       target = pakfire_repo_get_path(repo);
+                       pakfire_repo_unref(repo);
 
-               target = pakfire_repo_get_path(repo);
-               pakfire_repo_unref(repo);
+               // If the repository could not be found, just write to the cwd
+               } else {
+                       target = getcwd(cwd, sizeof(cwd));
+               }
        }
 
        // If no build ID was passed, we generate a random one