Bitbake -c clean removed source

22,534

Solution 1

1) How do I get the source back?

bitbake -ccleansstate <package_name>
bitbake <package_name>

This will make sure bitbake won't use shared state and will have to actually do all the tasks during the second command (including unpack and patch, which will populate sources in a directory in $WORKDIR).

2) What is the safe way of rebuilding the source after making modifications?

If you want to modify sources in $WORKDIR as a quick hack, then

bitbake -f -ccompile <package_name>
bitbake <package_name>

will mark the compile task as dirty and when the next command builds the recipe, all tasks from compile onwards will be executed. Note that bitbake will warn you about the dirty state until you do a cleansstate, and also that cleansstate will wipe the $WORKDIR alongside your changes: so this is only useful for quick tests.

If you're looking for a way to do more development and still quickly test things with a yocto/OE build alongside the development, take a look at devtool. I expect part 4.3.1.2. (Use devtool modify to Enable Work on Code Associated with an Existing Recipe) might be relevant for you.

Solution 2

bitbake -c cleansstate <package name>

will not remove the source, so do_fetch content will be as it is. And next time

bitbake <package name>

So, do_fetch will not execute next time but rest of the. Such as do_patch, do_metadata, do_compile, etc. If you want to try with some changes at the source level, you can also have a try of

bitbake <package name> -c devshell

I found devshell a convenient way to try with some source or inpackage level changes and tryout. It does open a new shell at the package location. Where you can give the commands locally. As simple as make.

Solution 3

In addition to great jku's answer:

ad.1) How do I get the sources back?

You can just simply fetch the source code, no other tasks are going to be executed:

bitbake -c fetch -f <package_name>

Generally by passing:

bitbake -c clean <package_name>

or with force option:

bitbake -c clean -f <package_name>

You have triggered the task do_clean from recipe responsible for this package. By checking the tasks code (directly in recipe or in inherited recipe) what exactly will be done. Also in the same directory build/tmp/work/ you can find a /temp/ with logs for each executed tasks. e.g.: log.do_fetch will contain output of task do_fetch() for this specific package.

Share:
22,534
Gomu
Author by

Gomu

Programming Languages: C, C++ Source Control Tool: GIT Platform: Linux, Windows VC++ "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John Woods

Updated on July 16, 2022

Comments

  • Gomu
    Gomu almost 2 years

    I'm beginner for 'BitBake'. I need to modify source code and build it. I found the sources to be located at build/tmp/work/ within a directory which has git commit id as its name. I wanted to rebuild the source. So I gave bitbake -c clean <package_name>, followed by bitbake <package_name>. The image got built. But, when I went back to modify the source, the git repository seems to be missing in its location.

    1) How do I get the source back?

    2) What is the safe way of rebuilding the source after making modifications?

    Thanks in advance.

  • Jan Hudec
    Jan Hudec over 3 years
    I did this, the sources appeared during the build, but they vanished again when the build completed.