Yocto recipe : how to install in specific folder

surfnerd picture surfnerd · Jul 8, 2015 · Viewed 11.7k times · Source

I have created a Yocto recipe for my program. What are the default folders that are building image from recipe ? At the time of building image, I want to move my files to another folder like "/opt/xyz".

Should I simply do "mv" or is there any other options?

Answer

flo picture flo · Jul 26, 2015

I guess you want to copy your compiled program to a folder such as ${bindir}:

Quote from Yocto ref-manual 1.1:
When specifying paths as part of the CONFFILES variable, it is good practice to use appropriate path variables. For example, ${sysconfdir} rather than /etc or ${bindir} rather than /usr/bin. You can find a list of these variables at the top of the meta/conf/bitbake.conf file in the Source Directory.

You can copy files from your working directory to any directory in the target filesystem. See the hello-world example for instance (note that the example is taken from the 1.1 reference manual, but I haven't found it yet in the newer version):

 DESCRIPTION = "Simple helloworld application"
 SECTION = "examples"
 LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 PR = "r0"

 SRC_URI = "file://helloworld.c"

 S = "${WORKDIR}"

 do_compile() {
    ${CC} helloworld.c -o helloworld
 }

 do_install() {
    install -d ${D}${bindir}
    install -m 0755 helloworld ${D}${bindir}
 }

In this example, the helloworld binary would be copied to /usr/bin on your image (could be /opt too, see Source Directory for the variable definition).