summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2
diff options
context:
space:
mode:
authorYu Ke <ke.yu@intel.com>2010-12-27 09:31:38 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-01-10 20:24:33 +0000
commit1589a1172f9432aed1cc9ce006f68cddf3073774 (patch)
tree48616149e847a09c87668f6342b64dce15f4f57f /bitbake/lib/bb/fetch2
parent550c3bd82115b4bdb8235da53cfc18b1dc39ad96 (diff)
downloadpoky-1589a1172f9432aed1cc9ce006f68cddf3073774.tar.gz
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>
Diffstat (limited to 'bitbake/lib/bb/fetch2')
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py34
-rw-r--r--bitbake/lib/bb/fetch2/bzr.py6
-rw-r--r--bitbake/lib/bb/fetch2/git.py8
-rw-r--r--bitbake/lib/bb/fetch2/hg.py10
-rw-r--r--bitbake/lib/bb/fetch2/svn.py10
5 files changed, 15 insertions, 53 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 16cf1fa2be..b9cca91684 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -358,7 +358,8 @@ def localpaths(d):
358 358
359 return local 359 return local
360 360
361srcrev_internal_call = False 361def get_autorev(d):
362 return "AUTOINC"
362 363
363def get_srcrev(d): 364def get_srcrev(d):
364 """ 365 """
@@ -369,18 +370,6 @@ def get_srcrev(d):
369 have been set. 370 have been set.
370 """ 371 """
371 372
372 #
373 # Ugly code alert. localpath in the fetchers will try to evaluate SRCREV which
374 # could translate into a call to here. If it does, we need to catch this
375 # and provide some way so it knows get_srcrev is active instead of being
376 # some number etc. hence the srcrev_internal_call tracking and the magic
377 # "SRCREVINACTION" return value.
378 #
379 # Neater solutions welcome!
380 #
381 if bb.fetch2.srcrev_internal_call:
382 return "SRCREVINACTION"
383
384 scms = [] 373 scms = []
385 374
386 # Only call setup_localpath on URIs which supports_srcrev() 375 # Only call setup_localpath on URIs which supports_srcrev()
@@ -548,6 +537,8 @@ class FetchData(object):
548 self.method = m 537 self.method = m
549 if hasattr(m,"urldata_init"): 538 if hasattr(m,"urldata_init"):
550 m.urldata_init(self, d) 539 m.urldata_init(self, d)
540 if m.supports_srcrev():
541 self.revision = Fetch.srcrev_internal_helper(self, d);
551 return 542 return
552 raise NoMethodError("Missing implementation for url %s" % url) 543 raise NoMethodError("Missing implementation for url %s" % url)
553 544
@@ -572,11 +563,7 @@ class FetchData(object):
572 local = "" 563 local = ""
573 self.localpath = local 564 self.localpath = local
574 if not local: 565 if not local:
575 try: 566 self.localpath = self.method.localpath(self.url, self, d)
576 bb.fetch2.srcrev_internal_call = True
577 self.localpath = self.method.localpath(self.url, self, d)
578 finally:
579 bb.fetch2.srcrev_internal_call = False
580 # We have to clear data's internal caches since the cached value of SRCREV is now wrong. 567 # We have to clear data's internal caches since the cached value of SRCREV is now wrong.
581 # Horrible... 568 # Horrible...
582 bb.data.delVar("ISHOULDNEVEREXIST", d) 569 bb.data.delVar("ISHOULDNEVEREXIST", d)
@@ -682,8 +669,8 @@ class Fetch(object):
682 """ 669 """
683 Return: 670 Return:
684 a) a source revision if specified 671 a) a source revision if specified
685 b) True if auto srcrev is in action 672 b) latest revision if SREREV="AUTOINC"
686 c) False otherwise 673 c) None if not specified
687 """ 674 """
688 675
689 if 'rev' in ud.parm: 676 if 'rev' in ud.parm:
@@ -704,10 +691,9 @@ class Fetch(object):
704 rev = data.getVar("SRCREV", d, 1) 691 rev = data.getVar("SRCREV", d, 1)
705 if rev == "INVALID": 692 if rev == "INVALID":
706 raise InvalidSRCREV("Please set SRCREV to a valid value") 693 raise InvalidSRCREV("Please set SRCREV to a valid value")
707 if not rev: 694 if rev == "AUTOINC":
708 return False 695 rev = ud.method.latest_revision(ud.url, ud, d)
709 if rev is "SRCREVINACTION": 696
710 return True
711 return rev 697 return rev
712 698
713 srcrev_internal_helper = staticmethod(srcrev_internal_helper) 699 srcrev_internal_helper = staticmethod(srcrev_internal_helper)
diff --git a/bitbake/lib/bb/fetch2/bzr.py b/bitbake/lib/bb/fetch2/bzr.py
index 1368f172d3..97b042b2a5 100644
--- a/bitbake/lib/bb/fetch2/bzr.py
+++ b/bitbake/lib/bb/fetch2/bzr.py
@@ -43,12 +43,6 @@ class Bzr(Fetch):
43 ud.pkgdir = os.path.join(data.expand('${BZRDIR}', d), ud.host, relpath) 43 ud.pkgdir = os.path.join(data.expand('${BZRDIR}', d), ud.host, relpath)
44 44
45 def localpath (self, url, ud, d): 45 def localpath (self, url, ud, d):
46 revision = Fetch.srcrev_internal_helper(ud, d)
47 if revision is True:
48 ud.revision = self.latest_revision(url, ud, d)
49 elif revision:
50 ud.revision = revision
51
52 if not ud.revision: 46 if not ud.revision:
53 ud.revision = self.latest_revision(url, ud, d) 47 ud.revision = self.latest_revision(url, ud, d)
54 48
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index 58ed1f4108..c62145770f 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -62,13 +62,7 @@ class Git(Fetch):
62 ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git" 62 ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
63 63
64 def localpath(self, url, ud, d): 64 def localpath(self, url, ud, d):
65 65 ud.tag = ud.revision
66 tag = Fetch.srcrev_internal_helper(ud, d)
67 if tag is True:
68 ud.tag = self.latest_revision(url, ud, d)
69 elif tag:
70 ud.tag = tag
71
72 if not ud.tag or ud.tag == "master": 66 if not ud.tag or ud.tag == "master":
73 ud.tag = self.latest_revision(url, ud, d) 67 ud.tag = self.latest_revision(url, ud, d)
74 68
diff --git a/bitbake/lib/bb/fetch2/hg.py b/bitbake/lib/bb/fetch2/hg.py
index 80a155108c..0ba84330a5 100644
--- a/bitbake/lib/bb/fetch2/hg.py
+++ b/bitbake/lib/bb/fetch2/hg.py
@@ -64,14 +64,8 @@ class Hg(Fetch):
64 def localpath(self, url, ud, d): 64 def localpath(self, url, ud, d):
65 if 'rev' in ud.parm: 65 if 'rev' in ud.parm:
66 ud.revision = ud.parm['rev'] 66 ud.revision = ud.parm['rev']
67 else: 67 elif not ud.revision:
68 tag = Fetch.srcrev_internal_helper(ud, d) 68 ud.revision = self.latest_revision(url, ud, d)
69 if tag is True:
70 ud.revision = self.latest_revision(url, ud, d)
71 elif tag:
72 ud.revision = tag
73 else:
74 ud.revision = self.latest_revision(url, ud, d)
75 69
76 ud.localfile = data.expand('%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision), d) 70 ud.localfile = data.expand('%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision), d)
77 71
diff --git a/bitbake/lib/bb/fetch2/svn.py b/bitbake/lib/bb/fetch2/svn.py
index c0a7a548cc..1116795e87 100644
--- a/bitbake/lib/bb/fetch2/svn.py
+++ b/bitbake/lib/bb/fetch2/svn.py
@@ -73,15 +73,9 @@ class Svn(Fetch):
73 if "DATE" in pv: 73 if "DATE" in pv:
74 ud.revision = "" 74 ud.revision = ""
75 else: 75 else:
76 rev = Fetch.srcrev_internal_helper(ud, d) 76 # use the initizlied revision
77 if rev is True: 77 if ud.revision:
78 ud.revision = self.latest_revision(url, ud, d)
79 ud.date = "" 78 ud.date = ""
80 elif rev:
81 ud.revision = rev
82 ud.date = ""
83 else:
84 ud.revision = ""
85 79
86 ud.localfile = data.expand('%s_%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision, ud.date), d) 80 ud.localfile = data.expand('%s_%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision, ud.date), d)
87 81