]> git.ipfire.org Git - people/stevee/pakfire.git/commitdiff
execute: Drop unused pakfire_execute_script function
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 3 Aug 2022 09:35:41 +0000 (09:35 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 3 Aug 2022 09:35:41 +0000 (09:35 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/execute.c
src/libpakfire/include/pakfire/execute.h
src/libpakfire/libpakfire.sym

index 531d1a51f135f8d28b561698b189b005428ca63d..1619248f0180e5569fb5f5c7a4728eaeae2e4611 100644 (file)
@@ -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,
index 0fbf80e2742795acdccf4a30595d2b8d0b3c2549..58d585251226ec4d917d3713062002d1b4884f31 100644 (file)
@@ -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,
index 19207afd49cab89c28c6ce84054f2cbcabbff90f..2efa4df105c599a4f587e2a0af53fe3cf5a673cb 100644 (file)
@@ -29,7 +29,6 @@ global:
        pakfire_create;
        pakfire_erase;
        pakfire_execute;
-       pakfire_execute_script;
        pakfire_get_arch;
        pakfire_get_path;
        pakfire_get_repo;