我有几个硬件平台(相同的CPU等)需要不同的asound.conf文件。
我控制目标平台的方式是通过 MACHINE 变量和目标图像(即MACHINE=machine_1 不错的 bitbake machine-1-bringup-image)
通常,如果只是替换 conf 文件,我只会创建一个 alsa-state.bbappend 并创建一个 do_install_append 函数来替换它。
但是,由于不同的硬件平台需要不同的 conf 文件,我不确定如何处理它。
我尝试将一些逻辑放入附加文件do_install_append函数中,但它不起作用。它并不总是选择正确的文件(就像它认为没有任何变化,所以它使用以前的缓存 conf?
这是我尝试过的附加文件之一的示例:
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
}
我可以根据逻辑在日志中看到正确的回声。
无论如何,我不认为我正在走的道路是处理这个问题的最好方法。
是否有一种"标准"方法可以根据目标映像或 MACHINE 变量安装不同的文件?
在特定情况下,您可以将配置文件放在特定于计算机的目录中(只需每台计算机的特定配置文件)。OpenEmbedded将获取最具体的一个。配方目录中的目录结构如下所示:
files/<machine1>/asound.conf
files/<machine2>/asound.conf
您的alsa-state.bbappend
将只包含一行(您无需更改do_install
,因为 alsa-state.bb 已经安装了asound.conf
):
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
顺便说一句:我们正在使用该设置在我们的项目中为每台机器提供特定的asound.state
文件。
此外,OpenEmbedded将检测到SRC_URI包含特定于机器的文件并相应地更改PACKAGE_ARCH,请参阅:https://www.yoctoproject.org/docs/2.5/mega-manual/mega-manual.html#var-SRC_URI_OVERRIDES_PACKAGE_ARCH
关于机器、发行版或架构特定文件的更多文字:OE 正在尝试在file://
抓取器中获取最具体的文件。它还搜索按发行版(例如files/<distro>/asound.conf
)和架构(例如armv7a,arm)命名的目录。如果要为某些设备集提供特定于文件的文件,则可能会很有用。详细信息:https://www.yoctoproject.org/docs/2.5/mega-manual/mega-manual.html#var-FILESOVERRIDES 和 https://www.yoctoproject.org/docs/2.5/mega-manual/mega-manual.html#best-practices-to-follow-when-creating-layers("将特定于计算机的文件放置在特定于计算机的位置"部分)
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 中,可以在函数追加的末尾使用,以便对函数进行特定于 MACHINE 的添加。
也许有用:https://www.yoctoproject.org/docs/2.4/mega-manual/mega-manual.html#var-OVERRIDES
clsulliv 的上述回答比宣传的要好。 供将来参考,以下是我使用的附加文件:
FILESEXTRAPATHS_prepend:= "${THISDIR}/${PN}:"
SRC_URI += "
file://machine1_asound.conf
file://machine2_asound.conf
"
do_install_append_machine1() {
echo " machine1"
echo " installing ${WORKDIR}/machine1_asound.conf to ${D}${sysconfdir}/asound.conf"
install -m 644 ${WORKDIR}/machine1_asound.conf ${D}${sysconfdir}/asound.conf
}
do_install_append_machine2() {
echo " machine2"
echo " installing ${WORKDIR}/machine2_asound.conf to ${D}${sysconfdir}/asound.conf"
install -m 644 ${WORKDIR}/machine2_asound.conf ${D}${sysconfdir}/asound.conf
}
感谢您的帮助!