diff options
author | Mykola Salomatin <mykola.salomatin@globallogic.com> | 2022-05-05 12:28:37 +0300 |
---|---|---|
committer | Mykola Salomatin <mykola.salomatin@globallogic.com> | 2022-05-05 12:28:37 +0300 |
commit | 76bdabe5709107f664a3d851ac2d3eb7a7073dd3 (patch) | |
tree | 43cff2ae4c3c8f104f5dd0623dbf064c6d4c1838 | |
parent | eeb29ee4deaa89e4f10bc193fb9e6714e420aece (diff) | |
parent | ca1aadba53b3683386bc034451212b8317492a83 (diff) | |
download | meta-mlinux-76bdabe5709107f664a3d851ac2d3eb7a7073dd3.tar.gz meta-mlinux-76bdabe5709107f664a3d851ac2d3eb7a7073dd3.tar.bz2 meta-mlinux-76bdabe5709107f664a3d851ac2d3eb7a7073dd3.zip |
Merge remote-tracking branch 'origin/6' into mpower-dev-nxp
15 files changed, 339 insertions, 230 deletions
diff --git a/recipes-connectivity/bluez/bluez5/bt-pan/bt-pan b/recipes-connectivity/bluez/bluez5/bt-pan/bt-pan index f142bb1..07fa125 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 @@ -134,17 +134,17 @@ global lg class BTError(Exception): pass def get_bus(): - bus = getattr(get_bus, 'cached_obj', None) - if not bus: bus = get_bus.cached_obj = dbus.SystemBus() - return bus + bus = getattr(get_bus, 'cached_obj', None) + if not bus: bus = get_bus.cached_obj = dbus.SystemBus() + return bus def get_manager(): - manager = getattr(get_manager, 'cached_obj', None) - if not manager: + manager = getattr(get_manager, 'cached_obj', None) + if not manager: try: - manager = get_manager.cached_obj = dbus.Interface( - get_bus().get_object(iface_base, '/'), - 'org.freedesktop.DBus.ObjectManager' ) + manager = get_manager.cached_obj = dbus.Interface( + get_bus().get_object(iface_base, '/'), + 'org.freedesktop.DBus.ObjectManager' ) except dbus.exceptions.DBusException as e: s="" try: @@ -160,14 +160,14 @@ def get_manager(): exit(1) else: raise - return manager + return manager def prop_get(obj, k, iface=None): - if iface is None: iface = obj.dbus_interface - return obj.Get(iface, k, dbus_interface=iface_props) + if iface is None: iface = obj.dbus_interface + return obj.Get(iface, k, dbus_interface=iface_props) def prop_set(obj, k, v, iface=None): - if iface is None: iface = obj.dbus_interface - return obj.Set(iface, k, v, dbus_interface=iface_props) + if iface is None: iface = obj.dbus_interface + return obj.Set(iface, k, v, dbus_interface=iface_props) msg='' def find_adapter(pattern=None): @@ -195,40 +195,40 @@ def find_adapter(pattern=None): exit(1) else: raise - return adapter + return adapter def find_adapter_in_objects(objects, pattern=None): - bus, obj = get_bus(), None - for path, ifaces in objects.iteritems(): - adapter = ifaces.get(iface_adapter) - if adapter is None: continue - if not pattern or pattern == adapter['Address'] or path.endswith(pattern): - obj = bus.get_object(iface_base, path) - yield dbus.Interface(obj, iface_adapter) - if obj is None: + bus, obj = get_bus(), None + for path, ifaces in objects.items(): + adapter = ifaces.get(iface_adapter) + if adapter is None: continue + if not pattern or pattern == adapter['Address'] or path.endswith(pattern): + obj = bus.get_object(iface_base, path) + yield dbus.Interface(obj, iface_adapter) + if obj is None: msg = 'Bluetooth adapter not found' - lg.error(msg) - raise BTError(msg) + lg.error(msg) + raise BTError(msg) def find_device(device_address, adapter_pattern=None): - return find_device_in_objects(get_manager().GetManagedObjects(), device_address, adapter_pattern) + return find_device_in_objects(get_manager().GetManagedObjects(), device_address, adapter_pattern) def find_device_in_objects(objects, device_address, adapter_pattern=None): - bus = get_bus() - path_prefix = '' - if adapter_pattern: - if not isinstance(adapter_pattern, types.StringTypes): adapter = adapter_pattern - else: adapter = find_adapter_in_objects(objects, adapter_pattern) - path_prefix = adapter.object_path - for path, ifaces in objects.iteritems(): - device = ifaces.get(iface_dev) - if device is None: continue - if device['Address'] == device_address and path.startswith(path_prefix): - obj = bus.get_object(iface_base, path) - return dbus.Interface(obj, iface_dev) + bus = get_bus() + path_prefix = '' + if adapter_pattern: + if not isinstance(adapter_pattern, types.StringTypes): adapter = adapter_pattern + else: adapter = find_adapter_in_objects(objects, adapter_pattern) + path_prefix = adapter.object_path + for path, ifaces in objects.items(): + device = ifaces.get(iface_dev) + if device is None: continue + if device['Address'] == device_address and path.startswith(path_prefix): + obj = bus.get_object(iface_base, path) + return dbus.Interface(obj, iface_dev) msg = 'Bluetooth device not found' - lg.error(msg) - raise BTError(msg) + lg.error(msg) + raise BTError(msg) pidPath = "" @@ -246,177 +246,177 @@ def hexdump(string): ### bt-pan def main(args=None): - import argparse - global lg + import argparse + global lg - # Set up logging initially info and above - lg = flog(myscript,'daemon','info') + # Set up logging initially info and above + lg = flog(myscript,'daemon','info') # cgitb.enable(format='text') - - parser = argparse.ArgumentParser( - description='BlueZ bluetooth PAN network server/client.') - - parser.add_argument('-i', '--device', metavar='local-addr/pattern', - help='Local device address/pattern to use (if not default).') - parser.add_argument('-a', '--device-all', action='store_true', - help='Use all local hci devices, not just default one.' - ' Only valid with "server" mode, mutually exclusive with --device option.') - parser.add_argument('-u', '--uuid', - metavar='uuid_or_shortcut', default='nap', - help='Service UUID to use. Can be either full UUID' - ' or one of the shortcuts: gn, panu, nap. Default: %(default)s.') - parser.add_argument('--systemd', action='store_true', - help='Use systemd service' - ' notification/watchdog mechanisms in daemon modes, if available.') - parser.add_argument('--debug', - action='store_true', help='Verbose operation mode.') - - cmds = parser.add_subparsers( dest='call', - title='Supported operations (have their own suboptions as well)' ) - - cmd = cmds.add_parser('server', help='Run infinitely as a NAP network server.') - cmd.add_argument('iface_name', - help='Bridge interface name to which each link will be added by bluez.' - ' It must be created and configured before starting the server.') - - cmd = cmds.add_parser('client', help='Connect to a PAN network.') - cmd.add_argument('remote_addr', help='Remote device address to connect to.') - cmd.add_argument('-d', '--disconnect', action='store_true', - help='Instead of connecting (default action), disconnect' - ' (if connected) and exit. Overrides all other options for this command.') - cmd.add_argument('-w', '--wait', action='store_true', - help='Go into an endless wait-loop after connection, terminating it on exit.') - cmd.add_argument('-c', '--if-not-connected', action='store_true', - help='Dont raise error if connection is already established.') - cmd.add_argument('-r', '--reconnect', action='store_true', - help='Force reconnection if some connection is already established.') - - opts = parser.parse_args() + + parser = argparse.ArgumentParser( + description='BlueZ bluetooth PAN network server/client.') + + parser.add_argument('-i', '--device', metavar='local-addr/pattern', + help='Local device address/pattern to use (if not default).') + parser.add_argument('-a', '--device-all', action='store_true', + help='Use all local hci devices, not just default one.' + ' Only valid with "server" mode, mutually exclusive with --device option.') + parser.add_argument('-u', '--uuid', + metavar='uuid_or_shortcut', default='nap', + help='Service UUID to use. Can be either full UUID' + ' or one of the shortcuts: gn, panu, nap. Default: %(default)s.') + parser.add_argument('--systemd', action='store_true', + help='Use systemd service' + ' notification/watchdog mechanisms in daemon modes, if available.') + parser.add_argument('--debug', + action='store_true', help='Verbose operation mode.') + + cmds = parser.add_subparsers( dest='call', + title='Supported operations (have their own suboptions as well)' ) + + cmd = cmds.add_parser('server', help='Run infinitely as a NAP network server.') + cmd.add_argument('iface_name', + help='Bridge interface name to which each link will be added by bluez.' + ' It must be created and configured before starting the server.') + + cmd = cmds.add_parser('client', help='Connect to a PAN network.') + cmd.add_argument('remote_addr', help='Remote device address to connect to.') + cmd.add_argument('-d', '--disconnect', action='store_true', + help='Instead of connecting (default action), disconnect' + ' (if connected) and exit. Overrides all other options for this command.') + cmd.add_argument('-w', '--wait', action='store_true', + help='Go into an endless wait-loop after connection, terminating it on exit.') + cmd.add_argument('-c', '--if-not-connected', action='store_true', + help='Dont raise error if connection is already established.') + cmd.add_argument('-r', '--reconnect', action='store_true', + help='Force reconnection if some connection is already established.') + + opts = parser.parse_args() if opts.debug: lg.setThreshold('debug') - if not opts.device_all: devs = [next(iter(find_adapter(opts.device)))] - else: - if opts.call != 'server': - parser.error('--device-all option is only valid with "server" mode.') - devs = list(find_adapter()) - devs = dict((prop_get(dev, 'Address'), dev) for dev in devs) - for dev_addr, dev in devs.viewitems(): - prop_set(dev, 'Powered', True) - lg.debug('Using local device (addr: %s): %s', dev_addr, dev.object_path) - - wait_iter_noop = 3600 - if opts.systemd: - from systemd import daemon - def wait_iter(): - if not wait_iter.sd_ready: - daemon.notify('READY=1') - daemon.notify('STATUS=Running in {} mode...'.format(opts.call)) - wait_iter.sd_ready = True - time.sleep(wait_iter.timeout) - if wait_iter.sd_wdt: daemon.notify('WATCHDOG=1') - wd_pid, wd_usec = (os.environ.get(k) for k in ['WATCHDOG_PID', 'WATCHDOG_USEC']) - if wd_pid and wd_pid.isdigit() and int(wd_pid) == os.getpid(): - wd_interval = float(wd_usec) / 2e6 # half of interval in seconds - assert wd_interval > 0, wd_interval - else: wd_interval = None - if wd_interval: - lg.debug('Initializing systemd watchdog pinger with interval: %ss', wd_interval) - wait_iter.sd_wdt, wait_iter.timeout = True, min(wd_interval, wait_iter_noop) - else: wait_iter.sd_wdt, wait_iter.timeout = False, wait_iter_noop - wait_iter.sd_ready = False - else: wait_iter = lambda: time.sleep(wait_iter_noop) - signal.signal(signal.SIGTERM, lambda sig,frm: sys.exit(0)) - - - if opts.call == 'server': + if not opts.device_all: devs = [next(iter(find_adapter(opts.device)))] + else: + if opts.call != 'server': + parser.error('--device-all option is only valid with "server" mode.') + devs = list(find_adapter()) + devs = dict((prop_get(dev, 'Address'), dev) for dev in devs) + for dev_addr, dev in devs.items(): + prop_set(dev, 'Powered', True) + lg.debug('Using local device (addr: %s): %s', dev_addr, dev.object_path) + + wait_iter_noop = 3600 + if opts.systemd: + from systemd import daemon + def wait_iter(): + if not wait_iter.sd_ready: + daemon.notify('READY=1') + daemon.notify('STATUS=Running in {} mode...'.format(opts.call)) + wait_iter.sd_ready = True + time.sleep(wait_iter.timeout) + if wait_iter.sd_wdt: daemon.notify('WATCHDOG=1') + wd_pid, wd_usec = (os.environ.get(k) for k in ['WATCHDOG_PID', 'WATCHDOG_USEC']) + if wd_pid and wd_pid.isdigit() and int(wd_pid) == os.getpid(): + wd_interval = float(wd_usec) / 2e6 # half of interval in seconds + assert wd_interval > 0, wd_interval + else: wd_interval = None + if wd_interval: + lg.debug('Initializing systemd watchdog pinger with interval: %ss', wd_interval) + wait_iter.sd_wdt, wait_iter.timeout = True, min(wd_interval, wait_iter_noop) + else: wait_iter.sd_wdt, wait_iter.timeout = False, wait_iter_noop + wait_iter.sd_ready = False + else: wait_iter = lambda: time.sleep(wait_iter_noop) + signal.signal(signal.SIGTERM, lambda sig,frm: sys.exit(0)) + + + if opts.call == 'server': inm = opts.iface_name - brctl = subprocess.Popen( - ['brctl', 'show', inm], - stdout=open(os.devnull, 'wb'), stderr=subprocess.PIPE ) - brctl_stderr = brctl.stderr.read() + brctl = subprocess.Popen( + ['brctl', 'show', inm], + stdout=open(os.devnull, 'wb'), stderr=subprocess.PIPE ) + brctl_stderr = brctl.stderr.read() writePidFile(opts.iface_name) - if brctl.wait() or brctl_stderr: - lg.error('brctl check failed for interface (missing?): {}'.format(inm)) - lg.error('Bridge interface must be added and configured before starting server, e.g. with:') - lg.error(' brctl addbr {}'.format(inm)) - lg.error(' brctl setfd {} 0'.format(inm)) - lg.error(' brctl stp {} off'.format(inm)) - lg.error(' ip addr add 10.101.225.84/24 dev {}'.format(inm)) - lg.error(' ip link set {} up'.format(inm)) - return 1 - - servers = list() - try: - for dev_addr, dev in devs.viewitems(): - server = dbus.Interface(dev, 'org.bluez.NetworkServer1') - server.Unregister(opts.uuid) # in case already registered - server.Register(opts.uuid, opts.iface_name) - servers.append(server) - lg.debug( 'Registered uuid %r with' - ' bridge/dev: %s / %s', opts.uuid, opts.iface_name, dev_addr ) - while True: wait_iter() - except KeyboardInterrupt: pass - finally: - if servers: - for server in servers: server.Unregister(opts.uuid) - lg.debug('Unregistered server uuids') - - - elif opts.call == 'client': - dev_remote = find_device(opts.remote_addr, devs.values()[0]) - lg.debug( 'Using remote device (addr: %s): %s', - prop_get(dev_remote, 'Address'), dev_remote.object_path ) - try: dev_remote.ConnectProfile(opts.uuid) - except: pass # no idea why it fails sometimes, but still creates dbus interface - net = dbus.Interface(dev_remote, 'org.bluez.Network1') - - if opts.disconnect: - try: net.Disconnect() - except dbus.exceptions.DBusException as err: - if err.get_dbus_name() != 'org.bluez.Error.Failed': raise - connected = prop_get(net, 'Connected') - if connected: raise - lg.debug( - 'Disconnected from network' - ' (dev_remote: %s, addr: %s) uuid %r, by explicit command', - dev_remote.object_path, prop_get(dev_remote, 'Address'), opts.uuid ) - return - - for n in xrange(2): - try: iface = net.Connect(opts.uuid) - except dbus.exceptions.DBusException as err: - if err.get_dbus_name() != 'org.bluez.Error.Failed': raise - connected = prop_get(net, 'Connected') - if not connected: raise - if opts.reconnect: - lg.debug( 'Detected pre-established connection' - ' (iface: %s), reconnecting', prop_get(net, 'Interface') ) - net.Disconnect() - continue - if not opts.if_not_connected: raise - else: break - lg.debug( - 'Connected to network (dev_remote: %s, addr: %s) uuid %r with iface: %s', - dev_remote.object_path, prop_get(dev_remote, 'Address'), opts.uuid, iface ) - - if opts.wait: - try: - while True: wait_iter() - except KeyboardInterrupt: pass - finally: - net.Disconnect() - lg.debug('Disconnected from network') - - - else: raise ValueError(opts.call) + if brctl.wait() or brctl_stderr: + lg.error('brctl check failed for interface (missing?): {}'.format(inm)) + lg.error('Bridge interface must be added and configured before starting server, e.g. with:') + lg.error(' brctl addbr {}'.format(inm)) + lg.error(' brctl setfd {} 0'.format(inm)) + lg.error(' brctl stp {} off'.format(inm)) + lg.error(' ip addr add 10.101.225.84/24 dev {}'.format(inm)) + lg.error(' ip link set {} up'.format(inm)) + return 1 + + servers = list() + try: + for dev_addr, dev in devs.items(): + server = dbus.Interface(dev, 'org.bluez.NetworkServer1') + server.Unregister(opts.uuid) # in case already registered + server.Register(opts.uuid, opts.iface_name) + servers.append(server) + lg.debug( 'Registered uuid %r with' + ' bridge/dev: %s / %s', opts.uuid, opts.iface_name, dev_addr ) + while True: wait_iter() + except KeyboardInterrupt: pass + finally: + if servers: + for server in servers: server.Unregister(opts.uuid) + lg.debug('Unregistered server uuids') + + + elif opts.call == 'client': + dev_remote = find_device(opts.remote_addr, devs.values()[0]) + lg.debug( 'Using remote device (addr: %s): %s', + prop_get(dev_remote, 'Address'), dev_remote.object_path ) + try: dev_remote.ConnectProfile(opts.uuid) + except: pass # no idea why it fails sometimes, but still creates dbus interface + net = dbus.Interface(dev_remote, 'org.bluez.Network1') + + if opts.disconnect: + try: net.Disconnect() + except dbus.exceptions.DBusException as err: + if err.get_dbus_name() != 'org.bluez.Error.Failed': raise + connected = prop_get(net, 'Connected') + if connected: raise + lg.debug( + 'Disconnected from network' + ' (dev_remote: %s, addr: %s) uuid %r, by explicit command', + dev_remote.object_path, prop_get(dev_remote, 'Address'), opts.uuid ) + return + + for n in xrange(2): + try: iface = net.Connect(opts.uuid) + except dbus.exceptions.DBusException as err: + if err.get_dbus_name() != 'org.bluez.Error.Failed': raise + connected = prop_get(net, 'Connected') + if not connected: raise + if opts.reconnect: + lg.debug( 'Detected pre-established connection' + ' (iface: %s), reconnecting', prop_get(net, 'Interface') ) + net.Disconnect() + continue + if not opts.if_not_connected: raise + else: break + lg.debug( + 'Connected to network (dev_remote: %s, addr: %s) uuid %r with iface: %s', + dev_remote.object_path, prop_get(dev_remote, 'Address'), opts.uuid, iface ) + + if opts.wait: + try: + while True: wait_iter() + except KeyboardInterrupt: pass + finally: + net.Disconnect() + lg.debug('Disconnected from network') + + + else: raise ValueError(opts.call) global pidPath - try: - os.remove(pidPath) + try: + os.remove(pidPath) except OSError: - pass - lg.debug('Finished') + pass + lg.debug('Finished') if __name__ == '__main__': sys.exit(main()) 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/python3-gatt-server_1.0.bb index d68d9af..712ad3e 100644 --- a/recipes-connectivity/bluez/python-gatt-server_1.0.bb +++ b/recipes-connectivity/bluez/python3-gatt-server_1.0.bb @@ -10,7 +10,7 @@ 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" +RDEPENDS_${PN} += "python3-dbus python3-pygobject" DBTEXEC = "${libexecdir}/bluetooth/" DEST = "${D}${DBTEXEC}" diff --git a/recipes-connectivity/bluez/python3-pygattlib.unused b/recipes-connectivity/bluez/python3-pygattlib.unused new file mode 100644 index 0000000..0a5aaee --- /dev/null +++ b/recipes-connectivity/bluez/python3-pygattlib.unused @@ -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 <mykola.salomatin@globallogic.com> +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-connectivity/lora/lora-gateway-sx1303_2.0.19.bb b/recipes-connectivity/lora/lora-gateway-sx1303_2.0.20.bb index 312eda4..312eda4 100644 --- a/recipes-connectivity/lora/lora-gateway-sx1303_2.0.19.bb +++ b/recipes-connectivity/lora/lora-gateway-sx1303_2.0.20.bb diff --git a/recipes-connectivity/lora/lora-gateway_5.0.10.bb b/recipes-connectivity/lora/lora-gateway_5.0.12.bb index 6be0c47..90f3f51 100644 --- a/recipes-connectivity/lora/lora-gateway_5.0.10.bb +++ b/recipes-connectivity/lora/lora-gateway_5.0.12.bb @@ -8,7 +8,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=a2bdef95625509f821ba00460e3ae0eb" DEPENDS = "gpsd" RDEPENDS_${PN} = "libgps" -PR = "r32" +PR = "r34" SRCREV = "${PV}" SRC_URI = "git://git.multitech.net/lora_gateway_mtac_full;branch=master;protocol=git \ diff --git a/recipes-connectivity/lora/lora-network-server_2.5.35.bb b/recipes-connectivity/lora/lora-network-server_2.5.47.bb index 395fb0f..80f44d2 100644 --- a/recipes-connectivity/lora/lora-network-server_2.5.35.bb +++ b/recipes-connectivity/lora/lora-network-server_2.5.47.bb @@ -13,8 +13,8 @@ SRC_URI = "https://multitech.net/downloads/lora-network-server_${PV}.tar.gz \ file://lora-network-server.default \ " -SRC_URI[md5sum] = "94044e85f244776fc3e79afece3f8205" -SRC_URI[sha256sum] = "d905d80f8375c81389a939ec78770c27cc979554bc2618f1ad162c94b3d8d3ce" +SRC_URI[md5sum] = "b6d9f84be49bb12971a75db13a31404c" +SRC_URI[sha256sum] = "ec53129b04d8ed5da97c8a710491e038b4e96d1470d8b9d38baf65e37f266784" # binaries are already stripped, so suppress warning INSANE_SKIP_${PN} = "already-stripped" diff --git a/recipes-connectivity/lora/lora-packet-forwarder_4.0.12.bb b/recipes-connectivity/lora/lora-packet-forwarder_4.0.18.bb index 35ffaf5..3eaa70a 100644 --- a/recipes-connectivity/lora/lora-packet-forwarder_4.0.12.bb +++ b/recipes-connectivity/lora/lora-packet-forwarder_4.0.18.bb @@ -8,7 +8,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=22af7693d7b76ef0fc76161c4be76c45" DEPENDS = "lora-gateway logrotate lora-logging gpsd" RDEPENDS_${PN} += "bash" FILESEXTRAPATHS_append_mtcdt3hs := ":${THISDIR}/lora-packet-forwarder/mtcdt3" -PR = "r30" +PR = "r32" SRCREV = "${PV}" PACKAGE_ARCH = "${MACHINE_ARCH}" diff --git a/recipes-devtools/python/python3-cffi_%.bbappend b/recipes-devtools/python/python3-cffi_%.bbappend new file mode 100644 index 0000000..59cde4e --- /dev/null +++ b/recipes-devtools/python/python3-cffi_%.bbappend @@ -0,0 +1,5 @@ +# pycparser is for doing build of C or C++ code and +# should not be on an embedded device +RDEPENDS_${PN}_class-target_remove = " \ + ${PYTHON_PN}-pycparser \ +" 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" |