struct pakfire_package* pkg;
int dep;
struct pakfire_filelist* filelist;
+ struct pakfire_scriptlet* scriptlet;
const char* pattern;
};
return r;
}
-static int pakfire_build_add_scriptlet_requires(struct pakfire_build* build,
- struct pakfire_package* pkg, struct pakfire_scriptlet* scriptlet) {
- char* prerequires = NULL;
- char path[PATH_MAX];
- size_t size;
- int r;
-
- const char* root = pakfire_get_path(build->pakfire);
-
- // Make filename
- r = pakfire_path(build->pakfire, path, "%s",
- PAKFIRE_TMP_DIR "/pakfire-scriptlet.XXXXXX");
- if (r)
- return r;
-
- // Fetch scriptlet payload
- const char* data = pakfire_scriptlet_get_data(scriptlet, &size);
+static int pakfire_build_send_scriptlet(struct pakfire* pakfire, void* data, int fd) {
+ const struct pakfire_find_deps_ctx* ctx = (struct pakfire_find_deps_ctx*)data;
+ size_t length = 0;
- // Create a temporary file
- FILE* f = pakfire_mktemp(path, 0);
- if (!f)
+ // Fetch the scriptlet
+ const char* p = pakfire_scriptlet_get_data(ctx->scriptlet, &length);
+ if (!p) {
+ ERROR(pakfire, "Could not fetch scriptlet: %m\n");
return 1;
+ }
- // Write scriptlet
- ssize_t bytes_written = fwrite(data, 1, size, f);
+ // Write it into the pipe
+ ssize_t bytes_written = write(fd, p, length);
if (bytes_written < 0) {
- ERROR(build->pakfire, "Could not write to %s: %m\n", path);
- fclose(f);
- goto ERROR;
+ ERROR(pakfire, "Could not send scriptlet: %m\n");
+ return 1;
}
- // Close file
- fclose(f);
+ return 0;
+}
- // Build commandline
- const char* args[] = {
- pakfire_path_relpath(root, path),
- NULL,
+static int pakfire_build_add_scriptlet_requires(struct pakfire_build* build,
+ struct pakfire_package* pkg, struct pakfire_scriptlet* scriptlet) {
+ int r;
+
+ struct pakfire_find_deps_ctx ctx = {
+ .pkg = pkg,
+ .dep = PAKFIRE_PKG_PREREQUIRES,
+ .scriptlet = scriptlet,
};
// Find all pre-requires
- r = pakfire_build_run_script(build, "find-prerequires", args, &prerequires);
+ r = pakfire_build_run_script(build, "find-prerequires", NULL,
+ pakfire_build_send_scriptlet, pakfire_build_process_deps, &ctx);
if (r)
goto ERROR;
- // Add all pre-requires to the package
- if (prerequires) {
- r = pakfire_str2deps(build->pakfire, pkg, PAKFIRE_PKG_PREREQUIRES, prerequires);
- if (r) {
- ERROR(build->pakfire, "Could not add pre-requires: %m\n");
- goto ERROR;
- }
- }
-
ERROR:
- if (r && *path)
- unlink(path);
- if (prerequires)
- free(prerequires);
return r;
}