Fetcher: break the "SRCREVINACTION" deadlock
Current fetcher has annoying "SRCREVINACTION" deadlock, which occurs when SRCREV=${AUTOREV}=@bb.fetch.get_srcrev(): get_srcrev()->setup_localpath()->srcrev_internal_helper() ->evaluate SRCREV->get_srcrev() current fetcher resolve the deadlock by introducing a "SRCREVINACTION" condition check. Althoguh it works, it is indeed not clean. This patch use antoehr idea to break the deadlock: break the dependency among SRCREV and get_srcrev(), i.e. assign a specific keyword "AUTOINC" to AUTOREV. when Fetcher meet this keyword, it will check and set the latest revision to urldata.revision. get_srcrev later can use the urldata.revision for value evaluation(SRCPV etc). In this case, SRCREV no longer depends on get_srcrev, and there is not deadlock anymore. Signed-off-by: Yu Ke <ke.yu@intel.com>
This commit is contained in:
parent
550c3bd821
commit
1589a1172f
|
@ -360,6 +360,9 @@ def localpaths(d):
|
||||||
|
|
||||||
srcrev_internal_call = False
|
srcrev_internal_call = False
|
||||||
|
|
||||||
|
def get_autorev(d):
|
||||||
|
return get_srcrev(d)
|
||||||
|
|
||||||
def get_srcrev(d):
|
def get_srcrev(d):
|
||||||
"""
|
"""
|
||||||
Return the version string for the current package
|
Return the version string for the current package
|
||||||
|
|
|
@ -358,7 +358,8 @@ def localpaths(d):
|
||||||
|
|
||||||
return local
|
return local
|
||||||
|
|
||||||
srcrev_internal_call = False
|
def get_autorev(d):
|
||||||
|
return "AUTOINC"
|
||||||
|
|
||||||
def get_srcrev(d):
|
def get_srcrev(d):
|
||||||
"""
|
"""
|
||||||
|
@ -369,18 +370,6 @@ def get_srcrev(d):
|
||||||
have been set.
|
have been set.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
#
|
|
||||||
# Ugly code alert. localpath in the fetchers will try to evaluate SRCREV which
|
|
||||||
# could translate into a call to here. If it does, we need to catch this
|
|
||||||
# and provide some way so it knows get_srcrev is active instead of being
|
|
||||||
# some number etc. hence the srcrev_internal_call tracking and the magic
|
|
||||||
# "SRCREVINACTION" return value.
|
|
||||||
#
|
|
||||||
# Neater solutions welcome!
|
|
||||||
#
|
|
||||||
if bb.fetch2.srcrev_internal_call:
|
|
||||||
return "SRCREVINACTION"
|
|
||||||
|
|
||||||
scms = []
|
scms = []
|
||||||
|
|
||||||
# Only call setup_localpath on URIs which supports_srcrev()
|
# Only call setup_localpath on URIs which supports_srcrev()
|
||||||
|
@ -548,6 +537,8 @@ class FetchData(object):
|
||||||
self.method = m
|
self.method = m
|
||||||
if hasattr(m,"urldata_init"):
|
if hasattr(m,"urldata_init"):
|
||||||
m.urldata_init(self, d)
|
m.urldata_init(self, d)
|
||||||
|
if m.supports_srcrev():
|
||||||
|
self.revision = Fetch.srcrev_internal_helper(self, d);
|
||||||
return
|
return
|
||||||
raise NoMethodError("Missing implementation for url %s" % url)
|
raise NoMethodError("Missing implementation for url %s" % url)
|
||||||
|
|
||||||
|
@ -572,11 +563,7 @@ class FetchData(object):
|
||||||
local = ""
|
local = ""
|
||||||
self.localpath = local
|
self.localpath = local
|
||||||
if not local:
|
if not local:
|
||||||
try:
|
self.localpath = self.method.localpath(self.url, self, d)
|
||||||
bb.fetch2.srcrev_internal_call = True
|
|
||||||
self.localpath = self.method.localpath(self.url, self, d)
|
|
||||||
finally:
|
|
||||||
bb.fetch2.srcrev_internal_call = False
|
|
||||||
# We have to clear data's internal caches since the cached value of SRCREV is now wrong.
|
# We have to clear data's internal caches since the cached value of SRCREV is now wrong.
|
||||||
# Horrible...
|
# Horrible...
|
||||||
bb.data.delVar("ISHOULDNEVEREXIST", d)
|
bb.data.delVar("ISHOULDNEVEREXIST", d)
|
||||||
|
@ -682,8 +669,8 @@ class Fetch(object):
|
||||||
"""
|
"""
|
||||||
Return:
|
Return:
|
||||||
a) a source revision if specified
|
a) a source revision if specified
|
||||||
b) True if auto srcrev is in action
|
b) latest revision if SREREV="AUTOINC"
|
||||||
c) False otherwise
|
c) None if not specified
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if 'rev' in ud.parm:
|
if 'rev' in ud.parm:
|
||||||
|
@ -704,10 +691,9 @@ class Fetch(object):
|
||||||
rev = data.getVar("SRCREV", d, 1)
|
rev = data.getVar("SRCREV", d, 1)
|
||||||
if rev == "INVALID":
|
if rev == "INVALID":
|
||||||
raise InvalidSRCREV("Please set SRCREV to a valid value")
|
raise InvalidSRCREV("Please set SRCREV to a valid value")
|
||||||
if not rev:
|
if rev == "AUTOINC":
|
||||||
return False
|
rev = ud.method.latest_revision(ud.url, ud, d)
|
||||||
if rev is "SRCREVINACTION":
|
|
||||||
return True
|
|
||||||
return rev
|
return rev
|
||||||
|
|
||||||
srcrev_internal_helper = staticmethod(srcrev_internal_helper)
|
srcrev_internal_helper = staticmethod(srcrev_internal_helper)
|
||||||
|
|
|
@ -43,12 +43,6 @@ class Bzr(Fetch):
|
||||||
ud.pkgdir = os.path.join(data.expand('${BZRDIR}', d), ud.host, relpath)
|
ud.pkgdir = os.path.join(data.expand('${BZRDIR}', d), ud.host, relpath)
|
||||||
|
|
||||||
def localpath (self, url, ud, d):
|
def localpath (self, url, ud, d):
|
||||||
revision = Fetch.srcrev_internal_helper(ud, d)
|
|
||||||
if revision is True:
|
|
||||||
ud.revision = self.latest_revision(url, ud, d)
|
|
||||||
elif revision:
|
|
||||||
ud.revision = revision
|
|
||||||
|
|
||||||
if not ud.revision:
|
if not ud.revision:
|
||||||
ud.revision = self.latest_revision(url, ud, d)
|
ud.revision = self.latest_revision(url, ud, d)
|
||||||
|
|
||||||
|
|
|
@ -62,13 +62,7 @@ class Git(Fetch):
|
||||||
ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
|
ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
|
||||||
|
|
||||||
def localpath(self, url, ud, d):
|
def localpath(self, url, ud, d):
|
||||||
|
ud.tag = ud.revision
|
||||||
tag = Fetch.srcrev_internal_helper(ud, d)
|
|
||||||
if tag is True:
|
|
||||||
ud.tag = self.latest_revision(url, ud, d)
|
|
||||||
elif tag:
|
|
||||||
ud.tag = tag
|
|
||||||
|
|
||||||
if not ud.tag or ud.tag == "master":
|
if not ud.tag or ud.tag == "master":
|
||||||
ud.tag = self.latest_revision(url, ud, d)
|
ud.tag = self.latest_revision(url, ud, d)
|
||||||
|
|
||||||
|
|
|
@ -64,14 +64,8 @@ class Hg(Fetch):
|
||||||
def localpath(self, url, ud, d):
|
def localpath(self, url, ud, d):
|
||||||
if 'rev' in ud.parm:
|
if 'rev' in ud.parm:
|
||||||
ud.revision = ud.parm['rev']
|
ud.revision = ud.parm['rev']
|
||||||
else:
|
elif not ud.revision:
|
||||||
tag = Fetch.srcrev_internal_helper(ud, d)
|
ud.revision = self.latest_revision(url, ud, d)
|
||||||
if tag is True:
|
|
||||||
ud.revision = self.latest_revision(url, ud, d)
|
|
||||||
elif tag:
|
|
||||||
ud.revision = tag
|
|
||||||
else:
|
|
||||||
ud.revision = self.latest_revision(url, ud, d)
|
|
||||||
|
|
||||||
ud.localfile = data.expand('%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision), d)
|
ud.localfile = data.expand('%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision), d)
|
||||||
|
|
||||||
|
|
|
@ -73,15 +73,9 @@ class Svn(Fetch):
|
||||||
if "DATE" in pv:
|
if "DATE" in pv:
|
||||||
ud.revision = ""
|
ud.revision = ""
|
||||||
else:
|
else:
|
||||||
rev = Fetch.srcrev_internal_helper(ud, d)
|
# use the initizlied revision
|
||||||
if rev is True:
|
if ud.revision:
|
||||||
ud.revision = self.latest_revision(url, ud, d)
|
|
||||||
ud.date = ""
|
ud.date = ""
|
||||||
elif rev:
|
|
||||||
ud.revision = rev
|
|
||||||
ud.date = ""
|
|
||||||
else:
|
|
||||||
ud.revision = ""
|
|
||||||
|
|
||||||
ud.localfile = data.expand('%s_%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision, ud.date), d)
|
ud.localfile = data.expand('%s_%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision, ud.date), d)
|
||||||
|
|
||||||
|
|
|
@ -537,7 +537,7 @@ UPDATECOMMAND_cvs = "/usr/bin/env cvs -d${CVSROOT} update -d -P ${CVSCOOPTS}"
|
||||||
UPDATECOMMAND_svn = "/usr/bin/env svn update ${SVNCOOPTS}"
|
UPDATECOMMAND_svn = "/usr/bin/env svn update ${SVNCOOPTS}"
|
||||||
SRCDATE = "${DATE}"
|
SRCDATE = "${DATE}"
|
||||||
SRCREV = "INVALID"
|
SRCREV = "INVALID"
|
||||||
AUTOREV = "${SRCPV}"
|
AUTOREV = "${@bb.fetch.get_autorev(d)}"
|
||||||
SRCPV = "${@bb.fetch.get_srcrev(d)}"
|
SRCPV = "${@bb.fetch.get_srcrev(d)}"
|
||||||
|
|
||||||
SRC_URI = "file://${FILE}"
|
SRC_URI = "file://${FILE}"
|
||||||
|
|
Loading…
Reference in New Issue