summaryrefslogtreecommitdiff
path: root/poky/bitbake
diff options
context:
space:
mode:
Diffstat (limited to 'poky/bitbake')
-rwxr-xr-xpoky/bitbake/bin/bitbake-worker8
-rw-r--r--poky/bitbake/contrib/vim/indent/bitbake.vim343
-rw-r--r--poky/bitbake/lib/bb/cooker.py4
-rw-r--r--poky/bitbake/lib/bb/fetch2/__init__.py4
-rw-r--r--poky/bitbake/lib/bb/fetch2/clearcase.py6
-rw-r--r--poky/bitbake/lib/bb/fetch2/git.py23
-rw-r--r--poky/bitbake/lib/bb/fetch2/hg.py27
-rw-r--r--poky/bitbake/lib/bb/parse/parse_py/ConfHandler.py46
-rw-r--r--poky/bitbake/lib/bb/runqueue.py42
-rw-r--r--poky/bitbake/lib/bb/tests/fetch.py20
-rw-r--r--poky/bitbake/lib/bb/tests/utils.py26
-rw-r--r--poky/bitbake/lib/bb/utils.py34
-rw-r--r--poky/bitbake/lib/prserv/serv.py6
13 files changed, 498 insertions, 91 deletions
diff --git a/poky/bitbake/bin/bitbake-worker b/poky/bitbake/bin/bitbake-worker
index 6776cadda..1e641e81c 100755
--- a/poky/bitbake/bin/bitbake-worker
+++ b/poky/bitbake/bin/bitbake-worker
@@ -195,9 +195,6 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, taskha
global worker_pipe_lock
pipein.close()
- signal.signal(signal.SIGTERM, sigterm_handler)
- # Let SIGHUP exit as SIGTERM
- signal.signal(signal.SIGHUP, sigterm_handler)
bb.utils.signal_on_parent_exit("SIGTERM")
# Save out the PID so that the event can include it the
@@ -212,6 +209,11 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, taskha
# This ensures signals sent to the controlling terminal like Ctrl+C
# don't stop the child processes.
os.setsid()
+
+ signal.signal(signal.SIGTERM, sigterm_handler)
+ # Let SIGHUP exit as SIGTERM
+ signal.signal(signal.SIGHUP, sigterm_handler)
+
# No stdin
newsi = os.open(os.devnull, os.O_RDWR)
os.dup2(newsi, sys.stdin.fileno())
diff --git a/poky/bitbake/contrib/vim/indent/bitbake.vim b/poky/bitbake/contrib/vim/indent/bitbake.vim
new file mode 100644
index 000000000..138103409
--- /dev/null
+++ b/poky/bitbake/contrib/vim/indent/bitbake.vim
@@ -0,0 +1,343 @@
+" Vim indent file
+" Language: BitBake
+" Copyright: Copyright (C) 2019 Agilent Technologies, Inc.
+" Maintainer: Chris Laplante <chris.laplante@agilent.com>
+" License: You may redistribute this under the same terms as Vim itself
+
+
+if exists("b:did_indent")
+ finish
+endif
+
+if exists("*BitbakeIndent")
+ finish
+endif
+
+runtime! indent/sh.vim
+unlet b:did_indent
+
+setlocal indentexpr=BitbakeIndent(v:lnum)
+setlocal autoindent nolisp
+
+function s:is_bb_python_func_def(lnum)
+ let stack = synstack(a:lnum, 1)
+ if len(stack) == 0
+ return 0
+ endif
+
+ let top = synIDattr(stack[0], "name")
+ echo top
+
+ return synIDattr(stack[0], "name") == "bbPyFuncDef"
+endfunction
+
+"""" begin modified from indent/python.vim, upstream commit 7a9bd7c1e0ce1baf5a02daf36eeae3638aa315c7
+"""" This copied code is licensed the same as Vim itself.
+setlocal indentkeys+=<:>,=elif,=except
+
+let s:keepcpo= &cpo
+set cpo&vim
+
+let s:maxoff = 50 " maximum number of lines to look backwards for ()
+
+function GetPythonIndent(lnum)
+
+ " If this line is explicitly joined: If the previous line was also joined,
+ " line it up with that one, otherwise add two 'shiftwidth'
+ if getline(a:lnum - 1) =~ '\\$'
+ if a:lnum > 1 && getline(a:lnum - 2) =~ '\\$'
+ return indent(a:lnum - 1)
+ endif
+ return indent(a:lnum - 1) + (exists("g:pyindent_continue") ? eval(g:pyindent_continue) : (shiftwidth() * 2))
+ endif
+
+ " If the start of the line is in a string don't change the indent.
+ if has('syntax_items')
+ \ && synIDattr(synID(a:lnum, 1, 1), "name") =~ "String$"
+ return -1
+ endif
+
+ " Search backwards for the previous non-empty line.
+ let plnum = prevnonblank(v:lnum - 1)
+
+ if plnum == 0
+ " This is the first non-empty line, use zero indent.
+ return 0
+ endif
+
+ call cursor(plnum, 1)
+
+ " Identing inside parentheses can be very slow, regardless of the searchpair()
+ " timeout, so let the user disable this feature if he doesn't need it
+ let disable_parentheses_indenting = get(g:, "pyindent_disable_parentheses_indenting", 0)
+
+ if disable_parentheses_indenting == 1
+ let plindent = indent(plnum)
+ let plnumstart = plnum
+ else
+ " searchpair() can be slow sometimes, limit the time to 150 msec or what is
+ " put in g:pyindent_searchpair_timeout
+ let searchpair_stopline = 0
+ let searchpair_timeout = get(g:, 'pyindent_searchpair_timeout', 150)
+
+ " If the previous line is inside parenthesis, use the indent of the starting
+ " line.
+ " Trick: use the non-existing "dummy" variable to break out of the loop when
+ " going too far back.
+ let parlnum = searchpair('(\|{\|\[', '', ')\|}\|\]', 'nbW',
+ \ "line('.') < " . (plnum - s:maxoff) . " ? dummy :"
+ \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
+ \ . " =~ '\\(Comment\\|Todo\\|String\\)$'",
+ \ searchpair_stopline, searchpair_timeout)
+ if parlnum > 0
+ " We may have found the opening brace of a BitBake Python task, e.g. 'python do_task {'
+ " If so, ignore it here - it will be handled later.
+ if s:is_bb_python_func_def(parlnum)
+ let parlnum = 0
+ let plindent = indent(plnum)
+ let plnumstart = plnum
+ else
+ let plindent = indent(parlnum)
+ let plnumstart = parlnum
+ endif
+ else
+ let plindent = indent(plnum)
+ let plnumstart = plnum
+ endif
+
+ " When inside parenthesis: If at the first line below the parenthesis add
+ " two 'shiftwidth', otherwise same as previous line.
+ " i = (a
+ " + b
+ " + c)
+ call cursor(a:lnum, 1)
+ let p = searchpair('(\|{\|\[', '', ')\|}\|\]', 'bW',
+ \ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
+ \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
+ \ . " =~ '\\(Comment\\|Todo\\|String\\)$'",
+ \ searchpair_stopline, searchpair_timeout)
+ if p > 0
+ if s:is_bb_python_func_def(p)
+ " Handle first non-empty line inside a BB Python task
+ if p == plnum
+ return shiftwidth()
+ endif
+
+ " Handle the user actually trying to close a BitBake Python task
+ let line = getline(a:lnum)
+ if line =~ '^\s*}'
+ return -2
+ endif
+
+ " Otherwise ignore the brace
+ let p = 0
+ else
+ if p == plnum
+ " When the start is inside parenthesis, only indent one 'shiftwidth'.
+ let pp = searchpair('(\|{\|\[', '', ')\|}\|\]', 'bW',
+ \ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
+ \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
+ \ . " =~ '\\(Comment\\|Todo\\|String\\)$'",
+ \ searchpair_stopline, searchpair_timeout)
+ if pp > 0
+ return indent(plnum) + (exists("g:pyindent_nested_paren") ? eval(g:pyindent_nested_paren) : shiftwidth())
+ endif
+ return indent(plnum) + (exists("g:pyindent_open_paren") ? eval(g:pyindent_open_paren) : (shiftwidth() * 2))
+ endif
+ if plnumstart == p
+ return indent(plnum)
+ endif
+ return plindent
+ endif
+ endif
+
+ endif
+
+
+ " Get the line and remove a trailing comment.
+ " Use syntax highlighting attributes when possible.
+ let pline = getline(plnum)
+ let pline_len = strlen(pline)
+ if has('syntax_items')
+ " If the last character in the line is a comment, do a binary search for
+ " the start of the comment. synID() is slow, a linear search would take
+ " too long on a long line.
+ if synIDattr(synID(plnum, pline_len, 1), "name") =~ "\\(Comment\\|Todo\\)$"
+ let min = 1
+ let max = pline_len
+ while min < max
+ let col = (min + max) / 2
+ if synIDattr(synID(plnum, col, 1), "name") =~ "\\(Comment\\|Todo\\)$"
+ let max = col
+ else
+ let min = col + 1
+ endif
+ endwhile
+ let pline = strpart(pline, 0, min - 1)
+ endif
+ else
+ let col = 0
+ while col < pline_len
+ if pline[col] == '#'
+ let pline = strpart(pline, 0, col)
+ break
+ endif
+ let col = col + 1
+ endwhile
+ endif
+
+ " If the previous line ended with a colon, indent this line
+ if pline =~ ':\s*$'
+ return plindent + shiftwidth()
+ endif
+
+ " If the previous line was a stop-execution statement...
+ " TODO: utilize this logic to deindent when ending a bbPyDefRegion
+ if getline(plnum) =~ '^\s*\(break\|continue\|raise\|return\|pass\|bb\.fatal\)\>'
+ " See if the user has already dedented
+ if indent(a:lnum) > indent(plnum) - shiftwidth()
+ " If not, recommend one dedent
+ return indent(plnum) - shiftwidth()
+ endif
+ " Otherwise, trust the user
+ return -1
+ endif
+
+ " If the current line begins with a keyword that lines up with "try"
+ if getline(a:lnum) =~ '^\s*\(except\|finally\)\>'
+ let lnum = a:lnum - 1
+ while lnum >= 1
+ if getline(lnum) =~ '^\s*\(try\|except\)\>'
+ let ind = indent(lnum)
+ if ind >= indent(a:lnum)
+ return -1 " indent is already less than this
+ endif
+ return ind " line up with previous try or except
+ endif
+ let lnum = lnum - 1
+ endwhile
+ return -1 " no matching "try"!
+ endif
+
+ " If the current line begins with a header keyword, dedent
+ if getline(a:lnum) =~ '^\s*\(elif\|else\)\>'
+
+ " Unless the previous line was a one-liner
+ if getline(plnumstart) =~ '^\s*\(for\|if\|try\)\>'
+ return plindent
+ endif
+
+ " Or the user has already dedented
+ if indent(a:lnum) <= plindent - shiftwidth()
+ return -1
+ endif
+
+ return plindent - shiftwidth()
+ endif
+
+ " When after a () construct we probably want to go back to the start line.
+ " a = (b
+ " + c)
+ " here
+ if parlnum > 0
+ return plindent
+ endif
+
+ return -1
+
+endfunction
+
+let &cpo = s:keepcpo
+unlet s:keepcpo
+
+""" end of stuff from indent/python.vim
+
+
+let b:did_indent = 1
+setlocal indentkeys+=0\"
+
+
+function BitbakeIndent(lnum)
+ if !has('syntax_items')
+ return -1
+ endif
+
+ let stack = synstack(a:lnum, 1)
+ if len(stack) == 0
+ return -1
+ endif
+
+ let name = synIDattr(stack[0], "name")
+
+ " TODO: support different styles of indentation for assignments. For now,
+ " we only support like this:
+ " VAR = " \
+ " value1 \
+ " value2 \
+ " "
+ "
+ " i.e. each value indented by shiftwidth(), with the final quote " completely unindented.
+ if name == "bbVarValue"
+ " Quote handling is tricky. kernel.bbclass has this line for instance:
+ " EXTRA_OEMAKE = " HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" " HOSTCPP="${BUILD_CPP}""
+ " Instead of trying to handle crazy cases like that, just assume that a
+ " double-quote on a line by itself (following an assignment) means the
+ " user is closing the assignment, and de-dent.
+ if getline(a:lnum) =~ '^\s*"$'
+ return 0
+ endif
+
+ let prevstack = synstack(a:lnum - 1, 1)
+ if len(prevstack) == 0
+ return -1
+ endif
+
+ let prevname = synIDattr(prevstack[0], "name")
+
+ " Only indent if there was actually a continuation character on
+ " the previous line, to avoid misleading indentation.
+ let prevlinelastchar = synIDattr(synID(a:lnum - 1, col([a:lnum - 1, "$"]) - 1, 1), "name")
+ let prev_continued = prevlinelastchar == "bbContinue"
+
+ " Did the previous line introduce an assignment?
+ if index(["bbVarDef", "bbVarFlagDef"], prevname) != -1
+ if prev_continued
+ return shiftwidth()
+ endif
+ endif
+
+ if !prev_continued
+ return 0
+ endif
+
+ " Autoindent can take it from here
+ return -1
+ endif
+
+ if index(["bbPyDefRegion", "bbPyFuncRegion"], name) != -1
+ let ret = GetPythonIndent(a:lnum)
+ " Should normally always be indented by at least one shiftwidth; but allow
+ " return of -1 (defer to autoindent) or -2 (force indent to 0)
+ if ret == 0
+ return shiftwidth()
+ elseif ret == -2
+ return 0
+ endif
+ return ret
+ endif
+
+ " TODO: GetShIndent doesn't detect tasks prepended with 'fakeroot'
+ " Need to submit a patch upstream to Vim to provide an extension point.
+ " Unlike the Python indenter, the Sh indenter is way too large to copy and
+ " modify here.
+ if name == "bbShFuncRegion"
+ return GetShIndent()
+ endif
+
+ " TODO:
+ " + heuristics for de-denting out of a bbPyDefRegion? e.g. when the user
+ " types an obvious BB keyword like addhandler or addtask, or starts
+ " writing a shell task. Maybe too hard to implement...
+
+ return -1
+endfunction
diff --git a/poky/bitbake/lib/bb/cooker.py b/poky/bitbake/lib/bb/cooker.py
index 20ef04d3f..e6442bff9 100644
--- a/poky/bitbake/lib/bb/cooker.py
+++ b/poky/bitbake/lib/bb/cooker.py
@@ -371,10 +371,6 @@ class BBCooker:
self.data.setVar('BB_CMDLINE', self.ui_cmdline)
- #
- # Copy of the data store which has been expanded.
- # Used for firing events and accessing variables where expansion needs to be accounted for
- #
if CookerFeatures.BASEDATASTORE_TRACKING in self.featureset:
self.disableDataTracking()
diff --git a/poky/bitbake/lib/bb/fetch2/__init__.py b/poky/bitbake/lib/bb/fetch2/__init__.py
index 1f5f8f1f1..07de6c269 100644
--- a/poky/bitbake/lib/bb/fetch2/__init__.py
+++ b/poky/bitbake/lib/bb/fetch2/__init__.py
@@ -1593,7 +1593,7 @@ class Fetch(object):
fn = d.getVar('FILE')
mc = d.getVar('__BBMULTICONFIG') or ""
if cache and fn and mc + fn in urldata_cache:
- self.ud = urldata_cache[mc + fn]
+ self.ud = urldata_cache[mc + fn + str(id(d))]
for url in urls:
if url not in self.ud:
@@ -1605,7 +1605,7 @@ class Fetch(object):
pass
if fn and cache:
- urldata_cache[mc + fn] = self.ud
+ urldata_cache[mc + fn + str(id(d))] = self.ud
def localpath(self, url):
if url not in self.urls:
diff --git a/poky/bitbake/lib/bb/fetch2/clearcase.py b/poky/bitbake/lib/bb/fetch2/clearcase.py
index 3dd93ad6b..e2934ef9f 100644
--- a/poky/bitbake/lib/bb/fetch2/clearcase.py
+++ b/poky/bitbake/lib/bb/fetch2/clearcase.py
@@ -145,18 +145,18 @@ class ClearCase(FetchMethod):
basecmd = "%s %s" % (ud.basecmd, command)
- if command is 'mkview':
+ if command == 'mkview':
if not "rcleartool" in ud.basecmd:
# Cleartool needs a -snapshot view
options.append("-snapshot")
options.append("-tag %s" % ud.viewname)
options.append(ud.viewdir)
- elif command is 'rmview':
+ elif command == 'rmview':
options.append("-force")
options.append("%s" % ud.viewdir)
- elif command is 'setcs':
+ elif command == 'setcs':
options.append("-overwrite")
options.append(ud.configspecfile)
diff --git a/poky/bitbake/lib/bb/fetch2/git.py b/poky/bitbake/lib/bb/fetch2/git.py
index 2d1d2cabd..fa41b078f 100644
--- a/poky/bitbake/lib/bb/fetch2/git.py
+++ b/poky/bitbake/lib/bb/fetch2/git.py
@@ -292,11 +292,21 @@ class Git(FetchMethod):
def clonedir_need_update(self, ud, d):
if not os.path.exists(ud.clonedir):
return True
+ if ud.shallow and ud.write_shallow_tarballs and self.clonedir_need_shallow_revs(ud, d):
+ return True
for name in ud.names:
if not self._contains_ref(ud, d, name, ud.clonedir):
return True
return False
+ def clonedir_need_shallow_revs(self, ud, d):
+ for rev in ud.shallow_revs:
+ try:
+ runfetchcmd('%s rev-parse -q --verify %s' % (ud.basecmd, rev), d, quiet=True, workdir=ud.clonedir)
+ except bb.fetch2.FetchError:
+ return rev
+ return None
+
def shallow_tarball_need_update(self, ud):
return ud.shallow and ud.write_shallow_tarballs and not os.path.exists(ud.fullshallow)
@@ -339,13 +349,7 @@ class Git(FetchMethod):
runfetchcmd(clone_cmd, d, log=progresshandler)
# Update the checkout if needed
- needupdate = False
- for name in ud.names:
- if not self._contains_ref(ud, d, name, ud.clonedir):
- needupdate = True
- break
-
- if needupdate:
+ if self.clonedir_need_update(ud, d):
output = runfetchcmd("%s remote" % ud.basecmd, d, quiet=True, workdir=ud.clonedir)
if "origin" in output:
runfetchcmd("%s remote rm origin" % ud.basecmd, d, workdir=ud.clonedir)
@@ -369,6 +373,11 @@ class Git(FetchMethod):
if not self._contains_ref(ud, d, name, ud.clonedir):
raise bb.fetch2.FetchError("Unable to find revision %s in branch %s even from upstream" % (ud.revisions[name], ud.branches[name]))
+ if ud.shallow and ud.write_shallow_tarballs:
+ missing_rev = self.clonedir_need_shallow_revs(ud, d)
+ if missing_rev:
+ raise bb.fetch2.FetchError("Unable to find revision %s even from upstream" % missing_rev)
+
def build_mirror_data(self, ud, d):
if ud.shallow and ud.write_shallow_tarballs:
if not os.path.exists(ud.fullshallow):
diff --git a/poky/bitbake/lib/bb/fetch2/hg.py b/poky/bitbake/lib/bb/fetch2/hg.py
index 15d729e7b..e21115deb 100644
--- a/poky/bitbake/lib/bb/fetch2/hg.py
+++ b/poky/bitbake/lib/bb/fetch2/hg.py
@@ -54,13 +54,6 @@ class Hg(FetchMethod):
else:
ud.proto = "hg"
- ud.setup_revisions(d)
-
- if 'rev' in ud.parm:
- ud.revision = ud.parm['rev']
- elif not ud.revision:
- ud.revision = self.latest_revision(ud, d)
-
# Create paths to mercurial checkouts
hgsrcname = '%s_%s_%s' % (ud.module.replace('/', '.'), \
ud.host, ud.path.replace('/', '.'))
@@ -74,6 +67,13 @@ class Hg(FetchMethod):
ud.localfile = ud.moddir
ud.basecmd = d.getVar("FETCHCMD_hg") or "/usr/bin/env hg"
+ ud.setup_revisions(d)
+
+ if 'rev' in ud.parm:
+ ud.revision = ud.parm['rev']
+ elif not ud.revision:
+ ud.revision = self.latest_revision(ud, d)
+
ud.write_tarballs = d.getVar("BB_GENERATE_MIRROR_TARBALLS")
def need_update(self, ud, d):
@@ -139,7 +139,7 @@ class Hg(FetchMethod):
cmd = "%s --config auth.default.prefix=* --config auth.default.username=%s --config auth.default.password=%s --config \"auth.default.schemes=%s\" pull" % (ud.basecmd, ud.user, ud.pswd, proto)
else:
cmd = "%s pull" % (ud.basecmd)
- elif command == "update":
+ elif command == "update" or command == "up":
if ud.user and ud.pswd:
cmd = "%s --config auth.default.prefix=* --config auth.default.username=%s --config auth.default.password=%s --config \"auth.default.schemes=%s\" update -C %s" % (ud.basecmd, ud.user, ud.pswd, proto, " ".join(options))
else:
@@ -247,12 +247,19 @@ class Hg(FetchMethod):
scmdata = ud.parm.get("scmdata", "")
if scmdata != "nokeep":
+ proto = ud.parm.get('protocol', 'http')
if not os.access(os.path.join(codir, '.hg'), os.R_OK):
logger.debug(2, "Unpack: creating new hg repository in '" + codir + "'")
runfetchcmd("%s init %s" % (ud.basecmd, codir), d)
logger.debug(2, "Unpack: updating source in '" + codir + "'")
- runfetchcmd("%s pull %s" % (ud.basecmd, ud.moddir), d, workdir=codir)
- runfetchcmd("%s up -C %s" % (ud.basecmd, revflag), d, workdir=codir)
+ if ud.user and ud.pswd:
+ runfetchcmd("%s --config auth.default.prefix=* --config auth.default.username=%s --config auth.default.password=%s --config \"auth.default.schemes=%s\" pull %s" % (ud.basecmd, ud.user, ud.pswd, proto, ud.moddir), d, workdir=codir)
+ else:
+ runfetchcmd("%s pull %s" % (ud.basecmd, ud.moddir), d, workdir=codir)
+ if ud.user and ud.pswd:
+ runfetchcmd("%s --config auth.default.prefix=* --config auth.default.username=%s --config auth.default.password=%s --config \"auth.default.schemes=%s\" up -C %s" % (ud.basecmd, ud.user, ud.pswd, proto, revflag), d, workdir=codir)
+ else:
+ runfetchcmd("%s up -C %s" % (ud.basecmd, revflag), d, workdir=codir)
else:
logger.debug(2, "Unpack: extracting source to '" + codir + "'")
runfetchcmd("%s archive -t files %s %s" % (ud.basecmd, revflag, codir), d, workdir=ud.moddir)
diff --git a/poky/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/poky/bitbake/lib/bb/parse/parse_py/ConfHandler.py
index 2e84b913d..af64d3446 100644
--- a/poky/bitbake/lib/bb/parse/parse_py/ConfHandler.py
+++ b/poky/bitbake/lib/bb/parse/parse_py/ConfHandler.py
@@ -119,30 +119,30 @@ def handle(fn, data, include):
oldfile = data.getVar('FILE', False)
abs_fn = resolve_file(fn, data)
- f = open(abs_fn, 'r')
-
- statements = ast.StatementGroup()
- lineno = 0
- while True:
- lineno = lineno + 1
- s = f.readline()
- if not s:
- break
- w = s.strip()
- # skip empty lines
- if not w:
- continue
- s = s.rstrip()
- while s[-1] == '\\':
- s2 = f.readline().rstrip()
+ with open(abs_fn, 'r') as f:
+
+ statements = ast.StatementGroup()
+ lineno = 0
+ while True:
lineno = lineno + 1
- if (not s2 or s2 and s2[0] != "#") and s[0] == "#" :
- bb.fatal("There is a confusing multiline, partially commented expression on line %s of file %s (%s).\nPlease clarify whether this is all a comment or should be parsed." % (lineno, fn, s))
- s = s[:-1] + s2
- # skip comments
- if s[0] == '#':
- continue
- feeder(lineno, s, abs_fn, statements)
+ s = f.readline()
+ if not s:
+ break
+ w = s.strip()
+ # skip empty lines
+ if not w:
+ continue
+ s = s.rstrip()
+ while s[-1] == '\\':
+ s2 = f.readline().rstrip()
+ lineno = lineno + 1
+ if (not s2 or s2 and s2[0] != "#") and s[0] == "#" :
+ bb.fatal("There is a confusing multiline, partially commented expression on line %s of file %s (%s).\nPlease clarify whether this is all a comment or should be parsed." % (lineno, fn, s))
+ s = s[:-1] + s2
+ # skip comments
+ if s[0] == '#':
+ continue
+ feeder(lineno, s, abs_fn, statements)
# DONE WITH PARSING... time to evaluate
data.setVar('FILE', abs_fn)
diff --git a/poky/bitbake/lib/bb/runqueue.py b/poky/bitbake/lib/bb/runqueue.py
index 18049436f..26492e708 100644
--- a/poky/bitbake/lib/bb/runqueue.py
+++ b/poky/bitbake/lib/bb/runqueue.py
@@ -1397,7 +1397,7 @@ class RunQueue:
cache[tid] = iscurrent
return iscurrent
- def validate_hashes(self, tocheck, data, currentcount=0, siginfo=False):
+ def validate_hashes(self, tocheck, data, currentcount=0, siginfo=False, summary=True):
valid = set()
if self.hashvalidate:
sq_data = {}
@@ -1410,15 +1410,15 @@ class RunQueue:
sq_data['hashfn'][tid] = self.rqdata.dataCaches[mc].hashfn[taskfn]
sq_data['unihash'][tid] = self.rqdata.runtaskentries[tid].unihash
- valid = self.validate_hash(sq_data, data, siginfo, currentcount)
+ valid = self.validate_hash(sq_data, data, siginfo, currentcount, summary)
return valid
- def validate_hash(self, sq_data, d, siginfo, currentcount):
- locs = {"sq_data" : sq_data, "d" : d, "siginfo" : siginfo, "currentcount" : currentcount}
+ def validate_hash(self, sq_data, d, siginfo, currentcount, summary):
+ locs = {"sq_data" : sq_data, "d" : d, "siginfo" : siginfo, "currentcount" : currentcount, "summary" : summary}
# Metadata has **kwargs so args can be added, sq_data can also gain new fields
- call = self.hashvalidate + "(sq_data, d, siginfo=siginfo, currentcount=currentcount)"
+ call = self.hashvalidate + "(sq_data, d, siginfo=siginfo, currentcount=currentcount, summary=summary)"
return bb.utils.better_eval(call, locs)
@@ -1605,7 +1605,7 @@ class RunQueue:
tocheck.add(tid)
- valid_new = self.validate_hashes(tocheck, self.cooker.data, 0, True)
+ valid_new = self.validate_hashes(tocheck, self.cooker.data, 0, True, summary=False)
# Tasks which are both setscene and noexec never care about dependencies
# We therefore find tasks which are setscene and noexec and mark their
@@ -1986,7 +1986,7 @@ class RunQueueExecute:
continue
logger.debug(1, "Task %s no longer deferred" % nexttask)
del self.sq_deferred[nexttask]
- valid = self.rq.validate_hashes(set([nexttask]), self.cooker.data, 0, False)
+ valid = self.rq.validate_hashes(set([nexttask]), self.cooker.data, 0, False, summary=False)
if not valid:
logger.debug(1, "%s didn't become valid, skipping setscene" % nexttask)
self.sq_task_failoutright(nexttask)
@@ -2303,16 +2303,22 @@ class RunQueueExecute:
for tid in changed:
if tid not in self.rqdata.runq_setscene_tids:
continue
+ if tid not in self.pending_migrations:
+ self.pending_migrations.add(tid)
+
+ for tid in self.pending_migrations.copy():
if tid in self.runq_running:
+ # Too late, task already running, not much we can do now
+ self.pending_migrations.remove(tid)
continue
- if tid in self.scenequeue_covered:
+
+ if tid in self.scenequeue_covered or tid in self.sq_live:
+ # Already ran this setscene task or it running
# Potentially risky, should we report this hash as a match?
logger.info("Already covered setscene for %s so ignoring rehash" % (tid))
+ self.pending_migrations.remove(tid)
continue
- if tid not in self.pending_migrations:
- self.pending_migrations.add(tid)
- for tid in self.pending_migrations.copy():
valid = True
# Check no tasks this covers are running
for dep in self.sqdata.sq_covered_tasks[tid]:
@@ -2361,9 +2367,13 @@ class RunQueueExecute:
if tid in self.build_stamps:
del self.build_stamps[tid]
- logger.info("Setscene task %s now valid and being rerun" % tid)
+ origvalid = False
+ if tid in self.sqdata.valid:
+ origvalid = True
self.sqdone = False
- update_scenequeue_data([tid], self.sqdata, self.rqdata, self.rq, self.cooker, self.stampcache, self)
+ update_scenequeue_data([tid], self.sqdata, self.rqdata, self.rq, self.cooker, self.stampcache, self, summary=False)
+ if tid in self.sqdata.valid and not origvalid:
+ logger.info("Setscene task %s became valid" % tid)
if changed:
self.holdoff_need_update = True
@@ -2692,9 +2702,9 @@ def build_scenequeue_data(sqdata, rqdata, rq, cooker, stampcache, sqrq):
sqdata.stamppresent = set()
sqdata.valid = set()
- update_scenequeue_data(sqdata.sq_revdeps, sqdata, rqdata, rq, cooker, stampcache, sqrq)
+ update_scenequeue_data(sqdata.sq_revdeps, sqdata, rqdata, rq, cooker, stampcache, sqrq, summary=True)
-def update_scenequeue_data(tids, sqdata, rqdata, rq, cooker, stampcache, sqrq):
+def update_scenequeue_data(tids, sqdata, rqdata, rq, cooker, stampcache, sqrq, summary=True):
tocheck = set()
@@ -2728,7 +2738,7 @@ def update_scenequeue_data(tids, sqdata, rqdata, rq, cooker, stampcache, sqrq):
tocheck.add(tid)
- sqdata.valid |= rq.validate_hashes(tocheck, cooker.data, len(sqdata.stamppresent), False)
+ sqdata.valid |= rq.validate_hashes(tocheck, cooker.data, len(sqdata.stamppresent), False, summary=summary)
sqdata.hashes = {}
for mc in sorted(sqdata.multiconfigs):
diff --git a/poky/bitbake/lib/bb/tests/fetch.py b/poky/bitbake/lib/bb/tests/fetch.py
index a0b656b61..83fad3ff0 100644
--- a/poky/bitbake/lib/bb/tests/fetch.py
+++ b/poky/bitbake/lib/bb/tests/fetch.py
@@ -1863,6 +1863,26 @@ class GitShallowTest(FetcherTest):
with self.assertRaises(bb.fetch2.FetchError):
self.fetch()
+ def test_shallow_fetch_missing_revs(self):
+ self.add_empty_file('a')
+ self.add_empty_file('b')
+ fetcher, ud = self.fetch(self.d.getVar('SRC_URI'))
+ self.git('tag v0.0 master', cwd=self.srcdir)
+ self.d.setVar('BB_GIT_SHALLOW_DEPTH', '0')
+ self.d.setVar('BB_GIT_SHALLOW_REVS', 'v0.0')
+ self.fetch_shallow()
+
+ def test_shallow_fetch_missing_revs_fails(self):
+ self.add_empty_file('a')
+ self.add_empty_file('b')
+ fetcher, ud = self.fetch(self.d.getVar('SRC_URI'))
+ self.d.setVar('BB_GIT_SHALLOW_DEPTH', '0')
+ self.d.setVar('BB_GIT_SHALLOW_REVS', 'v0.0')
+
+ with self.assertRaises(bb.fetch2.FetchError), self.assertLogs("BitBake.Fetcher", level="ERROR") as cm:
+ self.fetch_shallow()
+ self.assertIn("Unable to find revision v0.0 even from upstream", cm.output[0])
+
@skipIfNoNetwork()
def test_bitbake(self):
self.git('remote add --mirror=fetch origin git://github.com/openembedded/bitbake', cwd=self.srcdir)
diff --git a/poky/bitbake/lib/bb/tests/utils.py b/poky/bitbake/lib/bb/tests/utils.py
index f4adf1d44..5c910b4b8 100644
--- a/poky/bitbake/lib/bb/tests/utils.py
+++ b/poky/bitbake/lib/bb/tests/utils.py
@@ -103,6 +103,32 @@ class Path(unittest.TestCase):
result = bb.utils._check_unsafe_delete_path(arg1)
self.assertEqual(result, correctresult, '_check_unsafe_delete_path("%s") != %s' % (arg1, correctresult))
+class Checksum(unittest.TestCase):
+ filler = b"Shiver me timbers square-rigged spike Gold Road galleon bilge water boatswain wherry jack pirate. Mizzenmast rum lad Privateer jack salmagundi hang the jib piracy Pieces of Eight Corsair. Parrel marooned black spot yawl provost quarterdeck cable no prey, no pay spirits lateen sail."
+
+ def test_md5(self):
+ import hashlib
+ with tempfile.NamedTemporaryFile() as f:
+ f.write(self.filler)
+ f.flush()
+ checksum = bb.utils.md5_file(f.name)
+ self.assertEqual(checksum, "bd572cd5de30a785f4efcb6eaf5089e3")
+
+ def test_sha1(self):
+ import hashlib
+ with tempfile.NamedTemporaryFile() as f:
+ f.write(self.filler)
+ f.flush()
+ checksum = bb.utils.sha1_file(f.name)
+ self.assertEqual(checksum, "249eb8fd654732ea836d5e702d7aa567898eca71")
+
+ def test_sha256(self):
+ import hashlib
+ with tempfile.NamedTemporaryFile() as f:
+ f.write(self.filler)
+ f.flush()
+ checksum = bb.utils.sha256_file(f.name)
+ self.assertEqual(checksum, "fcfbae8bf6b721dbb9d2dc6a9334a58f2031a9a9b302999243f99da4d7f12d0f")
class EditMetadataFile(unittest.TestCase):
_origfile = """
diff --git a/poky/bitbake/lib/bb/utils.py b/poky/bitbake/lib/bb/utils.py
index d035949b3..8d40bcdf8 100644
--- a/poky/bitbake/lib/bb/utils.py
+++ b/poky/bitbake/lib/bb/utils.py
@@ -520,22 +520,26 @@ def unlockfile(lf):
fcntl.flock(lf.fileno(), fcntl.LOCK_UN)
lf.close()
-def md5_file(filename):
- """
- Return the hex string representation of the MD5 checksum of filename.
- """
- import hashlib, mmap
+def _hasher(method, filename):
+ import mmap
with open(filename, "rb") as f:
- m = hashlib.md5()
try:
with mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) as mm:
for chunk in iter(lambda: mm.read(8192), b''):
- m.update(chunk)
+ method.update(chunk)
except ValueError:
# You can't mmap() an empty file so silence this exception
pass
- return m.hexdigest()
+ return method.hexdigest()
+
+
+def md5_file(filename):
+ """
+ Return the hex string representation of the MD5 checksum of filename.
+ """
+ import hashlib
+ return _hasher(hashlib.md5(), filename)
def sha256_file(filename):
"""
@@ -543,24 +547,14 @@ def sha256_file(filename):
filename.
"""
import hashlib
-
- s = hashlib.sha256()
- with open(filename, "rb") as f:
- for line in f:
- s.update(line)
- return s.hexdigest()
+ return _hasher(hashlib.sha256(), filename)
def sha1_file(filename):
"""
Return the hex string representation of the SHA1 checksum of the filename
"""
import hashlib
-
- s = hashlib.sha1()
- with open(filename, "rb") as f:
- for line in f:
- s.update(line)
- return s.hexdigest()
+ return _hasher(hashlib.sha1(), filename)
def preserved_envvars_exported():
"""Variables which are taken from the environment and placed in and exported
diff --git a/poky/bitbake/lib/prserv/serv.py b/poky/bitbake/lib/prserv/serv.py
index be3acec36..b854ba14b 100644
--- a/poky/bitbake/lib/prserv/serv.py
+++ b/poky/bitbake/lib/prserv/serv.py
@@ -243,6 +243,7 @@ class PRServer(SimpleXMLRPCServer):
try:
pid = os.fork()
if pid > 0:
+ self.socket.close() # avoid ResourceWarning in parent
return pid
except OSError as e:
raise Exception("%s [%d]" % (e.strerror, e.errno))
@@ -379,9 +380,8 @@ def stop_daemon(host, port):
ip = socket.gethostbyname(host)
pidfile = PIDPREFIX % (ip, port)
try:
- pf = open(pidfile,'r')
- pid = int(pf.readline().strip())
- pf.close()
+ with open(pidfile) as pf:
+ pid = int(pf.readline().strip())
except IOError:
pid = None