static int pakfire_build_add_scriptlet_requires(struct pakfire_build* build,
struct pakfire_package* pkg, struct pakfire_scriptlet* scriptlet) {
- struct pakfire_pty_buffer buffer = {};
+ struct pakfire_input_buffer buffer = {};
int r;
struct pakfire_find_deps_ctx ctx = {
};
return pakfire_jail_communicate(build->jail, argv, NULL, 0,
- pakfire_pty_send_buffer, &buffer, pakfire_build_process_scriptlet_dep, &ctx);
+ pakfire_jail_send_buffer, &buffer, pakfire_build_process_scriptlet_dep, &ctx);
}
static int pakfire_build_package_add_scriptlet(struct pakfire_build* build,
return pakfire_jail_run_if_possible(pakfire, argv);
}
+
+ssize_t pakfire_jail_send_buffer(struct pakfire_ctx* ctx,
+ void* data, char* buffer, size_t length) {
+ struct pakfire_input_buffer* input = data;
+
+ // Check input
+ if (!input)
+ return -EINVAL;
+
+ // If there is nothing left to send we are done
+ if (!input->length)
+ return 0;
+
+ // Cap length if we have less data to send
+ if (input->length < length)
+ length = input->length;
+
+ // Copy the data
+ memcpy(buffer, input->data, length);
+
+ // Advance the buffer
+ input->data += length;
+ input->length -= length;
+
+ return length;
+}
int pakfire_jail_ldconfig(struct pakfire* pakfire);
int pakfire_jail_run_systemd_tmpfiles(struct pakfire* pakfire);
+// Streaming functions
+struct pakfire_input_buffer {
+ const char* data;
+ size_t length;
+};
+
+ssize_t pakfire_jail_send_buffer(struct pakfire_ctx* ctx,
+ void* data, char* buffer, size_t length);
+
#endif /* PAKFIRE_JAIL_H */
return 0;
}
-ssize_t pakfire_pty_send_buffer(struct pakfire_ctx* ctx,
- void* data, char* buffer, size_t length) {
- struct pakfire_pty_buffer* input = data;
-
- // Check input
- if (!input)
- return -EINVAL;
-
- // If there is nothing left to send we are done
- if (!input->length)
- return 0;
-
- // Cap length if we have less data to send
- if (input->length < length)
- length = input->length;
-
- // Copy the data
- memcpy(buffer, input->data, length);
-
- // Advance the buffer
- input->data += length;
- input->length -= length;
-
- return length;
-}
-
ssize_t pakfire_pty_send_filelist(struct pakfire_ctx* ctx,
void* data, char* buffer, size_t length) {
struct pakfire_pty_filelist* input = data;
int pakfire_pty_open(struct pakfire_pty* pty);
-typedef int (*pakfire_pty_stdout_callback)(
- struct pakfire_ctx* ctx, void* data, const char* line, const size_t length);
-
-struct pakfire_pty_buffer {
- const char* data;
- size_t length;
-};
-
-ssize_t pakfire_pty_send_buffer(struct pakfire_ctx* ctx,
- void* data, char* buffer, size_t length);
-
// Stream a filelist
struct pakfire_pty_filelist {
#include <pakfire/mount.h>
#include <pakfire/packagelist.h>
#include <pakfire/pakfire.h>
-#include <pakfire/pty.h>
#include <pakfire/key.h>
#include <pakfire/repo.h>
#include <pakfire/repolist.h>
}
static PyObject* Pakfire_execute(PakfireObject* self, PyObject* args, PyObject* kwargs) {
- struct pakfire_pty_buffer input = {};
+ struct pakfire_input_buffer input = {};
struct pakfire_jail* jail = NULL;
struct pakfire_env* env = NULL;
const char** argv = NULL;
// Register the input callback
if (input.data)
- input_callback = pakfire_pty_send_buffer;
+ input_callback = pakfire_jail_send_buffer;
// Create a new jail
r = pakfire_jail_create(&jail, self->pakfire);