summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/bb/build.py6
-rw-r--r--bitbake/lib/bb/fetch/__init__.py11
-rw-r--r--bitbake/lib/bb/fetch/osc.py4
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py11
-rw-r--r--bitbake/lib/bb/utils.py4
5 files changed, 13 insertions, 23 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py
index f127796c07..bd9b93a12d 100644
--- a/bitbake/lib/bb/build.py
+++ b/bitbake/lib/bb/build.py
@@ -405,9 +405,8 @@ def make_stamp(task, d, file_name = None):
405 stamp = stamp_internal(task, d, file_name) 405 stamp = stamp_internal(task, d, file_name)
406 # Remove the file and recreate to force timestamp 406 # Remove the file and recreate to force timestamp
407 # change on broken NFS filesystems 407 # change on broken NFS filesystems
408 if os.access(stamp, os.F_OK):
409 os.remove(stamp)
410 if stamp: 408 if stamp:
409 bb.utils.remove(stamp)
411 f = open(stamp, "w") 410 f = open(stamp, "w")
412 f.close() 411 f.close()
413 412
@@ -417,8 +416,7 @@ def del_stamp(task, d, file_name = None):
417 (d can be a data dict or dataCache) 416 (d can be a data dict or dataCache)
418 """ 417 """
419 stamp = stamp_internal(task, d, file_name) 418 stamp = stamp_internal(task, d, file_name)
420 if os.access(stamp, os.F_OK): 419 bb.utils.remove(stamp)
421 os.remove(stamp)
422 420
423def stampfile(taskname, d): 421def stampfile(taskname, d):
424 return stamp_internal(taskname, d, None) 422 return stamp_internal(taskname, d, None)
diff --git a/bitbake/lib/bb/fetch/__init__.py b/bitbake/lib/bb/fetch/__init__.py
index 07eb77dbfc..cd9410d04c 100644
--- a/bitbake/lib/bb/fetch/__init__.py
+++ b/bitbake/lib/bb/fetch/__init__.py
@@ -31,6 +31,7 @@ import logging
31import bb 31import bb
32from bb import data 32from bb import data
33from bb import persist_data 33from bb import persist_data
34from bb import utils
34 35
35logger = logging.getLogger("BitBake.Fetch") 36logger = logging.getLogger("BitBake.Fetch")
36 37
@@ -217,12 +218,6 @@ def init(urls, d, setup = True):
217def mirror_from_string(data): 218def mirror_from_string(data):
218 return [ i.split() for i in (data or "").replace('\\n','\n').split('\n') if i ] 219 return [ i.split() for i in (data or "").replace('\\n','\n').split('\n') if i ]
219 220
220def removefile(f):
221 try:
222 os.remove(f)
223 except:
224 pass
225
226def verify_checksum(u, ud, d): 221def verify_checksum(u, ud, d):
227 """ 222 """
228 verify the MD5 and SHA256 checksum for downloaded src 223 verify the MD5 and SHA256 checksum for downloaded src
@@ -293,7 +288,7 @@ def go(d, urls = None):
293 localpath = ud.localpath 288 localpath = ud.localpath
294 except FetchError: 289 except FetchError:
295 # Remove any incomplete file 290 # Remove any incomplete file
296 removefile(ud.localpath) 291 bb.utils.remove(ud.localpath)
297 # Finally, try fetching uri, u, from MIRRORS 292 # Finally, try fetching uri, u, from MIRRORS
298 mirrors = mirror_from_string(bb.data.getVar('MIRRORS', d, True)) 293 mirrors = mirror_from_string(bb.data.getVar('MIRRORS', d, True))
299 localpath = try_mirrors (d, u, mirrors) 294 localpath = try_mirrors (d, u, mirrors)
@@ -517,7 +512,7 @@ def try_mirrors(d, uri, mirrors, check = False, force = False):
517 import sys 512 import sys
518 (type, value, traceback) = sys.exc_info() 513 (type, value, traceback) = sys.exc_info()
519 logger.debug(2, "Mirror fetch failure: %s", value) 514 logger.debug(2, "Mirror fetch failure: %s", value)
520 removefile(ud.localpath) 515 bb.utils.remove(ud.localpath)
521 continue 516 continue
522 return None 517 return None
523 518
diff --git a/bitbake/lib/bb/fetch/osc.py b/bitbake/lib/bb/fetch/osc.py
index 26820967a3..8e0423d762 100644
--- a/bitbake/lib/bb/fetch/osc.py
+++ b/bitbake/lib/bb/fetch/osc.py
@@ -11,6 +11,7 @@ import sys
11import logging 11import logging
12import bb 12import bb
13from bb import data 13from bb import data
14from bb import utils
14from bb.fetch import Fetch 15from bb.fetch import Fetch
15from bb.fetch import FetchError 16from bb.fetch import FetchError
16from bb.fetch import MissingParameterError 17from bb.fetch import MissingParameterError
@@ -123,8 +124,7 @@ class Osc(Fetch):
123 """ 124 """
124 125
125 config_path = os.path.join(data.expand('${OSCDIR}', d), "oscrc") 126 config_path = os.path.join(data.expand('${OSCDIR}', d), "oscrc")
126 if (os.path.exists(config_path)): 127 bb.utils.remove(config_path)
127 os.remove(config_path)
128 128
129 f = open(config_path, 'w') 129 f = open(config_path, 'w')
130 f.write("[general]\n") 130 f.write("[general]\n")
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 751e514121..2aeb8b8fe1 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -31,6 +31,7 @@ import logging
31import bb 31import bb
32from bb import data 32from bb import data
33from bb import persist_data 33from bb import persist_data
34from bb import utils
34 35
35logger = logging.getLogger("BitBake.Fetch") 36logger = logging.getLogger("BitBake.Fetch")
36 37
@@ -217,12 +218,6 @@ def init(urls, d, setup = True):
217def mirror_from_string(data): 218def mirror_from_string(data):
218 return [ i.split() for i in (data or "").replace('\\n','\n').split('\n') if i ] 219 return [ i.split() for i in (data or "").replace('\\n','\n').split('\n') if i ]
219 220
220def removefile(f):
221 try:
222 os.remove(f)
223 except:
224 pass
225
226def verify_checksum(u, ud, d): 221def verify_checksum(u, ud, d):
227 """ 222 """
228 verify the MD5 and SHA256 checksum for downloaded src 223 verify the MD5 and SHA256 checksum for downloaded src
@@ -293,7 +288,7 @@ def go(d, urls = None):
293 localpath = ud.localpath 288 localpath = ud.localpath
294 except FetchError: 289 except FetchError:
295 # Remove any incomplete file 290 # Remove any incomplete file
296 removefile(ud.localpath) 291 bb.utils.remove(ud.localpath)
297 # Finally, try fetching uri, u, from MIRRORS 292 # Finally, try fetching uri, u, from MIRRORS
298 mirrors = mirror_from_string(bb.data.getVar('MIRRORS', d, True)) 293 mirrors = mirror_from_string(bb.data.getVar('MIRRORS', d, True))
299 localpath = try_mirrors (d, u, mirrors) 294 localpath = try_mirrors (d, u, mirrors)
@@ -503,7 +498,7 @@ def try_mirrors(d, uri, mirrors, check = False, force = False):
503 import sys 498 import sys
504 (type, value, traceback) = sys.exc_info() 499 (type, value, traceback) = sys.exc_info()
505 logger.debug(2, "Mirror fetch failure: %s", value) 500 logger.debug(2, "Mirror fetch failure: %s", value)
506 removefile(ud.localpath) 501 bb.utils.remove(ud.localpath)
507 continue 502 continue
508 return None 503 return None
509 504
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 5b3710f84f..40b5f2f3dc 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -582,10 +582,12 @@ def build_environment(d):
582 582
583def remove(path, recurse=False): 583def remove(path, recurse=False):
584 """Equivalent to rm -f or rm -rf""" 584 """Equivalent to rm -f or rm -rf"""
585 if not path:
586 return
585 import os, errno, shutil 587 import os, errno, shutil
586 try: 588 try:
587 os.unlink(path) 589 os.unlink(path)
588 except OSError, exc: 590 except OSError as exc:
589 if recurse and exc.errno == errno.EISDIR: 591 if recurse and exc.errno == errno.EISDIR:
590 shutil.rmtree(path) 592 shutil.rmtree(path)
591 elif exc.errno != errno.ENOENT: 593 elif exc.errno != errno.ENOENT: