| DEPENDS += " \ | |
| bare-metal-gpio-monitor \ | |
| google-usb-network \ | |
| " | |
| RDEPENDS:${PN}:append = " \ | |
| bare-metal-gpio-monitor \ | |
| google-usb-network \ | |
| " | |
| FILES:${PN} += " \ | |
| ${systemd_system_unitdir}/google-usb-static*.service.d \ | |
| " | |
| PACKAGE_ARCH = "${MACHINE_ARCH}" | |
| python check_usb_static_units() { | |
| import glob | |
| import os | |
| import re | |
| d_unitdir = d.getVar('D') + d.getVar('systemd_system_unitdir') | |
| sysroot_unitdir = d.getVar('RECIPE_SYSROOT') + d.getVar('systemd_system_unitdir') | |
| sysroot_confdir = d.getVar('RECIPE_SYSROOT') + d.getVar('datadir') + '/google-usb-network' | |
| if not os.path.lexists(os.path.join(sysroot_unitdir, 'google-usb-static@.service')): | |
| bb.fatal('google-usb-static@.service missing from google-usb-network sysroot') | |
| staged_gadgets = sorted( | |
| os.path.basename(p)[:-len('.conf')] | |
| for p in glob.glob(os.path.join(sysroot_confdir, '*.conf')) | |
| ) | |
| if not staged_gadgets: | |
| bb.fatal('No static USB gadget configs in google-usb-network sysroot') | |
| dropin_gadgets = sorted( | |
| os.path.basename(p)[len('google-usb-static@'):-len('.service.d')] | |
| for p in glob.glob(os.path.join(d_unitdir, 'google-usb-static@*.service.d')) | |
| if os.path.basename(p) != 'google-usb-static@.service.d' | |
| ) | |
| if dropin_gadgets and staged_gadgets != dropin_gadgets: | |
| bb.fatal('Staged google-usb-network gadgets (%s) do not match drop-ins (%s)' % | |
| (' '.join(staged_gadgets), ' '.join(dropin_gadgets))) | |
| confs = glob.glob(os.path.join(d_unitdir, 'google-usb-static*.service.d', '*.conf')) | |
| if not confs: | |
| bb.fatal('No google-usb-static*.service.d/*.conf drop-ins installed by %s' % d.getVar('PN')) | |
| for conf in confs: | |
| has_after = False | |
| with open(conf) as f: | |
| for line in f: | |
| m = re.match(r'^(After|Before|Wants|Requires|BindsTo)=(.+)', line.strip()) | |
| if not m: | |
| continue | |
| if m.group(1) == 'After': | |
| has_after = True | |
| for unit in m.group(2).split(): | |
| matches = ( | |
| glob.glob(os.path.join(d_unitdir, unit)) + | |
| glob.glob(os.path.join(d_unitdir, '*.target.wants', unit)) + | |
| glob.glob(os.path.join(sysroot_unitdir, unit)) + | |
| glob.glob(os.path.join(sysroot_unitdir, '*.target.wants', unit)) | |
| ) | |
| if not matches: | |
| bb.fatal('%s references missing or unenabled unit %s' % (conf, unit)) | |
| if not has_after: | |
| bb.fatal('%s missing After= ordering directive' % conf) | |
| } | |
| do_install[postfuncs] += "check_usb_static_units" |