diff --git a/src/bin/lorax b/src/bin/lorax index e58fb610..abef5db6 100755 --- a/src/bin/lorax +++ b/src/bin/lorax @@ -130,5 +130,4 @@ if __name__ == "__main__": sys.stderr.write("Error writing %s/.discinfo file.\n" % (output,)) # clean up - trash = [yumconf, treedir, buildinstdir] - pylorax.cleanup(trash) + pylorax.cleanup() diff --git a/src/pylorax/__init__.py b/src/pylorax/__init__.py index 2004e2ea..2c1f3719 100644 --- a/src/pylorax/__init__.py +++ b/src/pylorax/__init__.py @@ -201,13 +201,14 @@ def cleanup(trash=[]): """ - if trash is []: - return + if trash != []: + for item in trash: + if os.path.isdir(item): + shutil.rmtree(item, ignore_errors=True) + else: + os.unlink(item) - for item in trash: - if os.path.isdir(item): - shutil.rmtree(item, ignore_errors=True) - else: - os.unlink(item) + if os.path.isdir(conf['tmpdir']): + shutil.rmtree(conf['tmpdir'], ignore_errors=True) return