How do I add my custom directory entirely to the rootfs of the yocto project? - yocto

How do I add my custom directory entirely to the rootfs of the yocto project?
I want to add a non-empty directory to Yocto rootfs
I proceeded by writing the do_install statement, but it was not possible to copy an entire non-empty folder to rootfs with "install -m".
do_install() {
install -m 0755 /MYDirectory ${D}/MyDirectory
}
This seems to fail because you can only copy a single file
What can I try?

see https://stackoverflow.com/a/47084404/3151114
and don't forget to add the directory to FILES, e.g.
FILES_${PN} += "/MyDirectory"
(just as https://stackoverflow.com/a/54311741/3151114)

Related

Adding a lib to yocto rootfs

I am using this recipe, which by default doesn't copy the resulting .a lib (it expects header only usage I think)
I am trying to get the resultant libspdlog.a into my sysroot, but I can't seem to make that happen. I coppied the recipe to my layer (had to anyway because my project refereces an older version of meta-oe)
So far i've tried:
FILES_${PN} += "${libdir}/libspdlog.a"
FILES_${PN}-dev += "${libdir}/libspdlog.a"
FILES_${PN}-staticdev += "${libdir}/libspdlog.a"
and
do_install() {
install -d ${D}${libdir}
install -m 0644 libspdlog.a ${D}${libdir}
}
I'm pretty sure do_install is not getting called.
I had to add to my IMAGE_INSTALL spd-dev so maybe this has something to do with it
Thanks
do_install is right and for now just have FILES_${PN} += "${libdir}/libspdlog.a".
If you have kept the same name of the recipe when you copied over you will need to add the following IMAGE_INSTALL_append = " spdlog" (in either local.conf or an image recipe if you have one) to put into image.
To verify do_install is working ok:
Inside your build folder (where you issue bitbake from) there will be tmp/work (if you haven't changed this in your local.conf)
Find the location of your recipe folder <recipe_name>/<recipe_version> (eg. spdlog/1.8.0-r0/)
Inside here there will be a packages-split/spdlog folder
Inside this you should see your structure usr/lib/libspdlog.a

Yocto - File is not present in my image (but present in tmp/work directory in build environment)

I add a recipe that create a file helloworld under directory /myDir.
After building image, I could see the file under /build/tmp/work/../../mydir/helloworld.
But the same is not present on the board.
app = "helloworld"
usrdir = "/myDir"
FILES_${PN} += "${usrdir}/${app}"
FILES_${PN}-dbg += "${usrdir}/.debug"
do_install() {
install -D -m 0755 ${B}/${app} ${D}/myDir/${app}
}
If I install helloworld under /usr/bin, then the file is present on the board.
What is wrong? Why the file installed in /usr/bin are deployed while files in /myDir are not? Any idea?
Regards,
Suresh.

How to place executable in to specied directory (path) under yocto buils

SECTION = "devel"
LICENSE = "CLOSED"
EXTERNALSRC := "${THISDIR}/../../../sample-applications/sampleap/src"
inherit cmake externalsrc
inherit autotools gettext
do_compile() /*section to compile */
{
${CC} ${EXTERNALSRC}/sampleapp.c ${LDFLAGS} -o sample
}
/* To install executable in to specified D */
do_install()
{
install -d ${D} ${bindir}##
install -m 0755 sample ${D} ${bindir}
}
I am new to Yocto build. I wrote simple .bb file.
Here my question is how to I change my destination directory ${D}.
I want to place my executable in different path.
The D variable represents the target rootfs. You can choose a specific folder on the target rootfs by specifying one of the prefixes defined in bitbake.conf or a relative path after ${D}.
Example:
...
install -d ${D}/home/root/mySamples
install -m 0755 sample ${D}/home/root/mySamples
...
If you want to place artifacts outside of the target rootfs instead, then you are actually misusing the Yocto Project. Anyway you can find the outputs of your recipe under the <BUILD_DIR>/tmp/work/<DISTRO-TARGET>/<RECIPE_NAME>/<RECIPE_VERSION>/image dir.

how bitbake copy the file to the rootfs

I have a directory like this:
app
--bin
--lib
--conf
--data
and compress it into app.tar.gz, how I copy the app.tar.gz to rootfs to as follows:
bin/*-->/usr/bin
lib/*--->/usr/lib or /usr/lib64
conf/*-->/etc
data/*--->/usr/share
You want a recipe which takes the tarball (from a SRC_URI) and a do_install function which places the files as needed into ${D}. The recipe will automatically create a package from the files. You can then install that package into the rootfs (e.g. using IMAGE_INSTALL += "").
You could copy the files directly into the rootfs with some kind of post rootfs function however you'd then lose the benefits of package management and manifest tracking of the bill of materials that went into the image and so on. If you really do want to do this, see meta/classes/rootfs-postcommands.bbclass for examples of functions which manipulate the rootfs image.

Compile rygel for yocto with plugins

I'm using bitbake to compile rygel for yocto from the meta-openembedded layer, with the plugins mpris and gst-launch.
As per the PACKAGECONFIG docs, I created a bbappend file and added the following:
EXTRA_OECONF = "--disable-introspection \
--disable-tracker-plugin \
--with-media-engine=gstreamer \
--enable-mpris-plugin \
--enable-gst-launch-plugin"
PR = "r1"
It compiles and installs, but has no plugins.
The append shows up when I run bitbake-layers show-appends, so at least bitbake is finding it. After running bitbake the directory tmp/work/core2-64-poky-linux/rygel/0.26.1-r1/image/usr/lib/rygel-2.6/plugins/ is populated. Then when I run the image /usr/lib/rygel-2.6/ contains an engines dir and nothing else.
Any idea where I'm going wrong?
I don't think your read all the way down to "If you want to change an existing PACKAGECONFIG block, you can do so one of two ways:".
From a bbappend, just do
PACKAGECONFIG_append = " mpris gst-launch"
In the recipe do_install, they remove some of the engines and plugins files. This might be the reason you do not see them in your image.
do_install_append() {
# Remove .la files for loadable modules
rm -f ${D}/${libdir}/rygel-${LIBV}/engines/*.la
rm -f ${D}/${libdir}/rygel-${LIBV}/plugins/*.la
}
your compiling plugins successfully and not able to see in board(rootfs)? if yes please add below line in your .bbappend file. '
FILES_${PN} += "${libdir}/*"
this will add all your compiled plugins to your rootfs image.