Skip to content
Snippets Groups Projects
Commit e4a35e5e authored by Simon McVittie's avatar Simon McVittie
Browse files

debootstrap: Clean up on success, or show log on failure


This is similar to what the debos action does.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent 2ab98b30
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@ import logging
import os
import subprocess
import sys
from contextlib import suppress
logger = logging.getLogger('flatdeb.debootstrap')
......@@ -63,7 +64,22 @@ def main() -> None:
argv.append(args.suite)
argv.append(args.sysroot)
argv.append(args.mirror)
subprocess.check_call(argv)
try:
subprocess.check_call(argv)
except subprocess.CalledProcessError:
with open(
str(Path(args.sysroot, 'debootstrap', 'debootstrap.log'))
) as reader:
for line in reader:
logger.error(line)
raise
with suppress(FileNotFoundError):
Path(args.sysroot, 'etc', 'resolv.conf').unlink()
subprocess.call(['chroot', args.sysroot, 'apt-get', 'clean'])
if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment