0
votes

I am trying to add a json to /etc on a device. Have read many SO answers and not found a solution. The new json is called audio_config.json, it is under files/ in the same directory as the .bbappend. Am using append because this file is needed only on one device model while the main recipe is on many models.

Doing this:

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI += "file://audio_config.json"

do_install_append() {
   install -d ${D}${sysconfdir}
   install -m 644 ${B}/audio_config.json ${D}${sysconfdir}
}

Gets an error saying that the json is not in the work directory. The same thing happens if I use ${WORKDIR} instead of ${B}. Other recipes in this tree follow this same model, not sure what the problem is.

If I use ${THISDIR} then it says that the json is not located in the base recipe directory - which it's not supposed to be.

From SO posts I have tried

FILES_${PN}-audio_config.json = "${sysconfdir}/audio_config.json"

But that seems to have no effect.

TIA!

3
Is it xraudio_config.json or audio_config.json? Cause your install seems to do install -m 644 ${B}/xraudio_config.json ${D}${sysconfdir}. - Alexander Bollaert
Sorry that was a typo, I have corrected it. - Jason
If the audio_config.json is located at ${RECIPE_APPEND_DIR}/files/audio_config.json, it should be able to find it, and then you should be able to do install -m 644 ${WORKDIR}/audio_config.json ${D}${sysconfdir} - Alexander Bollaert
Did you try to debug verifying both SRC_URI and FILESEXTRAPATHS using bbdebug ? You can also use devshell task to ensure file is present in working path ? - ogs

3 Answers

0
votes

According to users and documentation, what I had above should have worked. But it didn't. What did work was this:

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

do_install_append() {
   install -d ${D}${sysconfdir}
   install -m 644 ${AUDIO_CONFIG_FILES}/audio_config.json ${D}${sysconfdir}
}

Using a variable for immediate expansion of $THISDIR set the local path correctly and the install occurs.

0
votes

In do_unpack() the file is copied to ${WORKDIR}, not ${B} (build dir) and not ${S} (sources dir). This recipe works for me with Yocto Dunfell:

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI += "file://audio_config.json"

do_install_append() {
   install -d ${D}${sysconfdir}
   install -m 644 ${WORKDIR}/audio_config.json ${D}${sysconfdir}
}

Note the different source path argument in the second call to install.

I'm guessing that there was a yocto/bitbake bug that affected you.

0
votes

You were right to add the FILES_${PN} to add the file to the image. But do not add any suffix to it, just append your file to the variable:

FILES_${PN} += "${sysconfdir}/audio_config.json"

Also, you should use the ${WORKDIR} in your install.

install -m 644 ${WORKDIR}/audio_config.json ${D}${sysconfdir}

Also check the work directory of your package to get some logs and see the files actually retrieved for an easier debugging.