]> arthur.barton.de Git - bup.git/commitdiff
Add a 'make install' target.
authorAvery Pennarun <apenwarr@gmail.com>
Thu, 1 Apr 2010 23:34:03 +0000 (19:34 -0400)
committerAvery Pennarun <apenwarr@gmail.com>
Thu, 1 Apr 2010 23:34:03 +0000 (19:34 -0400)
Also change main.py to search around in appropriate places for the installed
library files.  By default, if your bup is in /usr/bin/bup, it'll look in
/usr/lib/bup.  (It drops two words off the end of the filename and adds
/lib/bup to the end.)

This also makes the Debian packager at
http://git.debian.org/collab-maint/bup
actually produce a usable package.

Makefile
main.py

index 40cae28223c0d55b49a6085164877bef36747fb0..217b85212af08a27040329605a71e15ce1c70ab2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -21,6 +21,28 @@ default: all
 
 all: cmds bup lib/bup/_hashsplit$(SOEXT) \
        Documentation/all
+
+INSTALL=install
+MANDIR=$(DESTDIR)/usr/share/man
+DOCDIR=$(DESTDIR)/usr/share/doc/bup
+BINDIR=$(DESTDIR)/usr/bin
+LIBDIR=$(DESTDIR)/usr/lib/bup
+install: all
+       $(INSTALL) -d $(MANDIR)/man1 $(DOCDIR) $(BINDIR) \
+               $(LIBDIR)/bup $(LIBDIR)/cmd
+       $(INSTALL) -o 0 -g 0 -m 0644 \
+               $(wildcard Documentation/*.1) \
+               $(MANDIR)/man1
+       $(INSTALL) -o 0 -g 0 -m 0644 \
+               $(wildcard Documentation/*.html) \
+               $(DOCDIR)
+       $(INSTALL) -o 0 -g 0 -m 0755 bup $(BINDIR)
+       $(INSTALL) -o 0 -g 0 -m 0755 \
+               $(wildcard cmd/bup-*) \
+               $(LIBDIR)/cmd
+       $(INSTALL) -o 0 -g 0 -m 0644 \
+               $(wildcard lib/bup/*.so lib/bup/*.py) \
+               $(LIBDIR)/bup
        
 %/all:
        $(MAKE) -C $* all
diff --git a/main.py b/main.py
index 77ec76b80bd2ac18826266db89c36cc432274c39..0ac7abc64857133117028602184e6fa17f4ea8f6 100755 (executable)
--- a/main.py
+++ b/main.py
@@ -5,10 +5,18 @@ import sys, os, subprocess, signal, getopt
 argv = sys.argv
 exe = argv[0]
 exepath = os.path.split(exe)[0] or '.'
+exeprefix = os.path.split(os.path.abspath(exepath))[0]
 
 # fix the PYTHONPATH to include our lib dir
-libpath = os.path.join(exepath, 'lib')
-cmdpath = os.path.join(exepath, 'cmd')
+if os.path.exists("%s/lib/bup/cmd/." % exeprefix):
+    # installed binary in /.../bin.
+    # eg. /usr/bin/bup means /usr/lib/bup/... is where our libraries are.
+    cmdpath = "%s/lib/bup/cmd" % exeprefix
+    libpath = "%s/lib/bup" % exeprefix
+else:
+    # running from the src directory without being installed first
+    cmdpath = os.path.join(exepath, 'cmd')
+    libpath = os.path.join(exepath, 'lib')
 sys.path[:0] = [libpath]
 os.environ['PYTHONPATH'] = libpath + ':' + os.environ.get('PYTHONPATH', '')
 os.environ['BUP_MAIN_EXE'] = os.path.abspath(exe)