summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2006-11-12 15:30:35 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2006-11-12 15:30:35 +0000
commitab6bc07a319278a1b61ab58dc660ad7e9508542a (patch)
treedd5a19cd00a87be24286ff5c20069d57a6531f1e
parent3f4f2ae322ba807b0729f33f3490cf77acd081f9 (diff)
downloadbitbake-ab6bc07a319278a1b61ab58dc660ad7e9508542a.tar.gz
fetchers: Only call createCopy and update_data after checking if the download already exists. Refactor parameters to wget's fetch_uri and make md5 a global urldata option.
-rw-r--r--lib/bb/fetch/__init__.py1
-rw-r--r--lib/bb/fetch/cvs.py8
-rw-r--r--lib/bb/fetch/svk.py13
-rw-r--r--lib/bb/fetch/svn.py8
-rw-r--r--lib/bb/fetch/wget.py35
5 files changed, 30 insertions, 35 deletions
diff --git a/lib/bb/fetch/__init__.py b/lib/bb/fetch/__init__.py
index 023b2e07c..ee0adf9fb 100644
--- a/lib/bb/fetch/__init__.py
+++ b/lib/bb/fetch/__init__.py
@@ -98,6 +98,7 @@ def initdata(url, d):
for m in methods:
if m.supports(url, ud, d):
ud.localpath = m.localpath(url, ud, d)
+ ud.md5 = ud.localpath + '.md5'
# if user sets localpath for file, use it instead.
if "localpath" in ud.parm:
ud.localpath = ud.parm["localpath"]
diff --git a/lib/bb/fetch/cvs.py b/lib/bb/fetch/cvs.py
index 668b81204..f79f46c73 100644
--- a/lib/bb/fetch/cvs.py
+++ b/lib/bb/fetch/cvs.py
@@ -63,10 +63,6 @@ class Cvs(Fetch):
def go(self, loc, ud, d):
- localdata = data.createCopy(d)
- data.setVar('OVERRIDES', "cvs:%s" % data.getVar('OVERRIDES', localdata), localdata)
- data.update_data(localdata)
-
# setup cvs options
options = []
@@ -104,6 +100,10 @@ class Cvs(Fetch):
cvsroot += ":" + ud.pswd
cvsroot += "@" + ud.host + ":" + ud.path
+ localdata = data.createCopy(d)
+ data.setVar('OVERRIDES', "cvs:%s" % data.getVar('OVERRIDES', localdata), localdata)
+ data.update_data(localdata)
+
data.setVar('CVSROOT', cvsroot, localdata)
data.setVar('CVSCOOPTS', " ".join(options), localdata)
data.setVar('CVSMODULE', ud.module, localdata)
diff --git a/lib/bb/fetch/svk.py b/lib/bb/fetch/svk.py
index 80b16d585..738ae5b70 100644
--- a/lib/bb/fetch/svk.py
+++ b/lib/bb/fetch/svk.py
@@ -65,20 +65,17 @@ class Svk(Fetch):
def go(self, loc, ud, d):
"""Fetch urls"""
- localdata = data.createCopy(d)
- data.setVar('OVERRIDES', "svk:%s" % data.getVar('OVERRIDES', localdata), localdata)
- data.update_data(localdata)
-
- # setup svk options
- options = []
-
if (ud.date != "now") and Fetch.try_mirror(d, ud.localfile):
return
svkroot = ud.host + ud.path
+ localdata = data.createCopy(d)
+ data.setVar('OVERRIDES', "svk:%s" % data.getVar('OVERRIDES', localdata), localdata)
+ data.update_data(localdata)
+
data.setVar('SVKROOT', svkroot, localdata)
- data.setVar('SVKCOOPTS', " ".join(options), localdata)
+ data.setVar('SVKCOOPTS', '', localdata)
data.setVar('SVKMODULE', ud.module, localdata)
svkcmd = "svk co -r {%s} %s/%s" % (date, svkroot, ud.module)
diff --git a/lib/bb/fetch/svn.py b/lib/bb/fetch/svn.py
index d788c82f0..a88617eb4 100644
--- a/lib/bb/fetch/svn.py
+++ b/lib/bb/fetch/svn.py
@@ -58,10 +58,6 @@ class Svn(Fetch):
def go(self, loc, ud, d):
"""Fetch url"""
- localdata = data.createCopy(d)
- data.setVar('OVERRIDES', "svn:%s" % data.getVar('OVERRIDES', localdata), localdata)
- data.update_data(localdata)
-
# setup svn options
options = []
@@ -86,6 +82,10 @@ class Svn(Fetch):
elif ud.date != "now":
options.append("-r {%s}" % ud.date)
+ localdata = data.createCopy(d)
+ data.setVar('OVERRIDES', "svn:%s" % data.getVar('OVERRIDES', localdata), localdata)
+ data.update_data(localdata)
+
data.setVar('SVNROOT', "%s://%s/%s" % (proto, svnroot, ud.module), localdata)
data.setVar('SVNCOOPTS', " ".join(options), localdata)
data.setVar('SVNMODULE', ud.module, localdata)
diff --git a/lib/bb/fetch/wget.py b/lib/bb/fetch/wget.py
index 562038041..2006f292a 100644
--- a/lib/bb/fetch/wget.py
+++ b/lib/bb/fetch/wget.py
@@ -70,10 +70,10 @@ class Wget(Fetch):
return wanted_sum == got_sum
- def fetch_uri(uri, basename, dl, md5, parm, d):
+ def fetch_uri(uri, ud, basename, d):
# the MD5 sum we want to verify
- wanted_md5sum = md5_sum(parm, d)
- if os.path.exists(dl):
+ wanted_md5sum = md5_sum(ud.parm, d)
+ if os.path.exists(ud.localpath):
# file exists, but we didnt complete it.. trying again..
fetchcmd = data.getVar("RESUMECOMMAND", d, 1)
else:
@@ -88,16 +88,15 @@ class Wget(Fetch):
return False
# check if sourceforge did send us to the mirror page
- dl_dir = data.getVar("DL_DIR", d, True)
- if not os.path.exists(dl):
- os.system("rm %s*" % dl) # FIXME shell quote it
+ if not os.path.exists(ud.localpath):
+ os.system("rm %s*" % ud.localpath) # FIXME shell quote it
bb.msg.debug(2, bb.msg.domain.Fetcher, "sourceforge.net send us to the mirror on %s" % basename)
return False
# supposedly complete.. write out md5sum
if bb.which(data.getVar('PATH', d), 'md5sum'):
try:
- md5pipe = os.popen('md5sum ' + dl)
+ md5pipe = os.popen('md5sum ' + ud.localpath)
md5data = (md5pipe.readline().split() or [ "" ])[0]
md5pipe.close()
except OSError:
@@ -107,38 +106,36 @@ class Wget(Fetch):
if not verify_md5sum(wanted_md5sum, md5data):
raise MD5SumError(uri)
- md5out = file(md5, 'w')
+ md5out = file(ud.md5, 'w')
md5out.write(md5data)
md5out.close()
return True
- localdata = data.createCopy(d)
- data.setVar('OVERRIDES', "wget:" + data.getVar('OVERRIDES', localdata), localdata)
- data.update_data(localdata)
-
completed = 0
basename = os.path.basename(ud.path)
- dl = data.expand(ud.localpath, localdata)
- md5 = dl + '.md5'
- if os.path.exists(md5):
+ if os.path.exists(ud.md5):
#complete, nothing to see here..
#touch md5 file to show activity
- os.utime(md5, None)
+ os.utime(ud.md5, None)
return
+ localdata = data.createCopy(d)
+ data.setVar('OVERRIDES', "wget:" + data.getVar('OVERRIDES', localdata), localdata)
+ data.update_data(localdata)
+
premirrors = [ i.split() for i in (data.getVar('PREMIRRORS', localdata, 1) or "").split('\n') if i ]
for (find, replace) in premirrors:
newuri = uri_replace(uri, find, replace, d)
if newuri != uri:
- if fetch_uri(newuri, basename, dl, md5, ud.parm, localdata):
+ if fetch_uri(newuri, ud, basename, localdata):
completed = 1
break
if completed:
return
- if fetch_uri(uri, basename, dl, md5, ud.parm, localdata):
+ if fetch_uri(uri, ud, basename, localdata):
return
# try mirrors
@@ -146,7 +143,7 @@ class Wget(Fetch):
for (find, replace) in mirrors:
newuri = uri_replace(uri, find, replace, d)
if newuri != uri:
- if fetch_uri(newuri, basename, dl, md5, ud.parm, localdata):
+ if fetch_uri(newuri, ud, basename, localdata):
completed = 1
break