Yocto: Install different config files based on MACHINE type or target image

て烟熏妆下的殇ゞ 提交于 2019-12-01 13:14:34
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
}

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.

Maybe useful: https://www.yoctoproject.org/docs/2.4/mega-manual/mega-manual.html#var-OVERRIDES

You can have configuration files in machine specific directories in your particular case (just a specific configuration file for each machine). OpenEmbedded will fetch the most specific one. The directory structure in your recipe directory will look like:

files/<machine1>/asound.conf
files/<machine2>/asound.conf

And your alsa-state.bbappend will contain just one line (you don't need to change do_install because alsa-state.bb already installs asound.conf):

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

BTW: We are using that setup to have specific asound.state file per machine in our project.

Moreover, OpenEmbedded will detect that SRC_URI contains machine specific file and change the PACKAGE_ARCH accordingly, see: https://www.yoctoproject.org/docs/2.5/mega-manual/mega-manual.html#var-SRC_URI_OVERRIDES_PACKAGE_ARCH

Few more words on machine, distro or arch specific files: OE is trying to fetch the most specific file in file:// fetcher. It searches also in the directories named by distro (e.g files/<distro>/asound.conf) and architecture (e.g. armv7a, arm). It might be useful if you want to have file specific for some set of devices. More information: https://www.yoctoproject.org/docs/2.5/mega-manual/mega-manual.html#var-FILESOVERRIDES and also https://www.yoctoproject.org/docs/2.5/mega-manual/mega-manual.html#best-practices-to-follow-when-creating-layers (section "Place Machine-Specific Files in Machine-Specific Locations")

The above answer by clsulliv worked better than advertised. For future reference below is the append file I used:

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
}

Thanks for the help!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!