diff options
-rw-r--r-- | bitbake/lib/bb/utils.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 3e90b6a306..d035949b3d 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -677,7 +677,7 @@ def _check_unsafe_delete_path(path): | |||
677 | return True | 677 | return True |
678 | return False | 678 | return False |
679 | 679 | ||
680 | def remove(path, recurse=False): | 680 | def remove(path, recurse=False, ionice=False): |
681 | """Equivalent to rm -f or rm -rf""" | 681 | """Equivalent to rm -f or rm -rf""" |
682 | if not path: | 682 | if not path: |
683 | return | 683 | return |
@@ -686,7 +686,10 @@ def remove(path, recurse=False): | |||
686 | if _check_unsafe_delete_path(path): | 686 | if _check_unsafe_delete_path(path): |
687 | raise Exception('bb.utils.remove: called with dangerous path "%s" and recurse=True, refusing to delete!' % path) | 687 | raise Exception('bb.utils.remove: called with dangerous path "%s" and recurse=True, refusing to delete!' % path) |
688 | # shutil.rmtree(name) would be ideal but its too slow | 688 | # shutil.rmtree(name) would be ideal but its too slow |
689 | subprocess.check_call(['rm', '-rf'] + glob.glob(path)) | 689 | cmd = [] |
690 | if ionice: | ||
691 | cmd = ['ionice', '-c', '3'] | ||
692 | subprocess.check_call(cmd + ['rm', '-rf'] + glob.glob(path)) | ||
690 | return | 693 | return |
691 | for name in glob.glob(path): | 694 | for name in glob.glob(path): |
692 | try: | 695 | try: |
@@ -695,12 +698,12 @@ def remove(path, recurse=False): | |||
695 | if exc.errno != errno.ENOENT: | 698 | if exc.errno != errno.ENOENT: |
696 | raise | 699 | raise |
697 | 700 | ||
698 | def prunedir(topdir): | 701 | def prunedir(topdir, ionice=False): |
699 | # Delete everything reachable from the directory named in 'topdir'. | 702 | # Delete everything reachable from the directory named in 'topdir'. |
700 | # CAUTION: This is dangerous! | 703 | # CAUTION: This is dangerous! |
701 | if _check_unsafe_delete_path(topdir): | 704 | if _check_unsafe_delete_path(topdir): |
702 | raise Exception('bb.utils.prunedir: called with dangerous path "%s", refusing to delete!' % topdir) | 705 | raise Exception('bb.utils.prunedir: called with dangerous path "%s", refusing to delete!' % topdir) |
703 | remove(topdir, recurse=True) | 706 | remove(topdir, recurse=True, ionice=ionice) |
704 | 707 | ||
705 | # | 708 | # |
706 | # Could also use return re.compile("(%s)" % "|".join(map(re.escape, suffixes))).sub(lambda mo: "", var) | 709 | # Could also use return re.compile("(%s)" % "|".join(map(re.escape, suffixes))).sub(lambda mo: "", var) |