通过元层覆盖 Yocto 类



感谢您的时间和支持

我打算使用 swupdate 进行更新。因此,我需要创建一个额外的分区,在其中存储恢复分区。

poky/meta/classes/image-live.bbclass

是创建分区并刷新根文件系统的类。我已经更新了上面的文件以再创建一个分区并存储 swupdate 根文件系统。

我如何在我自己的BSP层中覆盖这个类,我不想碰poky源代码。

通常在Yocto中,无法像 .bb文件(使用 .bbappend (那样覆盖.bbclass文件,要存档需要复制整个类文件并移动到另一层,我能够使用此配置来管理它:

层结构:

$ tree ../meta-test/
../meta-test/
├── classes
│   └── image-live.bbclass
├── conf
│   └── layer.conf
├── COPYING.MIT
├── README
└── recipes-example
└── example.bb
3 directories, 5 files

example.bb食谱的内容:

$ cat ../meta-test/recipes-example/example/example.bb 
LICENSE = "CLOSED"
inherit image-live

最后非常重要的事情*,配置文件 conf/bblayers.conf需要配置这个顺序meta-test/上面的meta/layer:

$ tail -n6 conf/bblayers.conf 
BBLAYERS ?= " 
/home/user/poky/meta-test 
/home/user/poky/meta 
/home/user/poky/meta-poky 
/home/user/poky/meta-yocto-bsp 
"
$ bitbake -e example -D | grep ^DEBUG:\sInheriting\s.*image-live.bbclass\s(from
DEBUG: Inheriting /home/user/poky/meta-test/classes/image-live.bbclass (from /home/user/poky/meta-test/recipes-example/example/example.bb:3)

*我不知道为什么 bitbake 图层优先级在这里不起作用,只有在 conf/bblayers.conf中修改图层顺序才能让我实现主要目标:

$ bitbake-layers show-layers
NOTE: Starting bitbake server...
layer                 path                                      priority
==========================================================================
meta                  /home/user/poky/meta        5
meta-test             /home/user/poky/meta-test   10
meta-poky             /home/user/poky/meta-poky   5
meta-yocto-bsp        /home/user/poky/meta-yocto-bsp  5

layermeta-test/undermeta/in conf/bblayers.conf

$ tail -n6 conf/bblayers.conf 
BBLAYERS ?= " 
/home/user/poky/meta 
/home/user/poky/meta-test 
/home/user/poky/meta-poky 
/home/user/poky/meta-yocto-bsp 
"    
$ bitbake -e example -D | grep ^DEBUG:\sInheriting\s.*image-live.bbclass\s(from
DEBUG: Inheriting /home/user/poky/meta/classes/image-live.bbclass (from /home/user/poky/meta-test/recipes-example/example/example.bb:3)

它于2012年在yocto邮件组上被分割: https://lists.yoctoproject.org/pipermail/yocto/2012-January/004379.html

仅创建与 astor555 编写的相同的类并重新排序层。您的BSP层将首先被解析/使用。

另一种选择是将原始image-live.bbclass复制到您自己的现有图层中,并将其重命名为有意义的(my-image-live.bbclass(,然后简单地将其继承到您需要的地方作为inherit my-image-live

最新更新