Make cleanup optional.
This commit is contained in:
parent
c5a278729e
commit
04c3a81b9e
1 changed files with 41 additions and 35 deletions
|
@ -129,6 +129,13 @@ class DistCatcher(object):
|
|||
self.find_files()
|
||||
return False
|
||||
|
||||
def cleanup(self):
|
||||
for path in self.files:
|
||||
if os.path.isdir(path):
|
||||
shutil.rmtree(path)
|
||||
else:
|
||||
os.unlink(path)
|
||||
|
||||
|
||||
def create_dist(
|
||||
session: Session,
|
||||
|
@ -137,13 +144,13 @@ def create_dist(
|
|||
packaging_tree: Optional[Tree] = None,
|
||||
include_controldir: bool = True,
|
||||
subdir: Optional[str] = None,
|
||||
cleanup: bool = False
|
||||
) -> Optional[str]:
|
||||
from .buildsystem import detect_buildsystems
|
||||
from .buildlog import InstallFixer
|
||||
|
||||
if subdir is None:
|
||||
subdir = "package"
|
||||
with session:
|
||||
if packaging_tree is not None:
|
||||
from .debian import satisfy_build_deps
|
||||
|
||||
|
@ -170,11 +177,8 @@ def create_dist(
|
|||
shutil.copy(path, target_dir)
|
||||
return os.path.join(target_dir, os.path.basename(path))
|
||||
finally:
|
||||
for path in dc.files:
|
||||
if os.path.isdir(path):
|
||||
shutil.rmtree(path)
|
||||
else:
|
||||
os.unlink(path)
|
||||
if cleanup:
|
||||
dc.cleanup()
|
||||
|
||||
logging.info("No tarball created :(")
|
||||
raise DistNoTarball()
|
||||
|
@ -187,13 +191,15 @@ def create_dist_schroot(
|
|||
packaging_tree: Optional[Tree] = None,
|
||||
include_controldir: bool = True,
|
||||
subdir: Optional[str] = None,
|
||||
cleanup: bool = False
|
||||
) -> Optional[str]:
|
||||
session = SchrootSession(chroot)
|
||||
with SchrootSession(chroot) as session:
|
||||
return create_dist(
|
||||
session, tree, target_dir,
|
||||
packaging_tree=packaging_tree,
|
||||
include_controldir=include_controldir,
|
||||
subdir=subdir)
|
||||
subdir=subdir,
|
||||
cleanup=cleanup)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue