Pakfire_execute_logging_callback = logging_callback;
// Execute script
- int r = pakfire_execute_script(self->pakfire, script, strlen(script), envp, flags,
+ int r = pakfire_execute_script(self->pakfire, script, strlen(script), NULL, envp, flags,
(logging_callback) ? __Pakfire_execute_logging_callback : NULL, NULL);
// Cleanup
"\n" \
"exit 0\n"
-static int pakfire_build_run_script(Pakfire pakfire, const char* filename,
+static int pakfire_build_run_script(Pakfire pakfire, const char* filename, const char* args[],
pakfire_execute_logging_callback logging_callback, void* data) {
char* script = NULL;
size_t size = 0;
}
// Execute it
- r = pakfire_execute_script(pakfire, script, size, NULL, 0, logging_callback, data);
+ r = pakfire_execute_script(pakfire, script, size, args, NULL, 0, logging_callback, data);
if (r) {
ERROR(pakfire, "Script '%s' failed with status %d\n", filename, r);
}
INFO(pakfire, "Running build stage '%s'\n", stage);
- r = pakfire_execute_script(pakfire, script, strlen(script), NULL, 0,
+ r = pakfire_execute_script(pakfire, script, strlen(script), NULL, NULL, 0,
logging_callback, data);
if (r) {
ERROR(pakfire, "Build stage '%s' failed with status %d\n", stage, r);
}
// Remove static libraries
- r = pakfire_build_run_script(pakfire, "compress-man-pages", logging_callback, data);
+ r = pakfire_build_run_script(pakfire, "compress-man-pages", NULL, logging_callback, data);
if (r)
goto ERROR;
}
PAKFIRE_EXPORT int pakfire_execute_script(Pakfire pakfire, const char* script, const size_t size,
- char* envp[], int flags, pakfire_execute_logging_callback logging_callback, void* data) {
+ const char* args[], char* envp[], int flags, pakfire_execute_logging_callback logging_callback, void* data) {
const char* root = pakfire_get_path(pakfire);
-
+ const char** argv = NULL;
char path[PATH_MAX];
int r;
goto out;
}
- const char* command = path;
- if (root)
- command = pakfire_path_relpath(root, path);
+ // Count how many arguments were passed
+ unsigned int argc = 1;
+ if (args) {
+ for (const char** arg = args; *arg; arg++)
+ argc++;
+ }
+
+ argv = calloc(argc + 1, sizeof(*argv));
+ if (!argv) {
+ ERROR(pakfire, "Could not allocate argv: %s\n", strerror(errno));
+ goto out;
+ }
+
+ // Set command
+ argv[0] = (root) ? pakfire_path_relpath(root, path) : path;
+
+ // Copy args
+ for (unsigned int i = 1; i < argc; i++)
+ argv[i] = args[i-1];
// Run the script
- r = pakfire_execute_command(pakfire, command, envp, flags, logging_callback, data);
+ r = pakfire_execute(pakfire, argv, envp, flags, logging_callback, data);
if (r) {
DEBUG(pakfire, "Script return code: %d\n", r);
}
out:
+ if (argv)
+ free(argv);
+
// Remove script from disk
if (*path)
unlink(path);
int pakfire_execute_command(Pakfire pakfire, const char* command, char* envp[],
int flags, pakfire_execute_logging_callback logging_callback, void* data);
int pakfire_execute_script(Pakfire pakfire, const char* script, const size_t size,
- char* envp[], int flags, pakfire_execute_logging_callback logging_callback, void* data);
+ const char* args[], char* envp[], int flags, pakfire_execute_logging_callback logging_callback, void* data);
enum {
PAKFIRE_EXECUTE_NONE = 0,
// Detect what kind of script this is and run it
if (pakfire_scriptlet_is_shell_script(scriptlet)) {
pakfire_execute_script(transaction->pakfire, scriptlet->data, scriptlet->size,
- NULL, 0, NULL, NULL);
+ NULL, NULL, 0, NULL, NULL);
} else {
ERROR(transaction->pakfire, "Scriptlet is of an unknown kind\n");
}