]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
bitbake/fetch2: Allow local file:// urls to be found on mirrors
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 8 Mar 2011 19:23:34 +0000 (11:23 -0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 6 May 2011 17:19:51 +0000 (18:19 +0100)
With the current implementation, file:// urls as used by sstate don't access the
mirror code, breaking sstate mirror support. This change enables the usual
mirror handling. To do this, we remove the localfile special case, using the basename
paramemter instead. We also ensure the downloads directory is checked for files.

The drawback of this change is that file urls containing "*" globing require special
casing in the core.

(From Poky rev: a778fb311540580476976e43f9c0576284f8dc38)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
lib/bb/fetch2/__init__.py
lib/bb/fetch2/local.py

index 0bb3678ce4c0c7a19cb79cf53bfdd849d17e87af..27fcc3cf76df0598ed7be816762e1a04cec5464b 100644 (file)
@@ -522,6 +522,7 @@ class FetchData(object):
         self.localpath = None
         self.lockfile = None
         self.mirrortarball = None
+        self.basename = None
         (self.type, self.host, self.path, self.user, self.pswd, self.parm) = decodeurl(data.expand(url, d))
         self.date = self.getSRCDate(d)
         self.url = url
@@ -561,11 +562,10 @@ class FetchData(object):
         elif self.localfile:
             self.localpath = self.method.localpath(self.url, self, d)
 
-        if self.localfile and self.localpath:
-            # Note: These files should always be in DL_DIR whereas localpath may not be.
-            basepath = bb.data.expand("${DL_DIR}/%s" % os.path.basename(self.localpath), d)
-            self.donestamp = basepath + '.done'
-            self.lockfile = basepath + '.lock'
+        # Note: These files should always be in DL_DIR whereas localpath may not be.
+        basepath = bb.data.expand("${DL_DIR}/%s" % os.path.basename(self.localpath or self.basename), d)
+        self.donestamp = basepath + '.done'
+        self.lockfile = basepath + '.lock'
 
     def setup_revisons(self, d):
         self.revisions = {}
@@ -907,9 +907,6 @@ class Fetch(object):
             m = ud.method
             localpath = ""
 
-            if not ud.localfile:
-                continue
-
             lf = bb.utils.lockfile(ud.lockfile)
 
             try:
@@ -945,7 +942,7 @@ class Fetch(object):
                         mirrors = mirror_from_string(bb.data.getVar('MIRRORS', self.d, True))
                         localpath = try_mirrors (self.d, ud, mirrors)
 
-                if not localpath or not os.path.exists(localpath):
+                if not localpath or ((not os.path.exists(localpath)) and localpath.find("*") == -1):
                     raise FetchError("Unable to fetch URL %s from any source." % u, u)
 
                 if os.path.exists(ud.donestamp):
index 77a296ec675c046cb8d93d7af1b3a7cc300925b4..ed9a047d8d162dc0dbb4558bd4333b3021fabcde 100644 (file)
@@ -40,6 +40,7 @@ class Local(FetchMethod):
 
     def urldata_init(self, ud, d):
         # We don't set localfile as for this fetcher the file is already local!
+        ud.basename = os.path.basename(ud.url.split("://")[1].split(";")[0])
         return
 
     def localpath(self, url, urldata, d):
@@ -49,6 +50,9 @@ class Local(FetchMethod):
         path = url.split("://")[1]
         path = path.split(";")[0]
         newpath = path
+        dldirfile = os.path.join(data.getVar("DL_DIR", d, True), os.path.basename(path))
+        if os.path.exists(dldirfile):
+            return dldirfile
         if path[0] != "/":
             filespath = data.getVar('FILESPATH', d, True)
             if filespath:
@@ -57,8 +61,17 @@ class Local(FetchMethod):
                 filesdir = data.getVar('FILESDIR', d, True)
                 if filesdir:
                     newpath = os.path.join(filesdir, path)
+        if not os.path.exists(newpath) and path.find("*") == -1:
+            return dldirfile
         return newpath
 
+    def need_update(self, url, ud, d):
+        if url.find("*") == -1:
+            return False
+        if os.path.exists(ud.localpath):
+            return False
+        return True
+
     def download(self, url, urldata, d):
         """Fetch urls (no-op for Local method)"""
         # no need to fetch local files, we'll deal with them in place.