
1. 为什么做这件事方案缺点现场apt install逐个装客户环境不可控、重复劳动、易漏装构建期一次性注入(本文)镜像即开即用、可复现、可批量出货核心思路:这些协议库在 Debian 源里都是现成包(libsnap7、libopen62541、libmodbus…),不需要自己编译,只要在 Isar 构建配置里把它们写进"预装包列表"即可。2. 方案原理(Isar 路径 B 机制)kas/my-custom.yml 设置 IOT2050_CUSTOM_SUPPORT = "1"(开关) ↓ meta-custom-packages.inc 定义包列表变量(放已有 meta-example 层,不新建层) ↓ iot2050-image-example.bb require 该 inc + 末尾 IMAGE_PREINSTALL 条件注入 ↓ GitHub Actions Build 行链上 kas/my-custom.yml → 构建出的镜像自带全部协议包三个关键设计:用IMAGE_PREINSTALL而不是IMAGE_INSTALL:这些全是 Debian 源现成包,不需要 recipe;IMAGE_INSTALL只用于本层 recipe 构建的包(用错会报Nothing PROVIDES)。开关控制:IOT2050_CUSTOM_SUPPORT = "1"不开时注入行为空,镜像保持原样,可随时回退。不要新建 layer:bitbake 的 layer 必须有conf/layer.conf,否则报layer.conf not found。把 inc 放进已有的meta-example层(与官方iot2050-package-selections.inc同目录、同引用机制)最稳。3. 协议包清单(8 个,全部有 Debian 包)协议语言LicenseDebian 包S7(snap7)C++(C API)LGPL-3.0libsnap7-1 libsnap7-devOPC UA(open62541)CMPL-2.0libopen62541-1.4 libopen62541-1.4-devModbus(libmodbus)CLGPL-2.1+libmodbus5 libmodbus-devMQTT Broker(mosquitto)CEPL-2.0 或 BSD-3-Clausemosquitto mosquitto-clientsMQTT Client C(paho)CEPL-2.0 或 BSD-3-Clauselibpaho-mqtt-devMQTT Client PythonPythonEPL-2.0 或 BSD-3-Clausepy