pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/devel/py-sysctl



Module Name:    pkgsrc
Committed By:   fox
Date:           Sun Sep 15 15:17:06 UTC 2019

Modified Files:
        pkgsrc/devel/py-sysctl: Makefile distinfo
        pkgsrc/devel/py-sysctl/patches: patch-sysctlmodule.c

Log Message:
py-sysctl: Fixes broken tests.

- Fixes the broken test for creating and destroying integer nodes via py-sysctl.
- Bumps PKGREVISION due to the fix.

This addresses the issue mentioned by maya@ in PR pkg/54530

Thanks to christos@ for helping with the fix.

Reveiwed by:    maya


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 pkgsrc/devel/py-sysctl/Makefile
cvs rdiff -u -r1.3 -r1.4 pkgsrc/devel/py-sysctl/distinfo
cvs rdiff -u -r1.1 -r1.2 pkgsrc/devel/py-sysctl/patches/patch-sysctlmodule.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/devel/py-sysctl/Makefile
diff -u pkgsrc/devel/py-sysctl/Makefile:1.7 pkgsrc/devel/py-sysctl/Makefile:1.8
--- pkgsrc/devel/py-sysctl/Makefile:1.7 Mon Sep  9 07:09:47 2019
+++ pkgsrc/devel/py-sysctl/Makefile     Sun Sep 15 15:17:06 2019
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.7 2019/09/09 07:09:47 maya Exp $
+# $NetBSD: Makefile,v 1.8 2019/09/15 15:17:06 fox Exp $
 
 DISTNAME=      py-sysctl-0.1
 PKGNAME=       ${PYPKGPREFIX}-sysctl-0.1
-PKGREVISION=   2
+PKGREVISION=   3
 CATEGORIES=    devel python
 MASTER_SITES=  ftp://ftp.NetBSD.org/pub/NetBSD/misc/cherry/
 

Index: pkgsrc/devel/py-sysctl/distinfo
diff -u pkgsrc/devel/py-sysctl/distinfo:1.3 pkgsrc/devel/py-sysctl/distinfo:1.4
--- pkgsrc/devel/py-sysctl/distinfo:1.3 Mon Sep  9 07:09:47 2019
+++ pkgsrc/devel/py-sysctl/distinfo     Sun Sep 15 15:17:06 2019
@@ -1,9 +1,9 @@
-$NetBSD: distinfo,v 1.3 2019/09/09 07:09:47 maya Exp $
+$NetBSD: distinfo,v 1.4 2019/09/15 15:17:06 fox Exp $
 
 SHA1 (py-sysctl-0.1.tar.gz) = 120483a57fc85790702223317b1e29ece62f5bb0
 RMD160 (py-sysctl-0.1.tar.gz) = 053144711e41f5518efc418795eec5e6e06750a1
 SHA512 (py-sysctl-0.1.tar.gz) = 4b6123625a212364ef5a2a367f13ec32194503b8881248e3909f5958adac05149ed2c22aa49b67468c3d1fc23386c16d97af747b8045b322c749f37d1a086005
 Size (py-sysctl-0.1.tar.gz) = 6746 bytes
 SHA1 (patch-setup.py) = eef1ae1e7a6d60f332514670ebcd1ee08dece131
-SHA1 (patch-sysctlmodule.c) = 55c7cec28080a936022e17f6e599f00b6825011c
+SHA1 (patch-sysctlmodule.c) = fd357f6205341ba7c9585f2788828a6e78ad7cb2
 SHA1 (patch-test.py) = ff610e1eb2371147454861dd80e4d31878ec0ae7

Index: pkgsrc/devel/py-sysctl/patches/patch-sysctlmodule.c
diff -u pkgsrc/devel/py-sysctl/patches/patch-sysctlmodule.c:1.1 pkgsrc/devel/py-sysctl/patches/patch-sysctlmodule.c:1.2
--- pkgsrc/devel/py-sysctl/patches/patch-sysctlmodule.c:1.1     Mon Sep  9 07:09:47 2019
+++ pkgsrc/devel/py-sysctl/patches/patch-sysctlmodule.c Sun Sep 15 15:17:06 2019
@@ -1,13 +1,18 @@
-$NetBSD: patch-sysctlmodule.c,v 1.1 2019/09/09 07:09:47 maya Exp $
+$NetBSD: patch-sysctlmodule.c,v 1.2 2019/09/15 15:17:06 fox Exp $
 
 Port to python 3
 
+Fixes how new integer data is inserted into nodes. It now sets the
+CTL_IMMEDIATE flag and value is placed in sysctl_idata. This fixes
+the failing test for creating and destroying integer type nodes.
+
 --- sysctlmodule.c.orig        2010-04-10 17:41:18.000000000 +0000
 +++ sysctlmodule.c
-@@ -33,6 +33,21 @@
+@@ -33,7 +33,22 @@
  #include <errno.h>
  #include <sys/sysctl.h>
  
+-/* 
 +struct module_state {
 +    PyObject *error;
 +};
@@ -23,9 +28,22 @@ Port to python 3
 +static struct module_state _state;
 +#endif
 +
- /* 
++/*
   * create Python object of type similar to the MIB node 'name'
   * This is basically the laziest way to do this, as we outsource the
+  * type recognition to the sysctl(3) API. Fantastic! :-)
+@@ -94,9 +109,9 @@ node_to_object(const char *name, void *v
+       return o;
+ }
+ 
+-/* 
++/*
+  * SYSCTL_TYPEMASK is used as an error type. This is an implementation
+- * detail. 
++ * detail.
+  */
+ static uint32_t
+ nodetype(char *nodepath)
 @@ -104,14 +119,12 @@ nodetype(char *nodepath)
  
        int rv;
@@ -42,6 +60,15 @@ Port to python 3
        rv = sysctlgetmibinfo(nodepath, NULL, NULL, cname, &csz, &rnode, SYSCTL_VERSION);
  
        if (rv == -1 || rnode == NULL) {
+@@ -133,7 +146,7 @@ nodetype(char *nodepath)
+  * discarded ),  and a new one, with requested string is assigned.
+  *
+  * XXX: This is a workaround for sysctl(3) not allowing strings longer
+- * than the current value. 
++ * than the current value.
+  * See: http://mail-index.netbsd.org/tech-kern/2009/10/22/msg006329.html
+  */
+ 
 @@ -149,7 +162,7 @@ write_sysctl_string(char *name, char *va
        size_t nodelen;
  
@@ -89,6 +116,24 @@ Port to python 3
  
        rv = sysctlbyname(name, NULL, &len, NULL, 0);
  
+@@ -350,7 +361,7 @@ write_sysctl(PyObject *self, PyObject *a
+                       return NULL;
+               }
+ 
+-              /* 
++              /*
+                * Strings are handled specially. We just use
+                * read_sysctl() to record the previous string value.
+                * We ignore and free(oldval)
+@@ -424,7 +435,7 @@ getnewleafname(const char *name, char *c
+ 
+ /*
+  * Get the common prefix of name from what's already in the MIB and
+- * what's been requested 
++ * what's been requested
+  */
+ static void
+ getprefixname(const char *name, char *pname)
 @@ -445,7 +456,7 @@ create_node(const char *name, int ctl_ty
  {
  
@@ -106,7 +151,21 @@ Port to python 3
        /* Check for NULL ptr dereference */
        assert (value != NULL || vlen == 0);
  
-@@ -533,7 +545,7 @@ create_sysctl(PyObject *self, PyObject *
+@@ -504,7 +516,12 @@ create_node(const char *name, int ctl_ty
+       memset(&node, 0, nodelen);
+       node.sysctl_num = CTL_CREATE;
+       node.sysctl_flags = SYSCTL_VERSION | flags | ctl_type;
+-      node.sysctl_data = value;
++      if (ctl_type == CTLTYPE_INT) {
++        node.sysctl_idata = *(int *) value;
++      }
++      else {
++        node.sysctl_data = value;
++      }
+       node.sysctl_size = vlen;
+ 
+       snprintf(node.sysctl_name, csz + 1, cname);
+@@ -533,7 +550,7 @@ create_sysctl(PyObject *self, PyObject *
        const char *typename = NULL;
        size_t typelen = 0;
  
@@ -115,7 +174,7 @@ Port to python 3
  
        /* XXX: Royal mess... needs more thought */
        if (!PyArg_ParseTuple(args, "s|s#O: Incorrect values passed to sysctl.write", &name, &typename, &typelen, &value)) {
-@@ -546,7 +558,7 @@ create_sysctl(PyObject *self, PyObject *
+@@ -546,7 +563,7 @@ create_sysctl(PyObject *self, PyObject *
        }
  
        /* XXX: Arrange to obtain the oldvalue */
@@ -124,12 +183,21 @@ Port to python 3
  
        if ((typename == NULL && typelen == 0)
            || (!strncmp(typename, "CTLTYPE_NODE", typelen)) ) {
-@@ -593,7 +605,12 @@ create_sysctl(PyObject *self, PyObject *
+@@ -578,7 +595,7 @@ create_sysctl(PyObject *self, PyObject *
+                       }
+               }
+ 
+-              if (!create_node(name, CTLTYPE_INT, CTLFLAG_READWRITE, &intval, sizeof intval)) {
++              if (!create_node(name, CTLTYPE_INT, CTLFLAG_READWRITE|CTLFLAG_IMMEDIATE, &intval, sizeof intval)) {
+                       return NULL;
+               } else {
+                       Py_RETURN_NONE;
+@@ -593,7 +610,12 @@ create_sysctl(PyObject *self, PyObject *
                                PyErr_SetString(PyExc_TypeError, "Value passed is of wrong type");
                                return NULL;
                        }
 +#if PY_MAJOR_VERSION >= 3
-+                      strval = PyUnicode_AsUTF8AndSize(value, &vlen);
++                      strval = (char *) PyUnicode_AsUTF8AndSize(value, &vlen);
 +                      if (strval == NULL) {
 +#else
                        if (-1 == PyString_AsStringAndSize(value, &strval, &vlen)) {
@@ -137,7 +205,19 @@ Port to python 3
                                PyErr_SetString(PyExc_TypeError, "Error decoding string from buffer \n");
                                return NULL;
                        }
-@@ -694,8 +711,61 @@ static PyMethodDef sysctl_methods[] = {
+@@ -682,9 +704,9 @@ destroy_sysctl(PyObject *self, PyObject 
+ }
+ 
+ static PyMethodDef sysctl_methods[] = {
+-      { "read", read_sysctl, METH_VARARGS, 
++      { "read", read_sysctl, METH_VARARGS,
+         "read value from sysctl node." },
+-      { "write", write_sysctl, METH_VARARGS, 
++      { "write", write_sysctl, METH_VARARGS,
+         "write value to sysctl node." },
+       { "create", create_sysctl, METH_VARARGS,
+         "create a sysctl node." },
+@@ -694,8 +716,61 @@ static PyMethodDef sysctl_methods[] = {
  };
  
  



Home | Main Index | Thread Index | Old Index