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.