Search code examples
gityoctoyocto-recipe

How to modify a yocto recipe to fetch source files from a local folder instead from official GitHub repository?


Installation on Pillow in the yocto linux distribution

I have installed the Pillow Python Library in my yocto-based distribution by the following recipe:

meta-openembedded/meta-python/recipes-devtools/python/python3-pillow_6.2.1.bb

and by adding the following instruction to my_image_recipe.bb:

IMAGE_INSTALL += "python3-pillow"

By the bitbake compilation of my_image_recipe.bb, Pillow has been installed in the Linux distribution.

Modify SRC_URI to fetch source from local directory

What I need is to create a python3-pillow_%.bbappend file to modify the value of the SRC_URI variable of the Pillow recipe. In the original recipe the value of that variable is:

SRC_URI = "git://github.com/python-pillow/Pillow.git;branch=6.2.x \
           file://0001-support-cross-compiling.patch \
           file://0001-explicitly-set-compile-options.patch \
"

With this value of SRC_URI, when I execute the command:

> bitbake python3-pillow

the source tree of Pillow is downloaded from the GitHub repository pointed by the URI value assigned to SRC_URI. As we can see above, the URL used for the download is:

git://github.com/python-pillow/Pillow.git;branch=6.2.x

By the fetching process the source files are saved in one my local folder called downloads. This folder is the target of all the downloads executed by the image build process.

After the image creation downloads contains the Pillow source tree in the following sub-folder:

downloads/git2/github.com.python-pillow.Pillow.git/

My question

I would like to copy the source tree downloaded into the path downloads/git2/github.com.python-pillow.Pillow.git/ in a different folder called my-downloads and modify the SRC_URI variable as followed:

SRC_URI = "file:///path/to/my-downloads/... \  # <---??? What do I have to write in this assignment exactly???
           file://0001-support-cross-compiling.patch \
           file://0001-explicitly-set-compile-options.patch \
"

In this way when I'll compile Pillow an other time, bitbake will take Pillow source tree from my-downloads and not from GitHub.

What exactly do I have to assign to SRC_URI in order for bitbake to find Pillow sources in my local folder my-downloads?


I have tried with the solution proposed here but it doesn't work in my context may be because I don't get sources from a local git repository, but directly from filesystem.


Solution

  • To get the source of Pillow from filesystem, instead from GitHub site, I had to create the file python3-pillow_%.bbappend, with the following assignment:

    SRC_URI = "git:///file:///path/to/my-downloads/github.com.python-pillow.Pillow.git;branch=6.2.x;protocol=file \
               file://0001-support-cross-compiling.patch \
               file://0001-explicitly-set-compile-options.patch \
    "
    

    Parameters protocol and branch for the GIT Fetcher

    As explained in the Bitbake User Manual to solve the problem showed in the question the most important concepts to know are:

    • set the GIT Fetcher by git://
    • set the parameter protocol=file for the GIT Fetcher
    • set the parameter branch=6.2.x for the GIT Fetcher

    By this way the code is fetched from filesystem and not from GitHub site.

    Note

    This post is useful, but for my problem in it is missed the parameter branch so when I tried its solution, it didn't perfectly answer my question.