Yocto - 如何给配方文件添加源码patch

本文介绍了如何在Yocto项目中使用devtool安全地对配方进行修改、构建和部署,避免了直接在工作目录操作可能导致的问题。通过devtool,用户可以在本地文件夹工作,并创建临时层管理修改,确保了代码的完整性与版本控制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Yocto - How to patch in a recipe with devtool
Yocto: Modifying, building, deploying and patching a recipe with Yocto devtool
[ Yocto: 使用 Yocto devtool 修改、构建、部署和修补配方  ]
OpenEmbedded 从源代码构建所有内容的一个好处是,对构建的任何内容进行修改都相当容易,但第一次这样做可能有点令人生畏。
作为构建配方的一部分,OE 会创建一个 <output_dir>/tmp/work/<architecture>/<recipe>/<version> 目录,称为 "工作目录"。构建配方的所有工作都在此完成。在这个目录中,你可以找到源代码,通常位于名为 <recipe_name>-<version> 或 "git"(取决于获取源代码的方式)的子目录下。在这里做一些简单的修改,然后重新编译,这是很诱人的做法(过去人们也经常这么做),但有几个原因说明这不是个好主意:
One of the useful things about OpenEmbedded building everything from source is that it's fairly easy to make changes to anything that gets built, but doing so for the first time can be a bit daunting.
As part of building a recipe, OE creates a <output_dir>/tmp/work/<architecture>/<recipe>/<version> directory, known as the "work directory". This is where all of the work done to build a recipe takes place. One of the things you'll find in this directory is the source, usually under a subdirectory named <recipe_name>-<version> or "git" (depending on how the fetched source is provided). The temptation (and what people used to do in the past) is to simply make changes here and then recompile, but there are several reasons why that's not a good idea:
  • 它很笨拙--你必须使用 bitbake -c compile -f 或 bitbake -C compile 来强制重新编译,因为编译系统不知道你做了任何改动
  • 稍有不慎,就很容易丢失修改内容,例如,运行 bitbake -c clean 会抹掉目录
  • It's awkward - you have to use bitbake -c compile -f or bitbake -C compile to force recompilation, since the build system doesn't know that you've made any changes
  • You can easily lose your changes if you're not careful e.g. running bitbake -c clean will wipe the directory out
另外,除了work目录,还有work-shared目录可以存放一些源文件。比如Kernel source就在这个目录里。
幸运的是,如果你使用的是 Fido (1.8) 或更高版本,有一个更好的方法,那就是使用 devtool 命令:
devtool 允许你将一个 Yocto 配方解压缩到本地文件夹中,这样你就可以在其中工作了。
devtool 会创建一个临时层,级别设置为 99,这样它就会覆盖所有其他层。它会检查你的代码,并创建一个 "devtool "分支。
在源文件中添加配方补丁的步骤如下:
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜流冰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值