From 205d9f31d962931bd33f03f78790fd60b8428b13 Mon Sep 17 00:00:00 2001 From: John Klug Date: Fri, 29 Apr 2022 14:43:42 -0500 Subject: Fix python issues in mLinux --- recipes-connectivity/bluez/bluez5/bt-pan/bt-pan | 2 +- recipes-connectivity/bluez/bluez5/bt-pan/init | 2 +- recipes-connectivity/bluez/bluez5/rfcomm/init | 8 ++-- recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py | 29 ++++++------- recipes-connectivity/bluez/bluez5_%.bbappend | 4 +- .../bluez/python-gatt-server_1.0.bb | 24 ----------- .../bluez/python3-gatt-server_1.0.bb | 24 +++++++++++ recipes-connectivity/bluez/python3-pygattlib.bb | 38 ++++++++++++++++ ...Fixed-build-with-Python3.8-and-Boost-1.72.patch | 50 ++++++++++++++++++++++ recipes-devtools/python/python3_%.bbappend | 17 ++++++++ recipes-navigation/gpsd/gpsd_3.20.bb | 4 +- 11 files changed, 153 insertions(+), 49 deletions(-) delete mode 100644 recipes-connectivity/bluez/python-gatt-server_1.0.bb create mode 100644 recipes-connectivity/bluez/python3-gatt-server_1.0.bb create mode 100644 recipes-connectivity/bluez/python3-pygattlib.bb create mode 100644 recipes-connectivity/bluez/python3-pygattlib/0001-Fixed-build-with-Python3.8-and-Boost-1.72.patch create mode 100644 recipes-devtools/python/python3_%.bbappend diff --git a/recipes-connectivity/bluez/bluez5/bt-pan/bt-pan b/recipes-connectivity/bluez/bluez5/bt-pan/bt-pan index f142bb1..8d01bdf 100755 --- a/recipes-connectivity/bluez/bluez5/bt-pan/bt-pan +++ b/recipes-connectivity/bluez/bluez5/bt-pan/bt-pan @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python from __future__ import absolute_import, print_function import os, sys, time, types, subprocess, signal diff --git a/recipes-connectivity/bluez/bluez5/bt-pan/init b/recipes-connectivity/bluez/bluez5/bt-pan/init index 2d3d70a..f8ac23f 100755 --- a/recipes-connectivity/bluez/bluez5/bt-pan/init +++ b/recipes-connectivity/bluez/bluez5/bt-pan/init @@ -2,7 +2,7 @@ NAME=bt-pan SERVER=/usr/libexec/bluetooth/${NAME} -PYTHON=$(readlink -f /usr/bin/python2) +PYTHON=$(readlink -f /usr/bin/python) BRIDGE=pan0 DNAME="${NAME}.${BRIDGE}" PIDFILE="/run/${DNAME}.pid" diff --git a/recipes-connectivity/bluez/bluez5/rfcomm/init b/recipes-connectivity/bluez/bluez5/rfcomm/init index 69455d8..08366ea 100755 --- a/recipes-connectivity/bluez/bluez5/rfcomm/init +++ b/recipes-connectivity/bluez/bluez5/rfcomm/init @@ -2,7 +2,7 @@ NAME=rfcomm SERVER=/usr/libexec/bluetooth/${NAME} -PYTHON=$(readlink -f /usr/bin/python2) +PYTHON=$(readlink -f /usr/bin/python) PIDFILE="/run/${NAME}.pid" ENABLED=yes @@ -16,12 +16,12 @@ fi case $1 in start) echo "Starting ${NAME}" - echo /usr/sbin/start-stop-daemon -S -p ${PIDFILE} -x ${PYTHON} -b -- ${SERVER} ${RFCOMMOPTS} - /usr/sbin/start-stop-daemon -S -p ${PIDFILE} -x ${PYTHON} -b -- ${SERVER} ${RFCOMMOPTS} + echo /usr/sbin/start-stop-daemon -S -p ${PIDFILE} -a ${SERVER} -n ${NAME} -b -- ${RFCOMMOPTS} + /usr/sbin/start-stop-daemon -S -p ${PIDFILE} -a ${SERVER} -n ${NAME} -b -- ${RFCOMMOPTS} ;; stop) - /usr/sbin/start-stop-daemon -K -p ${PIDFILE} -x ${PYTHON} + /usr/bin/pkill --ns $(cat "$PIDFILE") -f " ${SERVER} " echo "Stopping ${DNAME}" ;; diff --git a/recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py b/recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py index e8f2554..cf8fec4 100644 --- a/recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py +++ b/recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python2 -import thread +#!/usr/bin/env python import os import dbus import dbus.service @@ -16,9 +15,7 @@ import grp import stat import atexit import re -import mmap import subprocess -import threading import struct import fcntl import termios @@ -298,9 +295,9 @@ class Profile(dbus.service.Object): # Bluetooth address portion of the path address = os.path.basename(self.path) - numaddr = address[address.find("_")+1:] + numaddr = address[address.find("_")+1:] # Replace _ with : - Name = bluetooth.lookup_name(numaddr.replace("_",":")) + Name = bluetooth.lookup_name(numaddr.replace("_",":")) print('NewConnection(%s, %s, %s:%d)' % (path,Name,type(fd).__name__,self.fd)) lg.info('NewConnection(%s, %s, %s:%d)' % (path,Name,type(fd).__name__,self.fd)) @@ -316,18 +313,18 @@ class Profile(dbus.service.Object): lg.debug('pseudoterminal major and minor: (%d,%d)' % (os.major(slavestat.st_rdev),self.minor)) if not os.path.isdir(RFCOMMDIR): lg.debug('Before mkdir: RFCOMMDIR %s' % (RFCOMMDIR)) - os.mkdir(RFCOMMDIR,0755) + os.mkdir(RFCOMMDIR,0o755) lg.debug('Address %s' % (address)) self.linkPath = RFCOMMDIR + '/' + address + '_' + Name + '_pts' + str(self.minor) - self.slavePath = SLAVEDIR + '/' + str(self.minor) + self.slavePath = SLAVEDIR + '/' + str(self.minor) lg.debug('termPath %s' % (self.linkPath)) self.removeLink(self.notexiting) # linkPath was removed lg.debug('os.symlink(%s,%s)' % (self.slavePath,self.linkPath)) - old = os.umask(002) + old = os.umask(0o002) lg.debug('past umask') try: os.symlink(self.slavePath,self.linkPath) @@ -471,7 +468,7 @@ class Profile(dbus.service.Object): try: os.write(self.fd,data) except Exception as e: - print '%s' % (e) + print('%s' % e) lg.error('%s' % (e)) self.RequestDisconnection(self.path) return True @@ -563,12 +560,12 @@ if __name__ == '__main__': if opts.pseudoterminal and opts.loopback: msg = 'Cannot have both pseudoterminal and loopback option' - print msg + print(msg) lg.error(msg) exit(1) if not opts.pseudoterminal and not opts.loopback and not opts.login: doterm = True - print "main: doterm is %s" % (str(doterm)) + print("main: doterm is %s" % (str(doterm))) if opts.pseudoterminal or opts.login: needpseudot = True @@ -594,7 +591,7 @@ if __name__ == '__main__': rpipe,wpipe = os.pipe() loginProcess = logins() Profile.w = wpipe - lg.debug('Call threading next') + lg.debug('Call StartLogin threading next') try: StartLoginThread = threading.Thread(target=loginProcess.StartLogin,args=[rpipe,mainloop]) except Exception as e: @@ -621,10 +618,10 @@ if __name__ == '__main__': try: manager.RegisterProfile(profile_path, opts.uuid, SPP_opts) except dbus.exceptions.DBusException as inst: - print 'dbus exception:',inst._dbus_error_name + print('dbus exception:',inst._dbus_error_name) lg.error('dbus exception: %s',inst._dbus_error_name) if inst._dbus_error_name == 'org.freedesktop.DBus.Error.AccessDenied': - print 'Try running as root' + print('Try running as root') exit(1) lg.debug('Completed Register Profile...') @@ -636,7 +633,7 @@ if __name__ == '__main__': pass except Exception as e: lg.error('mainloop exception: %s' % (e)) - print '\nSerial Port Profile: ERROR Goodbye' + print('\nSerial Port Profile: ERROR Goodbye') lg.error('Serial Port Profile: ERROR Goodbye') data = struct.pack('i',-1) os.write(wpipe,data) diff --git a/recipes-connectivity/bluez/bluez5_%.bbappend b/recipes-connectivity/bluez/bluez5_%.bbappend index c484558..191ff00 100644 --- a/recipes-connectivity/bluez/bluez5_%.bbappend +++ b/recipes-connectivity/bluez/bluez5_%.bbappend @@ -6,8 +6,8 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" EXTRA_OECONF += "--enable-deprecated --enable-experimental" -RDEPENDS_${PN}-pand += "bash python-dbus python-logging python-syslog python-subprocess python-argparse" -RDEPENDS_${PN}-rfcomm += "bash python-pygobject python-syslog python-logging python-dbus python-pybluez" +RDEPENDS_${PN}-pand += "bash python3-dbus python3-logging python3-syslog" +RDEPENDS_${PN}-rfcomm += "bash python3-pygobject python3-syslog python3-logging python3-dbus python3-pybluez python3-mmap" RDEPENDS_bluez5 += "bash" SRC_URI += "\ diff --git a/recipes-connectivity/bluez/python-gatt-server_1.0.bb b/recipes-connectivity/bluez/python-gatt-server_1.0.bb deleted file mode 100644 index d68d9af..0000000 --- a/recipes-connectivity/bluez/python-gatt-server_1.0.bb +++ /dev/null @@ -1,24 +0,0 @@ -inherit allarch -HOMEPAGE = "https://github.com/Jumperr-labs/python-gatt-server" -SRCREV = "a39ef9773e9ba845f4303b1dfd2efddf24b02238" -PR = "r0" - -S = "${WORKDIR}/git" - -LICENSE = "GPLv2" -LIC_FILES_CHKSUM = "file://LICENSE;md5=c53d04442d1a229d62549856b7ec456a" - -SRC_URI = "git://github.com/Jumperr-labs/python-gatt-server.git;protocol=https" - -RDEPENDS_${PN} += "python-dbus python-pygobject" - -DBTEXEC = "${libexecdir}/bluetooth/" -DEST = "${D}${DBTEXEC}" - -FILES_${PN} = "${DBTEXEC}" - - -do_install_append() { - install -d ${DEST}/${PN} - install -m 0755 ${S}/*.py ${DEST}/${PN} -} diff --git a/recipes-connectivity/bluez/python3-gatt-server_1.0.bb b/recipes-connectivity/bluez/python3-gatt-server_1.0.bb new file mode 100644 index 0000000..712ad3e --- /dev/null +++ b/recipes-connectivity/bluez/python3-gatt-server_1.0.bb @@ -0,0 +1,24 @@ +inherit allarch +HOMEPAGE = "https://github.com/Jumperr-labs/python-gatt-server" +SRCREV = "a39ef9773e9ba845f4303b1dfd2efddf24b02238" +PR = "r0" + +S = "${WORKDIR}/git" + +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://LICENSE;md5=c53d04442d1a229d62549856b7ec456a" + +SRC_URI = "git://github.com/Jumperr-labs/python-gatt-server.git;protocol=https" + +RDEPENDS_${PN} += "python3-dbus python3-pygobject" + +DBTEXEC = "${libexecdir}/bluetooth/" +DEST = "${D}${DBTEXEC}" + +FILES_${PN} = "${DBTEXEC}" + + +do_install_append() { + install -d ${DEST}/${PN} + install -m 0755 ${S}/*.py ${DEST}/${PN} +} diff --git a/recipes-connectivity/bluez/python3-pygattlib.bb b/recipes-connectivity/bluez/python3-pygattlib.bb new file mode 100644 index 0000000..0a5aaee --- /dev/null +++ b/recipes-connectivity/bluez/python3-pygattlib.bb @@ -0,0 +1,38 @@ +DESCRIPTION = "Python BLE GATT Library" +HOMEPAGE = "https://bitbucket.org/OscarAcena/pygattlib" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +DEPENDS = "boost bluez5 glib-2.0" + +inherit setuptools3 + +PR = "r3" +SRCREV = "f319522a2e719a9a05220b42ac16eb360be3fe1c" +SRC_URI = "git://git@gitlab.multitech.net/aep/pygattlib.git;protocol=ssh;branch=master \ + file://0001-Fixed-build-with-Python3.8-and-Boost-1.72.patch \ +" + +SRC_URI[md5sum] = "014bf03c4812f74b6c9e86e1e895bb82" +SRC_URI[sha256sum] = "f759070d59597db1f8d10991497f133eddb9d7f990d15571031d93a397a772e2" + +S = "${WORKDIR}/git" + +inherit autotools-brokensep pkgconfig + +# necessary to let the call for python3-config succeed +export BUILD_SYS +export HOST_SYS +export STAGING_INCDIR +export STAGING_LIBDIR + +do_compile() { + oe_runmake +} + +#TODO +# QA Issue: File /usr/lib/python3.8/lib-dynload/gattlib.so in package pygattlib doesn't have GNU_HASH (didn't pass LDFLAGS?) [ldflags] +do_install() { + install -d ${D}/${libdir}/python3.8/lib-dynload + install -m 0755 ${WORKDIR}/git/src/gattlib.so ${D}/${libdir}/python3.8/lib-dynload/gattlib.so +} diff --git a/recipes-connectivity/bluez/python3-pygattlib/0001-Fixed-build-with-Python3.8-and-Boost-1.72.patch b/recipes-connectivity/bluez/python3-pygattlib/0001-Fixed-build-with-Python3.8-and-Boost-1.72.patch new file mode 100644 index 0000000..7ea253f --- /dev/null +++ b/recipes-connectivity/bluez/python3-pygattlib/0001-Fixed-build-with-Python3.8-and-Boost-1.72.patch @@ -0,0 +1,50 @@ +From 085eb27d2931ffa99a38043ef630107aca1017c9 Mon Sep 17 00:00:00 2001 +From: Mykola Salomatin +Date: Thu, 12 Aug 2021 17:31:15 +0300 +Subject: [PATCH] Fixed build with Python3.8 and Boost 1.72 + +--- + setup.py | 6 ++---- + src/Makefile | 9 ++------- + 2 files changed, 4 insertions(+), 11 deletions(-) + +diff --git a/setup.py b/setup.py +index 3a9f534..19246cf 100755 +--- a/setup.py ++++ b/setup.py +@@ -18,10 +18,8 @@ if sys.platform.startswith('linux'): + glib_libs = glib_libs.strip().split("-l") + glib_libs = [x.strip() for x in glib_libs if x] + +- if sys.version_info.major == 3: +- boost_libs = ["boost_python-py34"] +- else: +- boost_libs = ["boost_python"] ++ boost_libs = ["boost_python38"] ++ + extension_modules = [ + Extension( + 'gattlib', +diff --git a/src/Makefile b/src/Makefile +index 4c742d2..325ee37 100644 +--- a/src/Makefile ++++ b/src/Makefile +@@ -7,13 +7,8 @@ TARGETS = gattlib.so + OBJECTS = att.o crypto.o uuid.o gatt.o gattrib.o btio.o log.o utils.o \ + gattservices.o gattlib.o bindings.o beacon.o + +-ifeq ($(PYTHON_VER),3) +- PYTHON_CONFIG = python3-config +- BOOST_PYTHON = boost_python-py34 +-else +- PYTHON_CONFIG = python-config +- BOOST_PYTHON = boost_python +-endif ++PYTHON_CONFIG = python3-config ++BOOST_PYTHON = boost_python38 + + CFLAGS += -ggdb -fPIC -Wall $$($(PYTHON_CONFIG) --includes) \ + -Ibluez $$(pkg-config --cflags glib-2.0) +-- +2.25.1 + diff --git a/recipes-devtools/python/python3_%.bbappend b/recipes-devtools/python/python3_%.bbappend new file mode 100644 index 0000000..70b4561 --- /dev/null +++ b/recipes-devtools/python/python3_%.bbappend @@ -0,0 +1,17 @@ +# Make python3 the default +# Remove this stuff if there is ever a python4. + +# Debian and Ubuntu have this (prior levels linked to python2) +PACKAGES_append = " python-is-python3" +ALLOW_EMPTY_python-is-python3 = "1" +pkg_postinst_python-is-python3_append() { + ln -sf python3 $D/usr/bin/python +} + +pkg_prerm_python-is-python3_append() { + if [ -L "$D/usr/bin/python" ] ; then + if [ "$(basename $(readlink $D/usr/bin/python))" == "python3" ] ; then + rm $D/usr/bin/python + fi + fi +} diff --git a/recipes-navigation/gpsd/gpsd_3.20.bb b/recipes-navigation/gpsd/gpsd_3.20.bb index 9afe0fe..cc8bd27 100644 --- a/recipes-navigation/gpsd/gpsd_3.20.bb +++ b/recipes-navigation/gpsd/gpsd_3.20.bb @@ -148,6 +148,7 @@ do_install_append() { #support for python install -d ${D}/${PYTHON_SITEPACKAGES_DIR}/gps install -m 755 ${S}/gps/*.py ${D}/${PYTHON_SITEPACKAGES_DIR}/gps + python3 -m compileall ${D}/${PYTHON_SITEPACKAGES_DIR}/gps #support for systemd install -d ${D}${systemd_unitdir}/system/ @@ -184,7 +185,7 @@ pkg_postrm_${PN}-conf() { } -PACKAGES =+ "libgps libgpsd gpsd-udev gpsd-conf gpsd-gpsctl gpspipe gps-utils python3-pygps-dbg python3-pygps" +PACKAGES =+ "libgps libgpsd gpsd-udev gpsd-conf gpsd-gpsctl gpspipe gps-utils python3-pygps-pyc python3-pygps-dbg python3-pygps" # PACKAGES =+ "${PN} ${PN}-dbg ${PN}-dev" # File does not exist: ${libdir}/libQgpsmm.prl @@ -196,6 +197,7 @@ FILES_${PN} += "${sbindir}/gpsd_*" FILES_${PN}-doc += "${docdir}" FILES_${PN}-conf = "${sysconfdir}/default ${sysconfdir}/init.d" +FILES_python3-pygps-pyc = "${PYTHON_SITEPACKAGES_DIR}/gps/__pycache__" RDEPENDS_${PN}-conf = "gpsd-gpsctl bash" -- cgit v1.2.3