diff options
Diffstat (limited to 'snag/src/build_db.c')
| -rw-r--r-- | snag/src/build_db.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/snag/src/build_db.c b/snag/src/build_db.c index 778ebd5..83bf6d9 100644 --- a/snag/src/build_db.c +++ b/snag/src/build_db.c @@ -1,7 +1,8 @@ #include "build_db.h" -#include "source_db.h" +#include "cfg.h" #include "util.h" +#include "source_db.h" #include <poll.h> #include <stdint.h> @@ -14,11 +15,6 @@ #include <sys/stat.h> #include <errno.h> -const char build_db_path[] = "./var/snag/builds"; -const size_t build_db_path_len = strlen(build_db_path); - -#define PKG_BUILD_CMD "./scripts/run_pkg_build.sh" - #define API_MESSAGE_NONE 0 #define API_MESSAGE_FINISHED 1 #define API_MESSAGE_TEST 2 @@ -38,15 +34,15 @@ bool package_setup_build(const package_info_t* info, package_build_t* build) { // create build info memset(build, 0, sizeof(*build)); build->package = info; - build->directory = vastrcat(build_db_path, "/", info->attrs.id, "-", timestamp_str); + build->directory = vastrcat(cfg.build_db, "/", info->attrs.id, "-", timestamp_str); // create build directory if (mkdir(build->directory, 0777) == -1) die("failed to create build directory: %s", strerror(errno)); // (re)create symlink to build directory - char* symlink_name = vastrcat(build_db_path, "/", info->attrs.id); + char* symlink_name = vastrcat(cfg.build_db, "/", info->attrs.id); if (unlink(symlink_name) == -1 && errno != ENOENT) die("failed to remove build symlink '%s': %s", symlink_name, strerror(errno)); - if (symlink(build->directory + build_db_path_len + 1, symlink_name) == -1) die("failed to create build symlink '%s': %s", symlink_name, strerror(errno)); + if (symlink(build->directory + cfg.build_db_len + 1, symlink_name) == -1) die("failed to create build symlink '%s': %s", symlink_name, strerror(errno)); free(symlink_name); // unpack package source (eventually this will be done by swenu api) @@ -87,11 +83,11 @@ void build_run(const package_build_t* build) { char buf2[1024]; snprintf(buf2, sizeof(buf2), "%d", api_to_sh[0]); // exec into install script - char* argv[] = { PKG_BUILD_CMD, buf1, buf2, build->package->script_path, NULL }; - char* envp[] = { NULL }; - execve(PKG_BUILD_CMD, argv, envp); + chdir(build->source_directory); + char* argv[] = { cfg.build_package_script, buf1, buf2, build->package->script_path, NULL }; + execv(cfg.build_package_script, argv); // what are you still doing here? - die("CHILD - execve to %s failed: %s", PKG_BUILD_CMD, strerror(errno)); + die("CHILD - execve to %s failed: %s", cfg.build_package_script, strerror(errno)); } else { // parent proc, close write end of pipe close(child_output[1]); |
