]> arthur.barton.de Git - bup.git/blobdiff - dev/cleanup-mounts-under
configure/cleanup: support python 3.10
[bup.git] / dev / cleanup-mounts-under
index c0c26715b8909b0028548dc8669490ec87124040..b1a9acb0a94448b51849620778a45f68cb34a345 100755 (executable)
@@ -1,9 +1,25 @@
 #!/bin/sh
 """": # -*-python-*-
-bup_python="$(dirname "$0")/../config/bin/python" || exit $?
-exec "$bup_python" "$0" ${1+"$@"}
+# This command is used by "make clean", so don't rely on ./configure
+set -e
+for python in \
+    python3 \
+    python3.10 \
+    python3.9 \
+    python3.8 \
+    python3.7 \
+    python3.6 \
+    python \
+    python2.7; do \
+    if command -v "$python"; then
+        exec "$python" "$0" "$@"
+    fi
+done
+echo "error: unable to find suitable python executable; please report" 1>&2
+exit 2
 """
 
+from __future__ import absolute_import, print_function
 from sys import stderr
 import os.path, re, subprocess, sys
 
@@ -21,13 +37,14 @@ def mntent_unescape(x):
 targets = sys.argv[1:]
 
 if not os.path.exists('/proc/mounts'):
-    print >> stderr, 'No /proc/mounts; skipping mount cleanup in', repr(targets)
+    print('No /proc/mounts; skipping mount cleanup in', repr(targets),
+          file=stderr)
     sys.exit(0)
 
 exit_status = 0
 for target in targets:
     if not os.path.isdir(target):
-        print >> stderr, repr(target), 'is not a directory'
+        print(repr(target), 'is not a directory', file=stderr)
         exit_status = 1
         continue
     top = os.path.realpath(target)