]> arthur.barton.de Git - bup.git/commitdiff
Makefile: don't depend on dev/python to clean
authorRob Browning <rlb@defaultvalue.org>
Sun, 21 Mar 2021 17:29:11 +0000 (12:29 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sun, 28 Mar 2021 21:20:38 +0000 (16:20 -0500)
"make clean" should always work, even if we can't build dev/python.
Thanks to Greg Troxel for reporting the problem, and Johannes Berg for
suggesting additional improvements.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Makefile
dev/cleanup-mounts-under

index f3205f73fa0d111e58334b8b90a9689a18ba734d..880e92944f680be7b95c20380a885b71bf457fc0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -145,7 +145,7 @@ dev/python: dev/python.c config/config.h
        $(CC) $(bup_python_cflags_embed) $< $(bup_python_ldflags_embed) -o $@-proposed
        dev/validate-python $@-proposed
        mv $@-proposed $@
-# Do not add to clean_paths - want it available until the very end
+clean_paths += dev/python dev/python-proposed
 
 dev/bup-exec: lib/cmd/bup.c config/config.h
        $(CC) $(bup_python_cflags_embed) $< $(bup_python_ldflags_embed) -fPIC \
@@ -247,7 +247,7 @@ import-docs: Documentation/clean
        $(pf); git archive origin/html | (cd Documentation && tar -xvf -)
        $(pf); git archive origin/man | (cd Documentation && tar -xvf -)
 
-clean: Documentation/clean dev/python
+clean: Documentation/clean
        cd config && rm -rf config.var
        cd config && rm -f \
          ${CONFIGURE_DETRITUS} ${CONFIGURE_FILES} ${GENERATED_FILES}
@@ -262,5 +262,3 @@ clean: Documentation/clean dev/python
        rm -rf test/int/testfs test/int/testfs.img testfs.img
        if test -e test/tmp; then dev/force-delete test/tmp; fi
        dev/configure-sampledata --clean
-        # Remove last so that cleanup tools can depend on it
-       rm -f dev/python
index b04f095560c277fd79de7dac0e097cf6ccfc9beb..fedc0b34a7a78390acab8c8423c69d3f18837901 100755 (executable)
@@ -1,9 +1,24 @@
 #!/bin/sh
 """": # -*-python-*-
-bup_python="$(dirname "$0")/../dev/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.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 +36,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)