"""Qualify linked chat code and ship its MIT notice without touching firmware.""" import hashlib import json from pathlib import Path import shutil import struct import subprocess import sys import tempfile import unittest ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ROOT / "scripts")) import package_meshtext_license as license import firmware_memory_manifest as memory import firmware_build_recipe as recipe import package_cascade_release as release SYMBOLS = ("_ZN4mesh2mt10encodeTextEj", "_ZN4mesh2mt10decodeTextEj", "_ZN6MyMesh16sendMeshtextTextEj", "_ZN6MyMesh19onForeignRadioFrameEj", "_ZN4mesh10Dispatcher22queueForeignRadioFrameEj") def elf32(path, symbols=SYMBOLS, flags=6, undefined=(), zero=()): names, table = bytearray(b"\0"), bytearray(16) data = b"CODE" * max(1, len(symbols)) for i, name in enumerate(symbols): offset = len(names) names += name.encode() + b"\0" table += struct.pack("