From: Michael Tremer Date: Mon, 25 Sep 2023 13:59:01 +0000 (+0000) Subject: libpakfire: Remove the unused copy_in/copy_out functions X-Git-Tag: 0.9.30~1653 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9281a6377330f3cddfb36ec2ffa83dd7062f675c;p=pakfire.git libpakfire: Remove the unused copy_in/copy_out functions Fixes: #12973 Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/pakfire.c b/src/_pakfire/pakfire.c index e17a8d638..6a8dc55bf 100644 --- a/src/_pakfire/pakfire.c +++ b/src/_pakfire/pakfire.c @@ -829,48 +829,6 @@ static PyObject* Pakfire_dist(PakfireObject* self, PyObject* args) { return ret; } -static PyObject* Pakfire_copy_in(PakfireObject* self, PyObject* args) { - const char* src = NULL; - const char* dst = NULL; - - if (!PyArg_ParseTuple(args, "ss", &src, &dst)) - return NULL; - - Py_BEGIN_ALLOW_THREADS - - int r = pakfire_copy_in(self->pakfire, src, dst); - if (r) { - Py_BLOCK_THREADS - PyErr_SetFromErrno(PyExc_OSError); - return NULL; - } - - Py_END_ALLOW_THREADS - - Py_RETURN_NONE; -} - -static PyObject* Pakfire_copy_out(PakfireObject* self, PyObject* args) { - const char* src = NULL; - const char* dst = NULL; - - if (!PyArg_ParseTuple(args, "ss", &src, &dst)) - return NULL; - - Py_BEGIN_ALLOW_THREADS - - int r = pakfire_copy_out(self->pakfire, src, dst); - if (r) { - Py_BLOCK_THREADS - PyErr_SetFromErrno(PyExc_OSError); - return NULL; - } - - Py_END_ALLOW_THREADS - - Py_RETURN_NONE; -} - static PyObject* Pakfire_get_repos(PakfireObject* self) { struct pakfire_repolist* repos = pakfire_get_repos(self->pakfire); if (!repos) { @@ -1253,18 +1211,6 @@ static struct PyMethodDef Pakfire_methods[] = { METH_NOARGS, NULL, }, - { - "copy_in", - (PyCFunction)Pakfire_copy_in, - METH_VARARGS, - NULL, - }, - { - "copy_out", - (PyCFunction)Pakfire_copy_out, - METH_VARARGS, - NULL, - }, { "dist", (PyCFunction)Pakfire_dist, diff --git a/src/libpakfire/include/pakfire/pakfire.h b/src/libpakfire/include/pakfire/pakfire.h index 2084e69c2..8cf822b1c 100644 --- a/src/libpakfire/include/pakfire/pakfire.h +++ b/src/libpakfire/include/pakfire/pakfire.h @@ -65,9 +65,6 @@ int pakfire_refresh(struct pakfire* pakfire, int flags); int pakfire_list_keys(struct pakfire* pakfire, struct pakfire_key*** keys); -int pakfire_copy_in(struct pakfire* pakfire, const char* src, const char* dst); -int pakfire_copy_out(struct pakfire* pakfire, const char* src, const char* dst); - const char* pakfire_get_arch(struct pakfire* pakfire); int pakfire_version_compare(struct pakfire* pakfire, const char* evr1, const char* evr2); diff --git a/src/libpakfire/libpakfire.sym b/src/libpakfire/libpakfire.sym index 26dce9ba5..5c50074f9 100644 --- a/src/libpakfire/libpakfire.sym +++ b/src/libpakfire/libpakfire.sym @@ -23,8 +23,6 @@ global: # pakfire pakfire_check; pakfire_clean; - pakfire_copy_in; - pakfire_copy_out; pakfire_create; pakfire_get_arch; pakfire_get_path; diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index 535b32b11..fb3ca747a 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -1281,115 +1281,6 @@ PAKFIRE_EXPORT int pakfire_refresh(struct pakfire* pakfire, int flags) { return pakfire_repo_walk(pakfire, __pakfire_repo_refresh, &flags); } -enum pakfire_copy_direction { - PAKFIRE_COPY_IN, - PAKFIRE_COPY_OUT, -}; - -static int __pakfire_copy(struct pakfire* pakfire, const char* src, const char* dst, - enum pakfire_copy_direction direction) { - struct archive* reader = NULL; - struct archive* writer = NULL; - struct archive_entry* entry = NULL; - FILE* f = NULL; - int r = 1; - - DEBUG(pakfire, "Copying %s to %s\n", src, dst); - - // Open the source file - f = fopen(src, "r"); - if (!f) { - ERROR(pakfire, "Could not open %s: %m\n", src); - goto ERROR; - } - - // Allocate reader - reader = pakfire_make_archive_disk_reader(pakfire, (direction == PAKFIRE_COPY_OUT)); - if (!reader) - goto ERROR; - - // Allocate writer - writer = pakfire_make_archive_disk_writer(pakfire, (direction == PAKFIRE_COPY_IN)); - if (!writer) - goto ERROR; - - // Create a new entry - entry = archive_entry_new(); - if (!entry) - goto ERROR; - - // Set the source path - archive_entry_copy_sourcepath(entry, src); - - // Set the destination path - archive_entry_set_pathname(entry, dst); - - // Read everything from source file - r = archive_read_disk_entry_from_file(reader, entry, fileno(f), NULL); - if (r) { - ERROR(pakfire, "Could not read from %s: %m\n", src); - goto ERROR; - } - - // Write file to destination - r = archive_write_header(writer, entry); - if (r) { - ERROR(pakfire, "Could not write %s: %m\n", dst); - goto ERROR; - } - - // Copy payload - if (archive_entry_filetype(entry) == AE_IFREG) { - r = pakfire_archive_copy_data_from_file(pakfire, writer, f); - if (r) - goto ERROR; - } - -ERROR: - if (f) - fclose(f); - if (entry) - archive_entry_free(entry); - if (reader) - archive_read_free(reader); - if (writer) - archive_write_free(writer); - - return r; -} - -PAKFIRE_EXPORT int pakfire_copy_in(struct pakfire* pakfire, const char* src, const char* dst) { - char path[PATH_MAX]; - int r; - - if (pakfire_on_root(pakfire)) { - errno = ENOTSUP; - return 1; - } - - r = pakfire_path(pakfire, path, "%s", dst); - if (r) - return r; - - return __pakfire_copy(pakfire, src, path, PAKFIRE_COPY_IN); -} - -PAKFIRE_EXPORT int pakfire_copy_out(struct pakfire* pakfire, const char* src, const char* dst) { - char path[PATH_MAX]; - int r; - - if (pakfire_on_root(pakfire)) { - errno = ENOTSUP; - return 1; - } - - r = pakfire_path(pakfire, path, "%s", src); - if (r) - return r; - - return __pakfire_copy(pakfire, path, dst, PAKFIRE_COPY_OUT); -} - PAKFIRE_EXPORT const char* pakfire_get_arch(struct pakfire* pakfire) { return pakfire->arches.nominal; }