5

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?

Rachid K.
  • 4,490
  • 3
  • 11
  • 30
surfnerd
  • 127
  • 2
  • 3
  • 9
  • Can you please explain more what you try to accomplish? Do you want to move files inside or outside of the final yocto image? – volker Jul 08 '15 at 15:50
  • 1
    Why don't you simply have your recipe install its files in the correct location (i.e. `/opt/xyz`)? – Anders Jul 09 '15 at 06:59

2 Answers2

12

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}
 }

 FILES_${PN} = "${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). Adjust FILES_${PN} var for ${sysconfdir} ${bindir} ${datadir} ${libdir} directories.

flo
  • 192
  • 1
  • 13
4
do_install(){
  install -d ${D}{base_prefix}/opt/xyz/          
  install -m ${WORKDIR}/yourbinary    ${D}${base_prefix}/opt/xyz/
}

FILES_${PN} = "${base_prefix}/opt/*"

above 1st line creates the dir in imagedir in that opt/xvz/

2nd line copy your binary to opt/xyz/dir

3rd line use to copy of your opt/xyz/binary to yocto rootfs.

tchap
  • 3,412
  • 3
  • 29
  • 46
yoctotutor.com
  • 5,145
  • 4
  • 26
  • 36