X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=blobdiff_plain;f=cmd%2Fbup;h=4b5097d5a2cf7b2c2801b3fe665844ea9baa57a0;hp=e442541bffb505572a9d0bc737b14eafa68a3970;hb=3c64b5788c3e6b10528a81285b71da2edbed8950;hpb=3fa656946d28bb8cac061b745e2edc26bc2d56ae diff --git a/cmd/bup b/cmd/bup index e442541..4b5097d 100755 --- a/cmd/bup +++ b/cmd/bup @@ -28,31 +28,11 @@ from subprocess import PIPE from sys import stderr, stdout import select -argv = sys.argv -exe = os.path.realpath(argv[0]) -exepath = os.path.split(exe)[0] or '.' - -# fix the PYTHONPATH to include our lib dir -if os.path.exists("%s/../bup/." % exepath): - # Everything is relative to exepath (i.e. LIBDIR/cmd/) - cmdpath = exepath - libpath = os.path.join(exepath, '..') - resourcepath = libpath -else: - # running from the src directory without being installed first - cmdpath = exepath - libpath = os.path.join(exepath, '../lib') - resourcepath = libpath -sys.path[:0] = [libpath] -os.environ['PYTHONPATH'] = libpath + ':' + os.environ.get('PYTHONPATH', '') -os.environ['BUP_MAIN_EXE'] = os.path.abspath(exe) -os.environ['BUP_RESOURCE_PATH'] = resourcepath - - -from bup import compat, helpers +from bup import compat, path, helpers from bup.compat import add_ex_tb, add_ex_ctx, wrap_main from bup.helpers import atoi, columnate, debug1, log, merge_dict, tty_width +cmdpath = path.cmddir() def usage(msg=""): log('Usage: bup [-?|--help] [-d BUP_DIR] [--debug] [--profile] ' @@ -77,7 +57,7 @@ def usage(msg=""): log('Other available commands:\n') cmds = [] - for c in sorted(os.listdir(cmdpath) + os.listdir(exepath)): + for c in sorted(os.listdir(cmdpath)): if c.startswith('bup-') and c.find('.') < 0: cname = c[4:] if cname not in common: @@ -92,13 +72,13 @@ def usage(msg=""): sys.exit(99) -if len(argv) < 2: +if len(sys.argv) < 2: usage() # Handle global options. try: optspec = ['help', 'version', 'debug', 'profile', 'bup-dir='] - global_args, subcmd = getopt.getopt(argv[1:], '?VDd:', optspec) + global_args, subcmd = getopt.getopt(sys.argv[1:], '?VDd:', optspec) except getopt.GetoptError as ex: usage('error: %s' % ex.msg) @@ -141,10 +121,7 @@ if not subcmd_name: usage() def subpath(s): - sp = os.path.join(exepath, 'bup-%s' % s) - if not os.path.exists(sp): - sp = os.path.join(cmdpath, 'bup-%s' % s) - return sp + return os.path.join(cmdpath, 'bup-%s' % s) subcmd[0] = subpath(subcmd_name) if not os.path.exists(subcmd[0]):