diff options
| author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2018-10-25 12:49:03 +0000 |
|---|---|---|
| committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2018-10-25 12:49:03 +0000 |
| commit | 1e5525cf6b00bbfe060cc5ddbb47cd59171ae49b (patch) | |
| tree | 4e3804eca6fe6a120b8bc3faaaac6279c72753ad /usr/src/lib | |
| parent | 7d3919ab7a2211492c9de34cc44e9ba9f2262b90 (diff) | |
| parent | 146341134a2d1d0e3b8b8bab1cf2750d28a3cb14 (diff) | |
| download | illumos-joyent-1e5525cf6b00bbfe060cc5ddbb47cd59171ae49b.tar.gz | |
[illumos-gate merge]
commit 146341134a2d1d0e3b8b8bab1cf2750d28a3cb14
9853 loader.efi: pointer targets in passing argument 2 of 'efi_print_global' differ in signedness
commit b31ca8080c8c8d3586fefd04058d800e36a99e56
9890 loader.efi: add poweroff command
commit 54fce4e949f3a6a305a415328f3b07e3bfd2c702
9917 cleanup stale function set_rdattr_params() in nfs4_srv.c
commit e8921a52c53ee69f7b65f054d9b2e886139daa59
9894 Deliver python3 modules
9904 Split python modules out into separate packages
5571 Provide 64-bit python modules
commit e24b44e5c3120c9b5c8e9b7440bc10c8b7413bfb
9879 more should have better screen size detection
Conflicts:
usr/src/tools/env/illumos.sh
Diffstat (limited to 'usr/src/lib')
25 files changed, 509 insertions, 89 deletions
diff --git a/usr/src/lib/pylibbe/Makefile b/usr/src/lib/pylibbe/Makefile index ee2a576b8a..670615ee8c 100644 --- a/usr/src/lib/pylibbe/Makefile +++ b/usr/src/lib/pylibbe/Makefile @@ -22,12 +22,15 @@ # # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright 2012 OmniTI Computer Consulting, Inc. All rights reserved. +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. # include ../Makefile.lib -SUBDIRS= $(MACH) -$(BUILD64)SUBDIRS += $(MACH64) +SUBDIRS= +$(BUILDPY2)SUBDIRS += $(MACH) +$(BUILD64)$(BUILDPY2)SUBDIRS += $(MACH64) +$(BUILD64)$(BUILDPY3)SUBDIRS += py3 XGETTEXT= $(GNUXGETTEXT) XGETFLAGS= $(GNUXGETFLAGS) diff --git a/usr/src/lib/pylibbe/Makefile.com b/usr/src/lib/pylibbe/Makefile.com index 3a2d866213..431bcfea1c 100644 --- a/usr/src/lib/pylibbe/Makefile.com +++ b/usr/src/lib/pylibbe/Makefile.com @@ -22,6 +22,7 @@ # # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright 2012 OmniTI Computer Consulting, Inc. All rights reserved. +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. # LIBRARY = libbe_py.a @@ -30,12 +31,11 @@ OBJECTS = libbe_py.o include ../../Makefile.lib -LIBLINKS = +LIBLINKS = SRCDIR = ../common ROOTLIBDIR= $(ROOT)/usr/lib/python$(PYTHON_VERSION)/vendor-packages ROOTLIBDIR64= $(ROOT)/usr/lib/python$(PYTHON_VERSION)/vendor-packages/64 -PYOBJS= $(PYSRCS:%.py=$(SRCDIR)/%.pyc) -PYFILES= $(PYSRCS) $(PYSRCS:%.py=%.pyc) +PYFILES= $(PYSRCS) ROOTPYBEFILES= $(PYFILES:%=$(ROOTLIBDIR)/%) CSTD= $(CSTD_GNU99) @@ -43,20 +43,17 @@ CSTD= $(CSTD_GNU99) LIBS = $(DYNLIB) LDLIBS += -lbe -lnvpair -lc CFLAGS += $(CCVERBOSE) -CPPFLAGS += -I$(ADJUNCT_PROTO)/usr/include/python$(PYTHON_VERSION) \ - -D_FILE_OFFSET_BITS=64 -I../../libbe/common +CPPFLAGS += -D_FILE_OFFSET_BITS=64 -I../../libbe/common \ + -I$(ADJUNCT_PROTO)/usr/include/python$(PYTHON_VERSION)$(PYTHON_SUFFIX) .KEEP_STATE: -all install := LDLIBS += -lpython$(PYTHON_VERSION) +all install := LDLIBS += -lpython$(PYTHON_VERSION)$(PYTHON_SUFFIX) all: $(PYOBJS) $(LIBS) install: all $(ROOTPYBEFILES) -$(ROOTLIBDIR)/%: % - $(INS.pyfile) - lint: lintcheck include ../../Makefile.targ diff --git a/usr/src/lib/pylibbe/common/libbe_py.c b/usr/src/lib/pylibbe/common/libbe_py.c index fb5102bdb6..3b4a3a3c42 100644 --- a/usr/src/lib/pylibbe/common/libbe_py.c +++ b/usr/src/lib/pylibbe/common/libbe_py.c @@ -60,7 +60,6 @@ PyObject *beUnmount(PyObject *, PyObject *); PyObject *bePrintErrors(PyObject *, PyObject *); PyObject *beGetErrDesc(PyObject *, PyObject *); char *beMapLibbePyErrorToString(int); -void initlibbe_py(); static boolean_t convertBEInfoToDictionary(be_node_list_t *be, PyObject **listDict); @@ -204,8 +203,8 @@ beCopy(PyObject *self, PyObject *args) } while (PyDict_Next(beNameProperties, &pos, &pkey, &pvalue)) { if (!convertPyArgsToNvlist(&beProps, 2, - PyString_AsString(pkey), - PyString_AsString(pvalue))) { + PyBytes_AS_STRING(pkey), + PyBytes_AS_STRING(pvalue))) { nvlist_free(beProps); nvlist_free(beAttrs); return (Py_BuildValue("[iss]", BE_PY_ERR_NVLIST, @@ -833,21 +832,21 @@ convertBEInfoToDictionary(be_node_list_t *be, PyObject **listDict) { if (be->be_node_name != NULL) { if (PyDict_SetItemString(*listDict, BE_ATTR_ORIG_BE_NAME, - PyString_FromString(be->be_node_name)) != 0) { + PyUnicode_FromString(be->be_node_name)) != 0) { return (B_FALSE); } } if (be->be_rpool != NULL) { if (PyDict_SetItemString(*listDict, BE_ATTR_ORIG_BE_POOL, - PyString_FromString(be->be_rpool)) != 0) { + PyUnicode_FromString(be->be_rpool)) != 0) { return (B_FALSE); } } if (be->be_mntpt != NULL) { if (PyDict_SetItemString(*listDict, BE_ATTR_MOUNTPOINT, - PyString_FromString(be->be_mntpt)) != 0) { + PyUnicode_FromString(be->be_mntpt)) != 0) { return (B_FALSE); } } @@ -881,7 +880,7 @@ convertBEInfoToDictionary(be_node_list_t *be, PyObject **listDict) if (be->be_root_ds != NULL) { if (PyDict_SetItemString(*listDict, BE_ATTR_ROOT_DS, - PyString_FromString(be->be_root_ds)) != 0) { + PyUnicode_FromString(be->be_root_ds)) != 0) { return (B_FALSE); } } @@ -895,14 +894,14 @@ convertBEInfoToDictionary(be_node_list_t *be, PyObject **listDict) if (be->be_policy_type != NULL) { if (PyDict_SetItemString(*listDict, BE_ATTR_POLICY, - PyString_FromString(be->be_policy_type)) != 0) { + PyUnicode_FromString(be->be_policy_type)) != 0) { return (B_FALSE); } } if (be->be_uuid_str != NULL) { if (PyDict_SetItemString(*listDict, BE_ATTR_UUID_STR, - PyString_FromString(be->be_uuid_str)) != 0) { + PyUnicode_FromString(be->be_uuid_str)) != 0) { return (B_FALSE); } } @@ -915,7 +914,7 @@ convertDatasetInfoToDictionary(be_dataset_list_t *ds, PyObject **listDict) { if (ds->be_dataset_name != NULL) { if (PyDict_SetItemString(*listDict, BE_ATTR_DATASET, - PyString_FromString(ds->be_dataset_name)) != 0) { + PyUnicode_FromString(ds->be_dataset_name)) != 0) { return (B_FALSE); } } @@ -927,7 +926,7 @@ convertDatasetInfoToDictionary(be_dataset_list_t *ds, PyObject **listDict) if (ds->be_ds_mntpt != NULL) { if (PyDict_SetItemString(*listDict, BE_ATTR_MOUNTPOINT, - PyString_FromString(ds->be_ds_mntpt)) != 0) { + PyUnicode_FromString(ds->be_ds_mntpt)) != 0) { return (B_FALSE); } } @@ -947,14 +946,14 @@ convertDatasetInfoToDictionary(be_dataset_list_t *ds, PyObject **listDict) if (ds->be_dataset_name != 0) { if (PyDict_SetItemString(*listDict, BE_ATTR_DATASET, - PyString_FromString(ds->be_dataset_name)) != 0) { + PyUnicode_FromString(ds->be_dataset_name)) != 0) { return (B_FALSE); } } if (ds->be_ds_plcy_type != NULL) { if (PyDict_SetItemString(*listDict, BE_ATTR_POLICY, - PyString_FromString(ds->be_ds_plcy_type)) != 0) { + PyUnicode_FromString(ds->be_ds_plcy_type)) != 0) { return (B_FALSE); } } @@ -974,7 +973,7 @@ convertSnapshotInfoToDictionary(be_snapshot_list_t *ss, PyObject **listDict) { if (ss->be_snapshot_name != NULL) { if (PyDict_SetItemString(*listDict, BE_ATTR_SNAP_NAME, - PyString_FromString(ss->be_snapshot_name)) != 0) { + PyUnicode_FromString(ss->be_snapshot_name)) != 0) { return (B_FALSE); } } @@ -988,7 +987,7 @@ convertSnapshotInfoToDictionary(be_snapshot_list_t *ss, PyObject **listDict) if (ss->be_snapshot_type != NULL) { if (PyDict_SetItemString(*listDict, BE_ATTR_POLICY, - PyString_FromString(ss->be_snapshot_type)) != 0) { + PyUnicode_FromString(ss->be_snapshot_type)) != 0) { return (B_FALSE); } } @@ -1103,9 +1102,42 @@ static struct PyMethodDef libbeMethods[] = { {NULL, NULL, 0, NULL} }; -void -initlibbe_py() +#if PY_MAJOR_VERSION >= 3 +static struct PyModuleDef libbe_module = { + PyModuleDef_HEAD_INIT, + "libbe_py", + NULL, + -1, + libbeMethods +}; +#endif + +static PyObject * +moduleinit() { /* PyMODINIT_FUNC; */ +#if PY_MAJOR_VERSION >= 3 + return (PyModule_Create(&libbe_module)); +#else + /* + * Python2 module initialisation functions are void and may not return + * a value. However, they will set an exception if appropriate. + */ (void) Py_InitModule("libbe_py", libbeMethods); + return (NULL); +#endif +} + +#if PY_MAJOR_VERSION >= 3 +PyMODINIT_FUNC +PyInit_libbe_py(void) +{ + return (moduleinit()); +} +#else +PyMODINIT_FUNC +initlibbe_py(void) +{ + (void) moduleinit(); } +#endif diff --git a/usr/src/lib/pylibbe/common/mapfile-py3 b/usr/src/lib/pylibbe/common/mapfile-py3 new file mode 100644 index 0000000000..ea39f9cfd8 --- /dev/null +++ b/usr/src/lib/pylibbe/common/mapfile-py3 @@ -0,0 +1,47 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. +# + +# +# MAPFILE HEADER START +# +# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. +# Object versioning must comply with the rules detailed in +# +# usr/src/lib/README.mapfiles +# +# You should not be making modifications here until you've read the most current +# copy of that file. If you need help, contact a gatekeeper for guidance. +# +# MAPFILE HEADER END +# + +$mapfile_version 2 + +SYMBOL_VERSION SUNWprivate { + global: + PyInit_libbe_py; + local: + *; +}; diff --git a/usr/src/lib/pylibbe/py3/Makefile b/usr/src/lib/pylibbe/py3/Makefile new file mode 100644 index 0000000000..d146f8c62c --- /dev/null +++ b/usr/src/lib/pylibbe/py3/Makefile @@ -0,0 +1,28 @@ +# CDDL HEADER START +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# CDDL HEADER END + +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. + +include ../Makefile.com +include ../../Makefile.lib.64 + +PYTHON = $(PYTHON3) +PYTHON_VERSION = $(PYTHON3_VERSION) +PYTHON_SUFFIX = $(PYTHON3_SUFFIX) +LDLIBS64 += -L$(ADJUNCT_PROTO)/usr/lib/$(MACH64) +MAPFILES = $(SRCDIR)/mapfile-py3 +$(ROOTLIBDIR)/$(DYNLIB) := FILEMODE= 755 + +$(ROOTLIBS): + $(INS.file) $(DYNLIB) + +install: all $(ROOTLIBS) diff --git a/usr/src/lib/pysolaris/Makefile b/usr/src/lib/pysolaris/Makefile index df3d21faa4..2c588428c3 100644 --- a/usr/src/lib/pysolaris/Makefile +++ b/usr/src/lib/pysolaris/Makefile @@ -21,11 +21,15 @@ # # Copyright 2010 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. # include ../Makefile.lib -SUBDIRS= $(MACH) +SUBDIRS= +$(BUILDPY2)SUBDIRS += $(MACH) +$(BUILD64)$(BUILDPY2)SUBDIRS += $(MACH64) +$(BUILD64)$(BUILDPY3)SUBDIRS += py3 all := TARGET= all install := TARGET= install @@ -34,7 +38,7 @@ clobber := TARGET= clobber lint := TARGET= lint PYCFIND = $(FIND) . -name '*.pyc' -PYCFILES = $(PYCFIND:sh) +PYCFILES = $(PYCFIND:sh) .KEEP_STATE: diff --git a/usr/src/lib/pysolaris/Makefile.com b/usr/src/lib/pysolaris/Makefile.com index 4a70113ab4..3d4c4777ce 100644 --- a/usr/src/lib/pysolaris/Makefile.com +++ b/usr/src/lib/pysolaris/Makefile.com @@ -20,6 +20,7 @@ # # # Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. # LIBRARY = misc.a @@ -30,28 +31,28 @@ PYSRCS= __init__.py include ../../Makefile.lib -LIBLINKS = +LIBLINKS = SRCDIR = ../common ROOTLIBDIR= $(ROOT)/usr/lib/python$(PYTHON_VERSION)/vendor-packages/solaris +ROOTLIBDIR64= $(ROOTLIBDIR)/64 PYOBJS= $(PYSRCS:%.py=$(SRCDIR)/%.pyc) PYFILES= $(PYSRCS) $(PYSRCS:%.py=%.pyc) -ROOTPYSOLFILES= $(PYFILES:%=$(ROOTLIBDIR)/%) +ROOTPYSOLFILES= $(PYFILES:%=$(ROOTLIBDIR)/%) -CSTD= $(CSTD_GNU99) -C99LMODE= -Xc99=%all +CSTD= $(CSTD_GNU99) +C99LMODE= -Xc99=%all LIBS = $(DYNLIB) -LDLIBS += -lc -lsec -lidmap -lpython$(PYTHON_VERSION) +LDLIBS += -lc -lsec -lidmap -lpython$(PYTHON_VERSION)$(PYTHON_SUFFIX) CFLAGS += $(CCVERBOSE) CPPFLAGS += -I$(ADJUNCT_PROTO)/usr/include/python2.6 CERRWARN += -_gcc=-Wno-unused-variable -CPPFLAGS += -I$(ADJUNCT_PROTO)/usr/include/python$(PYTHON_VERSION) +CPPFLAGS += \ + -I$(ADJUNCT_PROTO)/usr/include/python$(PYTHON_VERSION)$(PYTHON_SUFFIX) -.KEEP_STATE: - -all: $(PYOBJS) $(LIBS) +all: -install: all $(ROOTPYSOLFILES) +.KEEP_STATE: $(ROOTLIBDIR)/%: % $(INS.pyfile) diff --git a/usr/src/lib/pysolaris/amd64/Makefile b/usr/src/lib/pysolaris/amd64/Makefile new file mode 100644 index 0000000000..4fa33a90bd --- /dev/null +++ b/usr/src/lib/pysolaris/amd64/Makefile @@ -0,0 +1,23 @@ +# +# CDDL HEADER START +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# +# CDDL HEADER END + +# +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. +# + +include ../Makefile.com +include ../../Makefile.lib.64 + +all: $(LIBS) +install: all $(ROOTLIBS64) diff --git a/usr/src/lib/pysolaris/common/mapfile-py3 b/usr/src/lib/pysolaris/common/mapfile-py3 new file mode 100644 index 0000000000..6e14724a62 --- /dev/null +++ b/usr/src/lib/pysolaris/common/mapfile-py3 @@ -0,0 +1,47 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. +# + +# +# MAPFILE HEADER START +# +# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. +# Object versioning must comply with the rules detailed in +# +# usr/src/lib/README.mapfiles +# +# You should not be making modifications here until you've read the most current +# copy of that file. If you need help, contact a gatekeeper for guidance. +# +# MAPFILE HEADER END +# + +$mapfile_version 2 + +SYMBOL_VERSION SUNWprivate { + global: + PyInit_misc; + local: + *; +}; diff --git a/usr/src/lib/pysolaris/common/misc.c b/usr/src/lib/pysolaris/common/misc.c index 13280d461f..211ab1b983 100644 --- a/usr/src/lib/pysolaris/common/misc.c +++ b/usr/src/lib/pysolaris/common/misc.c @@ -21,6 +21,7 @@ /* * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. */ #include <Python.h> @@ -85,7 +86,7 @@ py_sid_to_name(PyObject *self, PyObject *args) return (NULL); } - ret = PyString_FromString(name); + ret = PyUnicode_FromString(name); free(name); return (ret); } @@ -121,8 +122,37 @@ static PyMethodDef solarismethods[] = { {NULL, NULL, 0, NULL} }; -void +#if PY_MAJOR_VERSION >= 3 +static struct PyModuleDef solaris_module = { + PyModuleDef_HEAD_INIT, + "solaris.misc", + NULL, + -1, + solarismethods +}; +#endif + +static PyObject * +moduleinit() +{ +#if PY_MAJOR_VERSION >= 3 + return (PyModule_Create(&solaris_module)); +#else + (void) Py_InitModule("solaris.misc", solarismethods); + return (NULL); +#endif +} + +#if PY_MAJOR_VERSION >= 3 +PyMODINIT_FUNC +PyInit_misc(void) +{ + return (moduleinit()); +} +#else +PyMODINIT_FUNC initmisc(void) { - PyObject *solaris_misc = Py_InitModule("solaris.misc", solarismethods); + (void) moduleinit(); } +#endif diff --git a/usr/src/lib/pysolaris/i386/Makefile b/usr/src/lib/pysolaris/i386/Makefile index cf68e8eb6d..926da3004e 100644 --- a/usr/src/lib/pysolaris/i386/Makefile +++ b/usr/src/lib/pysolaris/i386/Makefile @@ -20,8 +20,10 @@ # # Copyright 2010 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. # include ../Makefile.com -install: all $(ROOTLIBS) +all: $(PYOBJS) $(LIBS) +install: all $(ROOTPYSOLFILES) $(ROOTLIBS) diff --git a/usr/src/lib/pysolaris/py3/Makefile b/usr/src/lib/pysolaris/py3/Makefile new file mode 100644 index 0000000000..700cc16ca5 --- /dev/null +++ b/usr/src/lib/pysolaris/py3/Makefile @@ -0,0 +1,37 @@ +# CDDL HEADER START +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# +# CDDL HEADER END + +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. + +include ../Makefile.com +include ../../Makefile.lib.64 + +PYTHON = $(PYTHON3) +PYTHON_VERSION = $(PYTHON3_VERSION) +PYTHON_SUFFIX = $(PYTHON3_SUFFIX) + +LDLIBS64 += -L$(ADJUNCT_PROTO)/usr/lib/$(MACH64) +MAPFILES= $(SRCDIR)/mapfile-py3 +ROOTPYSOLFILES= $(PYSRCS:%=$(ROOTLIBDIR)/%) +$(ROOTLIBDIR)/$(DYNLIB) := FILEMODE= 755 + +all: $(LIBS) +install: all $(ROOTLIBS) $(ROOTPYSOLFILES) + +$(ROOTLIBDIR)/%.so: %.so + $(INS.file) + +$(ROOTLIBDIR)/%: ../common/% + $(INS.pyfile) + $(PYTHON) -mpy_compile $@ + diff --git a/usr/src/lib/pyzfs/Makefile b/usr/src/lib/pyzfs/Makefile index c69270f58f..2cf7b8a517 100644 --- a/usr/src/lib/pyzfs/Makefile +++ b/usr/src/lib/pyzfs/Makefile @@ -21,11 +21,15 @@ # # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. # include ../Makefile.lib -SUBDIRS= $(MACH) +SUBDIRS= +$(BUILDPY2)SUBDIRS += $(MACH) +$(BUILD64)$(BUILDPY2)SUBDIRS += $(MACH64) +$(BUILD64)$(BUILDPY3)SUBDIRS += py3 XGETTEXT= $(GNUXGETTEXT) XGETFLAGS= $(GNUXGETFLAGS) @@ -38,7 +42,7 @@ lint := TARGET= lint MSGFIND = $(FIND) . -name '*.py' -o -name '*.c' MSGFILES = $(MSGFIND:sh) PYCFIND = $(FIND) . -name '*.pyc' -PYCFILES = $(PYCFIND:sh) +PYCFILES = $(PYCFIND:sh) POFILE = pyzfs.po .KEEP_STATE: diff --git a/usr/src/lib/pyzfs/Makefile.com b/usr/src/lib/pyzfs/Makefile.com index 59720a8334..347b4316eb 100644 --- a/usr/src/lib/pyzfs/Makefile.com +++ b/usr/src/lib/pyzfs/Makefile.com @@ -20,6 +20,7 @@ # # # Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. # LIBRARY = ioctl.a @@ -27,15 +28,15 @@ VERS = OBJECTS = ioctl.o PYSRCS= __init__.py util.py dataset.py \ - allow.py unallow.py \ - userspace.py groupspace.py holds.py table.py - + allow.py unallow.py \ + userspace.py groupspace.py holds.py table.py include ../../Makefile.lib -LIBLINKS = +LIBLINKS = SRCDIR = ../common ROOTLIBDIR= $(ROOT)/usr/lib/python$(PYTHON_VERSION)/vendor-packages/zfs +ROOTLIBDIR64= $(ROOTLIBDIR)/64 PYOBJS= $(PYSRCS:%.py=$(SRCDIR)/%.pyc) PYFILES= $(PYSRCS) $(PYSRCS:%.py=%.pyc) ROOTPYZFSFILES= $(PYFILES:%=$(ROOTLIBDIR)/%) @@ -44,18 +45,17 @@ CSTD= $(CSTD_GNU99) C99LMODE= -Xc99=%all LIBS = $(DYNLIB) -LDLIBS += -lc -lnvpair -lpython$(PYTHON_VERSION) -lzfs +LDLIBS += -lc -lnvpair -lpython$(PYTHON_VERSION)$(PYTHON_SUFFIX) -lzfs CFLAGS += $(CCVERBOSE) CERRWARN += -_gcc=-Wno-unused-variable -CPPFLAGS += -I$(ADJUNCT_PROTO)/usr/include/python$(PYTHON_VERSION) +CPPFLAGS += \ + -I$(ADJUNCT_PROTO)/usr/include/python$(PYTHON_VERSION)$(PYTHON_SUFFIX) CPPFLAGS += -I../../../uts/common/fs/zfs CPPFLAGS += -I../../../common/zfs .KEEP_STATE: -all: $(PYOBJS) $(LIBS) - -install: all $(ROOTPYZFSFILES) +all: $(ROOTLIBDIR)/%: % $(INS.pyfile) @@ -63,6 +63,12 @@ $(ROOTLIBDIR)/%: % $(ROOTLIBDIR)/%: ../common/% $(INS.pyfile) +$(ROOTLIBDIR64)/%: % + $(INS.pyfile) + +$(ROOTLIBDIR64)/%: ../common/% + $(INS.pyfile) + lint: lintcheck include ../../Makefile.targ diff --git a/usr/src/lib/pyzfs/amd64/Makefile b/usr/src/lib/pyzfs/amd64/Makefile new file mode 100644 index 0000000000..f3fde27d22 --- /dev/null +++ b/usr/src/lib/pyzfs/amd64/Makefile @@ -0,0 +1,21 @@ +# CDDL HEADER START +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# CDDL HEADER END + +# +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. +# + +include ../Makefile.com +include ../../Makefile.lib.64 + +all: $(LIBS) +install: all $(ROOTLIBS64) diff --git a/usr/src/lib/pyzfs/common/allow.py b/usr/src/lib/pyzfs/common/allow.py index 2c01280b4b..91d4834679 100644 --- a/usr/src/lib/pyzfs/common/allow.py +++ b/usr/src/lib/pyzfs/common/allow.py @@ -21,6 +21,7 @@ # # Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2013 by Delphix. All rights reserved. +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. # """This module implements the "zfs allow" and "zfs unallow" subcommands. @@ -146,7 +147,7 @@ def args_to_perms(parser, options, who, perms): baseperms = None d = dict() - + def storeperm(typechr, inheritchr, arg): assert typechr in "ugecs" assert inheritchr in "ld-" @@ -251,20 +252,20 @@ def canonicalized_perm(permname): except KeyError: raise zfs.util.ZFSError(errno.EINVAL, permname, _("invalid permission")) - + def print_perms(): """Print the set of supported permissions.""" print(_("\nThe following permissions are supported:\n")) fmt = "%-16s %-14s\t%s" print(fmt % (_("NAME"), _("TYPE"), _("NOTES"))) - for (name, note) in sorted(perms_subcmd.iteritems()): + for (name, note) in sorted(perms_subcmd.items()): print(fmt % (name, _("subcommand"), note)) - for (name, note) in sorted(perms_other.iteritems()): + for (name, note) in sorted(perms_other.items()): print(fmt % (name, _("other"), note)) - for (name, prop) in sorted(zfs.dataset.proptable.iteritems()): + for (name, prop) in sorted(zfs.dataset.proptable.items()): if prop.visible and prop.delegatable(): print(fmt % (name, _("property"), "")) @@ -335,7 +336,6 @@ def do_allow(): print(s + "-" * (70-len(s))) print(p[fs]) return - (options, args) = parser.parse_args(sys.argv[2:]) diff --git a/usr/src/lib/pyzfs/common/dataset.py b/usr/src/lib/pyzfs/common/dataset.py index 9d4652235a..752449486f 100644 --- a/usr/src/lib/pyzfs/common/dataset.py +++ b/usr/src/lib/pyzfs/common/dataset.py @@ -20,6 +20,7 @@ # CDDL HEADER END # # Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. # """Implements the Dataset class, providing methods for manipulating ZFS @@ -69,7 +70,7 @@ class Property(object): return self.attr != "readonly" proptable = dict() -for name, t in zfs.ioctl.get_proptable().iteritems(): +for name, t in zfs.ioctl.get_proptable().items(): proptable[name] = Property(t) del name, t @@ -79,7 +80,7 @@ def getpropobj(name): try: return proptable[name] except KeyError: - for p in proptable.itervalues(): + for p in proptable.values(): if p.colname and p.colname.lower() == name: return p raise @@ -90,7 +91,7 @@ class Dataset(object): Generally, this class provides interfaces to the C functions in zfs.ioctl which actually interface with the kernel to manipulate datasets. - + Unless otherwise noted, any method can raise a ZFSError to indicate failure.""" @@ -101,7 +102,7 @@ class Dataset(object): types=("filesystem", "volume"), snaps=True): """Open the named dataset, checking that it exists and is of the specified type. - + name is the string name of this dataset. props is the property settings dict from zfs.ioctl.next_dataset. @@ -137,7 +138,7 @@ class Dataset(object): Currently only works for native properties (those with a Property object.) - + Raises KeyError if propname does not specify a native property. Does not raise ZFSError. """ @@ -165,7 +166,7 @@ class Dataset(object): yield ds for child in ds.descendents(): yield child - + def userspace(self, prop): """A generator function which iterates over a userspace-type property. @@ -177,14 +178,14 @@ class Dataset(object): """ d = zfs.ioctl.userspace_many(self.name, prop) - for ((domain, rid), space) in d.iteritems(): + for ((domain, rid), space) in d.items(): yield (domain, rid, space) def userspace_upgrade(self): """Initialize the accounting information for userused@... and groupused@... properties.""" return zfs.ioctl.userspace_upgrade(self.name) - + def set_fsacl(self, un, d): """Add to the "zfs allow"-ed permissions on this Dataset. @@ -219,7 +220,7 @@ def snapshots_fromcmdline(dsnames, recursive): try: ds = Dataset(dsname) yield ds - except zfs.util.ZFSError, e: + except zfs.util.ZFSError as e: if not recursive or e.errno != errno.ENOENT: raise if recursive: @@ -229,6 +230,6 @@ def snapshots_fromcmdline(dsnames, recursive): try: yield Dataset(child.name + "@" + snapname) - except zfs.util.ZFSError, e: + except zfs.util.ZFSError as e: if e.errno != errno.ENOENT: raise diff --git a/usr/src/lib/pyzfs/common/holds.py b/usr/src/lib/pyzfs/common/holds.py index 0a1508e76a..63645e329c 100644 --- a/usr/src/lib/pyzfs/common/holds.py +++ b/usr/src/lib/pyzfs/common/holds.py @@ -20,6 +20,7 @@ # CDDL HEADER END # # Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. # """This module implements the "zfs holds" subcommand. @@ -59,12 +60,12 @@ def do_holds(): fields = ("name", "tag", "timestamp") rjustfields = () - printing = False + printing = False gotone = False - t = zfs.table.Table(fields, rjustfields) + t = zfs.table.Table(fields, rjustfields) for ds in zfs.dataset.snapshots_fromcmdline(args, options.recursive): gotone = True - for tag, tm in ds.get_holds().iteritems(): + for tag, tm in ds.get_holds().items(): val = {"name": ds.name, "tag": tag, "timestamp": time.ctime(tm)} t.addline(ds.name, val) diff --git a/usr/src/lib/pyzfs/common/ioctl.c b/usr/src/lib/pyzfs/common/ioctl.c index d8c0d18679..55c03fc2b8 100644 --- a/usr/src/lib/pyzfs/common/ioctl.c +++ b/usr/src/lib/pyzfs/common/ioctl.c @@ -21,6 +21,7 @@ /* * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. */ #include <Python.h> @@ -131,7 +132,7 @@ dict2nvl(PyObject *d) nvlist_t *nvl; int err; PyObject *key, *value; - int pos = 0; + Py_ssize_t pos = 0; if (!PyDict_Check(d)) { PyErr_SetObject(PyExc_ValueError, d); @@ -142,7 +143,11 @@ dict2nvl(PyObject *d) assert(err == 0); while (PyDict_Next(d, &pos, &key, &value)) { +#if PY_MAJOR_VERSION >= 3 + char *keystr = PyBytes_AsString(key); +#else char *keystr = PyString_AsString(key); +#endif if (keystr == NULL) { PyErr_SetObject(PyExc_KeyError, key); nvlist_free(nvl); @@ -155,11 +160,19 @@ dict2nvl(PyObject *d) nvlist_free(valnvl); } else if (value == Py_None) { err = nvlist_add_boolean(nvl, keystr); +#if PY_MAJOR_VERSION >= 3 + } else if (PyBytes_Check(value)) { +#else } else if (PyString_Check(value)) { +#endif +#if PY_MAJOR_VERSION >= 3 + char *valstr = PyBytes_AsString(value); +#else char *valstr = PyString_AsString(value); +#endif err = nvlist_add_string(nvl, keystr, valstr); - } else if (PyInt_Check(value)) { - uint64_t valint = PyInt_AsUnsignedLongLongMask(value); + } else if (PyLong_Check(value)) { + uint64_t valint = PyLong_AsUnsignedLongLongMask(value); err = nvlist_add_uint64(nvl, keystr, valint); } else if (PyBool_Check(value)) { boolean_t valbool = value == Py_True ? B_TRUE : B_FALSE; @@ -525,19 +538,49 @@ static PyMethodDef zfsmethods[] = { {NULL, NULL, 0, NULL} }; -void -initioctl(void) +#if PY_MAJOR_VERSION >= 3 +static struct PyModuleDef zfs_module = { + PyModuleDef_HEAD_INIT, + "zfs.ioctl", + NULL, + -1, + zfsmethods +}; +#endif + +static PyObject * +moduleinit() { - PyObject *zfs_ioctl = Py_InitModule("zfs.ioctl", zfsmethods); - PyObject *zfs_util = PyImport_ImportModule("zfs.util"); - PyObject *devfile; + PyObject *zfs_ioctl, *zfs_util, *devfile; +#if PY_MAJOR_VERSION >= 3 + zfs_ioctl = PyModule_Create(&zfs_module); +#else + zfs_ioctl = Py_InitModule("zfs.ioctl", zfsmethods); +#endif + zfs_util = PyImport_ImportModule("zfs.util"); if (zfs_util == NULL) - return; + return (NULL); ZFSError = PyObject_GetAttrString(zfs_util, "ZFSError"); devfile = PyObject_GetAttrString(zfs_util, "dev"); zfsdevfd = PyObject_AsFileDescriptor(devfile); zfs_prop_init(); + + return (zfs_ioctl); +} + +#if PY_MAJOR_VERSION >= 3 +PyMODINIT_FUNC +PyInit_ioctl(void) +{ + return (moduleinit()); } +#else +PyMODINIT_FUNC +initioctl(void) +{ + (void) moduleinit(); +} +#endif diff --git a/usr/src/lib/pyzfs/common/mapfile-py3 b/usr/src/lib/pyzfs/common/mapfile-py3 new file mode 100644 index 0000000000..a45e760e01 --- /dev/null +++ b/usr/src/lib/pyzfs/common/mapfile-py3 @@ -0,0 +1,47 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. +# + +# +# MAPFILE HEADER START +# +# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. +# Object versioning must comply with the rules detailed in +# +# usr/src/lib/README.mapfiles +# +# You should not be making modifications here until you've read the most current +# copy of that file. If you need help, contact a gatekeeper for guidance. +# +# MAPFILE HEADER END +# + +$mapfile_version 2 + +SYMBOL_VERSION SUNWprivate { + global: + PyInit_ioctl; + local: + *; +}; diff --git a/usr/src/lib/pyzfs/common/table.py b/usr/src/lib/pyzfs/common/table.py index 87aab1d6f1..173f06b5a0 100644 --- a/usr/src/lib/pyzfs/common/table.py +++ b/usr/src/lib/pyzfs/common/table.py @@ -20,6 +20,7 @@ # CDDL HEADER END # # Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. # import zfs.util @@ -34,7 +35,7 @@ class Table: self.rjustfields = rjustfields self.maxfieldlen = dict.fromkeys(fields, 0) self.lines = list() - + def __updatemax(self, k, v): self.maxfieldlen[k] = max(self.maxfieldlen.get(k, None), v) @@ -46,6 +47,8 @@ class Table: v = str(values[f]) va.append(v) self.__updatemax(f, len(v)) + if sortkey == None: + sortkey = [] self.lines.append((sortkey, va)) def printme(self, headers=True): diff --git a/usr/src/lib/pyzfs/common/userspace.py b/usr/src/lib/pyzfs/common/userspace.py index 79355e1e23..89cc18b241 100644 --- a/usr/src/lib/pyzfs/common/userspace.py +++ b/usr/src/lib/pyzfs/common/userspace.py @@ -20,6 +20,7 @@ # CDDL HEADER END # # Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. # """This module implements the "zfs userspace" and "zfs groupspace" subcommands. @@ -115,7 +116,7 @@ def process_one_raw(acct, options, prop, elem): except KeyError: pass; key = (isgroup, domain, rid) - + try: v = acct[key] except KeyError: @@ -241,6 +242,6 @@ def do_userspace(): return l t = zfs.table.Table(options.fields, rjustfields) - for val in acct.itervalues(): + for val in acct.values(): t.addline(cmpkey(val), val) t.printme(not options.noheaders) diff --git a/usr/src/lib/pyzfs/common/util.py b/usr/src/lib/pyzfs/common/util.py index cfc21ac57c..f384501c11 100644 --- a/usr/src/lib/pyzfs/common/util.py +++ b/usr/src/lib/pyzfs/common/util.py @@ -20,6 +20,7 @@ # CDDL HEADER END # # Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. # """This module provides utility functions for ZFS. @@ -54,11 +55,11 @@ def default_repr(self): return "<%s %s>" % \ (self.__class__.__name__, repr(self.__dict__)) -class ZFSError(StandardError): +class ZFSError(Exception): """This exception class represents a potentially user-visible ZFS error. If uncaught, it will be printed and the process will exit with exit code 1. - + errno -- the error number (eg, from ioctl(2)).""" __slots__ = "why", "task", "errno" diff --git a/usr/src/lib/pyzfs/i386/Makefile b/usr/src/lib/pyzfs/i386/Makefile index 4ce880c2ae..82d8120e69 100644 --- a/usr/src/lib/pyzfs/i386/Makefile +++ b/usr/src/lib/pyzfs/i386/Makefile @@ -20,8 +20,10 @@ # # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. # include ../Makefile.com -install: all $(ROOTLIBS) +all: $(PBOJECT) $(LIBS) +install: all $(ROOTPYZFSFILES) $(ROOTLIBS) diff --git a/usr/src/lib/pyzfs/py3/Makefile b/usr/src/lib/pyzfs/py3/Makefile new file mode 100644 index 0000000000..27e04f084e --- /dev/null +++ b/usr/src/lib/pyzfs/py3/Makefile @@ -0,0 +1,39 @@ +# CDDL HEADER START +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# +# CDDL HEADER END + +# +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. +# + +include ../Makefile.com +include ../../Makefile.lib.64 + +PYTHON = $(PYTHON3) +PYTHON_VERSION = $(PYTHON3_VERSION) +PYTHON_SUFFIX = $(PYTHON3_SUFFIX) + +LDLIBS64 += -L$(ADJUNCT_PROTO)/usr/lib/$(MACH64) +MAPFILES= $(SRCDIR)/mapfile-py3 +ROOTPYZFSFILES= $(PYSRCS:%=$(ROOTLIBDIR)/%) +$(ROOTLIBDIR)/$(DYNLIB) := FILEMODE= 755 + +all: $(LIBS) +install: all $(ROOTLIBS) $(ROOTPYZFSFILES) + +$(ROOTLIBDIR)/%.so: %.so + $(INS.file) + +$(ROOTLIBDIR)/%: ../common/% + $(INS.pyfile) + $(PYTHON) -mpy_compile $@ + |
