]> arthur.barton.de Git - bup.git/blobdiff - lib/cmd/fsck-cmd.py
Remove $(dirname "$0") from sys.path
[bup.git] / lib / cmd / fsck-cmd.py
index 293024e8d81948492a857eef4d96903f1277ca66..911bab8b8bda9ad767929d538812f17e54ff68d4 100755 (executable)
@@ -1,18 +1,32 @@
 #!/bin/sh
 """": # -*-python-*-
-bup_python="$(dirname "$0")/bup-python" || exit $?
-exec "$bup_python" "$0" ${1+"$@"}
+# https://sourceware.org/bugzilla/show_bug.cgi?id=26034
+export "BUP_ARGV_0"="$0"
+arg_i=1
+for arg in "$@"; do
+    export "BUP_ARGV_${arg_i}"="$arg"
+    shift
+    arg_i=$((arg_i + 1))
+done
+# Here to end of preamble replaced during install
+bup_python="$(dirname "$0")/../../config/bin/python" || exit $?
+exec "$bup_python" "$0"
 """
 # end of bup preamble
 
 from __future__ import absolute_import, print_function
-import sys, os, glob, subprocess
+
+# Intentionally replace the dirname "$0" that python prepends
+import os, sys
+sys.path[0] = os.path.dirname(os.path.realpath(__file__)) + '/..'
+
+import glob, subprocess
 from shutil import rmtree
 from subprocess import PIPE, Popen
 from tempfile import mkdtemp
 from binascii import hexlify
 
-from bup import options, git
+from bup import compat, options, git
 from bup.compat import argv_bytes
 from bup.helpers import Sha1, chunkyreader, istty2, log, progress
 from bup.io import byte_stream
@@ -184,7 +198,7 @@ par2-ok     immediately return 0 if par2 is ok, 1 if not
 disable-par2  ignore par2 even if it is available
 """
 o = options.Options(optspec)
-(opt, flags, extra) = o.parse(sys.argv[1:])
+opt, flags, extra = o.parse(compat.argv[1:])
 opt.verbose = opt.verbose or 0
 
 par2_setup()
@@ -199,7 +213,7 @@ if opt.disable_par2:
 git.check_repo_or_die()
 
 if extra:
-    extra = [argv_byes(x) for x in extra]
+    extra = [argv_bytes(x) for x in extra]
 else:
     debug('fsck: No filenames given: checking all packs.\n')
     extra = glob.glob(git.repo(b'objects/pack/*.pack'))