From: Michael Tremer Date: Wed, 3 Aug 2022 09:35:41 +0000 (+0000) Subject: execute: Drop unused pakfire_execute_script function X-Git-Tag: 0.9.28~602 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ec490b0b5c8b9d86e7894edbdf0a752ba5fdc01;p=pakfire.git execute: Drop unused pakfire_execute_script function Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/execute.c b/src/libpakfire/execute.c index 531d1a51f..1619248f0 100644 --- a/src/libpakfire/execute.c +++ b/src/libpakfire/execute.c @@ -131,88 +131,6 @@ ERROR: return r; } -PAKFIRE_EXPORT int pakfire_execute_script(struct pakfire* pakfire, const char* script, const size_t size, - 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; - - // Write the scriptlet to disk - r = pakfire_path_join(path, root, "pakfire-script.XXXXXX"); - if (r < 0) - goto out; - - // Open a temporary file - int fd = mkstemp(path); - if (fd < 0) { - ERROR(pakfire, "Could not open a temporary file: %m\n"); - r = errno; - } - - DEBUG(pakfire, "Writing script to %s:\n%.*s\n", path, (int)size, script); - - // Write data - ssize_t bytes_written = write(fd, script, size); - if (bytes_written < (ssize_t)size) { - ERROR(pakfire, "Could not write script to file %s: %m\n", path); - r = errno; - goto out; - } - - // Make the script executable - r = fchmod(fd, S_IRUSR|S_IWUSR|S_IXUSR); - if (r) { - ERROR(pakfire, "Could not set executable permissions on %s: %m\n", path); - r = errno; - goto out; - } - - // Close file - r = close(fd); - if (r) { - ERROR(pakfire, "Could not close script file %s: %m\n", path); - r = errno; - goto out; - } - - // 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: %m\n"); - 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(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); - - return r; -} - int pakfire_execute_shell(struct pakfire* pakfire) { const char* argv[] = { "/bin/bash", "--login", NULL, diff --git a/src/libpakfire/include/pakfire/execute.h b/src/libpakfire/include/pakfire/execute.h index 0fbf80e27..58d585251 100644 --- a/src/libpakfire/include/pakfire/execute.h +++ b/src/libpakfire/include/pakfire/execute.h @@ -28,8 +28,6 @@ typedef int (*pakfire_execute_logging_callback)(struct pakfire* pakfire, void* d int pakfire_execute(struct pakfire* pakfire, const char* argv[], char* envp[], int flags, pakfire_execute_logging_callback logging_callback, void* data); -int pakfire_execute_script(struct pakfire* pakfire, const char* script, const size_t size, - const char* args[], char* envp[], int flags, pakfire_execute_logging_callback logging_callback, void* data); enum { PAKFIRE_EXECUTE_NONE = 0, diff --git a/src/libpakfire/libpakfire.sym b/src/libpakfire/libpakfire.sym index 19207afd4..2efa4df10 100644 --- a/src/libpakfire/libpakfire.sym +++ b/src/libpakfire/libpakfire.sym @@ -29,7 +29,6 @@ global: pakfire_create; pakfire_erase; pakfire_execute; - pakfire_execute_script; pakfire_get_arch; pakfire_get_path; pakfire_get_repo;