title: yocto d.getVar fails
body: <p>Learning Yocto from <a href="http://book.yoctoprojectbook.com/index" rel="nofollow noreferrer">http://book.yoctoprojectbook.com/index</a>. Chapter 4 has the following code </p>
  
  <pre><code>SUMMARY = "Recipe to build the 'nano' editor"
  
  PN = "nano"
  PV = "2.2.6"
  
  SITE = "http://www.nano-editor.org/dist"
  PV_MAJOR = "${@bb.data.getVar('PV', d, 1).split('.')[0]}"
  PV_MINOR = "${@bb.data.getVar('PV', d, 1).split('.')[1]}"
  
  SRC_URI = "${SITE}/v${PV_MAJOR}.${PV_MINOR}/${PN}-${PV}.tar.gz"
  SRC_URI[md5sum] = "03233ae480689a008eb98feb1b599807"
  SRC_URI[sha256sum] = \
  "be68e133b5e81df41873d32c517b3e5950770c00fc5f4dd23810cd635abce67a"
  
  python do_fetch() {
      bb.plain("Downloading source tarball from ${SRC_URI} ...")
      src_uri = (d.getVar('SRC_URI', True) or "").split()
      if 0 == len(src_uri):
          bb.fatal('Empty URI')
      try:
          fetcher = bb.fetch2.Fetch(src_uri, d)
          fetcher.download()
      except bb.fetch2.BBFetchException:
          bb.fatal('Could not fetch source tarball.')
      bb.plain("Download successful.")
  }
  
  addtask fetch before do_build
  
  python do_unpack() {
      bb.plain("Unpacking source tarball ...")
      os.system("tar x -C ${WORKDIR} -f ${DL_DIR}/${P}.tar.gz")
      bb.plain("Unpacked source tarball.")
  }
  
  addtask unpack before do_build after do_fetch
  
  python do_configure() {
      bb.plain("Configuring source package ...")
      os.system("cd ${WORKDIR}/${P} &amp;&amp; ./configure")
      bb.plain("Configured source package.")
  }
  
  addtask configure before do_build after do_unpack
  
  python do_compile() {
      bb.plain("Compiling package ...")
      os.system("cd ${WORKDIR}/${P} &amp;&amp; make")
      bb.plain("Compiled package.")
  }
  
  addtask compile before do_build after do_configure
  
  do_clean[nostamp] = "1"
  do_clean() {
      rm -rf ${WORKDIR}/${P}
      rm -f ${TMPDIR}/stamps/*
  }
  
  addtask clean
  </code></pre>
  
  <p>The recipe is located in meta-hello/recipes-editor/nano. Basically it is trying to build a <code>nano</code> text editor package. It is failing at the <code>do_fetch()</code> task. After some print statement debugging I figured out that the failure happens at this line: <code>src_uri = (d.getVar('SRC_URI', True) or "").split()</code>, specifically at <code>d.getVar('SRC_URI', True)</code>. I'm not really sure what exactly is causing the problem. Would anyone care to help? I'm running a <code>rocko</code> build of <code>yocto</code>.</p>
  
  <p>Here is the terminal output I get when I run the recipe:</p>
  
  <pre><code>$bitbake nano
  NOTE: Not using a cache. Set CACHE = &lt;directory&gt; to enable.
  Parsing recipes: 100% |#################################################################################################################| Time: 0:00:00
  Parsing of 2 .bb files complete (0 cached, 2 parsed). 2 targets, 0 skipped, 0 masked, 0 errors.
  NOTE: Resolving any missing task queue dependencies
  Initialising tasks: 100% |##############################################################################################################| Time: 0:00:00
  NOTE: Executing RunQueue Tasks
  Downloading source tarball from ${SRC_URI} ...
  ERROR: nano-2.2.6-r0 do_fetch: Function failed: do_fetch
  ERROR: Logfile of failure stored in: /home/some-user/projects/bbhello/tmp/work/nano-2.2.6-r0/temp/log.do_fetch.14350
  ERROR: Task (/home/some-user/projects/bbhello/meta-hello/recipes-editor/nano/nano.bb:do_fetch) failed with exit code '1'
  NOTE: Tasks Summary: Attempted 1 tasks of which 0 didn't need to be rerun and 1 failed.
  
  Summary: 1 task failed:
    /home/some-user/projects/bbhello/meta-hello/recipes-editor/nano/nano.bb:do_fetch
  Summary: There was 1 ERROR message shown, returning a non-zero exit code.
  </code></pre>
  
  <p>And here is the actual log file:</p>
  
  <pre><code>DEBUG: Executing python function do_fetch
  Downloading source tarball from ${SRC_URI} ...
  DEBUG: Python function do_fetch finished
  ERROR: Function failed: do_fetch
  </code></pre>