diff options
author | Tudor Florea <tudor.florea@enea.com> | 2014-10-16 03:05:19 +0200 |
---|---|---|
committer | Tudor Florea <tudor.florea@enea.com> | 2014-10-16 03:05:19 +0200 |
commit | c527fd1f14c27855a37f2e8ac5346ce8d940ced2 (patch) | |
tree | bb002c1fdf011c41dbd2f0927bed23ecb5f83c97 /bitbake/lib/bb/fetch2/local.py | |
download | poky-daisy-140929.tar.gz |
initial commit for Enea Linux 4.0-140929daisy-140929
Migrated from the internal git server on the daisy-enea-point-release branch
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'bitbake/lib/bb/fetch2/local.py')
-rw-r--r-- | bitbake/lib/bb/fetch2/local.py | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/bitbake/lib/bb/fetch2/local.py b/bitbake/lib/bb/fetch2/local.py new file mode 100644 index 0000000000..5c4e42a942 --- /dev/null +++ b/bitbake/lib/bb/fetch2/local.py | |||
@@ -0,0 +1,116 @@ | |||
1 | # ex:ts=4:sw=4:sts=4:et | ||
2 | # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- | ||
3 | """ | ||
4 | BitBake 'Fetch' implementations | ||
5 | |||
6 | Classes for obtaining upstream sources for the | ||
7 | BitBake build tools. | ||
8 | |||
9 | """ | ||
10 | |||
11 | # Copyright (C) 2003, 2004 Chris Larson | ||
12 | # | ||
13 | # This program is free software; you can redistribute it and/or modify | ||
14 | # it under the terms of the GNU General Public License version 2 as | ||
15 | # published by the Free Software Foundation. | ||
16 | # | ||
17 | # This program is distributed in the hope that it will be useful, | ||
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | # GNU General Public License for more details. | ||
21 | # | ||
22 | # You should have received a copy of the GNU General Public License along | ||
23 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
24 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
25 | # | ||
26 | # Based on functions from the base bb module, Copyright 2003 Holger Schurig | ||
27 | |||
28 | import os | ||
29 | import urllib | ||
30 | import bb | ||
31 | import bb.utils | ||
32 | from bb import data | ||
33 | from bb.fetch2 import FetchMethod, FetchError | ||
34 | from bb.fetch2 import logger | ||
35 | |||
36 | class Local(FetchMethod): | ||
37 | def supports(self, urldata, d): | ||
38 | """ | ||
39 | Check to see if a given url represents a local fetch. | ||
40 | """ | ||
41 | return urldata.type in ['file'] | ||
42 | |||
43 | def urldata_init(self, ud, d): | ||
44 | # We don't set localfile as for this fetcher the file is already local! | ||
45 | ud.decodedurl = urllib.unquote(ud.url.split("://")[1].split(";")[0]) | ||
46 | ud.basename = os.path.basename(ud.decodedurl) | ||
47 | ud.basepath = ud.decodedurl | ||
48 | return | ||
49 | |||
50 | def localpath(self, urldata, d): | ||
51 | """ | ||
52 | Return the local filename of a given url assuming a successful fetch. | ||
53 | """ | ||
54 | path = urldata.decodedurl | ||
55 | newpath = path | ||
56 | if path[0] != "/": | ||
57 | filespath = data.getVar('FILESPATH', d, True) | ||
58 | if filespath: | ||
59 | logger.debug(2, "Searching for %s in paths: \n%s" % (path, "\n ".join(filespath.split(":")))) | ||
60 | newpath = bb.utils.which(filespath, path) | ||
61 | if not newpath: | ||
62 | filesdir = data.getVar('FILESDIR', d, True) | ||
63 | if filesdir: | ||
64 | logger.debug(2, "Searching for %s in path: %s" % (path, filesdir)) | ||
65 | newpath = os.path.join(filesdir, path) | ||
66 | if (not newpath or not os.path.exists(newpath)) and path.find("*") != -1: | ||
67 | # For expressions using '*', best we can do is take the first directory in FILESPATH that exists | ||
68 | newpath = bb.utils.which(filespath, ".") | ||
69 | logger.debug(2, "Searching for %s in path: %s" % (path, newpath)) | ||
70 | return newpath | ||
71 | if not os.path.exists(newpath): | ||
72 | dldirfile = os.path.join(d.getVar("DL_DIR", True), path) | ||
73 | logger.debug(2, "Defaulting to %s for %s" % (dldirfile, path)) | ||
74 | bb.utils.mkdirhier(os.path.dirname(dldirfile)) | ||
75 | return dldirfile | ||
76 | return newpath | ||
77 | |||
78 | def need_update(self, ud, d): | ||
79 | if ud.url.find("*") != -1: | ||
80 | return False | ||
81 | if os.path.exists(ud.localpath): | ||
82 | return False | ||
83 | return True | ||
84 | |||
85 | def download(self, urldata, d): | ||
86 | """Fetch urls (no-op for Local method)""" | ||
87 | # no need to fetch local files, we'll deal with them in place. | ||
88 | if self.supports_checksum(urldata) and not os.path.exists(urldata.localpath): | ||
89 | locations = [] | ||
90 | filespath = data.getVar('FILESPATH', d, True) | ||
91 | if filespath: | ||
92 | locations = filespath.split(":") | ||
93 | filesdir = data.getVar('FILESDIR', d, True) | ||
94 | if filesdir: | ||
95 | locations.append(filesdir) | ||
96 | locations.append(d.getVar("DL_DIR", True)) | ||
97 | |||
98 | msg = "Unable to find file " + urldata.url + " anywhere. The paths that were searched were:\n " + "\n ".join(locations) | ||
99 | raise FetchError(msg) | ||
100 | |||
101 | return True | ||
102 | |||
103 | def checkstatus(self, urldata, d): | ||
104 | """ | ||
105 | Check the status of the url | ||
106 | """ | ||
107 | if urldata.localpath.find("*") != -1: | ||
108 | logger.info("URL %s looks like a glob and was therefore not checked.", urldata.url) | ||
109 | return True | ||
110 | if os.path.exists(urldata.localpath): | ||
111 | return True | ||
112 | return False | ||
113 | |||
114 | def clean(self, urldata, d): | ||
115 | return | ||
116 | |||