Yocto:根据机器类型或目标映像安装不同的配置文件 [英] Yocto: Install different config files based on MACHINE type or target image

查看:89
本文介绍了Yocto:根据机器类型或目标映像安装不同的配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个需要不同asound.conf文件的硬件平台(相同的cpu等).

I've got a couple of HW platforms (same cpu, etc.) that require different asound.conf files.

我控制目标平台的方式是通过MACHINE变量和目标图像(即 MACHINE = machine_1漂亮的bitbake machine-1-bringup-image )

The way that I'm controlling the target platform is via the MACHINE variable and target image (i.e., MACHINE=machine_1 nice bitbake machine-1-bringup-image)

通常,如果仅替换conf文件,我将创建一个alsa-state.bbappend并创建一个do_install_append函数来替换它.

Normally, if just replacing the conf file I'd just create an alsa-state.bbappend and create a do_install_append function to replace it.

但是,由于不同的硬件平台需要不同的conf文件,因此我不确定如何处理.

However since the different HW platforms require differ conf files I'm unsure how to handle it.

我尝试将一些逻辑放入附加文件do_install_append函数中,但无法正常工作.它并不总是选择正确的文件(就像它认为没有什么变化,因此它使用以前的缓存conf?)

I've tried putting some logic into the append file do_install_append function but it's not working out. It's not always picking up the correct file (like it thinks that nothing has changed so that it uses the previous cached conf?)

这是我尝试过的一个附加文件的示例:

Here's an example of one of the append files that I've tried:

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

SRC_URI += " \ file://asound_MACHINE1.conf \ 
               file://asound_MACHINE2.conf \ "

do_install_append() {

echo "    alsa-state.bbappend MACHINE: ${MACHINE}"
if [ "${MACHINE}" = "machine_1" ]; then
    echo "    machine_1"
    echo "    installing ${WORKDIR}/asound_MACHINE1.conf to ${D}${sysconfdir}/asound.conf"

    install -m 644 ${WORKDIR}/asound_MACHINE1.conf {D}${sysconfdir}/asound.conf

else
    echo "    installing ${WORKDIR}/asound_MACHINE2.conf to ${D}${sysconfdir}/asound.conf"
    install -m 644 ${WORKDIR}/asound_MACHINE2.conf ${D}${sysconfdir}/asound.conf

fi

}

我可以按照逻辑在日志中看到正确的回声.

I can see the correct echoes in the logs per the logic.

无论如何,我都不认为我要走的路是解决此问题的最佳方法.

At any rate I don't think that the path I'm going down is the best way to deal with this.

是否有一种标准"方式可以根据目标映像或MACHINE变量安装不同的文件?

Is there a 'standard' way to have different files installed based on either the target image or MACHINE variable?

推荐答案

do_install_append () {
    // install common things here
}

do_install_append_machine-1 () {
    // install machine-1 specific things here
}

do_install_append_machine-2 () {
    // install machine-2 specific things here
}

MACHINE的值会自动添加到OVERRIDES中,可以在函数附加的末尾使用OVERRIDES来为函数添加MACHINE特定的附加内容.

The value of MACHINE is automatically added to OVERRIDES, which can be used at the end of a function append to have a MACHINE-specific addition to a function.

可能有用: https://www.yoctoproject.org/docs/2.4/mega-manual/mega-manual.html#var-OVERRIDES

这篇关于Yocto:根据机器类型或目标映像安装不同的配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆