Reputation: 4508
Learning Yocto from http://book.yoctoprojectbook.com/index. Chapter 4 has the following 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} && ./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} && 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
The recipe is located in meta-hello/recipes-editor/nano. Basically it is trying to build a nano
text editor package. It is failing at the do_fetch()
task. After some print statement debugging I figured out that the failure happens at this line: src_uri = (d.getVar('SRC_URI', True) or "").split()
, specifically at d.getVar('SRC_URI', True)
. I'm not really sure what exactly is causing the problem. Would anyone care to help? I'm running a rocko
build of yocto
.
Here is the terminal output I get when I run the recipe:
$bitbake nano
NOTE: Not using a cache. Set CACHE = <directory> 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.
And here is the actual log file:
DEBUG: Executing python function do_fetch
Downloading source tarball from ${SRC_URI} ...
DEBUG: Python function do_fetch finished
ERROR: Function failed: do_fetch
Upvotes: 0
Views: 4509
Reputation: 2348
I'm not sure what you're testing but if I try this example it fails during parsing with:
ERROR: ExpansionError during parsing /media/build/poky/meta/recipes-core/base-files/test_1.0.bb
Traceback (most recent call last): File "/media/build/poky/bitbake/lib/bb/data_smart.py", line 412, in DataSmart.expandWithRefs(s='${SITE}/v${PV_MAJOR}.${PV_MINOR}/${PN}-${PV}.tar.gz', varname='SRC_URI'): try: > s = expand_var_regexp.sub(varparse.var_sub, s) try: File "/media/build/poky/bitbake/lib/bb/data_smart.py", line 111, in VariableParse.var_sub(match=<_sre.SRE_Match object; span=(9, 20), match='${PV_MAJOR}'>): else: > var = self.d.getVarFlag(key, "_content") self.references.add(key) File "/media/build/poky/bitbake/lib/bb/data_smart.py", line 794, in DataSmart.getVarFlag(var='PV_MAJOR', flag='_content', expand=True, noweakdefault=False, parsing=False): cachename = var + "[" + flag + "]" > value = self.expand(value, cachename) File "/media/build/poky/bitbake/lib/bb/data_smart.py", line 436, in DataSmart.expand(s="${@bb.data.getVar('PV', d, 1).split('.')[0]}", varname='PV_MAJOR'): def expand(self, s, varname = None): > return self.expandWithRefs(s, varname).value File "/media/build/poky/bitbake/lib/bb/data_smart.py", line 426, in DataSmart.expandWithRefs(s="${@bb.data.getVar('PV', d, 1).split('.')[0]}", varname='PV_MAJOR'): except Exception as exc: > raise ExpansionError(varname, s, exc) from exc bb.data_smart.ExpansionError: Failure expanding variable PV_MAJOR, expression was ${@bb.data.getVar('PV', d, 1).split('.')[0]} which triggered exception AttributeError: module 'bb.data' has no attribute 'getVar'
which is because the bb.data.getVar('PV', d, 1) needs to be d.getVar('PV', True). This recipe as stated cannot parse under rocko so I don't think you're running the recipe you think you are?
Upvotes: 2