]> arthur.barton.de Git - bup.git/blobdiff - lib/cmd/index-cmd.py
Prefer python 3, and mention intent to drop python 2 support
[bup.git] / lib / cmd / index-cmd.py
index b131db990264b9079c2b41e1c2007d16075c01ff..b3925b3135c0ad90e5780bde535116839926573f 100755 (executable)
@@ -1,15 +1,26 @@
 #!/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
 from binascii import hexlify
-import sys, stat, time, os, errno, re
+import errno, os, re, stat, sys, time
 
-from bup import metadata, options, git, index, drecurse, hlinkdb
+sys.path[:0] = [os.path.dirname(os.path.realpath(__file__)) + '/..']
+
+from bup import compat, metadata, options, git, index, drecurse, hlinkdb
 from bup.compat import argv_bytes
 from bup.drecurse import recursive_dirlist
 from bup.hashsplit import GIT_MODE_TREE, GIT_MODE_FILE
@@ -74,13 +85,12 @@ def clear_index(indexfile):
 
 
 def update_index(top, excluded_paths, exclude_rxs, xdev_exceptions, out=None):
-    # tmax and start must be epoch nanoseconds.
+    # tmax must be epoch nanoseconds.
     tmax = (time.time() - 1) * 10**9
     ri = index.Reader(indexfile)
     msw = index.MetaStoreWriter(indexfile + b'.meta')
     wi = index.Writer(indexfile, msw, tmax)
     rig = IterHelper(ri.iter(name=top))
-    tstart = int(time.time()) * 10**9
 
     hlinks = hlinkdb.HLinkDB(indexfile + b'.hlink')
 
@@ -120,7 +130,7 @@ def update_index(top, excluded_paths, exclude_rxs, xdev_exceptions, out=None):
 
         if rig.cur and rig.cur.name == path:    # paths that already existed
             need_repack = False
-            if(rig.cur.stale(pst, tstart, check_device=opt.check_device)):
+            if(rig.cur.stale(pst, check_device=opt.check_device)):
                 try:
                     meta = metadata.from_path(path, statinfo=pst)
                 except (OSError, IOError) as e:
@@ -231,7 +241,7 @@ v,verbose  increase log output (can be used more than once)
 x,xdev,one-file-system  don't cross filesystem boundaries
 """
 o = options.Options(optspec)
-(opt, flags, extra) = o.parse(sys.argv[1:])
+opt, flags, extra = o.parse(compat.argv[1:])
 
 if not (opt.modified or \
         opt['print'] or \
@@ -308,7 +318,8 @@ if opt['print'] or opt.status or opt.modified:
         if opt.hash:
             line += hexlify(ent.sha) + b' '
         if opt.long:
-            line += b'%7s %7s ' % (oct(ent.mode), oct(ent.gitmode))
+            line += b'%7s %7s ' % (oct(ent.mode).encode('ascii'),
+                                   oct(ent.gitmode).encode('ascii'))
         out.write(line + (name or b'./') + b'\n')
 
 if opt.check and (opt['print'] or opt.status or opt.modified or opt.update):