From 58836733803e389866f3e7e88b3c377f630008c3 Mon Sep 17 00:00:00 2001 From: Anders Ingemann Date: Sat, 12 Dec 2015 23:53:13 +0100 Subject: [PATCH] umount /sys & /proc when debootstrap is aborted --- bootstrapvz/common/tasks/bootstrap.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bootstrapvz/common/tasks/bootstrap.py b/bootstrapvz/common/tasks/bootstrap.py index 75d882b..ceceb37 100644 --- a/bootstrapvz/common/tasks/bootstrap.py +++ b/bootstrapvz/common/tasks/bootstrap.py @@ -79,8 +79,17 @@ class Bootstrap(Task): # Optional bootstrapping script to modify the bootstrapping process arguments.append(info.bootstrap_script) - from ..tools import log_check_call - log_check_call(executable + options + arguments) + try: + from ..tools import log_check_call + log_check_call(executable + options + arguments) + except KeyboardInterrupt: + # Sometimes ../root/sys and ../root/proc are still mounted when + # quitting debootstrap prematurely. This break the cleanup process, + # so we unmount manually (ignore the exit code, the dirs may not be mounted). + from ..tools import log_call + log_call(['umount', os.path.join(info.root, 'sys')]) + log_call(['umount', os.path.join(info.root, 'proc')]) + raise class IncludePackagesInBootstrap(Task):