Handling failed task in Yocto recipe












0















I need some advice on how to handle errors in recipe tasks. Consider the following snippet for a Yocto recipe recipe:



do_compile_custom() {
oe_runmake // oe_runmake command fails
}
addtask compile_custom after do_compile before do_install


When oe_runmake fails, i want to execute some custom command and to continue with the build so i thought that this should work.



do_compile_custom() {
oe_runmake || true // oe_runmake command fails
if [ $? -ne 0 ]; then
bberror "MAKE FAILED"
fi
}
addtask compile_custom after do_compile before do_install


But when oe_runmake fails, it exits the task and the rest of the task is not executed. I don't see




MAKE FAILED




in my build log.



I started to investigate bitbake Events so the next thing i did was to add an event handler in my recipe, without any event filters at first to see all the events received.



do_compile_custom() {
oe_runmake // oe_runmake command fails
}
addtask compile_custom after do_compile before do_install

addhandler failure_eventhandler
python failure_eventhandler() {
from bb.event import getName
print("strtogrep The name of the Event is %s" % getName(e))
}


With this implementation of the recipe, from the handler i am only able to see 3 events printed:



| The name of the Event is RecipePreFinalise
| The name of the Event is RecipeTaskPreProcess
| The name of the Event is RecipeParsed


From all the events defined in bitbake, i was expecting to get TaskFailed Event after the task fails but this is never received. Does anyone have some suggestions on how to handle this?










share|improve this question



























    0















    I need some advice on how to handle errors in recipe tasks. Consider the following snippet for a Yocto recipe recipe:



    do_compile_custom() {
    oe_runmake // oe_runmake command fails
    }
    addtask compile_custom after do_compile before do_install


    When oe_runmake fails, i want to execute some custom command and to continue with the build so i thought that this should work.



    do_compile_custom() {
    oe_runmake || true // oe_runmake command fails
    if [ $? -ne 0 ]; then
    bberror "MAKE FAILED"
    fi
    }
    addtask compile_custom after do_compile before do_install


    But when oe_runmake fails, it exits the task and the rest of the task is not executed. I don't see




    MAKE FAILED




    in my build log.



    I started to investigate bitbake Events so the next thing i did was to add an event handler in my recipe, without any event filters at first to see all the events received.



    do_compile_custom() {
    oe_runmake // oe_runmake command fails
    }
    addtask compile_custom after do_compile before do_install

    addhandler failure_eventhandler
    python failure_eventhandler() {
    from bb.event import getName
    print("strtogrep The name of the Event is %s" % getName(e))
    }


    With this implementation of the recipe, from the handler i am only able to see 3 events printed:



    | The name of the Event is RecipePreFinalise
    | The name of the Event is RecipeTaskPreProcess
    | The name of the Event is RecipeParsed


    From all the events defined in bitbake, i was expecting to get TaskFailed Event after the task fails but this is never received. Does anyone have some suggestions on how to handle this?










    share|improve this question

























      0












      0








      0








      I need some advice on how to handle errors in recipe tasks. Consider the following snippet for a Yocto recipe recipe:



      do_compile_custom() {
      oe_runmake // oe_runmake command fails
      }
      addtask compile_custom after do_compile before do_install


      When oe_runmake fails, i want to execute some custom command and to continue with the build so i thought that this should work.



      do_compile_custom() {
      oe_runmake || true // oe_runmake command fails
      if [ $? -ne 0 ]; then
      bberror "MAKE FAILED"
      fi
      }
      addtask compile_custom after do_compile before do_install


      But when oe_runmake fails, it exits the task and the rest of the task is not executed. I don't see




      MAKE FAILED




      in my build log.



      I started to investigate bitbake Events so the next thing i did was to add an event handler in my recipe, without any event filters at first to see all the events received.



      do_compile_custom() {
      oe_runmake // oe_runmake command fails
      }
      addtask compile_custom after do_compile before do_install

      addhandler failure_eventhandler
      python failure_eventhandler() {
      from bb.event import getName
      print("strtogrep The name of the Event is %s" % getName(e))
      }


      With this implementation of the recipe, from the handler i am only able to see 3 events printed:



      | The name of the Event is RecipePreFinalise
      | The name of the Event is RecipeTaskPreProcess
      | The name of the Event is RecipeParsed


      From all the events defined in bitbake, i was expecting to get TaskFailed Event after the task fails but this is never received. Does anyone have some suggestions on how to handle this?










      share|improve this question














      I need some advice on how to handle errors in recipe tasks. Consider the following snippet for a Yocto recipe recipe:



      do_compile_custom() {
      oe_runmake // oe_runmake command fails
      }
      addtask compile_custom after do_compile before do_install


      When oe_runmake fails, i want to execute some custom command and to continue with the build so i thought that this should work.



      do_compile_custom() {
      oe_runmake || true // oe_runmake command fails
      if [ $? -ne 0 ]; then
      bberror "MAKE FAILED"
      fi
      }
      addtask compile_custom after do_compile before do_install


      But when oe_runmake fails, it exits the task and the rest of the task is not executed. I don't see




      MAKE FAILED




      in my build log.



      I started to investigate bitbake Events so the next thing i did was to add an event handler in my recipe, without any event filters at first to see all the events received.



      do_compile_custom() {
      oe_runmake // oe_runmake command fails
      }
      addtask compile_custom after do_compile before do_install

      addhandler failure_eventhandler
      python failure_eventhandler() {
      from bb.event import getName
      print("strtogrep The name of the Event is %s" % getName(e))
      }


      With this implementation of the recipe, from the handler i am only able to see 3 events printed:



      | The name of the Event is RecipePreFinalise
      | The name of the Event is RecipeTaskPreProcess
      | The name of the Event is RecipeParsed


      From all the events defined in bitbake, i was expecting to get TaskFailed Event after the task fails but this is never received. Does anyone have some suggestions on how to handle this?







      yocto bitbake openembedded






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 27 '18 at 15:40









      Mihai PopMihai Pop

      309418




      309418
























          1 Answer
          1






          active

          oldest

          votes


















          1














          The reason why You can't occur MAKE FAILES log message is the consequence of oe_runmake function.



          As You can see implementation of oe_runmake (from meta/classes/base.bbclass file), runs die() logging function in case of any failures:



          58 oe_runmake() {                                     
          59 oe_runmake_call "$@" || die "oe_runmake failed"
          60 }


          Lately on die() function use bbfatal_log() function (from meta/classes/logging.bbclass file), which finally end's with exit 1:



          66 bbfatal_log() {
          67 if [ -p ${LOGFIFO} ] ; then
          68 printf "%b" "bbfatal_log $*" > ${LOGFIFO}
          69 else
          70 echo "ERROR: $*"
          71 fi
          72 exit 1
          73 }


          I think easiest way for You to archive Your goal, is to give up with using default do_compile implementation task in order that have a custom compile task, with error handling:



          # disable do_compile task
          do_compile[noexec] = "1"

          do_compile_custom() {
          oe_runmake_custom_call() {
          bbnote ${MAKE} ${EXTRA_OEMAKE} "$@"
          ${MAKE} ${EXTRA_OEMAKE} "$@"
          }

          oe_runmake_custom_call || bbwarn "oe_runmake_custom failed"
          if [ $? -ne 0 ]; then
          bberror "MAKE FAILED"
          fi
          }
          addtask compile_custom before do_install





          share|improve this answer
























          • This works for me but i still would like to know why are the events not working

            – Mihai Pop
            Nov 28 '18 at 10:13











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53503158%2fhandling-failed-task-in-yocto-recipe%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          The reason why You can't occur MAKE FAILES log message is the consequence of oe_runmake function.



          As You can see implementation of oe_runmake (from meta/classes/base.bbclass file), runs die() logging function in case of any failures:



          58 oe_runmake() {                                     
          59 oe_runmake_call "$@" || die "oe_runmake failed"
          60 }


          Lately on die() function use bbfatal_log() function (from meta/classes/logging.bbclass file), which finally end's with exit 1:



          66 bbfatal_log() {
          67 if [ -p ${LOGFIFO} ] ; then
          68 printf "%b" "bbfatal_log $*" > ${LOGFIFO}
          69 else
          70 echo "ERROR: $*"
          71 fi
          72 exit 1
          73 }


          I think easiest way for You to archive Your goal, is to give up with using default do_compile implementation task in order that have a custom compile task, with error handling:



          # disable do_compile task
          do_compile[noexec] = "1"

          do_compile_custom() {
          oe_runmake_custom_call() {
          bbnote ${MAKE} ${EXTRA_OEMAKE} "$@"
          ${MAKE} ${EXTRA_OEMAKE} "$@"
          }

          oe_runmake_custom_call || bbwarn "oe_runmake_custom failed"
          if [ $? -ne 0 ]; then
          bberror "MAKE FAILED"
          fi
          }
          addtask compile_custom before do_install





          share|improve this answer
























          • This works for me but i still would like to know why are the events not working

            – Mihai Pop
            Nov 28 '18 at 10:13
















          1














          The reason why You can't occur MAKE FAILES log message is the consequence of oe_runmake function.



          As You can see implementation of oe_runmake (from meta/classes/base.bbclass file), runs die() logging function in case of any failures:



          58 oe_runmake() {                                     
          59 oe_runmake_call "$@" || die "oe_runmake failed"
          60 }


          Lately on die() function use bbfatal_log() function (from meta/classes/logging.bbclass file), which finally end's with exit 1:



          66 bbfatal_log() {
          67 if [ -p ${LOGFIFO} ] ; then
          68 printf "%b" "bbfatal_log $*" > ${LOGFIFO}
          69 else
          70 echo "ERROR: $*"
          71 fi
          72 exit 1
          73 }


          I think easiest way for You to archive Your goal, is to give up with using default do_compile implementation task in order that have a custom compile task, with error handling:



          # disable do_compile task
          do_compile[noexec] = "1"

          do_compile_custom() {
          oe_runmake_custom_call() {
          bbnote ${MAKE} ${EXTRA_OEMAKE} "$@"
          ${MAKE} ${EXTRA_OEMAKE} "$@"
          }

          oe_runmake_custom_call || bbwarn "oe_runmake_custom failed"
          if [ $? -ne 0 ]; then
          bberror "MAKE FAILED"
          fi
          }
          addtask compile_custom before do_install





          share|improve this answer
























          • This works for me but i still would like to know why are the events not working

            – Mihai Pop
            Nov 28 '18 at 10:13














          1












          1








          1







          The reason why You can't occur MAKE FAILES log message is the consequence of oe_runmake function.



          As You can see implementation of oe_runmake (from meta/classes/base.bbclass file), runs die() logging function in case of any failures:



          58 oe_runmake() {                                     
          59 oe_runmake_call "$@" || die "oe_runmake failed"
          60 }


          Lately on die() function use bbfatal_log() function (from meta/classes/logging.bbclass file), which finally end's with exit 1:



          66 bbfatal_log() {
          67 if [ -p ${LOGFIFO} ] ; then
          68 printf "%b" "bbfatal_log $*" > ${LOGFIFO}
          69 else
          70 echo "ERROR: $*"
          71 fi
          72 exit 1
          73 }


          I think easiest way for You to archive Your goal, is to give up with using default do_compile implementation task in order that have a custom compile task, with error handling:



          # disable do_compile task
          do_compile[noexec] = "1"

          do_compile_custom() {
          oe_runmake_custom_call() {
          bbnote ${MAKE} ${EXTRA_OEMAKE} "$@"
          ${MAKE} ${EXTRA_OEMAKE} "$@"
          }

          oe_runmake_custom_call || bbwarn "oe_runmake_custom failed"
          if [ $? -ne 0 ]; then
          bberror "MAKE FAILED"
          fi
          }
          addtask compile_custom before do_install





          share|improve this answer













          The reason why You can't occur MAKE FAILES log message is the consequence of oe_runmake function.



          As You can see implementation of oe_runmake (from meta/classes/base.bbclass file), runs die() logging function in case of any failures:



          58 oe_runmake() {                                     
          59 oe_runmake_call "$@" || die "oe_runmake failed"
          60 }


          Lately on die() function use bbfatal_log() function (from meta/classes/logging.bbclass file), which finally end's with exit 1:



          66 bbfatal_log() {
          67 if [ -p ${LOGFIFO} ] ; then
          68 printf "%b" "bbfatal_log $*" > ${LOGFIFO}
          69 else
          70 echo "ERROR: $*"
          71 fi
          72 exit 1
          73 }


          I think easiest way for You to archive Your goal, is to give up with using default do_compile implementation task in order that have a custom compile task, with error handling:



          # disable do_compile task
          do_compile[noexec] = "1"

          do_compile_custom() {
          oe_runmake_custom_call() {
          bbnote ${MAKE} ${EXTRA_OEMAKE} "$@"
          ${MAKE} ${EXTRA_OEMAKE} "$@"
          }

          oe_runmake_custom_call || bbwarn "oe_runmake_custom failed"
          if [ $? -ne 0 ]; then
          bberror "MAKE FAILED"
          fi
          }
          addtask compile_custom before do_install






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 28 '18 at 7:57









          lukaszgardlukaszgard

          504410




          504410













          • This works for me but i still would like to know why are the events not working

            – Mihai Pop
            Nov 28 '18 at 10:13



















          • This works for me but i still would like to know why are the events not working

            – Mihai Pop
            Nov 28 '18 at 10:13

















          This works for me but i still would like to know why are the events not working

          – Mihai Pop
          Nov 28 '18 at 10:13





          This works for me but i still would like to know why are the events not working

          – Mihai Pop
          Nov 28 '18 at 10:13




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53503158%2fhandling-failed-task-in-yocto-recipe%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Contact image not getting when fetch all contact list from iPhone by CNContact

          count number of partitions of a set with n elements into k subsets

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks