From b29143ed03687b884d6a5ee30aaaff825fcd784a2b0bd1008e9abce7f7527c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=C3=A9ta=20Machov=C3=A1?= Date: Tue, 10 Jun 2025 15:03:42 +0000 Subject: [PATCH] - Convert to pip-based build OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-python-prctl?expand=0&rev=14 --- .gitattributes | 23 +++++++++ .gitignore | 1 + COPYING | 41 +++++++++++++++ bigendian.patch | 27 ++++++++++ check-for-python310-correctly.patch | 13 +++++ correct-uname-comparsion.patch | 13 +++++ disable-sandboxed-test.patch | 12 +++++ disable_no_new_privs.patch | 12 +++++ dont-check-builddir.patch | 20 ++++++++ memory_failure_early_kill.patch | 12 +++++ powerpc.patch | 80 +++++++++++++++++++++++++++++ python-prctl-1.8.1.tar.gz | 3 ++ python-python-prctl.changes | 57 ++++++++++++++++++++ python-python-prctl.spec | 78 ++++++++++++++++++++++++++++ skip-speculation.patch | 12 +++++ 15 files changed, 404 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 COPYING create mode 100644 bigendian.patch create mode 100644 check-for-python310-correctly.patch create mode 100644 correct-uname-comparsion.patch create mode 100644 disable-sandboxed-test.patch create mode 100644 disable_no_new_privs.patch create mode 100644 dont-check-builddir.patch create mode 100644 memory_failure_early_kill.patch create mode 100644 powerpc.patch create mode 100644 python-prctl-1.8.1.tar.gz create mode 100644 python-python-prctl.changes create mode 100644 python-python-prctl.spec create mode 100644 skip-speculation.patch diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..cc5cd81 --- /dev/null +++ b/COPYING @@ -0,0 +1,41 @@ +python-prctl - A python(ic) interface to the prctl syscall +Copyright (C) 2010-2020 Dennis Kaarsemaker + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +--------------------------------------------------------------------- + +The documentation is heavily based on the linux manpages prctl and +capabilities, which is covered by the following license: + +Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the +entire resulting derived work is distributed under the terms of a +permission notice identical to this one + +Since the Linux kernel and libraries are constantly changing, this +manual page may be incorrect or out-of-date. The author(s) assume no +responsibility for errors or omissions, or for damages resulting from +the use of the information contained herein. The author(s) may not +have taken the same level of care in the production of this manual, +which is licensed free of charge, as they might when working +professionally. + +Formatted or processed versions of this manual, if unaccompanied by +the source, must acknowledge the copyright and authors of this work. +License. diff --git a/bigendian.patch b/bigendian.patch new file mode 100644 index 0000000..0c69604 --- /dev/null +++ b/bigendian.patch @@ -0,0 +1,27 @@ +Index: python-prctl-1.8.1/_prctlmodule.c +=================================================================== +--- python-prctl-1.8.1.orig/_prctlmodule.c ++++ python-prctl-1.8.1/_prctlmodule.c +@@ -51,6 +51,7 @@ prctl_prctl(PyObject *self, PyObject *ar + long option = 0; + long arg = 0; + long arg2 = 0; ++ int intarg = 0; + char *argstr = NULL; + char name[17] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; + int result; +@@ -378,12 +379,12 @@ prctl_prctl(PyObject *self, PyObject *ar + #ifdef PR_GET_TID_ADDRESS + case(PR_GET_TID_ADDRESS): + #endif +- result = prctl(option, &arg, 0, 0, 0); ++ result = prctl(option, &intarg, 0, 0, 0); + if(result < 0) { + PyErr_SetFromErrno(PyExc_OSError); + return NULL; + } +- return PyInt_FromLong(arg); ++ return PyInt_FromLong(intarg); + case(PR_SET_NAME): + case(PR_GET_NAME): + result = prctl(option, name, 0, 0, 0); diff --git a/check-for-python310-correctly.patch b/check-for-python310-correctly.patch new file mode 100644 index 0000000..f4ec399 --- /dev/null +++ b/check-for-python310-correctly.patch @@ -0,0 +1,13 @@ +Index: python-prctl-1.8.1/test_prctl.py +=================================================================== +--- python-prctl-1.8.1.orig/test_prctl.py ++++ python-prctl-1.8.1/test_prctl.py +@@ -20,7 +20,7 @@ except ImportError: + pass + + curdir = os.path.dirname(__file__) +-builddir = os.path.join(curdir, 'build', 'lib.%s-%s' % (distutils.util.get_platform(), sys.version[0:3])) ++builddir = os.path.join(curdir, 'build', 'lib.%s-%s' % (distutils.util.get_platform(), '.'.join([str(x) for x in sys.version_info[:2]]))) + + # Always run from the builddir + if not os.path.exists(builddir) or \ diff --git a/correct-uname-comparsion.patch b/correct-uname-comparsion.patch new file mode 100644 index 0000000..569cd3c --- /dev/null +++ b/correct-uname-comparsion.patch @@ -0,0 +1,13 @@ +Index: python-prctl-1.8.1/test_prctl.py +=================================================================== +--- python-prctl-1.8.1.orig/test_prctl.py ++++ python-prctl-1.8.1/test_prctl.py +@@ -245,7 +245,7 @@ class PrctlTest(unittest.TestCase): + @require('mpx_enable_management') + def test_mpx(self): + """Test MPX enabling/disabling""" +- if os.uname().release > "5.4": ++ if tuple(int(x) for x in os.uname().release.split('.')[:2]) > (5, 4): + self.assertRaises(OSError, prctl.mpx_enable_management) + self.assertRaises(OSError, prctl.mpx_disable_management) + else: diff --git a/disable-sandboxed-test.patch b/disable-sandboxed-test.patch new file mode 100644 index 0000000..ca186eb --- /dev/null +++ b/disable-sandboxed-test.patch @@ -0,0 +1,12 @@ +Index: python-prctl-1.8.1/test_prctl.py +=================================================================== +--- python-prctl-1.8.1.orig/test_prctl.py ++++ python-prctl-1.8.1/test_prctl.py +@@ -240,6 +240,7 @@ class PrctlTest(unittest.TestCase): + else: + self.assertRaises(OSError, prctl.pac_reset_keys, prctl.PAC_APIAKEY) + ++ @unittest.skip('borked in sandbox') + def test_proctitle(self): + """Test setting the process title, including too long titles""" + with open('/proc/self/cmdline') as fd: diff --git a/disable_no_new_privs.patch b/disable_no_new_privs.patch new file mode 100644 index 0000000..84151b7 --- /dev/null +++ b/disable_no_new_privs.patch @@ -0,0 +1,12 @@ +Index: python-prctl-1.8.1/test_prctl.py +=================================================================== +--- python-prctl-1.8.1.orig/test_prctl.py ++++ python-prctl-1.8.1/test_prctl.py +@@ -259,6 +259,7 @@ class PrctlTest(unittest.TestCase): + self.assertEqual(prctl.get_name(), name[:15]) + + @require('get_no_new_privs') ++ @unittest.skip('test fails, because ping doesn\'t use capabilities anymore (boo#1174504)') + def test_no_new_privs(self): + """Test the no_new_privs function""" + self.assertEqual(prctl.get_no_new_privs(), 0) diff --git a/dont-check-builddir.patch b/dont-check-builddir.patch new file mode 100644 index 0000000..6ccc524 --- /dev/null +++ b/dont-check-builddir.patch @@ -0,0 +1,20 @@ +Index: python-prctl-1.8.1/test_prctl.py +=================================================================== +--- python-prctl-1.8.1.orig/test_prctl.py ++++ python-prctl-1.8.1/test_prctl.py +@@ -22,15 +22,6 @@ except ImportError: + curdir = os.path.dirname(__file__) + builddir = os.path.join(curdir, 'build', 'lib.%s-%s' % (distutils.util.get_platform(), '.'.join([str(x) for x in sys.version_info[:2]]))) + +-# Always run from the builddir +-if not os.path.exists(builddir) or \ +- not os.path.exists(os.path.join(builddir, 'prctl.py')) or \ +- not os.path.exists(os.path.join(builddir, '_prctl' + so)) or \ +- int(os.path.getmtime(os.path.join(curdir, 'prctl.py'))) > int(os.path.getmtime(os.path.join(builddir, 'prctl.py'))) or \ +- os.path.getmtime(os.path.join(curdir, '_prctlmodule.c')) > os.path.getmtime(os.path.join(builddir, '_prctl' + so)): +- sys.stderr.write("Please build the extension first, using ./setup.py build\n") +- sys.exit(1) +-sys.path.insert(0, builddir) + + import prctl + import _prctl diff --git a/memory_failure_early_kill.patch b/memory_failure_early_kill.patch new file mode 100644 index 0000000..1658ce3 --- /dev/null +++ b/memory_failure_early_kill.patch @@ -0,0 +1,12 @@ +Index: python-prctl-1.8.1/test_prctl.py +=================================================================== +--- python-prctl-1.8.1.orig/test_prctl.py ++++ python-prctl-1.8.1/test_prctl.py +@@ -182,6 +182,7 @@ class PrctlTest(unittest.TestCase): + self.assertEqual(prctl.get_keepcaps(), False) + + @require('set_mce_kill') ++ @unittest.skipIf(sys.maxsize <= 2**32 or arch == 's390x', 'no such file on this architecture') + def test_mce_kill(self): + """Test the MCE_KILL setting""" + if not os.path.exists('/proc/sys/vm/memory_failure_early_kill'): diff --git a/powerpc.patch b/powerpc.patch new file mode 100644 index 0000000..257c8f8 --- /dev/null +++ b/powerpc.patch @@ -0,0 +1,80 @@ +Index: python-prctl-1.8.1/test_prctl.py +=================================================================== +--- python-prctl-1.8.1.orig/test_prctl.py ++++ python-prctl-1.8.1/test_prctl.py +@@ -45,6 +45,8 @@ def require(attr): + class PrctlTest(unittest.TestCase): + # There are architecture specific tests + arch = os.uname()[4] ++ if arch == 'ppc' or arch == 'ppc64' or arch == 'ppc64le': ++ arch = 'powerpc' + # prctl behaviour differs when root, so you should test as root and non-root + am_root = os.geteuid() == 0 + +@@ -111,6 +113,7 @@ class PrctlTest(unittest.TestCase): + self.assertEqual(prctl.get_dumpable(), False) + self.assertRaises(TypeError, prctl.get_dumpable, "42") + ++ @unittest.skip('cannot change endianness of running python interpreter') + def test_endian(self): + """Test manipulation of the endianness setting""" + if self.arch == 'powerpc': +@@ -137,13 +140,55 @@ class PrctlTest(unittest.TestCase): + self.assertRaises(OSError, prctl.get_fpemu) + self.assertRaises(OSError, prctl.set_fpemu, prctl.FPEMU_SIGFPE) + ++# define PR_FP_EXC_SW_ENABLE 0x80 /* Use FPEXC for FP exception enables */ ++# define PR_FP_EXC_DIV 0x010000 /* floating point divide by zero */ ++# define PR_FP_EXC_OVF 0x020000 /* floating point overflow */ ++# define PR_FP_EXC_UND 0x040000 /* floating point underflow */ ++# define PR_FP_EXC_RES 0x080000 /* floating point inexact result */ ++# define PR_FP_EXC_INV 0x100000 /* floating point invalid operation */ ++# define PR_FP_EXC_DISABLED 0 /* FP exceptions disabled */ ++# define PR_FP_EXC_NONRECOV 1 /* async non-recoverable exc. mode */ ++# define PR_FP_EXC_ASYNC 2 /* async recoverable exception mode */ ++# define PR_FP_EXC_PRECISE 3 /* precise exception mode */ ++ def print_fpexc(self, fpexc): ++ if fpexc == 0: ++ print("PR_FP_EXC_DISABLED") ++ else: ++ if fpexc & 3 == _prctl.PR_FP_EXC_ASYNC: ++ print('PR_FP_EXC_ASYNC') ++ if fpexc & 3 == _prctl.PR_FP_EXC_NONRECOV: ++ print('PR_FP_EXC_NONRECOV') ++ if fpexc & 3 == _prctl.PR_FP_EXC_PRECISE: ++ print('PR_FP_EXC_PRECISE') ++ if fpexc & prctl.PR_FP_EXC_SW_ENABLE: ++ print('PR_FP_EXC_SW_ENABLE') ++ if fpexc & _prctl.PR_FP_EXC_DIV: ++ print('PR_FP_EXC_DIV') ++ if fpexc & _prctl.PR_FP_EXC_OVF: ++ print('PR_FP_EXC_OVF') ++ if fpexc & _prctl.PR_FP_EXC_UND: ++ print('PR_FP_EXC_UND') ++ if fpexc & _prctl.PR_FP_EXC_RES: ++ print('PR_FP_EXC_RES') ++ if fpexc & _prctl.PR_FP_EXC_INV: ++ print('PR_FP_EXC_INV') ++ print('\n'); ++ + def test_fpexc(self): + """Test manipulation of the fpexc setting""" + if self.arch == 'powerpc': +- # FIXME - untested +- prctl.set_fpexc(prctl.FP_EXC_SW_ENABLE) +- self.assertEqual(prctl.get_fpexc() & prctl.PR_FP_EXC_SW_ENABLE, prctl.PR_FP_EXC_SW_ENABLE) ++ fpexc = prctl.get_fpexc() ++ self.print_fpexc(fpexc) ++ # Did not find a sane combination of flags that is supported. ++ self.assertRaises(OSError, prctl.set_fpexc, ++ prctl.FP_EXC_SW_ENABLE | _prctl.PR_FP_EXC_ASYNC | _prctl.PR_FP_EXC_DIV | _prctl.PR_FP_EXC_INV) ++ self.print_fpexc(prctl.get_fpexc()) ++ self.assertEqual(prctl.get_fpexc(), fpexc) ++ prctl.set_fpexc(_prctl.PR_FP_EXC_DISABLED) ++ self.print_fpexc(prctl.get_fpexc()) ++ self.assertEqual(prctl.get_fpexc(), _prctl.PR_FP_EXC_DISABLED) + self.assertRaises(ValueError, prctl.set_fpexc, 999) ++ prctl.set_fpexc(fpexc) + else: + self.assertRaises(OSError, prctl.get_fpexc) + self.assertRaises(OSError, prctl.set_fpexc) diff --git a/python-prctl-1.8.1.tar.gz b/python-prctl-1.8.1.tar.gz new file mode 100644 index 0000000..4754952 --- /dev/null +++ b/python-prctl-1.8.1.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b4ca9a25a7d4f1ace4fffd1f3a2e64ef5208fe05f929f3edd5e27081ca7e67ce +size 28033 diff --git a/python-python-prctl.changes b/python-python-prctl.changes new file mode 100644 index 0000000..d012d3e --- /dev/null +++ b/python-python-prctl.changes @@ -0,0 +1,57 @@ +------------------------------------------------------------------- +Tue Jun 10 15:01:50 UTC 2025 - Markéta Machová + +- Convert to pip-based build + +------------------------------------------------------------------- +Fri Oct 7 07:39:38 UTC 2022 - Markéta Machová + +- Add patch dont-check-builddir.patch + * The check whether the tests run in builddir is broken, turn it off + and assume everything is fine (we would see it if not). + +------------------------------------------------------------------- +Thu Feb 17 05:33:37 UTC 2022 - Steve Kowalik + +- Update to 1.8.1: + * No changelog. +- Rebase all patches. +- Add patch correct-uname-comparsion.patch: + * Support Linux >= 5.10 correctly. +- Add patch check-for-python310-correctly.patch: + * Check for Python 3.10 correctly. +- Add patch skip-speculation.patch: + * Skip a test that does not work in the OBS sandbox. + +------------------------------------------------------------------- +Tue Oct 27 09:54:52 UTC 2020 - Hans-Peter Jansen + +- Disable test of no_new_privs with disable_no_new_privs.patch + test fails, because ping doesn't use capabilities anymore (boo#1174504) + +------------------------------------------------------------------- +Fri Sep 4 13:48:25 UTC 2020 - Marketa Calabkova + +- Fixing arch-dependent test failures (bsc#1176085): + * renamed failing-on-i586.patch to memory_failure_early_kill.patch + * and modified it to skip the test also on s390x + * added bigendian.patch + * added powerpc.patch + * huge thanks to Michal Suchánek + +------------------------------------------------------------------- +Wed Aug 19 07:46:50 UTC 2020 - Marketa Calabkova + +- Add failing-on-i586.patch to disable failing i586 test + +------------------------------------------------------------------- +Tue Aug 11 07:51:14 UTC 2020 - Tomáš Chvátal + +- Add patch to disable test failing in sandbox: + https://github.com/seveas/python-prctl/issues/17 + * disable-sandboxed-test.patch + +------------------------------------------------------------------- +Tue Aug 11 07:37:51 UTC 2020 - Tomáš Chvátal + +- Initial commit jsc#SLE-13272 diff --git a/python-python-prctl.spec b/python-python-prctl.spec new file mode 100644 index 0000000..6889580 --- /dev/null +++ b/python-python-prctl.spec @@ -0,0 +1,78 @@ +# +# spec file for package python-python-prctl +# +# Copyright (c) 2025 SUSE LLC +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +Name: python-python-prctl +Version: 1.8.1 +Release: 0 +Summary: Python(ic) interface to the linux prctl syscall +License: GPL-3.0-or-later +URL: https://github.com/seveas/python-prctl +Source: https://files.pythonhosted.org/packages/source/p/python-prctl/python-prctl-%{version}.tar.gz +Source99: https://raw.githubusercontent.com/seveas/python-prctl/master/COPYING +Patch0: disable-sandboxed-test.patch +Patch1: memory_failure_early_kill.patch +Patch2: bigendian.patch +Patch3: powerpc.patch +Patch4: disable_no_new_privs.patch +Patch5: correct-uname-comparsion.patch +Patch6: check-for-python310-correctly.patch +Patch7: skip-speculation.patch +Patch8: dont-check-builddir.patch +BuildRequires: %{python_module devel} +BuildRequires: %{python_module pip} +BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} +BuildRequires: fdupes +BuildRequires: iputils +BuildRequires: pkgconfig +BuildRequires: procps +BuildRequires: python-rpm-macros +BuildRequires: pkgconfig(libcap) +%python_subpackages + +%description +The linux prctl function allows you to control specific characteristics of a +process' behaviour. Usage of the function is fairly messy though, due to +limitations in C and linux. This module provides a nice non-messy python(ic) +interface. + +Besides prctl, this library also wraps libcap for complete capability handling +and allows you to set the process name as seen in ps and top. + +%prep +%autosetup -p1 -n python-prctl-%{version} +cp %{SOURCE99} . + +%build +%pyproject_wheel + +%install +%pyproject_install +%python_expand %fdupes %{buildroot}%{$python_sitearch} + +%check +%python_expand PYTHONPATH=%{buildroot}%{$python_sitearch} $python test_prctl.py + +%files %{python_files} +%license COPYING +%doc README +%{python_sitearch}/prctl.py +%{python_sitearch}/python[-_]prctl-%{version}*-info +%pycache_only %{python_sitearch}/__pycache__/prctl* + +%changelog diff --git a/skip-speculation.patch b/skip-speculation.patch new file mode 100644 index 0000000..fbae1c8 --- /dev/null +++ b/skip-speculation.patch @@ -0,0 +1,12 @@ +Index: python-prctl-1.8.1/test_prctl.py +=================================================================== +--- python-prctl-1.8.1.orig/test_prctl.py ++++ python-prctl-1.8.1/test_prctl.py +@@ -371,6 +371,7 @@ class PrctlTest(unittest.TestCase): + self.assertRaises(OSError, set_true) + + @require('set_speculation_ctrl') ++ @unittest.skip('borked in sandbox') + def test_speculation_ctrl(self): + self.assertTrue(prctl.get_speculation_ctrl(prctl.SPEC_STORE_BYPASS) > 0) + self.assertTrue(prctl.get_speculation_ctrl(prctl.SPEC_INDIRECT_BRANCH) > 0)