bitbake: lib/bb: Don't use deprecated bb.data.getVar/setVar API

The old style bb.data.getVar/setVar API is obsolete. Most of bitbake
doesn't use it but there were some pieces that escaped conversion. This
patch fixes the remaining users mostly in the fetchers.

(Bitbake rev: ff7892fa808116acc1ac50effa023a4cb031a5fc)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2016-11-16 11:19:01 +00:00
parent 4d8ee55164
commit 8de811ae76
9 changed files with 24 additions and 24 deletions

View File

@ -1282,7 +1282,7 @@ class FetchMethod(object):
Can also setup variables in urldata for use in go (saving code duplication
and duplicate code execution)
"""
return os.path.join(data.getVar("DL_DIR", d, True), urldata.localfile)
return os.path.join(d.getVar("DL_DIR", True), urldata.localfile)
def supports_checksum(self, urldata):
"""

View File

@ -110,7 +110,7 @@ class ClearCase(FetchMethod):
ud.basecmd = d.getVar("FETCHCMD_ccrc", True) or spawn.find_executable("cleartool") or spawn.find_executable("rcleartool")
if data.getVar("SRCREV", d, True) == "INVALID":
if d.getVar("SRCREV", True) == "INVALID":
raise FetchError("Set a valid SRCREV for the clearcase fetcher in your recipe, e.g. SRCREV = \"/main/LATEST\" or any other label of your choice.")
ud.label = d.getVar("SRCREV", False)
@ -124,7 +124,7 @@ class ClearCase(FetchMethod):
ud.viewname = "%s-view%s" % (ud.identifier, d.getVar("DATETIME", d, True))
ud.csname = "%s-config-spec" % (ud.identifier)
ud.ccasedir = os.path.join(data.getVar("DL_DIR", d, True), ud.type)
ud.ccasedir = os.path.join(d.getVar("DL_DIR", True), ud.type)
ud.viewdir = os.path.join(ud.ccasedir, ud.viewname)
ud.configspecfile = os.path.join(ud.ccasedir, ud.csname)
ud.localfile = "%s.tar.gz" % (ud.identifier)
@ -144,7 +144,7 @@ class ClearCase(FetchMethod):
self.debug("configspecfile = %s" % ud.configspecfile)
self.debug("localfile = %s" % ud.localfile)
ud.localfile = os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
ud.localfile = os.path.join(d.getVar("DL_DIR", True), ud.localfile)
def _build_ccase_command(self, ud, command):
"""

View File

@ -182,9 +182,9 @@ class Git(FetchMethod):
if ud.usehead:
ud.unresolvedrev['default'] = 'HEAD'
ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git -c core.fsyncobjectfiles=0"
ud.basecmd = d.getVar("FETCHCMD_git", True) or "git -c core.fsyncobjectfiles=0"
ud.write_tarballs = ((data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) or "0") != "0") or ud.rebaseable
ud.write_tarballs = ((d.getVar("BB_GENERATE_MIRROR_TARBALLS", True) or "0") != "0") or ud.rebaseable
ud.setup_revisons(d)

View File

@ -84,7 +84,7 @@ class Hg(FetchMethod):
ud.pkgdir = os.path.join(hgdir, hgsrcname)
ud.moddir = os.path.join(ud.pkgdir, ud.module)
ud.localfile = ud.moddir
ud.basecmd = data.getVar("FETCHCMD_hg", d, True) or "/usr/bin/env hg"
ud.basecmd = d.getVar("FETCHCMD_hg", True) or "/usr/bin/env hg"
ud.write_tarballs = d.getVar("BB_GENERATE_MIRROR_TARBALLS", True)

View File

@ -63,13 +63,13 @@ class Local(FetchMethod):
newpath = path
if path[0] == "/":
return [path]
filespath = data.getVar('FILESPATH', d, True)
filespath = d.getVar('FILESPATH', True)
if filespath:
logger.debug(2, "Searching for %s in paths:\n %s" % (path, "\n ".join(filespath.split(":"))))
newpath, hist = bb.utils.which(filespath, path, history=True)
searched.extend(hist)
if not newpath:
filesdir = data.getVar('FILESDIR', d, True)
filesdir = d.getVar('FILESDIR', True)
if filesdir:
logger.debug(2, "Searching for %s in path: %s" % (path, filesdir))
newpath = os.path.join(filesdir, path)
@ -100,10 +100,10 @@ class Local(FetchMethod):
# no need to fetch local files, we'll deal with them in place.
if self.supports_checksum(urldata) and not os.path.exists(urldata.localpath):
locations = []
filespath = data.getVar('FILESPATH', d, True)
filespath = d.getVar('FILESPATH', True)
if filespath:
locations = filespath.split(":")
filesdir = data.getVar('FILESDIR', d, True)
filesdir = d.getVar('FILESDIR', True)
if filesdir:
locations.append(filesdir)
locations.append(d.getVar("DL_DIR", True))

View File

@ -90,7 +90,7 @@ class Npm(FetchMethod):
self.basecmd = d.getVar("FETCHCMD_wget", True) or "/usr/bin/env wget -O -t 2 -T 30 -nv --passive-ftp --no-check-certificate "
ud.prefixdir = prefixdir
ud.write_tarballs = ((data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) or "0") != "0")
ud.write_tarballs = ((d.getVar("BB_GENERATE_MIRROR_TARBALLS", True) or "0") != "0")
ud.mirrortarball = 'npm_%s-%s.tar.xz' % (ud.pkgname, ud.version)
ud.fullmirror = os.path.join(d.getVar("DL_DIR", True), ud.mirrortarball)

View File

@ -51,17 +51,17 @@ class Repo(FetchMethod):
if not ud.manifest.endswith('.xml'):
ud.manifest += '.xml'
ud.localfile = data.expand("repo_%s%s_%s_%s.tar.gz" % (ud.host, ud.path.replace("/", "."), ud.manifest, ud.branch), d)
ud.localfile = d.expand("repo_%s%s_%s_%s.tar.gz" % (ud.host, ud.path.replace("/", "."), ud.manifest, ud.branch))
def download(self, ud, d):
"""Fetch url"""
if os.access(os.path.join(data.getVar("DL_DIR", d, True), ud.localfile), os.R_OK):
if os.access(os.path.join(d.getVar("DL_DIR", True), ud.localfile), os.R_OK):
logger.debug(1, "%s already exists (or was stashed). Skipping repo init / sync.", ud.localpath)
return
gitsrcname = "%s%s" % (ud.host, ud.path.replace("/", "."))
repodir = data.getVar("REPODIR", d, True) or os.path.join(data.getVar("DL_DIR", d, True), "repo")
repodir = d.getVar("REPODIR", True) or os.path.join(d.getVar("DL_DIR", True), "repo")
codir = os.path.join(repodir, gitsrcname, ud.manifest)
if ud.user:

View File

@ -92,7 +92,7 @@ class SFTP(FetchMethod):
else:
ud.basename = os.path.basename(ud.path)
ud.localfile = data.expand(urllib.parse.unquote(ud.basename), d)
ud.localfile = d.expand(urllib.parse.unquote(ud.basename))
def download(self, ud, d):
"""Fetch urls"""
@ -104,7 +104,7 @@ class SFTP(FetchMethod):
port = '-P %d' % urlo.port
urlo.port = None
dldir = data.getVar('DL_DIR', d, True)
dldir = d.getVar('DL_DIR', True)
lpath = os.path.join(dldir, ud.localfile)
user = ''

View File

@ -68,7 +68,7 @@ class VariableReferenceTest(ReferenceTest):
def test_python_reference(self):
self.setEmptyVars(["BAR"])
self.parseExpression("${@bb.data.getVar('BAR', d, True) + 'foo'}")
self.parseExpression("${@d.getVar('BAR', True) + 'foo'}")
self.assertReferences(set(["BAR"]))
class ShellReferenceTest(ReferenceTest):
@ -209,17 +209,17 @@ be. These unit tests are testing snippets."""
return " " + value
def test_getvar_reference(self):
self.parseExpression("bb.data.getVar('foo', d, True)")
self.parseExpression("d.getVar('foo', True)")
self.assertReferences(set(["foo"]))
self.assertExecs(set())
def test_getvar_computed_reference(self):
self.parseExpression("bb.data.getVar('f' + 'o' + 'o', d, True)")
self.parseExpression("d.getVar('f' + 'o' + 'o', True)")
self.assertReferences(set())
self.assertExecs(set())
def test_getvar_exec_reference(self):
self.parseExpression("eval('bb.data.getVar(\"foo\", d, True)')")
self.parseExpression("eval('d.getVar(\"foo\", True)')")
self.assertReferences(set())
self.assertExecs(set(["eval"]))
@ -269,7 +269,7 @@ be. These unit tests are testing snippets."""
class DependencyReferenceTest(ReferenceTest):
pydata = """
bb.data.getVar('somevar', d, True)
d.getVar('somevar', True)
def test(d):
foo = 'bar %s' % 'foo'
def test2(d):
@ -285,9 +285,9 @@ def a():
test(d)
bb.data.expand(bb.data.getVar("something", False, d), d)
bb.data.expand(d.getVar("something", False), d)
bb.data.expand("${inexpand} somethingelse", d)
bb.data.getVar(a(), d, False)
d.getVar(a(), False)
"""
def test_python(self):