I'm trying to change the alsa-utils recipe to add a configure option for the state dir. I need to move it to '/etc'.
I used devtool to modify, edit-recipe, and build without any issues. When I try to update-recipe, I get the following message:
INFO: No patches or local source files needed updating
And it's not creating the .bbappend for my recipe changes. I haven't changed anything in the source directory.
Any ideas of what I'm doing wrong?
update-recipe creates a proper directory tree with .bbappend and .patch files in your layer only if you have commited any changes to the source directory.
If you don't want to create .bbappend manually, commit some changes to the source code you've got via devtool, run update-recipe, remove any reference to the patch file in your newly created recipe.
Related
I built the yocto image for my board . Now I need to apply this patch
First, how do I figure out which recipe the patch goes to?
Second, how do I apply this patch?
(I checked similar question but its patching yocto system itself, I don't want that)
I can list all my recipes with this command I found
bitbake-layers show-recipes
But I still don't know which of these recipes builds the file drivers/rpmsg/virtio_rpmsg_bus.c, the file I need to patch.
I also found three directories that have this c file:
find . -name virtio_rpmsg_bus.c
./build_wayland/tmp/work-shared/imx8mm-var-dart/kernel-source/drivers/rpmsg/virtio_rpmsg_bus.c
./build_wayland/tmp/work/aarch64-fslc-linux/linux-libc-headers/5.4-r0/linux-5.4/drivers/rpmsg/virtio_rpmsg_bus.c
./build_wayland/tmp/work/aarch64-mx8mm-fslc-linux/linux-imx-headers/5.4-r0/git/drivers/rpmsg/virtio_rpmsg_bus.c
These recipe folders have recipes-kernel/linux directory
sources/meta-freescale-3rdparty/recipes-kernel
sources/meta-freescale/recipes-kernel
sources/poky/meta-skeleton/recipes-kernel
sources/poky/meta/recipes-kernel
sources/poky/meta-yocto-bsp/recipes-kernel
sources/meta-virtualization/recipes-kernel
sources/meta-variscite-fslc/recipes-kernel
sources/meta-openembedded/meta-gnome/recipes-kernel
sources/meta-openembedded/meta-initramfs/recipes-kernel
sources/meta-openembedded/meta-networking/recipes-kernel
sources/meta-openembedded/meta-oe/recipes-kernel
I don't know which of these recipes might be building my c file virtio_rpmsg_bus.c
So I haven't done the build myself but here is what I could gather (this is a bit of a long shot on certain points... hope everything works, I'm open to discussion if that's not the case).
Finding the recipe to patch: In my opinion this might be often tricky to find what recipe does what in Yocto. If I'm not mistaken (which is very much a possibility) you should have a layer called meta-xilinx-bsp. Wihtin this layer there should be recipes-kernel/linux/linux_xlnx_[version].bb. This should be the recipe the patch should go to.
Applying the patch: To apply the patch the simplest way is to append the recipe.
Create the folder structure: In your own layer you need to reproduce the structure where the recipe is in the original layer. Here: meta-myLayer/recipes-kernel/linux/. In this folder create linux-xlnx_%.bbappend.
Create a .bbappend file: With this structure and name yocto will know this is an append to the original linux-xlnx_[verion_number].bb recipe. The % is put here instead of a version number. This is a wildcard and will append any version of the linux-xlnx recipe. Should you want to append only a specific version you can replace % by a version number.
Add the patch file to your directory: To do so create a folder called linux-xlnx next to you recipe. And within this folder create your patch file by copying the content you have in something like my-xlnx-patch.patch
Reference the patch file in the .bbappend: Indicate the file path in your linux-xlnx_%.bbappend as follow:
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI_append = " \
file://my-xlnx-patch.patch \
"
I'm not 100% sure you need the first line but this will tell yocto that you have a patch file for this recipe and if I'm not mistaken yocto will take care of applying it.
I made some changes on u-boot source /tmp/work/beaglebone_my-poky-linux-gnueabi/u-boot/1_2018.07-r0/git
When I rebuild with bitbake core-image-minimal. Bitbake is not overwriting images in the path /images/.
Then I used clean, cleansstate, but both of them deleted all my changes in the u-boot/1_2018.07-r0/git directory.
What is the most efficient way to customize the u-boot and kernel?
Thank you.
Changing a recipe's fetched sources directory is not enough to permanently modify source code in Yocto as it is just a temporary working directory that, as you experienced, can be cleaned and all.
Changes to Yocto recipes sources can be made by:
modifying the source code in the working directory
creating a patch for your changes
change/create some recipe to apply your patch
the patch will be applied in build time
This section describes the process of modifying source code and creating a patch:
https://www.yoctoproject.org/docs/1.6.1/kernel-dev/kernel-dev.html#modifying-source-code
This section describes the process of creating an extra layer and a recipe for the patches you created in order to apply them during build time:
https://www.yoctoproject.org/docs/1.6.1/kernel-dev/kernel-dev.html#modifying-source-code
I need to build an image for a Xilinx FPGA. Followed these directions. Everything worked and I managed to build it. Now I need to add an extra layer. I thought all I needed to do is to modify .repo/manifests/default.xml (add this layer, https://github.com/sbabic/meta-swupdate/tree/rocko) and then execute
repo sync
but I'm getting errors saying that changes to multitude of files will be overwritten by a checkout (these are the files that were built).
So how do I add a layer to my current environment and rebuild with a new layer without actually rebuilding the whole thing?
cd ./sources/
git clone https://github.com/sbabic/meta-swupdate.git
cd ../conf/
vi ./bblayers.conf
add **{BSPDIR}/sources/meta-swupdate \** before (")
vi ./local.conf
add **IMAGE_INSTALL_append = " swupdate" **
bitbake
How to add Layer example: https://www.youtube.com/watch?v=3HsaoVqX7dg
Is it good practice to edit source code in poky/build/tmp/work directory ? because if we accidentally cleansstate ,the changes will be erased.
Alternatively we can edit source code in "files" directory along with recipe file but since mostly code here is in zipped form due to large number of files , so we will need to unzip and zip again just to change one line of code.
So what is best way to edit source code in yocto ?
If your question is about permanent changes, then Dan's answer is the one to follow. I.e. add a <recipe name>.bbappend to the recipe in your own layer, in which you add
SRC_URI += "file://mypatch1.patch \
file://mypatch2.patch \
"
enumerating all the patches you need.
If there's a large number of patches, it might make sense to fork the upstream repository, and maintain your own branch in your fork. In that case, you'll likely want to reference your own repository, instead of either the upstream repository or tarball.
OTOH, if your question was more about work-in-progress; then sure, doing it in oky/build/tmp/workoky/build/tmp/work/xxxx will work. (And quite likely, it's what most people have been doing for a long time).
However, there's a much better way in recent releases (from 1.8, fido). The new tool is called devtool. You can use it as follows:
devtool modify -x <recipe-name> <path-to-unpack-source>
unpacks the source and creates a new bbappend to build from the unpacked source. It also creates a git repo in the source directory.
Now you can modify the source. You can test-build your modified source by running devtool build <recipe-name>. Once you're satisfied, use git add ... and git commit to commit your changes to the local repo. Once you've commited the changes to the local repo, you can run:
devtool update-recipe <recipe-name>
to update the recipe in question. When you're satisfied, you can run devtool reset <recipe-name> to remove the temporary bbappend.
See also: Yocto manual on modifying source code
If you are continuously "patching" a given package manually, I would recommend you to look at implementing a .bbappend file in a separate layer which applies your patch using the do_patch function (http://www.yoctoproject.org/docs/2.0/mega-manual/mega-manual.html#patching-dev-environment).
I am trying to add new c file in place of file that already comes after downloading the package from git.Tried bbappend but the original file is still there.also modified src_uri += file://fileone.c but that is also not overwriting file.
Any suggestions would be of great help
Regards
Mayank
This is where devtool modify can be very helpful if you're using the jethro (2.0) release or later. Assuming you have already sourced the environment setup script:
devtool modify <recipename>
It will tell you where it has extracted the source - cd into that directory.
Make the changes to the file that you want - which could be overwriting it completely.
git commit -a to commit your changes
devtool update-recipe <recipename> -a /path/to/your/custom/layer (assuming you want to create a bbappend in a custom layer, otherwise just omit the -a and path to apply the changes to the original recipe instead).
If you are completely finished, you can devtool reset <recipename> to put everything back to building completely from the metadata.
So the original C file is part of the release tarball (or git, or wherever the release comes from) and you want to replace that file with your own before configure and compile happen?
Replacing the whole file is just a special case of any smaller changes you might want to do the source files, so just do what you would do in those cases: create a patch the replaces the file and add the patch with SRC_URI += file://replace-file-with-my-file.patch.
I use this work flow (in the project source directory, e.g. poky/build/tmp/work/corei7-64-poky-linux/my-project):
# initialize git (only if this is not a git repo already)
git init
git add *
git commit -m "original code"
# <--- here you should replace the file
git commit -a -m "Replace file with a better file"
git format-patch -1
Now you should have a patch file that you can copy into the proper recipe directory.