You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

编写适配Meson+Wrap的nvme-cli Yocto Recipe遇依赖问题求解决

Yocto构建nvme-cli 2.x版本的依赖问题解决方案

问题场景

在Yocto项目中尝试添加nvme-cli 2.x版本软件包(1.13版本后构建系统切换为Meson),自行编写的Recipe如下:

SUMMARY = "NVMe management command line interface"
AUTHOR = "......"
HOMEPAGE = "https://github.com/linux-nvme/nvme-cli"
SECTION = "console/utils"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://LICENSE;md5=8264535c0c4e9c6c335635c4026a8022"
DEPENDS = "util-linux"
PV .= "+git${SRCPV}"

SRC_URI = "git://github.com/linux-nvme/nvme-cli.git"
SRCREV = "0b2961e62f4138f991c3af6b5deea60d9900174e"

S = "${WORKDIR}/git"

inherit meson bash-completion systemd

构建时触发错误:

Run-time dependency libnvme found: NO (tried pkgconfig and cmake)
Looking for a fallback subproject for the dependency libnvme

../git/meson.build:48:0: ERROR: Automatic wrap-based subproject downloading is disabled

根源是Yocto的meson.bbclass默认设置--wrap-mode nodownload参数,禁止Meson自动下载依赖子项目,而nvme-cli 2.x依赖的libnvme未在当前构建环境中配置对应的Recipe。

成熟解决方案

方案1:添加libnvme独立Recipe(推荐)

这是符合Yocto依赖管理规范的标准做法,通过单独维护libnvme的Recipe,让Yocto统一管控依赖的构建与版本:

  1. 创建libnvme的Recipe文件(示例路径:recipes-support/libnvme/libnvme_git.bb),内容参考:
SUMMARY = "NVMe userspace library"
HOMEPAGE = "https://github.com/linux-nvme/libnvme"
SECTION = "libs"
LICENSE = "LGPL-2.1-or-later"
LIC_FILES_CHKSUM = "file://COPYING;md5=4fbd65380cdd255951079008b364516c"

DEPENDS = "util-linux"

SRC_URI = "git://github.com/linux-nvme/libnvme.git"
# 需选择与nvme-cli版本匹配的libnvme commit,可查看nvme-cli的submodule配置确认对应版本
SRCREV = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

S = "${WORKDIR}/git"

inherit meson pkgconfig
  1. 修改nvme-cli的Recipe,将libnvme添加到依赖列表:
DEPENDS = "util-linux libnvme"
  1. 重新构建nvme-cli,Yocto会自动先完成libnvme的构建,再推进nvme-cli的编译流程。

方案2:临时允许Meson下载子项目(不推荐)

若仅用于临时验证,不想单独维护libnvme的Recipe,可在nvme-cli的Recipe中覆盖MESONOPTS参数,调整Meson的子项目下载模式:

MESONOPTS_remove = "--wrap-mode nodownload"
MESONOPTS_append = "--wrap-mode default"

该方式绕过了Yocto的依赖管控机制,依赖子项目的版本由Meson自动获取,无法通过Yocto的SRCREV固定版本,长期维护存在构建不可复现的风险,仅适合短期测试场景。

内容的提问来源于stack exchange,提问作者GT Lee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 10:35:19