diff options
Diffstat (limited to 'bitbake/lib/bb/fetch/__init__.py')
-rw-r--r-- | bitbake/lib/bb/fetch/__init__.py | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/bitbake/lib/bb/fetch/__init__.py b/bitbake/lib/bb/fetch/__init__.py index 364bdffff1..40b0c699ab 100644 --- a/bitbake/lib/bb/fetch/__init__.py +++ b/bitbake/lib/bb/fetch/__init__.py | |||
@@ -27,10 +27,13 @@ BitBake build tools. | |||
27 | from __future__ import absolute_import | 27 | from __future__ import absolute_import |
28 | from __future__ import print_function | 28 | from __future__ import print_function |
29 | import os, re | 29 | import os, re |
30 | import logging | ||
30 | import bb | 31 | import bb |
31 | from bb import data | 32 | from bb import data |
32 | from bb import persist_data | 33 | from bb import persist_data |
33 | 34 | ||
35 | logger = logging.getLogger("BitBake.Fetch") | ||
36 | |||
34 | class MalformedUrl(Exception): | 37 | class MalformedUrl(Exception): |
35 | """Exception raised when encountering an invalid url""" | 38 | """Exception raised when encountering an invalid url""" |
36 | 39 | ||
@@ -117,9 +120,8 @@ def encodeurl(decoded): | |||
117 | return url | 120 | return url |
118 | 121 | ||
119 | def uri_replace(uri, uri_find, uri_replace, d): | 122 | def uri_replace(uri, uri_find, uri_replace, d): |
120 | # bb.msg.note(1, bb.msg.domain.Fetcher, "uri_replace: operating on %s" % uri) | ||
121 | if not uri or not uri_find or not uri_replace: | 123 | if not uri or not uri_find or not uri_replace: |
122 | bb.msg.debug(1, bb.msg.domain.Fetcher, "uri_replace: passed an undefined value, not replacing") | 124 | logger.debug(1, "uri_replace: passed an undefined value, not replacing") |
123 | uri_decoded = list(decodeurl(uri)) | 125 | uri_decoded = list(decodeurl(uri)) |
124 | uri_find_decoded = list(decodeurl(uri_find)) | 126 | uri_find_decoded = list(decodeurl(uri_find)) |
125 | uri_replace_decoded = list(decodeurl(uri_replace)) | 127 | uri_replace_decoded = list(decodeurl(uri_replace)) |
@@ -135,13 +137,8 @@ def uri_replace(uri, uri_find, uri_replace, d): | |||
135 | localfn = bb.fetch.localpath(uri, d) | 137 | localfn = bb.fetch.localpath(uri, d) |
136 | if localfn: | 138 | if localfn: |
137 | result_decoded[loc] = os.path.dirname(result_decoded[loc]) + "/" + os.path.basename(bb.fetch.localpath(uri, d)) | 139 | result_decoded[loc] = os.path.dirname(result_decoded[loc]) + "/" + os.path.basename(bb.fetch.localpath(uri, d)) |
138 | # bb.msg.note(1, bb.msg.domain.Fetcher, "uri_replace: matching %s against %s and replacing with %s" % (i, uri_decoded[loc], uri_replace_decoded[loc])) | ||
139 | else: | 140 | else: |
140 | # bb.msg.note(1, bb.msg.domain.Fetcher, "uri_replace: no match") | ||
141 | return uri | 141 | return uri |
142 | # else: | ||
143 | # for j in i: | ||
144 | # FIXME: apply replacements against options | ||
145 | return encodeurl(result_decoded) | 142 | return encodeurl(result_decoded) |
146 | 143 | ||
147 | methods = [] | 144 | methods = [] |
@@ -158,9 +155,9 @@ def fetcher_init(d): | |||
158 | # When to drop SCM head revisions controlled by user policy | 155 | # When to drop SCM head revisions controlled by user policy |
159 | srcrev_policy = bb.data.getVar('BB_SRCREV_POLICY', d, 1) or "clear" | 156 | srcrev_policy = bb.data.getVar('BB_SRCREV_POLICY', d, 1) or "clear" |
160 | if srcrev_policy == "cache": | 157 | if srcrev_policy == "cache": |
161 | bb.msg.debug(1, bb.msg.domain.Fetcher, "Keeping SRCREV cache due to cache policy of: %s" % srcrev_policy) | 158 | logger.debug(1, "Keeping SRCREV cache due to cache policy of: %s", srcrev_policy) |
162 | elif srcrev_policy == "clear": | 159 | elif srcrev_policy == "clear": |
163 | bb.msg.debug(1, bb.msg.domain.Fetcher, "Clearing SRCREV cache due to cache policy of: %s" % srcrev_policy) | 160 | logger.debug(1, "Clearing SRCREV cache due to cache policy of: %s", srcrev_policy) |
164 | try: | 161 | try: |
165 | bb.fetch.saved_headrevs = pd.getKeyValues("BB_URI_HEADREVS") | 162 | bb.fetch.saved_headrevs = pd.getKeyValues("BB_URI_HEADREVS") |
166 | except: | 163 | except: |
@@ -190,11 +187,11 @@ def fetcher_compare_revisons(d): | |||
190 | changed = False | 187 | changed = False |
191 | for key in data: | 188 | for key in data: |
192 | if key not in data2 or data2[key] != data[key]: | 189 | if key not in data2 or data2[key] != data[key]: |
193 | bb.msg.debug(1, bb.msg.domain.Fetcher, "%s changed" % key) | 190 | logger.debug(1, "%s changed", key) |
194 | changed = True | 191 | changed = True |
195 | return True | 192 | return True |
196 | else: | 193 | else: |
197 | bb.msg.debug(2, bb.msg.domain.Fetcher, "%s did not change" % key) | 194 | logger.debug(2, "%s did not change", key) |
198 | return False | 195 | return False |
199 | 196 | ||
200 | # Function call order is usually: | 197 | # Function call order is usually: |
@@ -334,7 +331,7 @@ def checkstatus(d, urls = None): | |||
334 | for u in urls: | 331 | for u in urls: |
335 | ud = urldata[u] | 332 | ud = urldata[u] |
336 | m = ud.method | 333 | m = ud.method |
337 | bb.msg.debug(1, bb.msg.domain.Fetcher, "Testing URL %s" % u) | 334 | logger.debug(1, "Testing URL %s" % u) |
338 | # First try checking uri, u, from PREMIRRORS | 335 | # First try checking uri, u, from PREMIRRORS |
339 | mirrors = mirror_from_string(bb.data.getVar('PREMIRRORS', d, True)) | 336 | mirrors = mirror_from_string(bb.data.getVar('PREMIRRORS', d, True)) |
340 | ret = try_mirrors(d, u, mirrors, True) | 337 | ret = try_mirrors(d, u, mirrors, True) |
@@ -398,7 +395,7 @@ def get_srcrev(d): | |||
398 | scms.append(u) | 395 | scms.append(u) |
399 | 396 | ||
400 | if len(scms) == 0: | 397 | if len(scms) == 0: |
401 | bb.msg.error(bb.msg.domain.Fetcher, "SRCREV was used yet no valid SCM was found in SRC_URI") | 398 | logger.error("SRCREV was used yet no valid SCM was found in SRC_URI") |
402 | raise ParameterError | 399 | raise ParameterError |
403 | 400 | ||
404 | if bb.data.getVar('BB_SRCREV_POLICY', d, True) != "cache": | 401 | if bb.data.getVar('BB_SRCREV_POLICY', d, True) != "cache": |
@@ -412,7 +409,7 @@ def get_srcrev(d): | |||
412 | # | 409 | # |
413 | format = bb.data.getVar('SRCREV_FORMAT', d, 1) | 410 | format = bb.data.getVar('SRCREV_FORMAT', d, 1) |
414 | if not format: | 411 | if not format: |
415 | bb.msg.error(bb.msg.domain.Fetcher, "The SRCREV_FORMAT variable must be set when multiple SCMs are used.") | 412 | logger.error("The SRCREV_FORMAT variable must be set when multiple SCMs are used.") |
416 | raise ParameterError | 413 | raise ParameterError |
417 | 414 | ||
418 | for scm in scms: | 415 | for scm in scms: |
@@ -454,7 +451,7 @@ def runfetchcmd(cmd, d, quiet = False): | |||
454 | if val: | 451 | if val: |
455 | cmd = 'export ' + var + '=\"%s\"; %s' % (val, cmd) | 452 | cmd = 'export ' + var + '=\"%s\"; %s' % (val, cmd) |
456 | 453 | ||
457 | bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % cmd) | 454 | logger.debug(1, "Running %s", cmd) |
458 | 455 | ||
459 | # redirect stderr to stdout | 456 | # redirect stderr to stdout |
460 | stdout_handle = os.popen(cmd + " 2>&1", "r") | 457 | stdout_handle = os.popen(cmd + " 2>&1", "r") |
@@ -490,7 +487,7 @@ def try_mirrors(d, uri, mirrors, check = False, force = False): | |||
490 | """ | 487 | """ |
491 | fpath = os.path.join(data.getVar("DL_DIR", d, 1), os.path.basename(uri)) | 488 | fpath = os.path.join(data.getVar("DL_DIR", d, 1), os.path.basename(uri)) |
492 | if not check and os.access(fpath, os.R_OK) and not force: | 489 | if not check and os.access(fpath, os.R_OK) and not force: |
493 | bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists, skipping checkout." % fpath) | 490 | logger.debug(1, "%s already exists, skipping checkout." % fpath) |
494 | return fpath | 491 | return fpath |
495 | 492 | ||
496 | ld = d.createCopy() | 493 | ld = d.createCopy() |
@@ -500,7 +497,7 @@ def try_mirrors(d, uri, mirrors, check = False, force = False): | |||
500 | try: | 497 | try: |
501 | ud = FetchData(newuri, ld) | 498 | ud = FetchData(newuri, ld) |
502 | except bb.fetch.NoMethodError: | 499 | except bb.fetch.NoMethodError: |
503 | bb.msg.debug(1, bb.msg.domain.Fetcher, "No method for %s" % uri) | 500 | logger.debug(1, "No method for %s", uri) |
504 | continue | 501 | continue |
505 | 502 | ||
506 | ud.setup_localpath(ld) | 503 | ud.setup_localpath(ld) |
@@ -518,7 +515,7 @@ def try_mirrors(d, uri, mirrors, check = False, force = False): | |||
518 | bb.fetch.MD5SumError): | 515 | bb.fetch.MD5SumError): |
519 | import sys | 516 | import sys |
520 | (type, value, traceback) = sys.exc_info() | 517 | (type, value, traceback) = sys.exc_info() |
521 | bb.msg.debug(2, bb.msg.domain.Fetcher, "Mirror fetch failure: %s" % value) | 518 | logger.debug(2, "Mirror fetch failure: %s" % value) |
522 | removefile(ud.localpath) | 519 | removefile(ud.localpath) |
523 | continue | 520 | continue |
524 | return None | 521 | return None |
@@ -654,7 +651,7 @@ class Fetch(object): | |||
654 | Check the status of a URL | 651 | Check the status of a URL |
655 | Assumes localpath was called first | 652 | Assumes localpath was called first |
656 | """ | 653 | """ |
657 | bb.msg.note(1, bb.msg.domain.Fetcher, "URL %s could not be checked for status since no method exists." % url) | 654 | logger.info("URL %s could not be checked for status since no method exists.", url) |
658 | return True | 655 | return True |
659 | 656 | ||
660 | def getSRCDate(urldata, d): | 657 | def getSRCDate(urldata, d): |