diff --git a/SOURCES/disable_loading_dmidecodemodule_on_non_x86_64.patch b/SOURCES/disable_loading_dmidecodemodule_on_non_x86_64.patch new file mode 100644 index 0000000..b78d5c4 --- /dev/null +++ b/SOURCES/disable_loading_dmidecodemodule_on_non_x86_64.patch @@ -0,0 +1,93 @@ +diff --git a/src/dmidecodemodule.c b/src/dmidecodemodule.c +index 1056a8fe9422..a4500bdd81ac 100644 +--- a/src/dmidecodemodule.c ++++ b/src/dmidecodemodule.c +@@ -40,6 +40,7 @@ + *. ******* AUTOHEADER END v1.1 ******* */ + + #include ++#include + + #include + #include "libxml_wrap.h" +@@ -679,6 +680,9 @@ static PyObject * dmidecode_clear_warnings(PyObject *self, PyObject *null) + Py_RETURN_TRUE; + } + ++static PyMethodDef DMIDataMethods_Dummy[] = { ++ {NULL, NULL, 0, NULL} ++}; + + static PyMethodDef DMIDataMethods[] = { + {(char *)"dump", dmidecode_dump, METH_NOARGS, (char *)"Dump dmidata to set file"}, +@@ -770,6 +774,10 @@ PyMODINIT_FUNC initdmidecodemod(void) + PyObject *module = NULL; + PyObject *version = NULL; + options *opt; ++ struct utsname buf; ++ ++ if (uname(&buf)) ++ return; + + xmlInitParser(); + xmlXPathInit(); +@@ -777,17 +785,22 @@ PyMODINIT_FUNC initdmidecodemod(void) + opt = (options *) malloc(sizeof(options)+2); + memset(opt, 0, sizeof(options)+2); + init(opt); +- module = Py_InitModule3((char *)"dmidecodemod", DMIDataMethods, +- "Python extension module for dmidecode"); + +- version = PyString_FromString(VERSION); +- Py_INCREF(version); +- PyModule_AddObject(module, "version", version); ++ if (memcmp(buf.machine, "x86_64", 6)) ++ module = Py_InitModule3((char *)"dmidecodemod", DMIDataMethods_Dummy, ++ "Python extension module for dummy dmidecode"); ++ else { ++ module = Py_InitModule3((char *)"dmidecodemod", DMIDataMethods, ++ "Python extension module for dmidecode"); + +- opt->dmiversion_n = dmidecode_get_version(opt); +- dmiver = dmixml_GetContent(opt->dmiversion_n); +- PyModule_AddObject(module, "dmi", dmiver ? PyString_FromString(dmiver) : Py_None); ++ version = PyString_FromString(VERSION); ++ Py_INCREF(version); ++ PyModule_AddObject(module, "version", version); + ++ opt->dmiversion_n = dmidecode_get_version(opt); ++ dmiver = dmixml_GetContent(opt->dmiversion_n); ++ PyModule_AddObject(module, "dmi", dmiver ? PyString_FromString(dmiver) : Py_None); ++ } + // Assign this options struct to the module as well with a destructor, that way it will + // clean up the memory for us. + PyModule_AddObject(module, "options", PyCObject_FromVoidPtr(opt, destruct_options)); +diff --git a/unit-tests/unit b/unit-tests/unit +index 8f9184b098c2..6e032a0c18d1 100755 +--- a/unit-tests/unit ++++ b/unit-tests/unit +@@ -4,6 +4,7 @@ + from pprint import pprint + import os, sys, random, tempfile, time + import commands ++import platform + from getopt import getopt + + # Setup temporary sys.path() with our build dir +@@ -135,8 +136,16 @@ def vwrite(msg, vLevel=0): + sys.stdout.write(msg) + sys.stdout.flush() + ++def get_machine(): ++ return platform.machine() ++ + ################################################################################ + ++# no need to test on non-x86_64 ++if get_machine() != "x86_64": ++ print("No need to test on non-x86_64.") ++ sys.exit(0) ++ + #. Let's ignore warnings from the module for the test units... + err = open('/dev/null', 'a+', 0) + os.dup2(err.fileno(), sys.stderr.fileno()) diff --git a/SPECS/python-dmidecode.spec b/SPECS/python-dmidecode.spec index 3edcf34..0b647c1 100644 --- a/SPECS/python-dmidecode.spec +++ b/SPECS/python-dmidecode.spec @@ -4,7 +4,7 @@ Summary: Python module to access DMI data Name: python-dmidecode Version: 3.12.2 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2 Group: System Environment/Libraries URL: https://github.com/nima/python-dmidecode/ @@ -19,6 +19,7 @@ ExcludeArch: s390x Patch0: disable-old-smbios-warning.patch Patch1: revert-interface-changes.patch +Patch2: disable_loading_dmidecodemodule_on_non_x86_64.patch %description python-dmidecode is a python extension module that uses the @@ -29,6 +30,7 @@ as python data structures or as XML data using libxml2. %setup -q %patch0 -p1 %patch1 -p1 +%patch2 -p1 %build make build @@ -56,6 +58,10 @@ rm -rf $RPM_BUILD_ROOT %{_datadir}/python-dmidecode/ %changelog +* Fri Aug 02 2019 Lianbo Jiang - 3.12.2-4 +- Disable loading the dmidecodemodule on non-x86_64 +- Resolves: #1688725 + * Sun Jul 22 2018 Lianbo Jiang - 3.12.2-3 - Modified upstream URL reference - Resolves: #1583926