aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2007-11-17 22:54:37 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2007-11-17 22:54:37 +0000
commitfa556f750772c2b37b67d5b6d09285b7ad3b3016 (patch)
tree2cd5cef0d9b3b67fc79996c0568d2c8ea967fd96
parentab202073c9dffd1363d9e2f4deb5ddd791bfeab8 (diff)
downloadbitbake-fa556f750772c2b37b67d5b6d09285b7ad3b3016.tar.gz
Fetcher SRCREV handling updates, improvements and fixes from Poky, typo fix for bin/bitbake
-rw-r--r--ChangeLog1
-rwxr-xr-xbin/bitbake2
-rw-r--r--lib/bb/fetch/__init__.py53
-rw-r--r--lib/bb/fetch/bzr.py27
-rw-r--r--lib/bb/fetch/git.py17
-rw-r--r--lib/bb/fetch/hg.py9
-rw-r--r--lib/bb/fetch/perforce.py2
-rw-r--r--lib/bb/fetch/svn.py16
8 files changed, 86 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index 52e49e953..55e1f77a6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -23,6 +23,7 @@ Changes in BitBake 1.8.x:
fetching (we don't care about the index). Fixes fetch errors.
- Add BB_GENERATE_MIRROR_TARBALLS option, set to 0 to make git fetches
faster at the expense of not creating mirror tarballs.
+ - SRCREV handling updates, improvements and fixes from Poky
Changes in Bitbake 1.8.8:
- Rewrite svn fetcher to make adding extra operations easier
diff --git a/bin/bitbake b/bin/bitbake
index 53185e58c..384175d85 100755
--- a/bin/bitbake
+++ b/bin/bitbake
@@ -50,7 +50,7 @@ def main():
usage = """%prog [options] [package ...]
Executes the specified task (default is 'build') for a given set of BitBake files.
-It expects that BBFILES is defined, which is a space seperated list of files to
+It expects that BBFILES is defined, which is a space separated list of files to
be executed. BBFILES does support wildcards.
Default BBFILES are the .bb files in the current directory.""" )
diff --git a/lib/bb/fetch/__init__.py b/lib/bb/fetch/__init__.py
index eed709581..4da92110e 100644
--- a/lib/bb/fetch/__init__.py
+++ b/lib/bb/fetch/__init__.py
@@ -170,6 +170,8 @@ def localpaths(d):
return local
+srcrev_internal_call = False
+
def get_srcrev(d):
"""
Return the version string for the current package
@@ -178,7 +180,21 @@ def get_srcrev(d):
In the multi SCM case, we build a value based on SRCREV_FORMAT which must
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.fetch.srcrev_internal_call:
+ return "SRCREVINACTION"
+
scms = []
+
# Only call setup_localpath on URIs which suppports_srcrev()
urldata = init(bb.data.getVar('SRC_URI', d, 1).split(), d, False)
for u in urldata:
@@ -273,12 +289,17 @@ class FetchData(object):
def setup_localpath(self, d):
self.setup = True
if "localpath" in self.parm:
+ # if user sets localpath for file, use it instead.
self.localpath = self.parm["localpath"]
else:
+ bb.fetch.srcrev_internal_call = True
self.localpath = self.method.localpath(self.url, self, d)
+ bb.fetch.srcrev_internal_call = False
+ # We have to clear data's internal caches since the cached value of SRCREV is now wrong.
+ # Horrible...
+ bb.data.delVar("ISHOULDNEVEREXIST", d)
self.md5 = self.localpath + '.md5'
self.lockfile = self.localpath + '.lock'
- # if user sets localpath for file, use it instead.
class Fetch(object):
@@ -345,6 +366,34 @@ class Fetch(object):
return data.getVar("SRCDATE", d, 1) or data.getVar("CVSDATE", d, 1) or data.getVar("DATE", d, 1)
getSRCDate = staticmethod(getSRCDate)
+ def srcrev_internal_helper(ud, d):
+ """
+ Return:
+ a) a source revision if specified
+ b) True if auto srcrev is in action
+ c) False otherwise
+ """
+
+ if 'rev' in ud.parm:
+ return ud.parm['rev']
+
+ if 'tag' in ud.parm:
+ return ud.parm['tag']
+
+ rev = None
+ if 'name' in ud.parm:
+ pn = data.getVar("PN", d, 1)
+ rev = data.getVar("SRCREV_pn-" + pn + "_" + ud.parm['name'], d, 1)
+ if not rev:
+ rev = data.getVar("SRCREV", d, 1)
+ if not rev:
+ return False
+ if rev is "SRCREVINACTION":
+ return True
+ return rev
+
+ srcrev_internal_helper = staticmethod(srcrev_internal_helper)
+
def try_mirror(d, tarfn):
"""
Try to use a mirrored version of the sources. We do this
@@ -434,7 +483,7 @@ class Fetch(object):
pd = persist_data.PersistData(d)
key = self._revision_key(url, ud, d)
- latest_rev = self.latest_revision(url, ud, d)
+ latest_rev = self._build_revision(url, ud, d)
last_rev = pd.getValue("BB_URI_LOCALCOUNT", key + "_rev")
count = pd.getValue("BB_URI_LOCALCOUNT", key + "_count")
diff --git a/lib/bb/fetch/bzr.py b/lib/bb/fetch/bzr.py
index c66d17fdd..b23e9eef8 100644
--- a/lib/bb/fetch/bzr.py
+++ b/lib/bb/fetch/bzr.py
@@ -45,19 +45,15 @@ class Bzr(Fetch):
relpath = relpath[1:]
ud.pkgdir = os.path.join(data.expand('${BZRDIR}', d), ud.host, relpath)
- if 'rev' in ud.parm:
- ud.revision = ud.parm['rev']
- else:
- # ***Nasty hack***
- rev = data.getVar("SRCREV", d, 0)
- if rev and "get_srcrev" in rev:
- ud.revision = self.latest_revision(url, ud, d)
- elif rev:
- ud.revision = rev
- else:
- ud.revision = ""
+ 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:
+ ud.revision = self.latest_revision(url, ud, d)
-
ud.localfile = data.expand('bzr_%s_%s_%s.tar.gz' % (ud.host, ud.path.replace('/', '.'), ud.revision), d)
return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
@@ -149,7 +145,10 @@ class Bzr(Fetch):
def _sortable_revision(self, url, ud, d):
"""
Return a sortable revision number which in our case is the revision number
- (use the cached version to avoid network access)
"""
- return self.latest_revision(url, ud, d)
+ return self._build_revision(url, ud, d)
+
+ def _build_revision(self, url, ud, d):
+ return ud.revision
+
diff --git a/lib/bb/fetch/git.py b/lib/bb/fetch/git.py
index 89b0be3d1..21259a23b 100644
--- a/lib/bb/fetch/git.py
+++ b/lib/bb/fetch/git.py
@@ -50,12 +50,16 @@ class Git(Fetch):
if 'protocol' in ud.parm:
ud.proto = ud.parm['protocol']
- tag = data.getVar("SRCREV", d, 0)
- if 'tag' in ud.parm and len(ud.parm['tag']) == 40:
- ud.tag = ud.parm['tag']
- elif tag and "get_srcrev" not in tag and len(tag) == 40:
+ tag = Fetch.srcrev_internal_helper(ud, d)
+ if tag is True:
+ ud.tag = self.latest_revision(url, ud, d)
+ elif tag:
ud.tag = tag
- else:
+
+ if not ud.tag:
+ ud.tag = self.latest_revision(url, ud, d)
+
+ if ud.tag == "master":
ud.tag = self.latest_revision(url, ud, d)
ud.localfile = data.expand('git_%s%s_%s.tar.gz' % (ud.host, ud.path.replace('/', '.'), ud.tag), d)
@@ -129,3 +133,6 @@ class Git(Fetch):
output = runfetchcmd("git ls-remote %s://%s%s" % (ud.proto, ud.host, ud.path), d, True)
return output.split()[0]
+ def _build_revision(self, url, ud, d):
+ return ud.tag
+
diff --git a/lib/bb/fetch/hg.py b/lib/bb/fetch/hg.py
index 8e8073e56..ee3bd2f7f 100644
--- a/lib/bb/fetch/hg.py
+++ b/lib/bb/fetch/hg.py
@@ -57,15 +57,6 @@ class Hg(Fetch):
if 'rev' in ud.parm:
ud.revision = ud.parm['rev']
- else:
- #
- rev = data.getVar("SRCREV", d, 0)
- if rev and "get_srcrev" in rev:
- ud.revision = self.latest_revision(url, ud, d)
- elif rev:
- ud.revision = rev
- else:
- ud.revision = ""
ud.localfile = data.expand('%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision), d)
diff --git a/lib/bb/fetch/perforce.py b/lib/bb/fetch/perforce.py
index 97b618228..b594d2bde 100644
--- a/lib/bb/fetch/perforce.py
+++ b/lib/bb/fetch/perforce.py
@@ -37,7 +37,7 @@ class Perforce(Fetch):
return ud.type in ['p4']
def doparse(url,d):
- parm=[]
+ parm = {}
path = url.split("://")[1]
delim = path.find("@");
if delim != -1:
diff --git a/lib/bb/fetch/svn.py b/lib/bb/fetch/svn.py
index 95b21fe20..5e5b31b3a 100644
--- a/lib/bb/fetch/svn.py
+++ b/lib/bb/fetch/svn.py
@@ -62,19 +62,16 @@ class Svn(Fetch):
ud.revision = ""
else:
#
- # ***Nasty hacks***
+ # ***Nasty hack***
# If DATE in unexpanded PV, use ud.date (which is set from SRCDATE)
- # Will warn people to switch to SRCREV here
- #
- # How can we tell when a user has overriden SRCDATE?
- # check for "get_srcdate" in unexpanded SRCREV - ugly
+ # Should warn people to switch to SRCREV here
#
pv = data.getVar("PV", d, 0)
if "DATE" in pv:
ud.revision = ""
else:
- rev = data.getVar("SRCREV", d, 0)
- if rev and "get_srcrev" in rev:
+ rev = Fetch.srcrev_internal_helper(ud, d)
+ if rev is True:
ud.revision = self.latest_revision(url, ud, d)
ud.date = ""
elif rev:
@@ -199,8 +196,9 @@ class Svn(Fetch):
def _sortable_revision(self, url, ud, d):
"""
Return a sortable revision number which in our case is the revision number
- (use the cached version to avoid network access)
"""
- return self.latest_revision(url, ud, d)
+ return self._build_revision(url, ud, d)
+ def _build_revision(self, url, ud, d):
+ return ud.revision