How can I add a task after do_deploy()? - yocto

I have written a recipe where I want to execute a task after do_deploy():
[...]
inherit deploy
[...]
do_deploy () {
echo "do_deploy() has been called."
}
addtask deploy after do_compile
do_after_deploy () {
echo "do_after_deploy() has been called."
}
addtask after_deploy after do_deploy
When I build the recipe the do_deploy() task is executed. However, the after_deploy() task is not.
When I manually execute the task with bitbake my_recipe -c after_deploy the instructions in the task are executed.
What is the reason for this? Is do_deploy() the very last task and BitBake doesn't let me add tasks after it?

do_deploy() gets executed by default because base.bbclass happens to make do_build (the default task) depend on do_deploy.
You should be able to make your new task run by default with
addtask after_deploy after do_deploy before do_build

Related

BitBake - what defines the order of tasks for a recipe?

Is there a way to list the order of tasks that shall be executed when a recipe is built with BitBake? I know I can build the recipe and then inspect log.task_order, but that's not what I'm after - I want to know where is the order of tasks defined for given recipe, without actually building it. I also know that there's bitbake <recipe_name> -c listtasks, but AFAIK, that lists all the available tasks, regardless if they are actually executed during the build.
Update:
The recipe I'm interested in is the kernel recipe, this is how its log.task_order looks like after a full clean build:
do_fetch
do_unpack
do_prepare_recipe_sysroot
do_kernel_checkout
do_symlink_kernsrc
do_validate_branches
do_kernel_metadata
do_patch
do_kernel_version_sanity_check
do_populate_lic
do_kernel_configme
do_configure
do_kernel_configcheck
do_compile
do_shared_workdir
do_kernel_link_images
do_compile_kernelmodules
do_strip
do_sizecheck
do_install
do_populate_sysroot
do_package
do_packagedata
do_package_qa
do_package_write_ipk
do_bundle_initramfs
do_deploy
I would expect that this sequence is defined somewhere in the recipe metadata, but I haven't found it.

do_compile is not getting called when an image class is inherited in Yocto

I have a requirement to inherit an image class( *.bbclass )and run a script from image recipe but my do_compile is not getting called.
For simplicity, I am putting up minimal sample code from poky source here which does similar thing which I want.
I have created a test recipe called inherit-test_0.1.bb under my own created layer meta-raxy.
Here is the inherit-test_0.1.bb recipe file,
SUMMARY = "Inherit Test Application"
LICENSE = "CLOSED"
inherit image
do_compile () {
echo MyRecipe
}
When I compile this recipe by bitbake inherit-test after setting up oe-init-build-env, I do not see my do_compile gets compiled since there is no log file present in working directory poky/build/tmp/work/qemux86-poky-linux/inherit-test/0.1-r0/temp/log.do_compile with the line MyRecipe
And if I remove inherit image, I see do_compile gets compiled as shown below in log file,
DEBUG: Executing shell function do_compile
MyRecipe
DEBUG: Shell function do_compile finished
Any help will really be appreciated.
Inheriting "image" states do_compile[noexec] = "1", among others, (as you can see in the image.bblcass file) which means that the do_compile task won't be executed. That is one of the several ways Yocto offers for delete a task.

How to run a single task in in Eclipse with gradle buildship?

Currently I have in my gradle.build file the tasks:
task helloA {
println 'hello A!'
}
task helloB {
println 'hello B!'
}
However executing task helloA via Gradle Tasks/other/helloA prints on the console:
hello A!
hello B!
:helloA UP-TO-DATE
BUILD SUCCESSFUL
However I would expect it to just print: 'hello A!' instead of
hello A!
hello B!
together.
How do I change that? I read through the gradle docs, but coudln't find something about that apart from some extensive workaround.
No task is executed at all in your buildfile, they are just configured.
Be aware that there are three phases in a Gradle run. Initialization, configuration and execution. In initialization phase, you define which projects are part of the build and where they are on disc (basically settings.gradle execution). In configuration phase all tasks are configured. In execution phase the tasks that need to be executed (explicitly called tasks or default tasks, depended upon directly or transitively by explicitly called or default tasks).
Try this and you will see:
task helloA {
println 'configure A!'
doLast {
println 'execute A!'
}
}
task helloB {
println 'configure B!'
doLast {
println 'execute B!'
}
}

capistrano v2 not failing / rolling back when custom task fails

i have to compile a custom c coded binary used by our rails app.
this setup is held in a custom rake file (ourapp.rake, below)
running cap v2 i noticed the make was failing but the deploy didn't "fail".
i since just made the task
system "cd #{thedir} && exit 1" # simulate failing of custom task
but the deploy:cold doesn't fail, the debug output (below) clearly shows make failing
am i missing something? i've tried
searching for error codes/failing scenario of capistrano - nothing (lots of mentions of trying to run custom scripts on failing)
system v run v invoke
help appreciated, code below
# ourapp.rake
namespace :ourapp do
desc "Compile and Install Performant Parser"
task :compile_performant_parser do
thedir=File.join(Rails.root, 'parser')
system "cd #{thedir} && make clean && make && make install"
end # compile
desc "Compile and Install Compareplans process"
task :compile_binary do
thedir=File.join(Rails.root, 'compareplans_process/src')
#system "cd #{thedir} && make clean && make && make install"
system "exit 1"
end # compile
task :install => [:compile_performant_parser, :compile_binary ] do
puts "Preparing Ourapp for run"
end
end
additions to deploy.rb
namespace :deploy do
desc "setup ourapp dependencies, dir, binaries and (later data)"
task :setup_ourapp do
run "cd #{current_release} && /usr/bin/env bundle exec rake our app:install RAILS_ENV=#{rails_env}"
end
after 'deploy:update_code', 'deploy:setup_ourapp'
end
so i figured out that capistrano does not exit, so you need to test the error code
Capistrano run local command exit on failure
and to rollback you need to use a transaction type
How do I use transactions within custom capistrano tasks?

How do I skip a rake task

Consider the following Rake tasks:
task deploy => [:package] do
end
task package => [:build] do
end
task build do
end
Is there a way to invoke Rake on the command line to execute the package and deploy tasks, but not the build task?
Short answer, no.
The way I usually go about this is instead of using the dependant task notion like you have above:
task deploy => [:package] do
end
I create an alias task for whatever action that is to be completed:
task all => [:build, :package, :deploy]
task fastDeploy => [:package, :deploy]
task deploy do
end
task package do
end
task build do
end
It's not very elegant, but I do find it to be more readable and you can visibly see the dependency of tasks on other tasks instead of the kind of spaghetti code structure the dependant notion can result in... when you have a lot of task it can be awkward to debug the logic to figure what's gone wrong and where at times.
Hope this helps.