Your message dated Sat, 7 Oct 2023 14:15:24 +0300
with message-id <ZSE9zK+Fptjtvdno@localhost>
and subject line kFreeBSD has been removed from Debian ports
has caused the Debian Bug report #918884,
regarding python-psutil: FTBFS on kfreebsd-any
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
918884: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=918884
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Source: python-psutil
Version: 5.4.8-1
Severity: important
Tags: ftbfs, patch
User: [email protected]
Usertags: kfreebsd

Hello,

Currently python-psutil FTBFS on GNU/kFreeBSD a missing port to that
architecture. Attached are two patches, kfreebsd-port.diff and kfreebsd-port-
test.diff to make python-psutil build properly on kfreebsd-any. The tests are
not run if kfreebsd-port-test.diff is not applied, but of course the same can be
fixed by setting DEB_BUILD_OPTIONS=nocheck. Note that the test suite is not yet
complete, typical test results are:  529 tests: failures=12, errors=44,
skipped=279. Needed changes are marked with FIXMEs in the patches.

Additionally, additional libraries for kfreebsd-any in debian/control is needed
for a proper build on Debian, see debian_control-5.4.8-1.diff.

Thanks!
--- a/debian/control	2018-11-23 20:36:51.000000000 +0100
+++ b/debian/control	2019-01-09 15:02:00.310282000 +0100
@@ -3,7 +3,7 @@
 Priority: optional
 Maintainer: Sandro Tosi <[email protected]>
 Uploaders: Debian Python Modules Team <[email protected]>
-Build-Depends: debhelper (>= 10), python-all-dev, python3-all-dev, python-all-dbg, python3-all-dbg, dh-python, procps, python3-sphinx, python-ipaddress, python-mock, python3-sphinx-rtd-theme
+Build-Depends: debhelper (>= 10), python-all-dev, python3-all-dev, python-all-dbg, python3-all-dbg, dh-python, procps, python3-sphinx, python-ipaddress, python-mock, python3-sphinx-rtd-theme, libkvm-dev [kfreebsd-any], libmemstat-dev [kfreebsd-any], libbsd-dev [kfreebsd-any], libutil-freebsd-dev [kfreebsd-any]
 Standards-Version: 4.2.1
 XS-Python-Version: all
 Homepage: https://github.com/giampaolo/psutil
Index: python-psutil-5.4.8/psutil/_psbsd.py
===================================================================
--- python-psutil-5.4.8.orig/psutil/_psbsd.py
+++ python-psutil-5.4.8/psutil/_psbsd.py
@@ -2,7 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-"""FreeBSD, OpenBSD and NetBSD platforms implementation."""
+"""FreeBSD, kFreeBSD, OpenBSD and NetBSD platforms implementation."""
 
 import contextlib
 import errno
@@ -19,6 +19,7 @@ from . import _psutil_posix as cext_posi
 from ._common import AF_INET6
 from ._common import conn_tmap
 from ._common import FREEBSD
+from ._common import KFREEBSD
 from ._common import memoize
 from ._common import memoize_when_activated
 from ._common import NETBSD
@@ -39,7 +40,7 @@ __extra__all__ = []
 # =====================================================================
 
 
-if FREEBSD:
+if FREEBSD or KFREEBSD:
     PROC_STATUSES = {
         cext.SIDL: _common.STATUS_IDLE,
         cext.SRUN: _common.STATUS_RUNNING,
@@ -333,7 +334,9 @@ def disk_partitions(all=False):
 
 
 disk_usage = _psposix.disk_usage
-disk_io_counters = cext.disk_io_counters
+# FIXME
+if not KFREEBSD:
+    disk_io_counters = cext.disk_io_counters
 
 
 # =====================================================================
Index: python-psutil-5.4.8/setup.py
===================================================================
--- python-psutil-5.4.8.orig/setup.py
+++ python-psutil-5.4.8/setup.py
@@ -31,6 +31,7 @@ sys.path.insert(0, os.path.join(HERE, "p
 from _common import AIX  # NOQA
 from _common import BSD  # NOQA
 from _common import FREEBSD  # NOQA
+from _common import KFREEBSD  # NOQA
 from _common import LINUX  # NOQA
 from _common import MACOS  # NOQA
 from _common import NETBSD  # NOQA
@@ -171,6 +172,20 @@ elif FREEBSD:
         define_macros=macros,
         libraries=["devstat"])
 
+elif KFREEBSD:
+    macros.append(("PSUTIL_KFREEBSD", 1))
+    ext = Extension(
+        'psutil._psutil_bsd',
+        sources=sources + [
+            'psutil/_psutil_bsd.c',
+            'psutil/arch/freebsd/specific.c',
+# FIXME
+#            'psutil/arch/freebsd/sys_socks.c',
+            'psutil/arch/freebsd/proc_socks.c',
+        ],
+        define_macros=macros,
+        libraries=["memstat", "util-freebsd"])
+
 elif OPENBSD:
     macros.append(("PSUTIL_OPENBSD", 1))
     ext = Extension(
@@ -266,6 +281,8 @@ if POSIX:
         if platform.release() == '5.10':
             posix_extension.sources.append('psutil/arch/solaris/v10/ifaddrs.c')
             posix_extension.define_macros.append(('PSUTIL_SUNOS10', 1))
+    elif KFREEBSD:
+        posix_extension.libraries=["bsd"]
     elif AIX:
         posix_extension.sources.append('psutil/arch/aix/ifaddrs.c')
 
Index: python-psutil-5.4.8/psutil/_common.py
===================================================================
--- python-psutil-5.4.8.orig/psutil/_common.py
+++ python-psutil-5.4.8/psutil/_common.py
@@ -43,7 +43,7 @@ PY3 = sys.version_info[0] == 3
 __all__ = [
     # constants
     'FREEBSD', 'BSD', 'LINUX', 'NETBSD', 'OPENBSD', 'MACOS', 'OSX', 'POSIX',
-    'SUNOS', 'WINDOWS',
+    'SUNOS', 'WINDOWS', 'KFREEBSD',
     'ENCODING', 'ENCODING_ERRS', 'AF_INET6',
     # connection constants
     'CONN_CLOSE', 'CONN_CLOSE_WAIT', 'CONN_CLOSING', 'CONN_ESTABLISHED',
@@ -78,6 +78,7 @@ LINUX = sys.platform.startswith("linux")
 MACOS = sys.platform.startswith("darwin")
 OSX = MACOS  # deprecated alias
 FREEBSD = sys.platform.startswith("freebsd")
+KFREEBSD = sys.platform.startswith("gnukfreebsd")
 OPENBSD = sys.platform.startswith("openbsd")
 NETBSD = sys.platform.startswith("netbsd")
 BSD = FREEBSD or OPENBSD or NETBSD
Index: python-psutil-5.4.8/psutil/_psutil_posix.c
===================================================================
--- python-psutil-5.4.8.orig/psutil/_psutil_posix.c
+++ python-psutil-5.4.8/psutil/_psutil_posix.c
@@ -28,13 +28,16 @@
     #include <netdb.h>
     #include <linux/types.h>
     #include <linux/if_packet.h>
-#elif defined(PSUTIL_BSD) || defined(PSUTIL_OSX)
+#elif defined(PSUTIL_BSD) || defined(PSUTIL_OSX)|| defined(PSUTIL_KFREEBSD)
     #include <netdb.h>
     #include <netinet/in.h>
     #include <net/if_dl.h>
     #include <sys/sockio.h>
     #include <net/if_media.h>
     #include <net/if.h>
+    #if defined(PSUTIL_KFREEBSD)
+      #include <bsd/string.h>
+    #endif
 #elif defined(PSUTIL_SUNOS)
     #include <netdb.h>
     #include <sys/sockio.h>
@@ -702,7 +705,8 @@ void init_psutil_posix(void)
     PyObject *module = Py_InitModule("_psutil_posix", PsutilMethods);
 #endif
 
-#if defined(PSUTIL_BSD) || defined(PSUTIL_OSX) || defined(PSUTIL_SUNOS) || defined(PSUTIL_AIX)
+#if defined(PSUTIL_BSD) || defined(PSUTIL_OSX) || defined(PSUTIL_SUNOS) || \
+  defined(PSUTIL_AIX) || defined(PSUTIL_KFREEBSD)
     PyModule_AddIntConstant(module, "AF_LINK", AF_LINK);
 #endif
 
Index: python-psutil-5.4.8/psutil/_psutil_bsd.c
===================================================================
--- python-psutil-5.4.8.orig/psutil/_psutil_bsd.c
+++ python-psutil-5.4.8/psutil/_psutil_bsd.c
@@ -75,6 +75,16 @@
     #else
         #include <utmpx.h>
     #endif
+#elif PSUTIL_KFREEBSD
+    #include "arch/freebsd/specific.h"
+    #include "arch/freebsd/sys_socks.h"
+    #include "arch/freebsd/proc_socks.h"
+
+    #include <kvm.h>
+    #include <sys/user.h>
+    #include <bsd/string.h>
+    #include <net/if_media.h>
+    #include <utmpx.h>
 #elif PSUTIL_OPENBSD
     #include "arch/openbsd/specific.h"
 
@@ -143,7 +153,7 @@ psutil_pids(PyObject *self, PyObject *ar
     if (num_processes > 0) {
         orig_address = proclist; // save so we can free it after we're done
         for (idx = 0; idx < num_processes; idx++) {
-#ifdef PSUTIL_FREEBSD
+#if defined(PSUTIL_FREEBSD) || defined(PSUTIL_KFREEBSD)
             py_pid = Py_BuildValue("i", proclist->ki_pid);
 #elif defined(PSUTIL_OPENBSD) || defined(PSUTIL_NETBSD)
             py_pid = Py_BuildValue("i", proclist->p_pid);
@@ -211,7 +221,7 @@ psutil_proc_oneshot_info(PyObject *self,
         return NULL;
 
     // Process
-#ifdef PSUTIL_FREEBSD
+#if defined(PSUTIL_FREEBSD) || defined(PSUTIL_KFREEBSD)
     sprintf(str, "%s", kp.ki_comm);
 #elif defined(PSUTIL_OPENBSD) || defined(PSUTIL_NETBSD)
     sprintf(str, "%s", kp.p_comm);
@@ -225,7 +235,7 @@ psutil_proc_oneshot_info(PyObject *self,
     }
 
     // Calculate memory.
-#ifdef PSUTIL_FREEBSD
+#if defined(PSUTIL_FREEBSD) || defined(PSUTIL_KFREEBSD)
     rss = (long)kp.ki_rssize * pagesize;
     vms = (long)kp.ki_size;
     memtext = (long)kp.ki_tsize * pagesize;
@@ -249,7 +259,7 @@ psutil_proc_oneshot_info(PyObject *self,
         memstack = (long)kp.p_vm_ssize * pagesize;
 #endif
 
-#ifdef PSUTIL_FREEBSD
+#if defined(PSUTIL_FREEBSD) || defined(PSUTIL_KFREEBSD)
     // what CPU we're on; top was used as an example:
     // https://svnweb.freebsd.org/base/head/usr.bin/top/machine.c?
     //     view=markup&pathrev=273835
@@ -269,7 +279,7 @@ psutil_proc_oneshot_info(PyObject *self,
     // Return a single big tuple with all process info.
     py_retlist = Py_BuildValue(
         "(lillllllidllllddddlllllbO)",
-#ifdef PSUTIL_FREEBSD
+#if defined(PSUTIL_FREEBSD) || defined(PSUTIL_KFREEBSD)
         //
         (long)kp.ki_ppid,                // (long) ppid
         (int)kp.ki_stat,                 // (int) status
@@ -365,7 +375,7 @@ psutil_proc_name(PyObject *self, PyObjec
     if (psutil_kinfo_proc(pid, &kp) == -1)
         return NULL;
 
-#ifdef PSUTIL_FREEBSD
+#if defined(PSUTIL_FREEBSD) || defined(PSUTIL_KFREEBSD)
     sprintf(str, "%s", kp.ki_comm);
 #elif defined(PSUTIL_OPENBSD) || defined(PSUTIL_NETBSD)
     sprintf(str, "%s", kp.p_comm);
@@ -425,7 +435,7 @@ psutil_cpu_times(PyObject *self, PyObjec
     size_t size = sizeof(cpu_time);
     int ret;
 
-#if defined(PSUTIL_FREEBSD) || defined(PSUTIL_NETBSD)
+#if defined(PSUTIL_FREEBSD) || defined(PSUTIL_KFREEBSD) || defined(PSUTIL_NETBSD)
     ret = sysctlbyname("kern.cp_time", &cpu_time, &size, NULL, 0);
 #elif PSUTIL_OPENBSD
     int mib[] = {CTL_KERN, KERN_CPTIME};
@@ -918,7 +928,7 @@ PsutilMethods[] = {
      "Return process cmdline as a list of cmdline arguments"},
     {"proc_threads", psutil_proc_threads, METH_VARARGS,
      "Return process threads"},
-#if defined(PSUTIL_FREEBSD) || defined(PSUTIL_OPENBSD)
+#if defined(PSUTIL_FREEBSD) || defined(PSUTIL_OPENBSD) || defined(PSUTIL_KFREEBSD)
     {"proc_connections", psutil_proc_connections, METH_VARARGS,
      "Return connections opened by process"},
     {"proc_cwd", psutil_proc_cwd, METH_VARARGS,
@@ -934,11 +944,14 @@ PsutilMethods[] = {
     {"proc_num_threads", psutil_proc_num_threads, METH_VARARGS,
      "Return number of threads used by process"},
 #endif
-#if defined(PSUTIL_FREEBSD)
+#if defined(PSUTIL_FREEBSD) || defined(PSUTIL_KFREEBSD)
     {"proc_exe", psutil_proc_exe, METH_VARARGS,
      "Return process pathname executable"},
+    /* FIXME */
+#if !defined(PSUTIL_KFREEBSD)
     {"proc_memory_maps", psutil_proc_memory_maps, METH_VARARGS,
      "Return a list of tuples for every process's memory map"},
+#endif
     {"proc_cpu_affinity_get", psutil_proc_cpu_affinity_get, METH_VARARGS,
      "Return process CPU affinity."},
     {"proc_cpu_affinity_set", psutil_proc_cpu_affinity_set, METH_VARARGS,
@@ -968,8 +981,11 @@ PsutilMethods[] = {
      "fs type for all partitions mounted on the system."},
     {"net_io_counters", psutil_net_io_counters, METH_VARARGS,
      "Return dict of tuples of networks I/O information."},
+    /* FIXME */
+#if !defined(PSUTIL_KFREEBSD)
     {"disk_io_counters", psutil_disk_io_counters, METH_VARARGS,
      "Return a Python dict of tuples for disk I/O information"},
+#endif
     {"users", psutil_users, METH_VARARGS,
      "Return currently connected users as a list of tuples"},
     {"cpu_stats", psutil_cpu_stats, METH_VARARGS,
@@ -1045,7 +1061,7 @@ void init_psutil_bsd(void)
     PyModule_AddIntConstant(module, "version", PSUTIL_VERSION);
     // process status constants
 
-#ifdef PSUTIL_FREEBSD
+#if defined(PSUTIL_FREEBSD) || defined(PSUTIL_KFREEBSD)
     PyModule_AddIntConstant(module, "SIDL", SIDL);
     PyModule_AddIntConstant(module, "SRUN", SRUN);
     PyModule_AddIntConstant(module, "SSLEEP", SSLEEP);
Index: python-psutil-5.4.8/psutil/arch/freebsd/specific.c
===================================================================
--- python-psutil-5.4.8.orig/psutil/arch/freebsd/specific.c
+++ python-psutil-5.4.8/psutil/arch/freebsd/specific.c
@@ -21,8 +21,13 @@
 #include <signal.h>
 #include <fcntl.h>
 #include <sys/vmmeter.h>  // needed for vmtotal struct
-#include <devstat.h>  // for swap mem
+#ifdef __FreeBSD_kernel__
+# include <kvm.h>
+# include <bsd/string.h>
+#else
+# include <devstat.h>  // for swap mem
 #include <libutil.h>  // process open files, shared libs (kinfo_getvmmap), cwd
+#endif
 #include <sys/cpuset.h>
 
 #include "../../_psutil_common.h"
@@ -66,6 +71,9 @@ psutil_kinfo_proc(const pid_t pid, struc
 }
 
 
+
+/* FIXME: Commented out becuse of psutil_disk_io_counters */
+#ifndef __FreeBSD_kernel__
 // remove spaces from string
 static void psutil_remove_spaces(char *str) {
     char *p1 = str;
@@ -75,6 +83,7 @@ static void psutil_remove_spaces(char *s
             p2++;
     while ((*p1++ = *p2++));
 }
+#endif
 
 
 // ============================================================================
@@ -532,7 +541,7 @@ error:
 }
 
 
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 800000
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 800000 || defined(__FreeBSD_kernel__)
 PyObject *
 psutil_proc_cwd(PyObject *self, PyObject *args) {
     long pid;
@@ -672,6 +681,8 @@ error:
 }
 
 
+/* FIXME */
+#ifndef __FreeBSD_kernel__
 PyObject *
 psutil_disk_io_counters(PyObject *self, PyObject *args) {
     int i;
@@ -738,8 +749,11 @@ error:
         free(stats.dinfo);
     return NULL;
 }
+#endif
 
 
+/* FIXME */
+#ifndef __FreeBSD_kernel__
 PyObject *
 psutil_proc_memory_maps(PyObject *self, PyObject *args) {
     // Return a list of tuples for every process memory maps.
@@ -853,6 +867,7 @@ error:
         free(freep);
     return NULL;
 }
+#endif
 
 
 PyObject*
Index: python-psutil-5.4.8/psutil/__init__.py
===================================================================
--- python-psutil-5.4.8.orig/psutil/__init__.py
+++ python-psutil-5.4.8/psutil/__init__.py
@@ -12,6 +12,7 @@ sensors) in Python. Supported platforms:
  - Windows
  - macOS
  - FreeBSD
+ - kFreeBSD
  - OpenBSD
  - NetBSD
  - Sun Solaris
@@ -77,6 +78,7 @@ from ._common import NIC_DUPLEX_UNKNOWN
 from ._common import AIX
 from ._common import BSD
 from ._common import FREEBSD  # NOQA
+from ._common import KFREEBSD  # NOQA
 from ._common import LINUX
 from ._common import MACOS
 from ._common import NETBSD  # NOQA
@@ -158,6 +160,9 @@ elif MACOS:
 elif BSD:
     from . import _psbsd as _psplatform
 
+elif KFREEBSD:
+    from . import _psbsd as _psplatform
+
 elif SUNOS:
     from . import _pssunos as _psplatform
     from ._pssunos import CONN_BOUND  # NOQA
@@ -202,7 +207,7 @@ __all__ = [
     "POWER_TIME_UNKNOWN", "POWER_TIME_UNLIMITED",
 
     "BSD", "FREEBSD", "LINUX", "NETBSD", "OPENBSD", "MACOS", "OSX", "POSIX",
-    "SUNOS", "WINDOWS", "AIX",
+    "SUNOS", "WINDOWS", "AIX", "KFREEBSD",
 
     # classes
     "Process", "Popen",
@@ -2023,7 +2028,8 @@ def disk_io_counters(perdisk=False, nowr
     executed first otherwise this function won't find any disk.
     """
     kwargs = dict(perdisk=perdisk) if LINUX else {}
-    rawdict = _psplatform.disk_io_counters(**kwargs)
+# FIXME
+    rawdict = _psplatform.disk_io_counters(**kwargs) if not KFREEBSD else {}
     if not rawdict:
         return {} if perdisk else None
     if nowrap:
Index: python-psutil-5.4.8/psutil/tests/test_system.py
===================================================================
--- python-psutil-5.4.8.orig/psutil/tests/test_system.py
+++ python-psutil-5.4.8/psutil/tests/test_system.py
@@ -22,6 +22,7 @@ import psutil
 from psutil import AIX
 from psutil import BSD
 from psutil import FREEBSD
+from psutil import KFREEBSD
 from psutil import LINUX
 from psutil import MACOS
 from psutil import NETBSD
@@ -695,7 +696,7 @@ class TestSystemAPIs(unittest.TestCase):
                     self.assertEqual(nt[6], nt.read_merged_count)
                     self.assertEqual(nt[7], nt.write_merged_count)
                     self.assertEqual(nt[8], nt.busy_time)
-                elif FREEBSD:
+                elif FREEBSD or KFREEBSD:
                     self.assertEqual(nt[6], nt.busy_time)
             for name in nt._fields:
                 assert getattr(nt, name) >= 0, nt
@@ -776,7 +777,7 @@ class TestSystemAPIs(unittest.TestCase):
 
     def test_os_constants(self):
         names = ["POSIX", "WINDOWS", "LINUX", "MACOS", "FREEBSD", "OPENBSD",
-                 "NETBSD", "BSD", "SUNOS"]
+                 "NETBSD", "BSD", "SUNOS", "KFREEBSD"]
         for name in names:
             self.assertIsInstance(getattr(psutil, name), bool, msg=name)
 
@@ -793,6 +794,7 @@ class TestSystemAPIs(unittest.TestCase):
                                   psutil.NETBSD].count(True), 1)
                 names.remove("BSD")
                 names.remove("FREEBSD")
+                names.remove("KFREEBSD")
                 names.remove("OPENBSD")
                 names.remove("NETBSD")
             elif "sunos" in sys.platform.lower() or \
Index: python-psutil-5.4.8/psutil/tests/test_bsd.py
===================================================================
--- python-psutil-5.4.8.orig/psutil/tests/test_bsd.py
+++ python-psutil-5.4.8/psutil/tests/test_bsd.py
@@ -18,6 +18,7 @@ import time
 import psutil
 from psutil import BSD
 from psutil import FREEBSD
+from psutil import KFREEBSD
 from psutil import NETBSD
 from psutil import OPENBSD
 from psutil.tests import get_test_subprocess
@@ -46,7 +47,7 @@ def sysctl(cmdline):
     returning only the value of interest.
     """
     result = sh("sysctl " + cmdline)
-    if FREEBSD:
+    if FREEBSD or KFREEBSD:
         result = result[result.find(": ") + 2:]
     elif OPENBSD or NETBSD:
         result = result[result.find("=") + 1:]

--- End Message ---
--- Begin Message ---
kFreeBSD has been removed from Debian ports:
https://lists.debian.org/debian-bsd/2023/07/msg00003.html

cu
Adrian

--- End Message ---

Reply via email to