3 # This command is used by "make clean", so don't rely on ./configure
13 if command -v "$python"; then
14 exec "$python" "$0" "$@"
17 echo "error: unable to find suitable python executable; please report" 1>&2
21 from __future__ import absolute_import, print_function
22 from sys import stderr
23 import os.path, re, subprocess, sys
25 def mntent_unescape(x):
33 return unescapes.get(m.group(0))
34 return re.sub(r'(\\\\|\\011|\\012|\\040)', replacement, x)
36 targets = sys.argv[1:]
38 if not os.path.exists('/proc/mounts'):
39 print('No /proc/mounts; skipping mount cleanup in', repr(targets),
44 for target in targets:
45 if not os.path.isdir(target):
46 print(repr(target), 'is not a directory', file=stderr)
49 top = os.path.realpath(target)
50 proc_mounts = open('/proc/mounts', 'r')
51 for line in proc_mounts:
52 _, point, fstype, _ = line.split(' ', 3)
53 point = mntent_unescape(point)
54 if top == point or os.path.commonprefix((top + '/', point)) == top + '/':
55 if fstype.startswith('fuse'):
56 if subprocess.call(['fusermount', '-uz', point]) != 0:
59 if subprocess.call(['umount', '-l', point]) != 0: