From: Michael Tremer Date: Tue, 18 May 2021 15:36:08 +0000 (+0000) Subject: arch: Internalize function to check if the host is compatible X-Git-Tag: 0.9.28~1285^2~128 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42bc4a4c71271de233ad118e5b3f320dfed6b3fd;p=pakfire.git arch: Internalize function to check if the host is compatible Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/_pakfiremodule.c b/src/_pakfire/_pakfiremodule.c index 557348549..ca1dd09f1 100644 --- a/src/_pakfire/_pakfiremodule.c +++ b/src/_pakfire/_pakfiremodule.c @@ -45,22 +45,9 @@ static PyObject* _pakfire_native_arch() { return PyUnicode_FromString(arch); } -static PyObject* _pakfire_arch_supported_by_host(PyObject* self, PyObject* args) { - const char* name = NULL; - - if (!PyArg_ParseTuple(args, "s", &name)) - return NULL; - - if (pakfire_arch_supported_by_host(name)) - Py_RETURN_TRUE; - - Py_RETURN_FALSE; -} - static PyMethodDef pakfireModuleMethods[] = { {"performance_index", (PyCFunction)performance_index, METH_VARARGS, NULL}, {"native_arch", (PyCFunction)_pakfire_native_arch, METH_NOARGS, NULL }, - {"arch_supported_by_host", (PyCFunction)_pakfire_arch_supported_by_host, METH_VARARGS, NULL }, { NULL, NULL, 0, NULL } }; diff --git a/src/libpakfire/arch.c b/src/libpakfire/arch.c index 39a522590..689adc99b 100644 --- a/src/libpakfire/arch.c +++ b/src/libpakfire/arch.c @@ -227,7 +227,7 @@ int pakfire_arch_is_compatible(const char* name, const char* compatible_arch) { return 0; } -PAKFIRE_EXPORT int pakfire_arch_supported_by_host(const char* name) { +static int pakfire_arch_supported_by_host(const char* name) { const char* native_arch = pakfire_arch_native(); // Check if those two architectures are compatible @@ -285,6 +285,11 @@ static char* find_interpreter(const char* path, const char* magic) { } char* pakfire_arch_find_interpreter(const char* name) { + // If the host supports this architecture natively, + // we do not need to search for the interpreter + if (pakfire_arch_supported_by_host(name)) + return NULL; + const struct pakfire_arch* arch = pakfire_arch_find(name); if (!arch) return NULL; diff --git a/src/libpakfire/include/pakfire/arch.h b/src/libpakfire/include/pakfire/arch.h index 3f93af298..a4c0c9786 100644 --- a/src/libpakfire/include/pakfire/arch.h +++ b/src/libpakfire/include/pakfire/arch.h @@ -23,7 +23,6 @@ int pakfire_arch_supported(const char* name); const char* pakfire_arch_native(); -int pakfire_arch_supported_by_host(const char* name); #ifdef PAKFIRE_PRIVATE diff --git a/src/libpakfire/libpakfire.sym b/src/libpakfire/libpakfire.sym index 821addf9f..1f07ba1fa 100644 --- a/src/libpakfire/libpakfire.sym +++ b/src/libpakfire/libpakfire.sym @@ -51,7 +51,6 @@ global: # arch pakfire_arch_native; pakfire_arch_supported; - pakfire_arch_supported_by_host; # archive pakfire_archive_count_signatures;