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()
|
self.find_files()
|
||||||
return False
|
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(
|
def create_dist(
|
||||||
session: Session,
|
session: Session,
|
||||||
|
@ -137,13 +144,13 @@ def create_dist(
|
||||||
packaging_tree: Optional[Tree] = None,
|
packaging_tree: Optional[Tree] = None,
|
||||||
include_controldir: bool = True,
|
include_controldir: bool = True,
|
||||||
subdir: Optional[str] = None,
|
subdir: Optional[str] = None,
|
||||||
|
cleanup: bool = False
|
||||||
) -> Optional[str]:
|
) -> Optional[str]:
|
||||||
from .buildsystem import detect_buildsystems
|
from .buildsystem import detect_buildsystems
|
||||||
from .buildlog import InstallFixer
|
from .buildlog import InstallFixer
|
||||||
|
|
||||||
if subdir is None:
|
if subdir is None:
|
||||||
subdir = "package"
|
subdir = "package"
|
||||||
with session:
|
|
||||||
if packaging_tree is not None:
|
if packaging_tree is not None:
|
||||||
from .debian import satisfy_build_deps
|
from .debian import satisfy_build_deps
|
||||||
|
|
||||||
|
@ -170,11 +177,8 @@ def create_dist(
|
||||||
shutil.copy(path, target_dir)
|
shutil.copy(path, target_dir)
|
||||||
return os.path.join(target_dir, os.path.basename(path))
|
return os.path.join(target_dir, os.path.basename(path))
|
||||||
finally:
|
finally:
|
||||||
for path in dc.files:
|
if cleanup:
|
||||||
if os.path.isdir(path):
|
dc.cleanup()
|
||||||
shutil.rmtree(path)
|
|
||||||
else:
|
|
||||||
os.unlink(path)
|
|
||||||
|
|
||||||
logging.info("No tarball created :(")
|
logging.info("No tarball created :(")
|
||||||
raise DistNoTarball()
|
raise DistNoTarball()
|
||||||
|
@ -187,13 +191,15 @@ def create_dist_schroot(
|
||||||
packaging_tree: Optional[Tree] = None,
|
packaging_tree: Optional[Tree] = None,
|
||||||
include_controldir: bool = True,
|
include_controldir: bool = True,
|
||||||
subdir: Optional[str] = None,
|
subdir: Optional[str] = None,
|
||||||
|
cleanup: bool = False
|
||||||
) -> Optional[str]:
|
) -> Optional[str]:
|
||||||
session = SchrootSession(chroot)
|
with SchrootSession(chroot) as session:
|
||||||
return create_dist(
|
return create_dist(
|
||||||
session, tree, target_dir,
|
session, tree, target_dir,
|
||||||
packaging_tree=packaging_tree,
|
packaging_tree=packaging_tree,
|
||||||
include_controldir=include_controldir,
|
include_controldir=include_controldir,
|
||||||
subdir=subdir)
|
subdir=subdir,
|
||||||
|
cleanup=cleanup)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue