<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>14480</bug_id>
          
          <creation_ts>2021-07-14 13:29:46 +0000</creation_ts>
          <short_desc>cannot use helper functions</short_desc>
          <delta_ts>2021-07-15 14:49:50 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>BitBake</product>
          <component>bitbake</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>NOTABUG</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Undecided</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Frans Meulenbroeks">fransmeulenbroeks</reporter>
          <assigned_to name="Richard Purdie">richard.purdie</assigned_to>
          <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>ross.burton</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Don&apos;t know</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>90918</commentid>
    <comment_count>0</comment_count>
    <who name="Frans Meulenbroeks">fransmeulenbroeks</who>
    <bug_when>2021-07-14 13:29:46 +0000</bug_when>
    <thetext>According to https://www.yoctoproject.org/docs/1.6/bitbake-user-manual/bitbake-user-manual.html#shell-functions I can call other shell functions

However this did not work

do_install_prepend_jetson-nano-emmc() {
        install -d ${D}/etc
        install -d ${D}/etc/network
        install -m 0640 ${WORKDIR}/interfaces_nano ${D}/etc/network/interfaces
}

do_install_prepend_jetson-nano-devkit-emmc() {
        do_install_prepend_jetson-nano-emmc
}

Idea here was to use the same code for two different machines

The dump dumps all the environment. In the beginning it says

Traceback (most recent call last):
  File &quot;/workdir/poky/bitbake/lib/bb/siggen.py&quot;, line 150, in SignatureGeneratorOEEquivHash._build_data(fn=&apos;/workdir/layers/myrecipe.bb&apos;, d=&lt;bb.data_smart.DataSmart object at 0x7fd122baf6a0&gt;):
             ignore_mismatch = ((d.getVar(&quot;BB_HASH_IGNORE_MISMATCH&quot;) or &apos;&apos;) == &apos;1&apos;)
    &gt;        tasklist, gendeps, lookupcache = bb.data.generate_dependencies(d, self.basewhitelist)

Then there is the env; at the end there is:

                     parser = bb.codeparser.ShellParser(key, logger)
    &gt;                parser.parse_shell(parsedvar.value)
                     deps = deps | shelldeps
  File &quot;/workdir/poky/bitbake/lib/bb/codeparser.py&quot;, line 343, in ShellParser.parse_shell(value=None):

    &gt;        self._parse_shell(value)
             self.execs = set(cmd for cmd in self.allexecs if cmd not in self.funcdefs)
  File &quot;/workdir/poky/bitbake/lib/bb/codeparser.py&quot;, line 354, in ShellParser._parse_shell(value=None):
             except Exception:
    &gt;            bb.error(&apos;Error during parse shell code, the last 5 lines are:\n%s&apos; % &apos;\n&apos;.join(value.split(&apos;\n&apos;)[-5:]))
                 raise
AttributeError: &apos;NoneType&apos; object has no attribute &apos;split&apos;


I&apos;ve no idea is this is an issue in bitbake or in the documentation or in poky
(btw this is on dunfell)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90939</commentid>
    <comment_count>1</comment_count>
    <who name="Ross Burton">ross.burton</who>
    <bug_when>2021-07-15 14:49:50 +0000</bug_when>
    <thetext>The problem is that you&apos;re using overrides, so what you&apos;re entering into the recipe isn&apos;t what actually gets evaluated.

do_install_prepend_jetson-nano-emmc means &quot;prepend this body to do_install if jeson-nano-emmc is in OVERRIDES&quot;.  At no point is there a shell function called do_install_prepend_jetson-nano-emmc.  Also, - isn&apos;t valid in shell functions so even if it was exposed in shell, it wouldn&apos;t have that name.

If you want to refactor your recipe to have common fragments then write explicit shell functions for those:

install_interfaces() {
        install -d ${D}/etc
        install -d ${D}/etc/network
        install -m 0640 ${WORKDIR}/interfaces_nano ${D}/etc/network/interfaces
}

do_install_prepend_jetson-nano-emmc() {
        install_interfaces
}

do_install_prepend_jetson-nano-devkit-emmc() {
        install_interfaces
}</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>