summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/local.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2014-12-08 21:22:26 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-01-08 09:52:52 +0000
commit26cd67e63a9451455def3be8ef03114dcac81ea5 (patch)
tree262d0f0a64d4416bab93bdf68ee14f9f09aab8ed /bitbake/lib/bb/fetch2/local.py
parent130958cc24ad306684d92a8d965f3772f30e196a (diff)
downloadpoky-26cd67e63a9451455def3be8ef03114dcac81ea5.tar.gz
bitbake: wget: Add localpaths method which gives localpath with history
In some cases for cache purpoes we not only need to know which file is going to be used but also which paths were considered. Add a localpaths method which includes the history. The core which() funciton already supports this, this just extends the function to preserve the extra data we need. localpath becomes just a special case of the case with history. (Bitbake rev: ea5efeac5c1f7986666c979f789786f29fc1619a) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2/local.py')
-rw-r--r--bitbake/lib/bb/fetch2/local.py54
1 files changed, 33 insertions, 21 deletions
diff --git a/bitbake/lib/bb/fetch2/local.py b/bitbake/lib/bb/fetch2/local.py
index 6fa188fc48..0785236a6b 100644
--- a/bitbake/lib/bb/fetch2/local.py
+++ b/bitbake/lib/bb/fetch2/local.py
@@ -51,29 +51,41 @@ class Local(FetchMethod):
51 """ 51 """
52 Return the local filename of a given url assuming a successful fetch. 52 Return the local filename of a given url assuming a successful fetch.
53 """ 53 """
54 return self.localpaths(urldata, d)[-1]
55
56 def localpaths(self, urldata, d):
57 """
58 Return the local filename of a given url assuming a successful fetch.
59 """
60 searched = []
54 path = urldata.decodedurl 61 path = urldata.decodedurl
55 newpath = path 62 newpath = path
56 if path[0] != "/": 63 if path[0] == "/":
57 filespath = data.getVar('FILESPATH', d, True) 64 return [path]
58 if filespath: 65 filespath = data.getVar('FILESPATH', d, True)
59 logger.debug(2, "Searching for %s in paths:\n %s" % (path, "\n ".join(filespath.split(":")))) 66 if filespath:
60 newpath = bb.utils.which(filespath, path) 67 logger.debug(2, "Searching for %s in paths:\n %s" % (path, "\n ".join(filespath.split(":"))))
61 if not newpath: 68 newpath, hist = bb.utils.which(filespath, path, history=True)
62 filesdir = data.getVar('FILESDIR', d, True) 69 searched.extend(hist)
63 if filesdir: 70 if not newpath:
64 logger.debug(2, "Searching for %s in path: %s" % (path, filesdir)) 71 filesdir = data.getVar('FILESDIR', d, True)
65 newpath = os.path.join(filesdir, path) 72 if filesdir:
66 if (not newpath or not os.path.exists(newpath)) and path.find("*") != -1: 73 logger.debug(2, "Searching for %s in path: %s" % (path, filesdir))
67 # For expressions using '*', best we can do is take the first directory in FILESPATH that exists 74 newpath = os.path.join(filesdir, path)
68 newpath = bb.utils.which(filespath, ".") 75 searched.append(newpath)
69 logger.debug(2, "Searching for %s in path: %s" % (path, newpath)) 76 if (not newpath or not os.path.exists(newpath)) and path.find("*") != -1:
70 return newpath 77 # For expressions using '*', best we can do is take the first directory in FILESPATH that exists
71 if not os.path.exists(newpath): 78 newpath, hist = bb.utils.which(filespath, ".", history=True)
72 dldirfile = os.path.join(d.getVar("DL_DIR", True), path) 79 searched.extend(hist)
73 logger.debug(2, "Defaulting to %s for %s" % (dldirfile, path)) 80 logger.debug(2, "Searching for %s in path: %s" % (path, newpath))
74 bb.utils.mkdirhier(os.path.dirname(dldirfile)) 81 return searched
75 return dldirfile 82 if not os.path.exists(newpath):
76 return newpath 83 dldirfile = os.path.join(d.getVar("DL_DIR", True), path)
84 logger.debug(2, "Defaulting to %s for %s" % (dldirfile, path))
85 bb.utils.mkdirhier(os.path.dirname(dldirfile))
86 searched.append(dldirfile)
87 return searched
88 return searched
77 89
78 def need_update(self, ud, d): 90 def need_update(self, ud, d):
79 if ud.url.find("*") != -1: 91 if ud.url.find("*") != -1: