changeset 20604:76b6299aa623

Merge illumos-gate
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Sun, 05 May 2019 16:25:23 -0400
parents e1ed8d6406d3 (current diff) 628a13d9b7eb (diff)
children 9b9c078a243b
files tools/env.sh usr/src/Makefile.master usr/src/pkg/Makefile usr/src/pkg/manifests/developer-build-onbld.mf usr/src/tools/Makefile usr/src/tools/onbld/Checks/Makefile usr/src/tools/onbld/Checks/Makefile.com usr/src/tools/onbld/Makefile.com usr/src/tools/onbld/Scm/Makefile.com usr/src/tools/onbld/py2/Makefile usr/src/tools/scripts/git-pbchk.py usr/src/tools/scripts/wscheck.py usr/src/tools/scripts/wsdiff.py
diffstat 34 files changed, 990 insertions(+), 436 deletions(-) [+]
line wrap: on
line diff
--- a/tools/env.sh	Mon May 13 09:59:03 2019 +0000
+++ b/tools/env.sh	Sun May 05 16:25:23 2019 -0400
@@ -87,3 +87,4 @@
 
 # Don't build python 3 versions of libs.
 export BUILDPY3='#'
+export BUILDPY3TOOLS='#'
--- a/usr/src/Makefile.master	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/Makefile.master	Sun May 05 16:25:23 2019 -0400
@@ -144,6 +144,8 @@
 PYTHON3_PKGVERS=	-35
 PYTHON3_SUFFIX=		m
 PYTHON3=		/usr/bin/python$(PYTHON3_VERSION)
+$(BUILDPY3TOOLS)TOOLS_PYTHON=		$(PYTHON3)
+$(BUILDPY2TOOLS)TOOLS_PYTHON=		$(PYTHON)
 SORT=		/usr/bin/sort
 TOUCH=		/usr/bin/touch
 WC=		/usr/bin/wc
@@ -214,7 +216,10 @@
 # files we must make certain to not adjust the mtime of the source
 # (.py) file.
 #
-INS.pyfile=	$(RM) $@; $(SED) -e "1s:^\#!@PYTHON@:\#!$(PYSHEBANG):" < $< > $@; $(CHMOD) $(FILEMODE) $@; $(TOUCH) -r $< $@
+INS.pyfile=	$(RM) $@; $(SED) \
+		-e "1s:^\#!@PYTHON@:\#!$(PYSHEBANG):" \
+		-e "1s:^\#!@TOOLS_PYTHON@:\#!$(TOOLS_PYTHON):" \
+		< $< > $@; $(CHMOD) $(FILEMODE) $@; $(TOUCH) -r $< $@
 
 # MACH must be set in the shell environment per uname -p on the build host
 # More specific architecture variables should be set in lower makefiles.
@@ -887,7 +892,10 @@
 	$(CHMOD) +x $@
 
 .py:
-	$(RM) $@; $(SED) -e "1s:^\#!@PYTHON@:\#!$(PYSHEBANG):" < $< > $@; $(CHMOD) +x $@
+	$(RM) $@; $(SED) \
+		-e "1s:^\#!@PYTHON@:\#!$(PYSHEBANG):" \
+		-e "1s:^\#!@TOOLS_PYTHON@:\#!$(TOOLS_PYTHON):" \
+		< $< > $@; $(CHMOD) +x $@
 
 .py.pyc:
 	$(RM) $@
--- a/usr/src/pkg/Makefile	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/pkg/Makefile	Sun May 05 16:25:23 2019 -0400
@@ -193,6 +193,8 @@
 	PYTHON3_PKGVERS=$(PYTHON3_PKGVERS) \
 	python2_ONLY=$(BUILDPY2) \
 	python3_ONLY=$(BUILDPY3) \
+	python2tools_ONLY=$(BUILDPY2TOOLS) \
+	python3tools_ONLY=$(BUILDPY3TOOLS) \
 	HUMAN_VERSION=$(VERSION)
 
 PKGDEP_TOKENS_i386= \
@@ -266,7 +268,7 @@
 #
 #	PKGSTAT		meaning
 #	----------	----------------------------------------------------
-# 	noincorp	Do not include in incorporation or group package
+#	noincorp	Do not include in incorporation or group package
 #	obsolete	Include in incorporation, but not group package
 #	renamed		Include in incorporation, but not group package
 #	current		Include in incorporation and group package
--- a/usr/src/pkg/manifests/developer-build-onbld.mf	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/pkg/manifests/developer-build-onbld.mf	Sun May 05 16:25:23 2019 -0400
@@ -26,6 +26,7 @@
 # Copyright 2014 Garrett D'Amore <garrett@damore.org>
 # Copyright 2016 Toomas Soome <tsoome@me.com>
 # Copyright 2016 Joyent, Inc.
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
 #
 
 set name=pkg.fmri value=pkg:/developer/build/onbld@$(PKGVERS)
@@ -49,10 +50,22 @@
 dir path=opt/onbld/lib
 dir path=opt/onbld/lib/$(ARCH)
 dir path=opt/onbld/lib/perl
-dir path=opt/onbld/lib/python$(PYTHON_VERSION)
-dir path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld
-dir path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks
-dir path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Scm
+$(python3tools_ONLY)dir path=opt/onbld/lib/python$(PYTHON3_VERSION)
+$(python3tools_ONLY)dir path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld
+$(python3tools_ONLY)dir \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks
+$(python3tools_ONLY)dir \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/__pycache__
+$(python3tools_ONLY)dir path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Scm
+$(python3tools_ONLY)dir \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Scm/__pycache__
+$(python3tools_ONLY)dir \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/__pycache__
+$(python2tools_ONLY)dir path=opt/onbld/lib/python$(PYTHON_VERSION)
+$(python2tools_ONLY)dir path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld
+$(python2tools_ONLY)dir \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks
+$(python2tools_ONLY)dir path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Scm
 dir path=opt/onbld/man
 dir path=opt/onbld/man/man1
 file path=opt/onbld/bin/$(ARCH)/btxld mode=0555
@@ -90,69 +103,203 @@
 file path=opt/onbld/etc/its.reg
 file path=opt/onbld/lib/perl/onbld_elfmod.pm
 file path=opt/onbld/lib/perl/onbld_elfmod_vertype.pm
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/CStyle.py \
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/CStyle.py \
+    mode=0444
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/Cddl.py \
+    mode=0444
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/CmtBlk.py \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/CStyle.pyc \
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/Comments.py \
+    mode=0444
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/Copyright.py \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/Cddl.py mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/Cddl.pyc \
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/DbLookups.py \
+    mode=0444
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/HdrChk.py \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/CmtBlk.py \
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/Keywords.py \
+    mode=0444
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/ManLint.py \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/CmtBlk.pyc \
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/Mapfile.py \
+    mode=0444
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/ProcessCheck.py \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/Comments.py \
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/SpellCheck.py \
+    mode=0444
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/WsCheck.py \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/Comments.pyc \
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/__init__.py \
+    mode=0444
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/__pycache__/CStyle.cpython$(PYTHON3_PKGVERS).pyc \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/Copyright.py \
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/__pycache__/Cddl.cpython$(PYTHON3_PKGVERS).pyc \
+    mode=0444
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/__pycache__/CmtBlk.cpython$(PYTHON3_PKGVERS).pyc \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/Copyright.pyc \
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/__pycache__/Comments.cpython$(PYTHON3_PKGVERS).pyc \
+    mode=0444
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/__pycache__/Copyright.cpython$(PYTHON3_PKGVERS).pyc \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/DbLookups.py \
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/__pycache__/DbLookups.cpython$(PYTHON3_PKGVERS).pyc \
+    mode=0444
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/__pycache__/HdrChk.cpython$(PYTHON3_PKGVERS).pyc \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/DbLookups.pyc \
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/__pycache__/Keywords.cpython$(PYTHON3_PKGVERS).pyc \
+    mode=0444
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/__pycache__/ManLint.cpython$(PYTHON3_PKGVERS).pyc \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/HdrChk.py \
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/__pycache__/Mapfile.cpython$(PYTHON3_PKGVERS).pyc \
+    mode=0444
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/__pycache__/ProcessCheck.cpython$(PYTHON3_PKGVERS).pyc \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/HdrChk.pyc \
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/__pycache__/SpellCheck.cpython$(PYTHON3_PKGVERS).pyc \
+    mode=0444
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/__pycache__/WsCheck.cpython$(PYTHON3_PKGVERS).pyc \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/Keywords.py \
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Checks/__pycache__/__init__.cpython$(PYTHON3_PKGVERS).pyc \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/Keywords.pyc \
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Scm/Ignore.py mode=0444
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Scm/__init__.py \
+    mode=0444
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Scm/__pycache__/Ignore.cpython$(PYTHON3_PKGVERS).pyc \
+    mode=0444
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/Scm/__pycache__/__init__.cpython$(PYTHON3_PKGVERS).pyc \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/ManLint.py \
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/__init__.py mode=0444
+$(python3tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON3_VERSION)/onbld/__pycache__/__init__.cpython$(PYTHON3_PKGVERS).pyc \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/ManLint.pyc \
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/CStyle.py \
+    mode=0444
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/CStyle.pyc \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/Mapfile.py \
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/Cddl.py mode=0444
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/Cddl.pyc \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/Mapfile.pyc \
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/CmtBlk.py \
+    mode=0444
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/CmtBlk.pyc \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/ProcessCheck.py \
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/Comments.py \
+    mode=0444
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/Comments.pyc \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/ProcessCheck.pyc \
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/Copyright.py \
+    mode=0444
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/Copyright.pyc \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/SpellCheck.py \
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/DbLookups.py \
+    mode=0444
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/DbLookups.pyc \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/SpellCheck.pyc \
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/HdrChk.py \
+    mode=0444
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/HdrChk.pyc \
+    mode=0444
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/Keywords.py \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/WsCheck.py \
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/Keywords.pyc \
+    mode=0444
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/ManLint.py \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/WsCheck.pyc \
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/ManLint.pyc \
+    mode=0444
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/Mapfile.py \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/__init__.py \
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/Mapfile.pyc \
+    mode=0444
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/ProcessCheck.py \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/__init__.pyc \
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/ProcessCheck.pyc \
+    mode=0444
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/SpellCheck.py \
+    mode=0444
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/SpellCheck.pyc \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Scm/Ignore.py mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Scm/Ignore.pyc mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Scm/__init__.py \
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/WsCheck.py \
+    mode=0444
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/WsCheck.pyc \
+    mode=0444
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/__init__.py \
+    mode=0444
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Checks/__init__.pyc \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Scm/__init__.pyc \
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Scm/Ignore.py mode=0444
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Scm/Ignore.pyc mode=0444
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Scm/__init__.py \
     mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/__init__.py mode=0444
-file path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/__init__.pyc mode=0444
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/Scm/__init__.pyc \
+    mode=0444
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/__init__.py mode=0444
+$(python2tools_ONLY)file \
+    path=opt/onbld/lib/python$(PYTHON_VERSION)/onbld/__init__.pyc mode=0444
 file path=opt/onbld/man/man1/Install.1
 file path=opt/onbld/man/man1/btxld.1
 file path=opt/onbld/man/man1/cddlchk.1
@@ -171,5 +318,6 @@
 license cr_Sun license=cr_Sun
 license lic_CDDL license=lic_CDDL
 link path=opt/onbld/bin/git-nits target=git-pbchk
-link path=opt/onbld/lib/python target=python$(PYTHON_VERSION)
+$(python2tools_ONLY)link path=opt/onbld/lib/python \
+    target=python$(PYTHON_VERSION)
 link path=opt/onbld/man/man1/git-nits.1 target=git-pbchk.1
--- a/usr/src/tools/Makefile	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/tools/Makefile	Sun May 05 16:25:23 2019 -0400
@@ -24,6 +24,8 @@
 # Copyright 2014 Garrett D'Amore <garrett@damore.org>
 # Copyright 2016 Toomas Soome <tsoome@me.com>
 # Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
+# Copyright (c) 2019, Joyent, Inc.
+# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
 #
 
 include ../Makefile.master
@@ -56,15 +58,26 @@
 	$(ROOTONBLD)/lib \
 	$(ROOTONBLD)/lib/$(MACH) \
 	$(ROOTONBLD)/lib/perl \
-	$(ROOTONBLD)/lib/python$(PYTHON_VERSION) \
-	$(ROOTONBLD)/lib/python$(PYTHON_VERSION)/onbld \
-	$(ROOTONBLD)/lib/python$(PYTHON_VERSION)/onbld/Checks \
-	$(ROOTONBLD)/lib/python$(PYTHON_VERSION)/onbld/Scm \
 	$(ROOTONBLD)/etc \
 	$(ROOTONBLD)/etc/exception_lists \
 	$(ROOTONBLD)/man \
 	$(ROOTONBLD)/man/man1
 
+$(BUILDPY2TOOLS)ROOTDIRS += \
+	$(ROOTONBLD)/lib/python$(PYTHON_VERSION) \
+	$(ROOTONBLD)/lib/python$(PYTHON_VERSION)/onbld \
+	$(ROOTONBLD)/lib/python$(PYTHON_VERSION)/onbld/Checks \
+	$(ROOTONBLD)/lib/python$(PYTHON_VERSION)/onbld/Scm
+
+$(BUILDPY3TOOLS)ROOTDIRS += \
+	$(ROOTONBLD)/lib/python$(PYTHON3_VERSION) \
+	$(ROOTONBLD)/lib/python$(PYTHON3_VERSION)/onbld \
+	$(ROOTONBLD)/lib/python$(PYTHON3_VERSION)/onbld/__pycache__ \
+	$(ROOTONBLD)/lib/python$(PYTHON3_VERSION)/onbld/Checks \
+	$(ROOTONBLD)/lib/python$(PYTHON3_VERSION)/onbld/Checks/__pycache__ \
+	$(ROOTONBLD)/lib/python$(PYTHON3_VERSION)/onbld/Scm \
+	$(ROOTONBLD)/lib/python$(PYTHON3_VERSION)/onbld/Scm/__pycache__
+
 all :=		TARGET= install
 install :=	TARGET= install
 clean :=	TARGET= clean
@@ -81,7 +94,7 @@
 clobber:= DOROOTDIRS=
 clean:= DOROOTDIRS=
 
-DOROOTONBLDLIBPY= $(ROOTONBLDLIBPY)
+$(BUILDPY2TOOLS)DOROOTONBLDLIBPY= $(ROOTONBLDLIBPY)
 clobber:= DOROOTONBLDLIBPY=
 clean:= DOROOTONBLDLIBPY=
 
--- a/usr/src/tools/Makefile.python	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/tools/Makefile.python	Sun May 05 16:25:23 2019 -0400
@@ -21,6 +21,7 @@
 
 #
 # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
 #
 
 #
@@ -31,12 +32,12 @@
 #
 #    PYSRCS   - List of python source files, these are also delivered as
 #               build product.
-#	      
+#
 #    PYOBJS   - List of compiled python (.pyc) files, with no directory prefix
-#	      
+#
 #    PYTOPDIR - Absolute (including $(ROOT)) path to which files will
 #               be installed, up until the version specific component.
-#	      
+#
 #    PYMODDIR - Relative path to which files will be installed, below
 #               the version specific component.
 #
@@ -63,32 +64,46 @@
 
 PYFILES = $(PYSRCS) $(PYOBJS)
 
-ROOTPYDIR = $(PYTOPDIR)/python$(PYTHON_VERSION)/$(PYMODDIR)
+ROOTPYDIR = $(PYTOPDIR)/python$(PYVER)/$(PYMODDIR)
 ROOTPYFILES	= $(PYFILES:%=$(ROOTPYDIR)/%)
 
 $(ROOTPYFILES) := FILEMODE = 0444
 
-PYVERSDIRS = python$(PYTHON_VERSION)
+PYVERSDIRS = python$(PYVER)
 
-PYVERSOBJS = $(PYOBJS:%=python$(PYTHON_VERSION)/%)
+PYVERSOBJS = $(PYOBJS:%=python$(PYVER)/%)
 
 CLOBBERFILES += $(PYVERSOBJS)
 CLOBBERDIRS += $(PYVERSDIRS)
 
 .KEEP_STATE:
 
-python$(PYTHON_VERSION)/%.pyc: %.py
-	@[ -d $(@D) ] || mkdir $(@D)
-	$(RM) $@
-	$(PYTHON) -mpy_compile $<
-	$(MV) $(*).pyc $@
-
-$(ROOTPYDIR)/%.pyc: python$(PYTHON_VERSION)/%.pyc
-	$(INS.pyfile)
-
-$(ROOTPYDIR)/%.py: %.py
+$(ROOTPYDIR)/%.py: ../%.py
 	$(INS.pyfile)
 
 pyclobber:
 	$(RM) $(CLOBBERFILES)
 	$(RM) -rf $(CLOBBERDIRS)
+
+# Python 2 module compilation
+
+python$(PYVER)/%.pyc: ../%.py
+	@[ -d $(@D) ] || mkdir $(@D)
+	$(RM) $@
+	$(PYTHON) -mpy_compile $<
+	$(MV) ../$(*).pyc $@
+
+$(ROOTPYDIR)/%.pyc: python$(PYVER)/%.pyc
+	$(INS.pyfile)
+
+# Python 3 module compilation
+
+python$(PYVER)/__pycache__/%.cpython$(PYPKGVERS).pyc: ../%.py
+	@[ -d $(@D) ] || mkdir -p $(@D)
+	$(RM) $@
+	$(PYTHON3) -mpy_compile $<
+	$(MV) ../__pycache__/$(*).cpython$(PYPKGVERS).pyc $@
+
+$(ROOTPYDIR)/__pycache__/%.pyc: python$(PYVER)/__pycache__/%.pyc
+	$(INS.pyfile)
+
--- a/usr/src/tools/onbld/Checks/Cddl.py	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/tools/onbld/Checks/Cddl.py	Sun May 05 16:25:23 2019 -0400
@@ -26,11 +26,14 @@
 # Use is subject to license terms.
 #
 
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
+
 #
 # Check that source files contain a valid CDDL block
 #
 
-import sys, CmtBlk
+import sys
+from onbld.Checks import CmtBlk
 
 # scmtest has a test for cddlchk that depends on the variable
 # Cddl.CmntChrs. However, that variable has been refactored into
@@ -43,7 +46,7 @@
 # The CDDL string above contains the block guards so that the text will
 # be tested by cddlchk. However, we don't want to include the initial
 # \n or the block guards in the text passed in.
-# 
+#
 CDDL = CDDL.splitlines()[3:-2]
 
 def cddlchk(fh, filename=None, lenient=False, verbose=False, output=sys.stderr):
--- a/usr/src/tools/onbld/Checks/CmtBlk.py	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/tools/onbld/Checks/CmtBlk.py	Sun May 05 16:25:23 2019 -0400
@@ -23,6 +23,7 @@
 
 #
 # Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
 #
 
 #
@@ -73,7 +74,7 @@
 	for line in fh:
 		line = line.rstrip('\r\n')
 		lineno += 1
-		
+
 		if StartRE.search(line):
 			in_cmt = True
 			lic.append(line)
@@ -110,7 +111,7 @@
 	for b in blocks:
 		try:
 			checkblock(b, full_text)
-		except CmtBlkError, e:
+		except CmtBlkError as e:
 			ret = 1
 			output.write(
 				"%s: %d: Error: Invalid line in %s block:\n"
@@ -120,7 +121,7 @@
 				"    '%s'\n" % (filename, e.lineno, blk_name,
 						e.shouldbe, e.seen))
 			break
-		
+
 	if verbose and not ret:
 		output.write("%s: Valid %s block\n" %
 			     (filename, blk_name))
--- a/usr/src/tools/onbld/Checks/Comments.py	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/tools/onbld/Checks/Comments.py	Sun May 05 16:25:23 2019 -0400
@@ -26,12 +26,13 @@
 #
 
 # Copyright 2007, 2010 Richard Lowe
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
 
 #
 # Check delta comments:
-# 	- Have the correct form.
-# 	- Have a synopsis matching that of the bug
-# 	- Appear only once.
+#	- Have the correct form.
+#	- Have a synopsis matching that of the bug
+#	- Appear only once.
 #
 
 import re, sys
@@ -113,9 +114,9 @@
 
 	if len(bugs) > 0 and check_db:
 		bugdb = BugDB()
-		results = bugdb.lookup(bugs.keys())
+		results = bugdb.lookup(list(bugs.keys()))
 
-	for crid, insts in bugs.iteritems():
+	for crid, insts in bugs.items():
 		if len(insts) > 1:
 			errors['dup'].append(crid)
 
--- a/usr/src/tools/onbld/Checks/DbLookups.py	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/tools/onbld/Checks/DbLookups.py	Sun May 05 16:25:23 2019 -0400
@@ -25,6 +25,7 @@
 #
 
 # Copyright 2010, Richard Lowe
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
 
 #
 # Various database lookup classes/methods, i.e.:
@@ -33,10 +34,13 @@
 #     * redmine (illumos.org)
 #
 
-import htmllib
 import re
-import urllib
-import urllib2
+try:
+	from urllib.request import urlopen, Request
+	from urllib.error import HTTPError
+except ImportError:
+	# Python 2
+	from urllib2 import Request, urlopen, HTTPError
 
 try:				# Python >= 2.5
 	from xml.etree import ElementTree
@@ -72,17 +76,17 @@
 		"""
 		for database in priority:
 			if database not in self.VALID_DBS:
-				raise BugDBException, database
+				raise BugDBException(database)
 		self.__priority = priority
 
 
 	def __illbug(self, cr):
 		url = "http://illumos.org/issues/%s.xml" % cr
-		req = urllib2.Request(url)
+		req = Request(url)
 
 		try:
-			data = urllib2.urlopen(req)
-		except urllib2.HTTPError, e:
+			data = urlopen(req)
+		except HTTPError as e:
 			if e.code == 404:
 				raise NonExistentBug(cr)
 			else:
--- a/usr/src/tools/onbld/Checks/Keywords.py	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/tools/onbld/Checks/Keywords.py	Sun May 05 16:25:23 2019 -0400
@@ -24,8 +24,8 @@
 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
+
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
 
 #
 # Mercurial (lack of) keyword checks
@@ -39,7 +39,7 @@
 #
 # Absolutely anything that appears to be an SCCS keyword.
 # It's impossible to programatically differentiate between these
-# and other, legitimate, uses of matching strings. 
+# and other, legitimate, uses of matching strings.
 #
 anykword = re.compile(r'%[A-ILMP-UWYZ]%')
 
@@ -56,14 +56,14 @@
 
     ret = 0
     lineno = 0
-    
+
     for line in fh:
         line = line.rstrip('\r\n')
         lineno += 1
-        
+
         if lenient and ident.search(line):
             continue
-        
+
         match = anykword.findall(line)
         if match:
             ret = 1
--- a/usr/src/tools/onbld/Checks/Makefile	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/tools/onbld/Checks/Makefile	Sun May 05 16:25:23 2019 -0400
@@ -23,39 +23,23 @@
 # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
 #
 
-# Copyright 2010, Richard Lowe
-# Copyright 2014 Garrett D'Amore <garrett@damore.org>
-# Copyright 2016, Joyent, Inc.
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
 
-include $(SRC)/Makefile.master
 include ../../Makefile.tools
 
-PYSRCS = \
-	CStyle.py	\
-	Cddl.py		\
-	CmtBlk.py	\
-	Comments.py	\
-	Copyright.py	\
-	DbLookups.py	\
-	HdrChk.py	\
-	Keywords.py	\
-	ManLint.py	\
-	Mapfile.py	\
-	ProcessCheck.py \
-	SpellCheck.py \
-	WsCheck.py \
-	__init__.py
+SUBDIRS=
+$(BUILDPY2TOOLS)SUBDIRS += py2
+$(BUILDPY3TOOLS)SUBDIRS += py3
 
-PYOBJS =	$(PYSRCS:%.py=%.pyc)
-PYTOPDIR =	$(ROOTONBLDLIB)
-PYMODDIR =	onbld/Checks
-
-include ../../Makefile.python
+all :=		TARGET= all
+install :=	TARGET= install
+clean :=	TARGET= clean
+clobber :=	TARGET= clobber
 
-all: $(PYVERSOJBS)
-
-install: all $(ROOTPYFILES)
+all install clean clobber: $(SUBDIRS)
 
-clean:
+$(SUBDIRS): FRC
+	@cd $@; pwd; $(MAKE) $(TARGET)
 
-clobber: clean pyclobber
+FRC:
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/tools/onbld/Checks/Makefile.com	Sun May 05 16:25:23 2019 -0400
@@ -0,0 +1,52 @@
+#
+# 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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+# Copyright 2010, Richard Lowe
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
+# Copyright 2016, Joyent, Inc.
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
+
+include $(SRC)/Makefile.master
+include ../../../Makefile.tools
+
+PYTOPDIR =	$(ROOTONBLDLIB)
+PYMODDIR =	onbld/Checks
+
+PYSRCS = \
+	CStyle.py	\
+	Cddl.py		\
+	CmtBlk.py	\
+	Comments.py	\
+	Copyright.py	\
+	DbLookups.py	\
+	HdrChk.py	\
+	Keywords.py	\
+	ManLint.py	\
+	Mapfile.py	\
+	ProcessCheck.py	\
+	SpellCheck.py	\
+	WsCheck.py	\
+	__init__.py
+
--- a/usr/src/tools/onbld/Checks/Mapfile.py	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/tools/onbld/Checks/Mapfile.py	Sun May 05 16:25:23 2019 -0400
@@ -22,6 +22,7 @@
 
 #
 # Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
 #
 
 #
@@ -38,7 +39,8 @@
 copy of that file. If you need help, contact a gatekeeper for guidance.
 '''
 
-import re, sys, CmtBlk
+import re, sys
+from onbld.Checks import CmtBlk
 
 MAPFILE = MAPFILE.splitlines()[1:]		# Don't include initial \n
 
@@ -51,9 +53,9 @@
 	# Verify that the mapfile is using version 2 syntax. Read and discard
 	# comment and empty lines until the first non-empty line is seen.
 	# This line must be '$mapfile_version 2'.
-        CmtRE = re.compile(r'#.*$')
-        LeadingWSRE = re.compile(r'^\s+')
-        VersionRE = re.compile(r'^\$mapfile_version\s+2\s*$')
+	CmtRE = re.compile(r'#.*$')
+	LeadingWSRE = re.compile(r'^\s+')
+	VersionRE = re.compile(r'^\$mapfile_version\s+2\s*$')
 	for line in fh:
 		line = CmtRE.sub(r'', line)
 		line = LeadingWSRE.sub(r'', line)
@@ -68,13 +70,12 @@
 
 		# We have verified version 2 syntax. Exit the loop
 		break
-		
 
 	# If the mapfile contains a SYMBOL_VERSION directive, the file
 	# must include a copy of the MAPFILE warning comment above. The
 	# comment is specific to symbol versioning, so we don't harrass
 	# the authors of mapfiles used exclusively for other purposes.
-        SymVerRE = re.compile(r'^\s*symbol_version\s+', re.IGNORECASE)
+	SymVerRE = re.compile(r'^\s*symbol_version\s+', re.IGNORECASE)
 	for line in fh:
 		# If we find a SYMBOL_VERSION, then verify that the comment
 		# is present. The comment usually precedes the mapfile_version
--- a/usr/src/tools/onbld/Checks/ProcessCheck.py	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/tools/onbld/Checks/ProcessCheck.py	Sun May 05 16:25:23 2019 -0400
@@ -23,8 +23,8 @@
 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
+
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
 
 #
 # Wrap a command-line check tool in a pythonic API
@@ -46,8 +46,8 @@
 	# don't deadlock with the child if both pipes fill.
 	#
 	try:
-		tmpfile = tempfile.TemporaryFile(prefix=command)
-	except EnvironmentError, e:
+		tmpfile = tempfile.TemporaryFile(prefix=command, mode="w+b")
+	except EnvironmentError as e:
 		output.write("Could not create temporary file: %s\n" % e)
 		return (3, None)
 
@@ -55,7 +55,7 @@
 		p = subprocess.Popen([command] + args,
 				     stdin=subprocess.PIPE, stdout=tmpfile,
 				     stderr=subprocess.STDOUT, close_fds=False)
-	except OSError, e:
+	except OSError as e:
 		output.write("Could not execute %s: %s\n" % (command, e))
 		return (3, None)
 
--- a/usr/src/tools/onbld/Checks/SpellCheck.py	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/tools/onbld/Checks/SpellCheck.py	Sun May 05 16:25:23 2019 -0400
@@ -21,6 +21,7 @@
 
 #
 # Copyright 2016 Joyent, Inc.
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
 #
 
 import re, sys
@@ -255,12 +256,12 @@
 misspellingREs = []
 alternateREs = []
 
-for misspelling, correct in misspellings.iteritems():
+for misspelling, correct in misspellings.items():
 	regex = re.compile(r'\b%s\b' % (misspelling), re.IGNORECASE)
 	entry = (regex, misspelling, correct)
 	misspellingREs.append(entry)
 
-for alternate, correct in alternates.iteritems():
+for alternate, correct in alternates.items():
 	regex = re.compile(r'\b%s\b' % (alternate), re.IGNORECASE)
 	entry = (regex, alternate, correct)
 	alternateREs.append(entry)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/tools/onbld/Checks/py2/Makefile	Sun May 05 16:25:23 2019 -0400
@@ -0,0 +1,45 @@
+#
+# 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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+# Copyright 2010, Richard Lowe
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
+# Copyright 2016, Joyent, Inc.
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
+
+include ../Makefile.com
+
+PYVER = $(PYTHON_VERSION)
+PYPKGVERS = $(PYTHON_PKGVERS)
+PYOBJS =	$(PYSRCS:%.py=%.pyc)
+
+include ../../../Makefile.python
+
+all: $(PYVERSOJBS)
+
+install: all $(ROOTPYFILES)
+
+clean:
+
+clobber: clean pyclobber
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/tools/onbld/Checks/py3/Makefile	Sun May 05 16:25:23 2019 -0400
@@ -0,0 +1,45 @@
+#
+# 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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+# Copyright 2010, Richard Lowe
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
+# Copyright 2016, Joyent, Inc.
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
+
+include ../Makefile.com
+
+PYVER = $(PYTHON3_VERSION)
+PYPKGVERS = $(PYTHON3_PKGVERS)
+PYOBJS = $(PYSRCS:%.py=__pycache__/%.cpython$(PYTHON3_PKGVERS).pyc)
+
+include ../../../Makefile.python
+
+all:
+install: $(ROOTPYFILES)
+
+clean:
+
+clobber: clean pyclobber
+
--- a/usr/src/tools/onbld/Makefile	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/tools/onbld/Makefile	Sun May 05 16:25:23 2019 -0400
@@ -23,38 +23,24 @@
 # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
 #
 
-include $(SRC)/Makefile.master
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
+
 include ../Makefile.tools
 
-SUBDIRS= \
-	Checks	\
-	Scm
-
-PYSRCS = \
-	__init__.py
-
-PYOBJS =	$(PYSRCS:%.py=%.pyc)
-PYTOPDIR = 	$(ROOTONBLDLIB)
-PYMODDIR =	onbld
+SUBDIRS=Checks Scm
+$(BUILDPY2TOOLS)SUBDIRS += py2
+$(BUILDPY3TOOLS)SUBDIRS += py3
 
-all	:= TARGET = all
-install := TARGET = install
-clean	:= TARGET = clean
-clobber := TARGET = clobber
-
-include ../Makefile.python
+all :=		TARGET= all
+install :=	TARGET= install
+clean :=	TARGET= clean
+clobber :=	TARGET= clobber
+lint :=		TARGET= lint
 
-.KEEP_STATE:
-
-all: $(PYVERSOBJS) $(SUBDIRS)
-
-install: all $(ROOTPYFILES) $(SUBDIRS)
-
-clean: $(SUBDIRS)
-
-clobber: clean pyclobber $(SUBDIRS)
+all install clean clobber lint: $(SUBDIRS)
 
 $(SUBDIRS): FRC
 	@cd $@; pwd; $(MAKE) $(TARGET)
 
 FRC:
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/tools/onbld/Makefile.com	Sun May 05 16:25:23 2019 -0400
@@ -0,0 +1,36 @@
+#
+# 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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, Joyent, Inc.
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
+#
+
+include $(SRC)/Makefile.master
+include ../../Makefile.tools
+
+PYTOPDIR =	$(ROOTONBLDLIB)
+PYMODDIR =	onbld
+
+PYSRCS = \
+	__init__.py
+
--- a/usr/src/tools/onbld/Scm/Makefile	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/tools/onbld/Scm/Makefile	Sun May 05 16:25:23 2019 -0400
@@ -21,26 +21,26 @@
 
 #
 # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2014, Joyent, Inc.
 #
 
-include $(SRC)/Makefile.master
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
+
 include ../../Makefile.tools
 
-PYSRCS = \
-	__init__.py	\
-	Ignore.py
-
-PYOBJS =	$(PYSRCS:%.py=%.pyc)
-PYTOPDIR =	$(ROOTONBLDLIB)
-PYMODDIR =	onbld/Scm
+SUBDIRS=
+$(BUILDPY2TOOLS)SUBDIRS += py2
+$(BUILDPY3TOOLS)SUBDIRS += py3
 
-include ../../Makefile.python
-
-all: $(PYVERSOBJS)
+all :=		TARGET= all
+install :=	TARGET= install
+clean :=	TARGET= clean
+clobber :=	TARGET= clobber
+lint :=		TARGET= lint
 
-install: all $(ROOTPYFILES)
+all install clean clobber lint: $(SUBDIRS)
 
-clean:
+$(SUBDIRS): FRC
+	@cd $@; pwd; $(MAKE) $(TARGET)
 
-clobber: clean pyclobber
+FRC:
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/tools/onbld/Scm/Makefile.com	Sun May 05 16:25:23 2019 -0400
@@ -0,0 +1,37 @@
+#
+# 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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, Joyent, Inc.
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
+#
+
+include $(SRC)/Makefile.master
+include ../../../Makefile.tools
+
+PYTOPDIR =	$(ROOTONBLDLIB)
+PYMODDIR =	onbld/Scm
+
+PYSRCS = \
+	__init__.py	\
+	Ignore.py
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/tools/onbld/Scm/py2/Makefile	Sun May 05 16:25:23 2019 -0400
@@ -0,0 +1,45 @@
+#
+# 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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+# Copyright 2010, Richard Lowe
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
+# Copyright 2016, Joyent, Inc.
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
+
+include ../Makefile.com
+
+PYVER = $(PYTHON_VERSION)
+PYPKGVERS = $(PYTHON_PKGVERS)
+PYOBJS =	$(PYSRCS:%.py=%.pyc)
+
+include ../../../Makefile.python
+
+all: $(PYVERSOJBS)
+
+install: all $(ROOTPYFILES)
+
+clean:
+
+clobber: clean pyclobber
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/tools/onbld/Scm/py3/Makefile	Sun May 05 16:25:23 2019 -0400
@@ -0,0 +1,45 @@
+#
+# 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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+# Copyright 2010, Richard Lowe
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
+# Copyright 2016, Joyent, Inc.
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
+
+include ../Makefile.com
+
+PYVER = $(PYTHON3_VERSION)
+PYPKGVERS = $(PYTHON3_PKGVERS)
+PYOBJS = $(PYSRCS:%.py=__pycache__/%.cpython$(PYTHON3_PKGVERS).pyc)
+
+include ../../../Makefile.python
+
+all:
+install: $(ROOTPYFILES)
+
+clean:
+
+clobber: clean pyclobber
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/tools/onbld/py2/Makefile	Sun May 05 16:25:23 2019 -0400
@@ -0,0 +1,45 @@
+#
+# 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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+# Copyright 2010, Richard Lowe
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
+# Copyright 2016, Joyent, Inc.
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
+
+include ../Makefile.com
+
+PYVER = $(PYTHON_VERSION)
+PYPKGVERS = $(PYTHON_PKGVERS)
+PYOBJS =	$(PYSRCS:%.py=%.pyc)
+
+include ../../Makefile.python
+
+all: $(PYVERSOJBS)
+
+install: all $(ROOTPYFILES)
+
+clean:
+
+clobber: clean pyclobber
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/tools/onbld/py3/Makefile	Sun May 05 16:25:23 2019 -0400
@@ -0,0 +1,45 @@
+#
+# 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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+# Copyright 2010, Richard Lowe
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
+# Copyright 2016, Joyent, Inc.
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
+
+include ../Makefile.com
+
+PYVER = $(PYTHON3_VERSION)
+PYPKGVERS = $(PYTHON3_PKGVERS)
+PYOBJS = $(PYSRCS:%.py=__pycache__/%.cpython$(PYTHON3_PKGVERS).pyc)
+
+include ../../Makefile.python
+
+all:
+install: $(ROOTPYFILES)
+
+clean:
+
+clobber: clean pyclobber
+
--- a/usr/src/tools/scripts/cddlchk.py	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/tools/scripts/cddlchk.py	Sun May 05 16:25:23 2019 -0400
@@ -1,4 +1,4 @@
-#!@PYTHON@
+#!@TOOLS_PYTHON@
 #
 # CDDL HEADER START
 #
@@ -22,13 +22,14 @@
 
 #
 # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
 #
 
 #
 # Check for valid CDDL blocks in source files.
 #
 
-import sys, os, getopt, fnmatch
+import sys, os, io, getopt, fnmatch
 
 sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "lib",
                                 "python%d.%d" % sys.version_info[:2]))
@@ -48,7 +49,7 @@
 		fh = None
 		try:
 			fh = open(exfile, 'r')
-		except IOError, e:
+		except IOError as e:
 			sys.stderr.write('Failed to open exception list: '
 					 '%s: %s\n' % (e.filename, e.strerror))
 			sys.exit(2)
@@ -91,15 +92,15 @@
 
 def check(filename, opts):
 	try:
-		fh = open(filename, 'r')
-	except IOError, e:
+		with io.open(filename, encoding='utf-8',
+		    errors='replace') as fh:
+			return cddlchk(fh, verbose=opts['verbose'],
+			       lenient=opts['lenient'],
+			       output=sys.stdout)
+	except IOError as e:
 		sys.stderr.write("failed to open '%s': %s\n" %
 				 (e.filename, e.strerror))
 		return 1
-	else:
-		return cddlchk(fh, verbose=opts['verbose'],
-			       lenient=opts['lenient'],
-			       output=sys.stdout)
 
 def walker(opts, dirname, fnames):
 	for f in fnames:
--- a/usr/src/tools/scripts/copyrightchk.py	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/tools/scripts/copyrightchk.py	Sun May 05 16:25:23 2019 -0400
@@ -1,4 +1,4 @@
-#!@PYTHON@
+#!@TOOLS_PYTHON@
 #
 # CDDL HEADER START
 #
@@ -22,13 +22,14 @@
 
 #
 # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
 #
 
 #
 # Check for valid SMI copyright notices in source files.
 #
 
-import sys, os
+import sys, os, io
 
 sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "lib",
                                 "python%d.%d" % sys.version_info[:2]))
@@ -41,13 +42,12 @@
 ret = 0
 for filename in sys.argv[1:]:
 	try:
-		fin = open(filename, 'r')
-	except IOError, e:
+		with io.open(filename, encoding='utf-8',
+		    errors='replace') as fin:
+			ret |= copyright(fin, output=sys.stdout)
+	except IOError as e:
 		sys.stderr.write("failed to open '%s': %s\n" %
 				 (e.filename, e.strerror))
 		continue
 
-	ret |= copyright(fin, output=sys.stdout)
-	fin.close()
-
 sys.exit(ret)
--- a/usr/src/tools/scripts/git-pbchk.py	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/tools/scripts/git-pbchk.py	Sun May 05 16:25:23 2019 -0400
@@ -21,16 +21,23 @@
 # Copyright (c) 2015, 2016 by Delphix. All rights reserved.
 # Copyright 2016 Nexenta Systems, Inc.
 # Copyright 2018 Joyent, Inc.
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
 #
 
+from __future__ import print_function
+
 import getopt
+import io
 import os
 import re
 import subprocess
 import sys
 import tempfile
 
-from cStringIO import StringIO
+if sys.version_info[0] < 3:
+    from cStringIO import StringIO
+else:
+    from io import StringIO
 
 #
 # Adjust the load path based on our location and the version of python into
@@ -65,15 +72,15 @@
     command = ["git"] + command
 
     try:
-        tmpfile = tempfile.TemporaryFile(prefix="git-nits")
-    except EnvironmentError, e:
+        tmpfile = tempfile.TemporaryFile(prefix="git-nits", mode="w+b")
+    except EnvironmentError as e:
         raise GitError("Could not create temporary file: %s\n" % e)
 
     try:
         p = subprocess.Popen(command,
                              stdout=tmpfile,
                              stderr=subprocess.PIPE)
-    except OSError, e:
+    except OSError as e:
         raise GitError("could not execute %s: %s\n" % (command, e))
 
     err = p.wait()
@@ -81,7 +88,10 @@
         raise GitError(p.stderr.read())
 
     tmpfile.seek(0)
-    return tmpfile
+    lines = []
+    for l in tmpfile:
+        lines.append(l.decode('utf-8', 'replace'))
+    return lines
 
 
 def git_root():
@@ -89,30 +99,19 @@
 
     p = git('rev-parse --git-dir')
 
-    if not p:
-        sys.stderr.write("Failed finding git workspace\n")
-        sys.exit(err)
-
-    return os.path.abspath(os.path.join(p.readlines()[0],
-                                        os.path.pardir))
-
+    return os.path.abspath(os.path.join(dir, os.path.pardir))
 
 def git_branch():
     """Return the current git branch"""
 
     p = git('branch')
 
-    if not p:
-        sys.stderr.write("Failed finding git branch\n")
-        sys.exit(err)
-
     for elt in p:
         if elt[0] == '*':
             if elt.endswith('(no branch)'):
                 return None
             return elt.split()[1]
 
-
 def git_parent_branch(branch):
     """Return the parent of the current git branch.
 
@@ -137,7 +136,6 @@
                 return remote
     return 'origin/master'
 
-
 def git_comments(parent):
     """Return a list of any checkin comments on this git branch"""
 
@@ -147,8 +145,7 @@
         sys.stderr.write("Failed getting git comments\n")
         sys.exit(err)
 
-    return [x.strip() for x in p.readlines() if x != ':SEP:\n']
-
+    return [x.strip() for x in p if x != ':SEP:\n']
 
 def git_file_list(parent, paths=None):
     """Return the set of files which have ever changed on this branch.
@@ -170,17 +167,15 @@
 
     return ret
 
-
 def not_check(root, cmd):
     """Return a function which returns True if a file given as an argument
     should be excluded from the check named by 'cmd'"""
 
-    ignorefiles = filter(os.path.exists,
+    ignorefiles = list(filter(os.path.exists,
                          [os.path.join(root, ".git", "%s.NOT" % cmd),
-                          os.path.join(root, "exception_lists", cmd)])
+                          os.path.join(root, "exception_lists", cmd)]))
     return Ignore.ignore(root, ignorefiles)
 
-
 def gen_files(root, parent, paths, exclude):
     """Return a function producing file names, relative to the current
     directory, of any file changed on this branch (limited to 'paths' if
@@ -202,20 +197,19 @@
             path = relpath(abspath, '.')
             try:
                 res = git("diff %s HEAD %s" % (parent, path))
-            except GitError, e:
+            except GitError as e:
                 # This ignores all the errors that can be thrown. Usually, this
                 # means that git returned non-zero because the file doesn't
                 # exist, but it could also fail if git can't create a new file
                 # or it can't be executed.  Such errors are 1) unlikely, and 2)
                 # will be caught by other invocations of git().
                 continue
-            empty = not res.readline()
+            empty = not res
             if (os.path.isfile(path) and not empty and
                 select(path) and not exclude(abspath)):
                 yield path
     return ret
 
-
 def comchk(root, parent, flist, output):
     output.write("Comments:\n")
 
@@ -243,9 +237,8 @@
 
     for f in flist(lambda x: MapfileRE.match(x) and not
                    NotMapSuffixRE.match(x)):
-        fh = open(f, 'r')
-        ret |= Mapfile.mapfilechk(fh, output=output)
-        fh.close()
+        with io.open(f, encoding='utf-8', errors='replace') as fh:
+            ret |= Mapfile.mapfilechk(fh, output=output)
     return ret
 
 
@@ -253,19 +246,16 @@
     ret = 0
     output.write("Copyrights:\n")
     for f in flist():
-        fh = open(f, 'r')
-        ret |= Copyright.copyright(fh, output=output)
-        fh.close()
+        with io.open(f, encoding='utf-8', errors='replace') as fh:
+            ret |= Copyright.copyright(fh, output=output)
     return ret
 
-
 def hdrchk(root, parent, flist, output):
     ret = 0
     output.write("Header format:\n")
     for f in flist(lambda x: x.endswith('.h')):
-        fh = open(f, 'r')
-        ret |= HdrChk.hdrchk(fh, lenient=True, output=output)
-        fh.close()
+        with io.open(f, encoding='utf-8', errors='replace') as fh:
+            ret |= HdrChk.hdrchk(fh, lenient=True, output=output)
     return ret
 
 
@@ -273,11 +263,10 @@
     ret = 0
     output.write("C style:\n")
     for f in flist(lambda x: x.endswith('.c') or x.endswith('.h')):
-        fh = open(f, 'r')
-        ret |= CStyle.cstyle(fh, output=output, picky=True,
+        with io.open(f, encoding='utf-8', errors='replace') as fh:
+            ret |= CStyle.cstyle(fh, output=output, picky=True,
                              check_posix_types=True,
                              check_continuation=True)
-        fh.close()
     return ret
 
 
@@ -286,28 +275,25 @@
     output.write("Man page format/spelling:\n")
     ManfileRE = re.compile(r'.*\.[0-9][a-z]*$', re.IGNORECASE)
     for f in flist(lambda x: ManfileRE.match(x)):
-        fh = open(f, 'r')
-        ret |= ManLint.manlint(fh, output=output, picky=True)
-        ret |= SpellCheck.spellcheck(fh, output=output)
-        fh.close()
+        with io.open(f, encoding='utf-8', errors='replace') as fh:
+            ret |= ManLint.manlint(fh, output=output, picky=True)
+            ret |= SpellCheck.spellcheck(fh, output=output)
     return ret
 
 def keywords(root, parent, flist, output):
     ret = 0
     output.write("SCCS Keywords:\n")
     for f in flist():
-        fh = open(f, 'r')
-        ret |= Keywords.keywords(fh, output=output)
-        fh.close()
+        with io.open(f, encoding='utf-8', errors='replace') as fh:
+            ret |= Keywords.keywords(fh, output=output)
     return ret
 
 def wscheck(root, parent, flist, output):
     ret = 0
     output.write("white space nits:\n")
     for f in flist():
-        fh = open(f, 'r')
-        ret |= WsCheck.wscheck(fh, output=output)
-        fh.close()
+        with io.open(f, encoding='utf-8', errors='replace') as fh:
+            ret |= WsCheck.wscheck(fh, output=output)
     return ret
 
 def run_checks(root, parent, cmds, paths='', opts={}):
@@ -324,17 +310,16 @@
     for cmd in cmds:
         s = StringIO()
 
-        exclude = not_check(root, cmd.func_name)
+        exclude = not_check(root, cmd.__name__)
         result = cmd(root, parent, gen_files(root, parent, paths, exclude),
                      output=s)
         ret |= result
 
         if result != 0:
-            print s.getvalue()
+            print(s.getvalue())
 
     return ret
 
-
 def nits(root, parent, paths):
     cmds = [copyright,
             cstyle,
@@ -342,10 +327,9 @@
             keywords,
             manlint,
             mapfilechk,
-	    wscheck]
+            wscheck]
     run_checks(root, parent, cmds, paths)
 
-
 def pbchk(root, parent, paths):
     cmds = [comchk,
             copyright,
@@ -354,10 +338,9 @@
             keywords,
             manlint,
             mapfilechk,
-	    wscheck]
+            wscheck]
     run_checks(root, parent, cmds)
 
-
 def main(cmd, args):
     parent_branch = None
     checkname = None
@@ -392,6 +375,6 @@
 if __name__ == '__main__':
     try:
         main(os.path.basename(sys.argv[0]), sys.argv[1:])
-    except GitError, e:
+    except GitError as e:
         sys.stderr.write("failed to run git:\n %s\n" % str(e))
         sys.exit(1)
--- a/usr/src/tools/scripts/hdrchk.py	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/tools/scripts/hdrchk.py	Sun May 05 16:25:23 2019 -0400
@@ -1,4 +1,4 @@
-#!@PYTHON@
+#!@TOOLS_PYTHON@
 #
 # CDDL HEADER START
 #
@@ -22,13 +22,14 @@
 
 #
 # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
 #
 
 #
 # Check header files conform to ON standards.
 #
 
-import sys, os, getopt
+import sys, os, io, getopt
 
 sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "lib",
                                 "python%d.%d" % sys.version_info[:2]))
@@ -59,11 +60,10 @@
 ret = 0
 for filename in args:
 	try:
-		fh = open(filename, 'r')
-	except IOError, e:
+		with io.open(filename, encoding='utf-8',
+		    errors='replace') as fh:
+			ret |= hdrchk(fh, lenient=lenient, output=sys.stderr)
+	except IOError as e:
 		sys.stderr.write("failed to open '%s': %s\n" %
 				 (e.filename, e.strerror))
-	else:
-		ret |= hdrchk(fh, lenient=lenient, output=sys.stderr)
-		fh.close()
 sys.exit(ret)
--- a/usr/src/tools/scripts/mapfilechk.py	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/tools/scripts/mapfilechk.py	Sun May 05 16:25:23 2019 -0400
@@ -1,4 +1,4 @@
-#!@PYTHON@
+#!@TOOLS_PYTHON@
 #
 # CDDL HEADER START
 #
@@ -22,13 +22,14 @@
 
 #
 # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
 #
 
 #
 # Check for valid link-editor mapfile comment blocks in source files.
 #
 
-import sys, os, getopt, fnmatch
+import sys, os, io, getopt, fnmatch
 
 sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "lib",
                                 "python%d.%d" % sys.version_info[:2]))
@@ -48,7 +49,7 @@
 		fh = None
 		try:
 			fh = open(exfile, 'r')
-		except IOError, e:
+		except IOError as e:
 			sys.stderr.write('Failed to open exception list: '
 					 '%s: %s\n' % (e.filename, e.strerror))
 			sys.exit(2)
@@ -90,14 +91,14 @@
 
 def check(filename, opts):
 	try:
-		fh = open(filename, 'r')
-	except IOError, e:
+		with io.open(filename, encoding='utf-8',
+		    errors='replace') as fh:
+			return mapfilechk(fh, verbose=opts['verbose'],
+			       output=sys.stdout)
+	except IOError as e:
 		sys.stderr.write("failed to open '%s': %s\n" %
 				 (e.filename, e.strerror))
 		return 1
-	else:
-		return mapfilechk(fh, verbose=opts['verbose'],
-			       output=sys.stdout)
 
 def walker(opts, dirname, fnames):
 	for f in fnames:
--- a/usr/src/tools/scripts/validate_pkg.py	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/tools/scripts/validate_pkg.py	Sun May 05 16:25:23 2019 -0400
@@ -1,4 +1,4 @@
-#!@PYTHON@
+#!@TOOLS_PYTHON@
 #
 # CDDL HEADER START
 #
@@ -25,6 +25,8 @@
 # Use is subject to license terms.
 #
 
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
+
 #
 # Compare the content generated by a build to a set of manifests
 # describing how that content is to be delivered.
@@ -132,13 +134,13 @@
             mo = m & stat.S_IRWXO
             e = self.editable
 
-            if (((mu & 02) == 0 and (mo & mg & 04) == 04) or
-                (t == "file" and mo & 01 == 1) or
+            if (((mu & 0o2) == 0 and (mo & mg & 0o4) == 0o4) or
+                (t == "file" and mo & 0o1 == 1) or
                 (mg, mo) == (mu, mu) or
                 ((t == "file" and not e or t == "dir" and o == "bin") and
-                (mg & 05 == mo & 05)) or
-                (t == "file" and o == "bin" and mu & 01 == 01) or
-                (m & 0105 != 0 and p.startswith("etc/security/dev/"))):
+                (mg & 0o5 == mo & 0o5)) or
+                (t == "file" and o == "bin" and mu & 0o1 == 0o1) or
+                (m & 0o105 != 0 and p.startswith("etc/security/dev/"))):
                 w.extend(["%s: owner \"%s\" may be safely " \
                     "changed to \"root\"" % (p, o)])
 
@@ -405,38 +407,38 @@
     def compare(self, other):
         """Compare two different sets of FileInfo objects.
         """
-        keys1 = frozenset(self.keys())
-        keys2 = frozenset(other.keys())
+        keys1 = frozenset(list(self.keys()))
+        keys2 = frozenset(list(other.keys()))
 
         common = keys1.intersection(keys2)
         onlykeys1 = keys1.difference(common)
         onlykeys2 = keys2.difference(common)
 
         if onlykeys1:
-            print "Entries present in %s but not %s:" % \
-                (self.name, other.name)
+            print("Entries present in %s but not %s:" % \
+                (self.name, other.name))
             for path in sorted(onlykeys1):
-                print("\t%s" % str(self[path]))
-            print ""
+                print(("\t%s" % str(self[path])))
+            print("")
 
         if onlykeys2:
-            print "Entries present in %s but not %s:" % \
-                (other.name, self.name)
+            print("Entries present in %s but not %s:" % \
+                (other.name, self.name))
             for path in sorted(onlykeys2):
-                print("\t%s" % str(other[path]))
-            print ""
+                print(("\t%s" % str(other[path])))
+            print("")
 
         nodifferences = True
         for path in sorted(common):
             if self[path] != other[path]:
                 if nodifferences:
                     nodifferences = False
-                    print "Entries that differ between %s and %s:" \
-                        % (self.name, other.name)
-                print("%14s %s" % (self.name, self[path]))
-                print("%14s %s" % (other.name, other[path]))
+                    print("Entries that differ between %s and %s:" \
+                        % (self.name, other.name))
+                print(("%14s %s" % (self.name, self[path])))
+                print(("%14s %s" % (other.name, other[path])))
         if not nodifferences:
-            print ""
+            print("")
 
 
 class BadProtolistFormat(Exception):
@@ -468,7 +470,7 @@
                 if path not in exceptions:
                     try:
                         newentries[path] = RealFileInfo(pdir, path)
-                    except OSError, e:
+                    except OSError as e:
                         sys.stderr.write("Warning: unable to stat %s: %s\n" %
                             (path, e))
                         continue
@@ -491,10 +493,10 @@
         # that cross proto dir boundaries.
         #
         hk2path = {}
-        for path, fileinfo in newentries.iteritems():
+        for path, fileinfo in newentries.items():
             if fileinfo.hardkey:
                 hk2path.setdefault(fileinfo.hardkey, set()).add(path)
-        for fileinfo in newentries.itervalues():
+        for fileinfo in newentries.values():
             if fileinfo.hardkey:
                 fileinfo.hardpaths.update(hk2path[fileinfo.hardkey])
         self.update(newentries)
@@ -510,7 +512,7 @@
 
         try:
             plist = open(protolist)
-        except IOError, exc:
+        except IOError as exc:
             raise IOError("cannot open proto list: %s" % str(exc))
 
         newentries = {}
@@ -543,10 +545,10 @@
 
         plist.close()
         hk2path = {}
-        for path, fileinfo in newentries.iteritems():
+        for path, fileinfo in newentries.items():
             if fileinfo.hardkey:
                 hk2path.setdefault(fileinfo.hardkey, set()).add(path)
-        for fileinfo in newentries.itervalues():
+        for fileinfo in newentries.values():
             if fileinfo.hardkey:
                 fileinfo.hardpaths.update(hk2path[fileinfo.hardkey])
         self.update(newentries)
@@ -582,9 +584,9 @@
         mfest = manifest.Manifest()
         try:
             mfest.set_content(open(os.path.join(root, mfile)).read())
-        except IOError, exc:
+        except IOError as exc:
             raise IOError("cannot read manifest: %s" % str(exc))
-        except actions.ActionError, exc:
+        except actions.ActionError as exc:
             raise ManifestParsingError(mfile, str(exc))
 
         #
@@ -657,10 +659,10 @@
                 modewarnings.update(self[path].checkmodes(modechecks))
 
         if len(modewarnings) > 0:
-            print "warning: unsafe permissions in %s" % mfile
+            print("warning: unsafe permissions in %s" % mfile)
             for w in sorted(modewarnings):
-                print w
-            print ""
+                print(w)
+            print("")
 
     def adddir(self, mdir, arch, modechecks, exceptions):
         """Walks the specified directory looking for pkg(5) manifests.
@@ -670,14 +672,14 @@
                 stat.S_ISREG(os.lstat(os.path.join(mdir, mfile)).st_mode)):
                 try:
                     self.addmanifest(mdir, mfile, arch, modechecks, exceptions)
-                except IOError, exc:
+                except IOError as exc:
                     sys.stderr.write("warning: %s\n" % str(exc))
 
     def resolvehardlinks(self):
         """Populates mode, group, and owner for resolved (ie link target
         is present in the manifest tree) hard links.
         """
-        for info in self.values():
+        for info in list(self.values()):
             if info.name() == "hardlink":
                 tgt = info.hardkey
                 if tgt in self:
@@ -696,7 +698,7 @@
         for fname in files:
             try:
                 self.readexceptionfile(fname, arch)
-            except IOError, exc:
+            except IOError as exc:
                 sys.stderr.write("warning: cannot read exception file: %s\n" %
                     str(exc))
 
@@ -772,7 +774,7 @@
     """
     try:
         opts, args = getopt.getopt(argv, 'a:e:Ll:Mm:p:vX:')
-    except getopt.GetoptError, exc:
+    except getopt.GetoptError as exc:
         usage(str(exc))
 
     if args:
@@ -849,8 +851,8 @@
             manifesttree.adddir(mdir, arch, modechecks, exceptions)
         if listonly:
             manifesttree.resolvehardlinks()
-            for info in manifesttree.values():
-                print "%s" % info.protostr()
+            for info in list(manifesttree.values()):
+                print("%s" % info.protostr())
             sys.exit(0)
         if modechecks is not None:
             sys.exit(0)
@@ -865,24 +867,24 @@
         for plist in protolists:
             try:
                 protolist.addprotolist(plist, exceptions)
-            except IOError, exc:
+            except IOError as exc:
                 sys.stderr.write("warning: %s\n" % str(exc))
         trees.append(protolist)
 
     if verbose and exceptions:
-        print "Entries present in exception list but missing from proto area:"
+        print("Entries present in exception list but missing from proto area:")
         for exc in sorted(exceptions):
-            print "\t%s" % exc
-        print ""
+            print("\t%s" % exc)
+        print("")
 
     usedexceptions = originalexceptions.difference(exceptions)
     harmfulexceptions = usedexceptions.intersection(manifesttree)
     if harmfulexceptions:
-        print "Entries present in exception list but also in manifests:"
+        print("Entries present in exception list but also in manifests:")
         for exc in sorted(harmfulexceptions):
-            print "\t%s" % exc
+            print("\t%s" % exc)
             del manifesttree[exc]
-        print ""
+        print("")
 
     trees[0].compare(trees[1])
 
--- a/usr/src/tools/scripts/wscheck.py	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/tools/scripts/wscheck.py	Sun May 05 16:25:23 2019 -0400
@@ -1,4 +1,4 @@
-#!@PYTHON@
+#!@TOOLS_PYTHON@
 #
 # CDDL HEADER START
 #
@@ -22,6 +22,7 @@
 
 #
 # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
 #
 
 #
@@ -29,7 +30,7 @@
 # (space tab, trailing space)
 #
 
-import sys, os
+import sys, os, io
 
 sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "lib",
                                 "python%d.%d" % sys.version_info[:2]))
@@ -42,13 +43,12 @@
 ret = 0
 for filename in sys.argv[1:]:
 	try:
-		fh = open(filename, 'r')
-	except IOError, e:
+		with io.open(filename, encoding='utf-8',
+		    errors='replace') as fh:
+			ret |= wscheck(fh, output=sys.stderr)
+	except IOError as e:
 		sys.stderr.write("failed to open '%s': %s\n" %
 				 (e.filename, e.strerror))
-                continue
-
-	ret |= wscheck(fh, output=sys.stderr)
-	fh.close()
+		continue
 
 sys.exit(ret)
--- a/usr/src/tools/scripts/wsdiff.py	Mon May 13 09:59:03 2019 +0000
+++ b/usr/src/tools/scripts/wsdiff.py	Sun May 05 16:25:23 2019 -0400
@@ -68,6 +68,7 @@
 #        -r      Log results and observed differences
 #        -i      Tell wsdiff which objects to compare via an input file list
 
+from __future__ import print_function
 import datetime, fnmatch, getopt, os, profile, commands
 import re, resource, select, shutil, signal, string, struct, sys, tempfile
 import time, threading
@@ -103,11 +104,12 @@
 # Ideally, we would purge use the use of __DATE__ from the source, but because
 # this is source we wish to distribute with Solaris "unchanged", we cannot modify.
 #
-wsdiff_exceptions = [ "usr/perl5/5.8.4/lib/sun4-solaris-64int/CORE/libperl.so.1",
-		      "usr/perl5/5.6.1/lib/sun4-solaris-64int/CORE/libperl.so.1",
-		      "usr/perl5/5.8.4/lib/i86pc-solaris-64int/CORE/libperl.so.1",
-		      "usr/perl5/5.6.1/lib/i86pc-solaris-64int/CORE/libperl.so.1"
-		      ]
+wsdiff_exceptions = [
+	"usr/perl5/5.8.4/lib/sun4-solaris-64int/CORE/libperl.so.1",
+	"usr/perl5/5.6.1/lib/sun4-solaris-64int/CORE/libperl.so.1",
+	"usr/perl5/5.8.4/lib/i86pc-solaris-64int/CORE/libperl.so.1",
+	"usr/perl5/5.6.1/lib/i86pc-solaris-64int/CORE/libperl.so.1"
+]
 
 #####
 # Logging routines
@@ -120,12 +122,12 @@
 	msg = "## " + msg
 	if debugon :
 		output_lock.acquire()
-		print >> sys.stdout, msg
+		print(msg)
 		sys.stdout.flush()
 		output_lock.release()
 		if logging :
 			log_lock.acquire()
-			print >> log, msg
+			print(msg, file=log)
 			log.flush()
 			log_lock.release()
 
@@ -133,25 +135,25 @@
 def info(msg) :
 
 	output_lock.acquire()
-	print >> sys.stdout, msg
+	print(msg)
 	sys.stdout.flush()
 	output_lock.release()
 	if logging :
 		log_lock.acquire()
-		print >> log, msg
+		print(msg, file=log)
 		log.flush()
 		log_lock.release()
 
 # Error message to be printed to the screen, and the log file
 def error(msg) :
-	
+
 	output_lock.acquire()
-	print >> sys.stderr, "ERROR:", msg
+	print("ERROR: " + msg, file=sys.stderr)
 	sys.stderr.flush()
 	output_lock.release()
 	if logging :
 		log_lock.acquire()
-		print >> log, "ERROR:", msg
+		print("ERROR: " + msg, file=log)
 		log.flush()
 		log_lock.release()
 
@@ -160,10 +162,10 @@
 
 	if logging :
 		log_lock.acquire()
-		print >> log, msg
+		print(msg, file=log)
 		log.flush()
 		log_lock.release()
-	
+
 #
 # Flag a detected file difference
 # Display the fileName to stdout, and log the difference
@@ -177,7 +179,7 @@
 	if sorted :
 		differentFiles.append(f)
 	else:
-		print >> sys.stdout, f
+		print(f)
 		sys.stdout.flush()
 	output_lock.release()
 
@@ -190,21 +192,21 @@
 
 	if logging :
 		log_lock.acquire()
-		print >> log, f
-		print >> log, "NOTE:", dtype, "difference detected."
+		print(f, file=log)
+		print("NOTE: " + dtype + " difference detected.", file=log)
 
 		difflen = len(diffs)
 		if difflen > 0 :
-			print >> log
+			print('', file=log)
 
 			if not vdiffs and difflen > diffs_sz_thresh :
+				print(diffs[:diffs_sz_thresh], file=log)
+				print("... truncated due to length: " +
+				      "use -v to override ...", file=log)
 				print >> log, diffs[:diffs_sz_thresh]
-				print >> log, \
-				      "... truncated due to length: " \
-				      "use -v to override ..."
 			else :
-				print >> log, diffs
-			print >> log, "\n"
+				print(diffs, file=log)
+			print('\n', file=log)
 		log.flush()
 		log_lock.release()
 
@@ -226,29 +228,30 @@
 		binaries = True
 		tmp_od1 = tmpf1 + ".od"
 		tmp_od2 = tmpf2 + ".od"
-		
+
 		cmd = od_cmd + " -c -t x4" + " " + tmpf1 + " > " + tmp_od1
 		os.system(cmd)
 		cmd = od_cmd + " -c -t x4" + " " + tmpf2 + " > " + tmp_od2
 		os.system(cmd)
-		
+
 		tmpf1 = tmp_od1
 		tmpf2 = tmp_od2
 
 	try:
-		data = commands.getoutput(diff_cmd + " " + tmpf1 + " " + tmpf2)
+		data = subprocess.check_output(
+		    diff_cmd + " " + tmpf1 + " " + tmpf2)
 		# Remove the temp files as we no longer need them.
 		if binaries :
 			try:
 				os.unlink(tmp_od1)
-			except OSError, e:
+			except OSError as e:
 				error("diffFileData: unlink failed %s" % e) 
 			try:
 				os.unlink(tmp_od2)
-			except OSError, e:
+			except OSError as e:
 				error("diffFileData: unlink failed %s" % e) 
 	except:
-		error("failed to get output of command: " + diff_cmd + " " \
+		error("failed to get output of command: " + diff_cmd + " "
 		    + tmpf1 + " " + tmpf2)
 
 		# Send exception for the failed command up
@@ -321,14 +324,15 @@
 #
 def usage() :
 	sys.stdout.flush()
-	print >> sys.stderr, """Usage: wsdiff [-dvVst] [-r results ] [-i filelist ] old new
+	print("""Usage: wsdiff [-dvVst] [-r results ] [-i filelist ] old new
         -d      Print debug messages about the progress
         -v      Do not truncate observed diffs in results
         -V      Log *all* ELF sect diffs vs. logging the first diff found
         -t      Use onbld tools in $SRC/tools
         -r      Log results and observed differences
         -s      Produce sorted list of differences
-        -i      Tell wsdiff which objects to compare via an input file list"""
+        -i      Tell wsdiff which objects to compare via an input file list""",
+	    file=sys.stderr)
 	sys.exit(1)
 
 #
@@ -358,7 +362,7 @@
 	# arguments, the paths to the base (old), ptch (new) proto areas
 	try:
 		optlist, args = getopt.getopt(sys.argv[1:], validOpts)
-	except getopt.error, val:
+	except getopt.error as val:
 		usage()
 
 	if len(args) != 2 :
@@ -505,7 +509,7 @@
 	baseFilesList = list(findFiles(base))
 	baseStringLength = len(base)
 	debug("Found " + str(len(baseFilesList)) + " files")
-	
+
 	debug("Getting the list of files in the patch area");
 	ptchFilesList = list(findFiles(ptch))
 	ptchStringLength = len(ptch)
@@ -543,10 +547,10 @@
 	debug("Eliminating deleted files from the list of objects")
 	for fileName in deletedFiles :
 		try:
-		       	compFiles.remove(fileName)
+			compFiles.remove(fileName)
 		except:
 			error("filelist.remove() failed")
-	debug("List for comparison reduced to " + str(len(compFiles)) \
+	debug("List for comparison reduced to " + str(len(compFiles))
 	    + " files")
 
 	# New files appear in the patch area, but not the base
@@ -625,10 +629,10 @@
 		elif ptch_present :
 			newFiles.append(fn)
 		else :
-			if os.path.islink(base + fn) and \
-			    os.path.islink(ptch + fn) :
+			if (os.path.islink(base + fn) and
+			    os.path.islink(ptch + fn)) :
 				continue
-			error(f + " in file list, but not in either tree. " + \
+			error(f + " in file list, but not in either tree. " +
 			    "Skipping...")
 
 	return compFiles, newFiles, deletedFiles
@@ -671,7 +675,7 @@
 
 	header = {}
 
-	hstring = commands.getoutput(elfdump_cmd + " -c " + f)
+	hstring = subprocess.check_output(elfdump_cmd + " -c " + f)
 
 	if len(hstring) == 0 :
 		error("Failed to dump ELF header for " + f)
@@ -688,7 +692,7 @@
 		section = sect[datap:].split()[1]
 		datap = sect.find("sh_type:");
 		if datap == -1 :
-			error("Could not get type for sect: " + section + \
+			error("Could not get type for sect: " + section +
 			      " in " + f)
 		sh_type = sect[datap:].split()[2]
 		header[section] = sh_type
@@ -700,10 +704,10 @@
 #
 def extract_elf_section(f, section) :
 
-	data = commands.getoutput(dump_cmd + " -sn " + section + " " + f)
+	data = subprocess.check_output(dump_cmd + " -sn " + section + " " + f)
 
 	if len(data) == 0 :
-		error(dump_cmd + "yielded no data on section " + section + \
+		error(dump_cmd + "yielded no data on section " + section +
 		    " of " + f)
 		raise
 		return
@@ -751,24 +755,24 @@
 		cmd1 = elfdump_cmd + " -i " + f1 + " > " + tmpFile1
 		cmd2 = elfdump_cmd + " -i " + f2 + " > " + tmpFile2
 	elif (section == ".symtab" or section == ".dynsym") :
-		cmd1 = elfdump_cmd + " -s -N " + section + " " + f1 + \
-		    " > " + tmpFile1
-		cmd2 = elfdump_cmd + " -s -N " + section + " " + f2 + \
-		    " > " + tmpFile2
+		cmd1 = (elfdump_cmd + " -s -N " + section + " " + f1 +
+		    " > " + tmpFile1)
+		cmd2 = (elfdump_cmd + " -s -N " + section + " " + f2 +
+		    " > " + tmpFile2)
 	elif (section in text_sections) :
 		# dis sometimes complains when it hits something it doesn't
 		# know how to disassemble. Just ignore it, as the output
 		# being generated here is human readable, and we've already
 		# correctly flagged the difference.
-		cmd1 = dis_cmd + " -t " + section + " " + f1 + \
-		       " 2>/dev/null | grep -v disassembly > " + tmpFile1
-		cmd2 = dis_cmd + " -t " + section + " " + f2 + \
-		       " 2>/dev/null | grep -v disassembly > " + tmpFile2
+		cmd1 = (dis_cmd + " -t " + section + " " + f1 +
+		       " 2>/dev/null | grep -v disassembly > " + tmpFile1)
+		cmd2 = (dis_cmd + " -t " + section + " " + f2 +
+		       " 2>/dev/null | grep -v disassembly > " + tmpFile2)
 	else :
-		cmd1 = elfdump_cmd + " -w " + tmpFile1 + " -N " + \
-		       section + " " + f1
-		cmd2 = elfdump_cmd + " -w " + tmpFile2 + " -N " + \
-		       section + " " + f2
+		cmd1 = (elfdump_cmd + " -w " + tmpFile1 + " -N " +
+		       section + " " + f1)
+		cmd2 = (elfdump_cmd + " -w " + tmpFile2 + " -N " +
+		       section + " " + f2)
 
 	os.system(cmd1)
 	os.system(cmd2)
@@ -778,12 +782,12 @@
 	# remove temp files as we no longer need them
 	try:
 		os.unlink(tmpFile1)
-	except OSError, e:
-		error("diff_elf_section: unlink failed %s" % e) 
+	except OSError as e:
+		error("diff_elf_section: unlink failed %s" % e)
 	try:
 		os.unlink(tmpFile2)
-	except OSError, e:
-		error("diff_elf_section: unlink failed %s" % e) 
+	except OSError as e:
+		error("diff_elf_section: unlink failed %s" % e)
 
 	return (data)
 
@@ -827,7 +831,7 @@
 		base_header = get_elfheader(base)
 	except:
 		return
- 	sections = base_header.keys()
+	sections = base_header.keys()
 
 	try:
 		ptch_header = get_elfheader(ptch)
@@ -856,25 +860,25 @@
 			slist = ""
 			for sect in e1_only_sections :
 				slist = slist + sect + "\t"
-			data = "ELF sections found in " + \
-				base + " but not in " + ptch + \
-				"\n\n" + slist
+			data = ("ELF sections found in " +
+				base + " but not in " + ptch +
+				"\n\n" + slist)
 
 		difference(fileName, "ELF", data)
 		return 1
-			
+
 	if len(e2_only_sections) > 0 :
 		if quiet :
 			return 1
-		
+
 		data = ""
 		if logging :
 			slist = ""
 			for sect in e2_only_sections :
 				slist = slist + sect + "\t"
-			data = "ELF sections found in " + \
-				ptch + " but not in " + base + \
-				"\n\n" + slist
+			data = ("ELF sections found in " +
+				ptch + " but not in " + base +
+				"\n\n" + slist)
 
 		difference(fileName, "ELF", data)
 		return 1
@@ -906,7 +910,7 @@
 		if len(s1) != len (s2) or s1 != s2:
 			if not quiet:
 				sh_type = base_header[sect]
-				data = diff_elf_section(base, ptch, \
+				data = diff_elf_section(base, ptch,
 							sect, sh_type)
 
 				# If all ELF sections are being reported, then
@@ -914,10 +918,10 @@
 				# stdout only once. Any other section differences
 				# should be logged to the results file directly
 				if not first_section :
-					log_difference(fileName, \
+					log_difference(fileName,
 					    "ELF " + sect, data)
 				else :
-					difference(fileName, "ELF " + sect, \
+					difference(fileName, "ELF " + sect,
 					    data)
 
 			if not reportAllSects :
@@ -951,7 +955,7 @@
 
 	fileName = fnFormat(base)
 	t = threading.currentThread()
-	ArchTmpDir1 = tmpDir1 + os.path.basename(base) + t.getName() 
+	ArchTmpDir1 = tmpDir1 + os.path.basename(base) + t.getName()
 	ArchTmpDir2 = tmpDir2 + os.path.basename(base) + t.getName()
 
 	#
@@ -963,42 +967,44 @@
 
 	try:
 		os.makedirs(ArchTmpDir1)
-	except OSError, e:
-		error("compareArchives: makedir failed %s" % e) 
+	except OSError as e:
+		error("compareArchives: makedir failed %s" % e)
 		return -1
 	try:
 		os.makedirs(ArchTmpDir2)
-	except OSError, e:
-		error("compareArchives: makedir failed %s" % e) 
+	except OSError as e:
+		error("compareArchives: makedir failed %s" % e)
 		return -1
 
 	# copy over the objects to the temp areas, and
 	# unpack them
 	baseCmd = "cp -fp " + base + " " + ArchTmpDir1
-	status, output = commands.getstatusoutput(baseCmd)
-	if status != 0 :
+	try:
+		output = subprocess.check_output(baseCmd)
+	except CalledProcessError:
 		error(baseCmd + " failed: " + output)
 		clearTmpDirs(ArchTmpDir1, ArchTmpDir2)
 		return -1
 
 	ptchCmd = "cp -fp " + ptch + " " + ArchTmpDir2
-	status, output = commands.getstatusoutput(ptchCmd)
-	if status != 0 :
+	try:
+		output = subprocess.check_output(ptchCmd)
+	except CalledProcessError:
 		error(ptchCmd + " failed: " + output)
 		clearTmpDirs(ArchTmpDir1, ArchTmpDir2)
 		return -1
 
 	bname = string.split(fileName, '/')[-1]
 	if fileType == "Java Archive" :
-		baseCmd = "cd " + ArchTmpDir1 + "; " + "jar xf " + bname + \
-			  "; rm -f " + bname + " META-INF/MANIFEST.MF"
-		ptchCmd = "cd " + ArchTmpDir2 + "; " + "jar xf " + bname + \
-			  "; rm -f " + bname + " META-INF/MANIFEST.MF"
+		baseCmd = ("cd " + ArchTmpDir1 + "; " + "jar xf " + bname +
+			  "; rm -f " + bname + " META-INF/MANIFEST.MF")
+		ptchCmd = ("cd " + ArchTmpDir2 + "; " + "jar xf " + bname +
+			  "; rm -f " + bname + " META-INF/MANIFEST.MF")
 	elif fileType == "ELF Object Archive" :
-		baseCmd = "cd " + ArchTmpDir1 + "; " + "/usr/bin/ar x " + \
-			  bname + "; rm -f " + bname
-		ptchCmd = "cd " + ArchTmpDir2 + "; " + "/usr/bin/ar x " + \
-			  bname + "; rm -f " + bname
+		baseCmd = ("cd " + ArchTmpDir1 + "; " + "/usr/ccs/bin/ar x " +
+			  bname + "; rm -f " + bname)
+		ptchCmd = ("cd " + ArchTmpDir2 + "; " + "/usr/ccs/bin/ar x " +
+			  bname + "; rm -f " + bname)
 	else :
 		error("unexpected file type: " + fileType)
 		clearTmpDirs(ArchTmpDir1, ArchTmpDir2)
@@ -1023,22 +1029,22 @@
 
 	for fn in ptchFlist :
 		if not fn in baseFlist :
-			difference(fileName, fileType, \
+			difference(fileName, fileType,
 				   fn + " added to " + fileName)
 			clearTmpDirs(ArchTmpDir1, ArchTmpDir2)
 			return 1
 
 	for fn in baseFlist :
 		if not fn in ptchFlist :
-			difference(fileName, fileType, \
+			difference(fileName, fileType,
 				   fn + " removed from " + fileName)
 			clearTmpDirs(ArchTmpDir1, ArchTmpDir2)
 			return 1
 
-		differs = compareOneFile((ArchTmpDir1 + fn), \
+		differs = compareOneFile((ArchTmpDir1 + fn),
 		    (ArchTmpDir2 + fn), True)
 		if differs :
-			difference(fileName, fileType, \
+			difference(fileName, fileType,
 				   fn + " in " + fileName + " differs")
 			clearTmpDirs(ArchTmpDir1, ArchTmpDir2)
 			return 1
@@ -1088,13 +1094,13 @@
 	if needToSnip :
 		toSnipBegin = string.find(baseData, toSnipBeginStr)
 		if toSnipBegin != -1 :
-			toSnipEnd = string.find(baseData[toSnipBegin:], \
-						toSnipEndStr) + \
-						len(toSnipEndStr)
-			baseData = baseData[:toSnipBegin] + \
-				   baseData[toSnipBegin + toSnipEnd:]
-			ptchData = ptchData[:toSnipBegin] + \
-				   ptchData[toSnipBegin + toSnipEnd:]
+			toSnipEnd = (string.find(baseData[toSnipBegin:],
+						toSnipEndStr) +
+						len(toSnipEndStr))
+			baseData = (baseData[:toSnipBegin] +
+				   baseData[toSnipBegin + toSnipEnd:])
+			ptchData = (ptchData[:toSnipBegin] +
+				   ptchData[toSnipBegin + toSnipEnd:])
 
 	if quiet :
 		if baseData != ptchData :
@@ -1123,11 +1129,11 @@
 	tmpFile2 = tmpDir2 + os.path.basename(ptch) + t.getName()
 
 	if fileType == "Sqlite Database" :
-		baseCmd = "echo .dump | " + sqlite_cmd + base + " > " + \
-			  tmpFile1
-		ptchCmd = "echo .dump | " + sqlite_cmd + ptch + " > " + \
-			  tmpFile2
-	
+		baseCmd = ("echo .dump | " + sqlite_cmd + base + " > " +
+			  tmpFile1)
+		ptchCmd = ("echo .dump | " + sqlite_cmd + ptch + " > " +
+			  tmpFile2)
+
 	os.system(baseCmd)
 	os.system(ptchCmd)
 
@@ -1153,24 +1159,24 @@
 			data = diffFileData(tmpFile1, tmpFile2);
 			try:
 				os.unlink(tmpFile1)
-			except OSError, e:
-				error("compareByDumping: unlink failed %s" % e) 
+			except OSError as e:
+				error("compareByDumping: unlink failed %s" % e)
 			try:
 				os.unlink(tmpFile2)
-			except OSError, e:
-				error("compareByDumping: unlink failed %s" % e) 
+			except OSError as e:
+				error("compareByDumping: unlink failed %s" % e)
 			difference(fileName, fileType, data)
- 		return 1
+		return 1
 
 	# Remove the temporary files now.
 	try:
 		os.unlink(tmpFile1)
-	except OSError, e:
-		error("compareByDumping: unlink failed %s" % e) 
+	except OSError as e:
+		error("compareByDumping: unlink failed %s" % e)
 	try:
 		os.unlink(tmpFile2)
-	except OSError, e:
-		error("compareByDumping: unlink failed %s" % e) 
+	except OSError as e:
+		error("compareByDumping: unlink failed %s" % e)
 
 	return 0
 
@@ -1182,7 +1188,7 @@
 def discontinue_processing(signl, frme):
 	global keep_processing
 
-	print >> sys.stderr, "Caught Ctrl-C, stopping the threads"
+	print("Caught Ctrl-C, stopping the threads", file=sys.stderr)
 	keep_processing = False
 
 	return 0
@@ -1263,10 +1269,10 @@
 	debug("Performing cleanup (" + str(ret) + ")")
 	if os.path.isdir(tmpDir1) > 0 :
 		shutil.rmtree(tmpDir1)
-	
+
 	if os.path.isdir(tmpDir2) > 0 :
 		shutil.rmtree(tmpDir2)
-		
+
 	if logging :
 		log.close()
 
@@ -1337,13 +1343,13 @@
 	if sorted :
 		differentFiles = []
 
-	# 
+	#
 	# Build paths to the tools required tools
 	#
 	# Try to look for tools in $SRC/tools if the "-t" option
 	# was specified
 	#
-	arch = commands.getoutput("uname -p")
+	arch = subprocess.check_output("uname -p")
 	if localTools :
 		try:
 			src = os.environ['SRC']
@@ -1386,8 +1392,7 @@
 		sys.exit(1)
 
 	if not os.path.exists(ptchRoot) :
-		error("new proto area: " + ptchRoot + \
-		      " does not exist")
+		error("new proto area: " + ptchRoot + " does not exist")
 		sys.exit(1)
 
 	#
@@ -1406,12 +1411,12 @@
 	tmpDir2 = "/tmp/wsdiff_tmp2_" + str(pid) + "/"
 	try:
 		os.makedirs(tmpDir1)
-	except OSError, e:
-		error("main: makedir failed %s" % e) 
+	except OSError as e:
+		error("main: makedir failed %s" % e)
 	try:
 		os.makedirs(tmpDir2)
-	except OSError, e:
-		error("main: makedir failed %s" % e) 
+	except OSError as e:
+		error("main: makedir failed %s" % e)
 
 	# Derive a catalog of new, deleted, and to-be-compared objects
 	# either from the specified base and patch proto areas, or from
@@ -1455,7 +1460,7 @@
 	# the appropriate comparison routine, where the compare
 	# will happen, and any differences will be reported / logged
 
-	# determine maximum number of worker threads by using 
+	# determine maximum number of worker threads by using
 	# DMAKE_MAX_JOBS environment variable set by nightly(1)
 	# or get number of CPUs in the system
 	try:
@@ -1511,4 +1516,3 @@
 	except KeyboardInterrupt :
 		cleanup(1);
 
-