]> arthur.barton.de Git - bup.git/commitdiff
Merge branch 'master' into meta
authorAvery Pennarun <apenwarr@gmail.com>
Mon, 30 May 2011 00:50:25 +0000 (20:50 -0400)
committerAvery Pennarun <apenwarr@gmail.com>
Mon, 30 May 2011 00:50:25 +0000 (20:50 -0400)
* master: (27 commits)
  t/test.sh: 'ls' on NetBSD sets -A by default as root; work around it.
  README: add a list of binary packages
  README: rework the title hierarchy
  Clarify the message when the BUP_DIR doesn't exist.
  Refactor: unify ls/ftp-ls code
  ftp/ls: Adjust documentation
  ls: include hidden files when explicitly requested
  ftp: implement ls -s (show hashes)
  ftp/ls: columnate output attached to a tty, else don't
  ftp: don't output trailing line for 'ls'
  ftp: output a newline on EOF when on a tty
  config: more config stuff to config/ subdir, call it from Makefile.
  cmd/{split,save}: support any compression level using the new -# feature.
  options.py: add support for '-#' style compression options.
  Add documentation for compression levels
  Add test case for compression level
  Add compression level options to bup save and bup split
  Make zlib compression level a parameter for Client
  Make zlib compression level a parameter of git.PackWriter
  Use is_superuser() rather than checking euid directly
  ...

Conflicts:
lib/bup/metadata.py

29 files changed:
Documentation/bup-ftp.md
Documentation/bup-ls.md
Documentation/bup-save.md
Documentation/bup-split.md
Makefile
README.md
cmd/ftp-cmd.py
cmd/ls-cmd.py
cmd/save-cmd.py
cmd/split-cmd.py
config/.gitignore [new file with mode: 0644]
config/Makefile [new file with mode: 0644]
config/config.vars.in [new file with mode: 0644]
config/configure [new file with mode: 0755]
config/configure.inc [new file with mode: 0644]
configure [new file with mode: 0755]
lib/bup/_helpers.c
lib/bup/client.py
lib/bup/git.py
lib/bup/helpers.py
lib/bup/ls.py [new file with mode: 0644]
lib/bup/metadata.py
lib/bup/options.py
lib/bup/t/thelpers.py
lib/bup/t/tindex.py
lib/bup/t/tmetadata.py
lib/bup/t/toptions.py
t/test-meta.sh
t/test.sh

index 817332010c406a85bb427526938dca067d0f6d32..a6117cc31c79c5352c445fac4b12c428583b3621 100644 (file)
@@ -27,10 +27,13 @@ lot of typing.
 
 The following commands are available inside `bup ftp`:
 
-ls [-a]
-:   print the contents of the current working directory. 
+ls [-s] [-a] [*path*]
+:   print the contents of a directory. If no path argument
+    is given, the current directory's contents are listed.
     If -a is given, also include hidden files (files which
-    start with a `.` character).
+    start with a `.` character). If -s is given, each file
+    is displayed with its hash from the bup archive to its
+    left.
 
 cd *dirname*
 :   change to a different working directory
index cef01be05210827d18c33ddfaf4bcd8bfb877e72..ed07ca64a1b61853e57d351950b06da4d4732312 100644 (file)
@@ -21,6 +21,13 @@ the `-n` option in `bup save`), the next level is the date
 of the backup, and subsequent levels correspond to files in
 the backup.
 
+When `bup ls` is asked to output on a tty, it formats its output
+in columns so that it can list as much as possible in as few lines
+as possible. However, when `bup ls` is asked to output to something
+other than a tty (say you pipe the output to another command, or you
+redirect it to a file), it will output one file name per line. This
+makes the listing easier to parse with external tools.
+
 Note that `bup ls` doesn't show hidden files by default and one needs to use
 the `-a` option to show them. Files are hidden when their name begins with a
 dot. For example, on the topmost level, the special directories named `.commit`
index 8ae40f17ee5451f61fdb6cec77256e665839e266..e895a2b880d94d8e4dbf97d0e503ab6019835bd8 100644 (file)
@@ -8,7 +8,7 @@ bup-save - create a new bup backup set
 
 # SYNOPSIS
 
-bup save [-r *host*:*path*] <-t|-c|-n *name*> [-f *indexfile*]
+bup save [-r *host*:*path*] <-t|-c|-n *name*> [-#] [-f *indexfile*]
 [-v] [-q] [--smaller=*maxsize*] <paths...>
 
 # DESCRIPTION
@@ -100,6 +100,12 @@ for `bup-index`(1).
     "bup save -n chroots --graft /root/chroot/a/etc=/chroots/a"
     would be saved as */chroots/a/etc*
 
+-*#*, --compress=*#*
+:   set the compression level to # (a value from 0-9, where
+    9 is the highest and 0 is no compression).  The default
+    is 1 (fast, loose compression)
+
+
 # EXAMPLE
 
     $ bup index -ux /etc
index c0c7406e08e77795826f9e28a473620cfbf86b7b..eba57ea0cf3dad3518c0316d58e6b85cc37f2368 100644 (file)
@@ -9,7 +9,7 @@ bup-split - save individual files to bup backup sets
 # SYNOPSIS
 
 bup split [-r *host*:*path*] <-b|-t|-c|-n *name*> [-v] [-q]
-  [--bench] [--max-pack-size=*bytes*]
+  [--bench] [--max-pack-size=*bytes*] [-#]
   [--max-pack-objects=*n*] [--fanout=*count]
   [--git-ids] [--keep-boundaries] [filenames...]
 
@@ -133,6 +133,11 @@ To get the data back, use `bup-join`(1).
     like k, M, or G to specify multiples of 1024,
     1024*1024, 1024*1024*1024 respectively.
 
+-*#*, --compress=*#*
+:   set the compression level to # (a value from 0-9, where
+    9 is the highest and 0 is no compression).  The default
+    is 1 (fast, loose compression)
+
 
 # EXAMPLE
     
index 2069099e91d7253f7f5c17bae5f87071f1fe0a64..e369f1de5e89ed4653df05193a1dc6233f68e437 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -16,10 +16,11 @@ Documentation/all: bup
 
 INSTALL=install
 PYTHON=python
-MANDIR=$(DESTDIR)/usr/share/man
-DOCDIR=$(DESTDIR)/usr/share/doc/bup
-BINDIR=$(DESTDIR)/usr/bin
-LIBDIR=$(DESTDIR)/usr/lib/bup
+PREFIX=/usr
+MANDIR=$(DESTDIR)$(PREFIX)/share/man
+DOCDIR=$(DESTDIR)$(PREFIX)/share/doc/bup
+BINDIR=$(DESTDIR)$(PREFIX)/bin
+LIBDIR=$(DESTDIR)$(PREFIX)/lib/bup
 install: all
        $(INSTALL) -d $(MANDIR)/man1 $(DOCDIR) $(BINDIR) \
                $(LIBDIR)/bup $(LIBDIR)/cmd $(LIBDIR)/tornado \
@@ -56,11 +57,17 @@ install: all
 
 %/clean:
        $(MAKE) -C $* clean
+       
+config/config.h: config/Makefile config/configure config/configure.inc \
+               $(wildcard config/*.in)
+       cd config && make config.h
 
 lib/bup/_helpers$(SOEXT): \
+               config/config.h \
                lib/bup/bupsplit.c lib/bup/_helpers.c lib/bup/csetup.py
        @rm -f $@
-       cd lib/bup && LDFLAGS="$(LDFLAGS)" CFLAGS="$(CFLAGS)" $(PYTHON) csetup.py build
+       cd lib/bup && \
+       LDFLAGS="$(LDFLAGS)" CFLAGS="$(CFLAGS)" $(PYTHON) csetup.py build
        cp lib/bup/build/*/_helpers$(SOEXT) lib/bup/
 
 .PHONY: lib/bup/_version.py
index 94d5c566edf1dc6b1b2a1f7a6bc8f0b71c6bbbaf..acc5e533cab901abbc127e417932b3b2f97ff115 100644 (file)
--- a/README.md
+++ b/README.md
@@ -81,7 +81,11 @@ Reasons you might want to avoid bup
    
    
 Getting started
----------------
+===============
+
+
+From source
+-----------
 
  - Check out the bup source code using git:
  
@@ -108,7 +112,23 @@ Getting started
        
     (The tests should pass.  If they don't pass for you, stop here and send
     me an email.)
-   
+
+
+From binary packages
+--------------------
+
+Binary packages of bup are known to be built for the following OSes:
+
+ - Debian:
+    http://packages.debian.org/search?searchon=names&keywords=bup
+ - Ubuntu:
+    http://packages.ubuntu.com/search?searchon=names&keywords=bup
+ - NetBSD
+
+
+Using bup
+---------
+
  - Try making a local backup as a tar file:
  
         tar -cvf - /etc | bup split -n local-etc -vv
@@ -171,7 +191,7 @@ That's all there is to it!
 
 
 Notes on FreeBSD
-================
+----------------
 
 - FreeBSD's default 'make' command doesn't like bup's Makefile. In order to
   compile the code, run tests and install bup, you need to install GNU Make
@@ -192,7 +212,7 @@ Notes on FreeBSD
 
 
 How it works
-------------
+============
 
 Basic storage:
 
@@ -326,7 +346,7 @@ join, index, save, etc.) to get details on that command.
 
 
 How you can help
-----------------
+================
 
 bup is a work in progress and there are many ways it can still be improved.
 If you'd like to contribute patches, ideas, or bug reports, please join the
index d63a7106f55a8a8b75ecdcda869c27e0e9eef91b..62f2cbc89af27d097c804265e9366338f85a5963 100755 (executable)
@@ -1,51 +1,22 @@
 #!/usr/bin/env python
 import sys, os, stat, fnmatch
-from bup import options, git, shquote, vfs
+from bup import options, git, shquote, vfs, ls
 from bup.helpers import *
 
 handle_ctrl_c()
 
 
-def node_name(text, n):
-    if stat.S_ISDIR(n.mode):
-        return '%s/' % text
-    elif stat.S_ISLNK(n.mode):
-        return '%s@' % text
-    else:
-        return '%s' % text
-
-
 class OptionError(Exception):
     pass
 
 
-ls_optspec = """
-ls [-a] [path...]
---
-a,all   include hidden files in the listing
-"""
-ls_opt = options.Options(ls_optspec, onabort=OptionError)
-
+# Check out lib/bup/ls.py for the opt spec
 def do_ls(cmd_args):
     try:
-        (opt, flags, extra) = ls_opt.parse(cmd_args)
+        ls.do_ls(cmd_args, pwd, onabort=OptionError)
     except OptionError, e:
         return
 
-    L = []
-
-    for path in (extra or ['.']):
-        n = pwd.try_resolve(path)
-
-        if stat.S_ISDIR(n.mode):
-            for sub in n:
-                name = sub.name
-                if opt.all or not len(name)>1 or not name.startswith('.'):
-                    L.append(node_name(name, sub))
-        else:
-            L.append(node_name(path, n))
-        print columnate(L, '')
-
 
 def write_to_file(inf, outf):
     for blob in chunkyreader(inf):
@@ -58,6 +29,7 @@ def inputiter():
             try:
                 yield raw_input('bup> ')
             except EOFError:
+                print ''  # Clear the line for the terminal's next prompt
                 break
     else:
         for line in sys.stdin:
index 3854a500e27a5dd772200a0a580966a261695e6b..581d6e116891387659dec7ee1d04fd6098bd37d0 100755 (executable)
@@ -1,48 +1,13 @@
 #!/usr/bin/env python
-import sys, stat
-from bup import options, git, vfs
+import sys
+from bup import git, vfs, ls
 from bup.helpers import *
 
-def print_node(text, n):
-    prefix = ''
-    if opt.hash:
-        prefix += "%s " % n.hash.encode('hex')
-    if stat.S_ISDIR(n.mode):
-        print '%s%s/' % (prefix, text)
-    elif stat.S_ISLNK(n.mode):
-        print '%s%s@' % (prefix, text)
-    else:
-        print '%s%s' % (prefix, text)
-
-
-optspec = """
-bup ls <dirs...>
---
-s,hash   show hash for each file
-a,all    show hidden files
-"""
-o = options.Options(optspec)
-(opt, flags, extra) = o.parse(sys.argv[1:])
 
 git.check_repo_or_die()
 top = vfs.RefList(None)
 
-if not extra:
-    extra = ['/']
-
-ret = 0
-for d in extra:
-    try:
-        n = top.lresolve(d)
-        if stat.S_ISDIR(n.mode):
-            for sub in n:
-                if opt.all or not sub.name.startswith('.'):
-                    print_node(sub.name, sub)
-        else:
-            if opt.all or not n.name.startswith('.'):
-                print_node(d, n)
-    except vfs.NodeError, e:
-        log('error: %s\n' % e)
-        ret = 1
+# Check out lib/bup/ls.py for the opt spec
+ret = ls.do_ls(sys.argv[1:], top, default='/', spec_prefix='bup ')
 
 sys.exit(ret)
index b00635a29691f62812dc5ccc08b603c634712454..fb45427aa69be87ed54a43c6f5f1cd0c93559b7e 100755 (executable)
@@ -21,6 +21,7 @@ f,indexfile=  the name of the index file (normally BUP_DIR/bupindex)
 strip      strips the path to every filename given
 strip-path= path-prefix to be stripped when saving
 graft=     a graft point *old_path*=*new_path* (can be used more than once)
+#,compress=  set compression level to # (0-9, 9 is highest) [1]
 """
 o = options.Options(optspec)
 (opt, flags, extra) = o.parse(sys.argv[1:])
@@ -74,7 +75,7 @@ if opt.remote or is_reverse:
 else:
     cli = None
     oldref = refname and git.read_ref(refname) or None
-    w = git.PackWriter()
+    w = git.PackWriter(compression_level=opt.compress)
 
 handle_ctrl_c()
 
index b243c61400e918fdae1b19a907177c38a61ea2a1..438fe40aaa73599938742d14fb77d77d1d522406 100755 (executable)
@@ -26,6 +26,7 @@ max-pack-size=  maximum bytes in a single pack
 max-pack-objects=  maximum number of objects in a single pack
 fanout=    maximum number of blobs in a single tree
 bwlimit=   maximum bytes/sec to transmit to server
+#,compress=  set compression level to # (0-9, 9 is highest) [1]
 """
 o = options.Options(optspec)
 (opt, flags, extra) = o.parse(sys.argv[1:])
@@ -61,7 +62,6 @@ if opt.date:
 else:
     date = time.time()
 
-
 total_bytes = 0
 def prog(filenum, nbytes):
     global total_bytes
@@ -84,13 +84,13 @@ refname = opt.name and 'refs/heads/%s' % opt.name or None
 if opt.noop or opt.copy:
     cli = pack_writer = oldref = None
 elif opt.remote or is_reverse:
-    cli = client.Client(opt.remote)
+    cli = client.Client(opt.remote, compression_level=opt.compress)
     oldref = refname and cli.read_ref(refname) or None
     pack_writer = cli.new_packwriter()
 else:
     cli = None
     oldref = refname and git.read_ref(refname) or None
-    pack_writer = git.PackWriter()
+    pack_writer = git.PackWriter(compression_level=opt.compress)
 
 if opt.git_ids:
     # the input is actually a series of git object ids that we should retrieve
diff --git a/config/.gitignore b/config/.gitignore
new file mode 100644 (file)
index 0000000..6f65774
--- /dev/null
@@ -0,0 +1,7 @@
+config.cmd
+config.h
+config.log
+config.mak
+config.md
+config.sub
+config.vars
\ No newline at end of file
diff --git a/config/Makefile b/config/Makefile
new file mode 100644 (file)
index 0000000..451e49d
--- /dev/null
@@ -0,0 +1,8 @@
+-include config.vars
+
+config.h: configure configure.inc $(wildcard *.in)
+       ./configure
+
+clean:
+       rm -f ${CONFIGURE_FILES} ${GENERATED_FILES}
+       rm -f *~ .*~
diff --git a/config/config.vars.in b/config/config.vars.in
new file mode 100644 (file)
index 0000000..7bc32ee
--- /dev/null
@@ -0,0 +1,2 @@
+CONFIGURE_FILES=@CONFIGURE_FILES@
+GENERATED_FILES=@GENERATED_FILES@
diff --git a/config/configure b/config/configure
new file mode 100755 (executable)
index 0000000..19cac07
--- /dev/null
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+TARGET=bup
+
+. ./configure.inc
+
+AC_INIT $TARGET
+
+if ! AC_PROG_CC; then
+    LOG " You need to have a functional C compiler to build $TARGET"
+    exit 1
+fi
+
+TLOGN "checking the GNU make"
+MAKE=`acLookFor make`
+if [ -z "$MAKE" ]; then
+    AC_FAIL " Cannot find make";
+fi
+
+MAKE_GNU=`$MAKE --version | grep "GNU Make"`
+if [ -z "$MAKE_GNU" ]; then
+    AC_FAIL " $MAKE is not GNU Make"
+fi
+
+MAKE_VERSION=`$MAKE --version | grep "GNU Make" | awk '{print $3}'`
+if [ -z "$MAKE_VERSION" ]; then
+    AC_FAIL " $MAKE --version does not return sensible output?"
+fi
+expr "$MAKE_VERSION" '>=' '3.81' || AC_FAIL "$MAKE must be >= version 3.81"
+TLOG " ok"
+
+TLOGN "checking the python"
+PYTHON=`acLookFor python`
+if [ -z "$PYTHON" ]; then
+    AC_FAIL " Cannot find python";
+fi
+TLOG " - you have some python program - ok"
+
+TLOGN "checking the git"
+GIT=`acLookFor git`
+if [ -z "$GIT" ]; then
+    AC_FAIL " Cannot find git";
+fi
+TLOG " - you have some git program - ok"
+
+
+# assuming the above checks pass, get the path of everything
+MF_PATH_INCLUDE        GMAKE make gmake
+MF_PATH_INCLUDE GIT git
+MF_PATH_INCLUDE TAR tar gtar
+MF_PATH_INCLUDE PYTHON python
+
+AC_CHECK_HEADERS sys/stat.h 
+AC_CHECK_FUNCS utimensat 
+AC_CHECK_FUNCS utime
+
+AC_OUTPUT config.vars
diff --git a/config/configure.inc b/config/configure.inc
new file mode 100644 (file)
index 0000000..a698422
--- /dev/null
@@ -0,0 +1,1305 @@
+#   @(#) configure.inc 1.40@(#)
+#   Copyright (c) 1999-2007 David Parsons. All rights reserved.
+#   
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#  1. Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#  3. My name may not be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#     
+#  THIS SOFTWARE IS PROVIDED BY DAVID PARSONS ``AS IS'' AND ANY
+#  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+#  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+#  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
+#  PARSONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+#  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+#  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+#  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+#  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+#  IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+#  THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+
+#
+# this preamble code is executed when this file is sourced and it picks
+# interesting things off the command line.
+#
+ac_default_path="/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin"
+
+ac_standard="--src=DIR         where the source lives (.)
+--prefix=DIR           where to install the final product (/usr/local)
+--execdir=DIR          where to put executables (prefix/bin)
+--sbindir=DIR          where to put static executables (prefix/sbin)
+--confdir=DIR          where to put configuration information (/etc)
+--libdir=DIR           where to put libraries (prefix/lib)
+--libexecdir=DIR       where to put private executables
+--mandir=DIR           where to put manpages"
+
+__fail=exit
+
+if dirname B/A 2>/dev/null >/dev/null; then
+__ac_dirname() {
+    dirname "$1"
+}
+else
+__ac_dirname() {
+    echo "$1" | sed -e 's:/[^/]*$::'
+}
+fi
+
+ac_progname=$0
+ac_configure_command=
+Q=\'
+for x in "$@"; do
+    ac_configure_command="$ac_configure_command $Q$x$Q"
+done
+# ac_configure_command="$*"
+
+__d=`__ac_dirname "$ac_progname"`
+if [ "$__d" = "$ac_progname" ]; then
+    AC_SRCDIR=`pwd`
+else
+    AC_SRCDIR=`cd $__d;pwd`
+fi
+
+__ac_dir() {
+    if test -d "$1"; then
+       (cd "$1";pwd)
+    else
+       echo "$1";
+    fi
+}
+
+while [ $# -gt 0 ]; do
+    unset matched
+
+    case X"$1" in
+    X--src|X--srcdir)
+       AC_SRCDIR=`__ac_dir "$2"`
+       _set_srcdir=1
+       shift 2;;
+
+    X--src=*|X--srcdir=*)
+       __d=`echo "$1" | sed -e 's/^[^=]*=//'`
+       AC_SRCDIR=`__ac_dir "$__d"`
+       _set_srcdir=1
+       shift 1 ;;
+
+    X--prefix)
+       AC_PREFIX=`__ac_dir "$2"`
+       _set_prefix=1
+       shift 2;;
+
+    X--prefix=*)
+       __d=`echo "$1"| sed -e 's/^[^=]*=//'`
+       AC_PREFIX=`__ac_dir "$__d"`
+       _set_prefix=1
+       shift 1;;
+
+    X--confdir)
+       AC_CONFDIR=`__ac_dir "$2"`
+       _set_confdir=1
+       shift 2;;
+
+    X--confdir=*)
+       __d=`echo "$1" | sed -e 's/^[^=]*=//'`
+       AC_CONFDIR=`__ac_dir "$__d"`
+       _set_confdir=1
+       shift 1;;
+
+    X--libexec|X--libexecdir)
+       AC_LIBEXEC=`__ac_dir "$2"`
+       _set_libexec=1
+       shift 2;;
+
+    X--libexec=*|X--libexecdir=*)
+       __d=`echo "$1" | sed -e 's/^[^=]*=//'`
+       AC_LIBEXEC=`__ac_dir "$__d"`
+       _set_libexec=1
+       shift 1;;
+
+    X--lib|X--libdir)
+       AC_LIBDIR=`__ac_dir "$2"`
+       _set_libdir=1
+       shift 2;;
+
+    X--lib=*|X--libdir=*)
+       __d=`echo "$1" | sed -e 's/^[^=]*=//'`
+       AC_LIBDIR=`__ac_dir "$__d"`
+       _set_libdir=1
+       shift 1;;
+
+    X--exec|X--execdir)
+       AC_EXECDIR=`__ac_dir "$2"`
+       _set_execdir=1
+       shift 2;;
+
+    X--exec=*|X--execdir=*)
+       __d=`echo "$1" | sed -e 's/^[^=]*=//'`
+       AC_EXECDIR=`__ac_dir "$__d"`
+       _set_execdir=1
+       shift 1;;
+
+    X--sbin|X--sbindir)
+       AC_SBINDIR=`__ac_dir "$2"`
+       _set_sbindir=1
+       shift 2;;
+
+    X--sbin=*|X--sbindir=*)
+       __d=`echo "$1" | sed -e 's/^[^=]*=//'`
+       AC_SBINDIR=`__ac_dir "$__d"`
+       _set_sbindir=1
+       shift 1;;
+
+    X--man|X--mandir)
+       AC_MANDIR=`__ac_dir "$2"`
+       _set_mandir=1
+       shift 2;;
+
+    X--man=*|X--mandir=*)
+       __d=`echo "$1" | sed -e 's/^[^=]*=//'`
+       AC_MANDIR=`__ac_dir "$__d"`
+       _set_mandir=1
+       shift 1;;
+
+    X--use-*=*)
+       _var=`echo "$1"| sed -n 's/^--use-\([A-Za-z][-A-Za-z0-9_]*\)=.*$/\1/p'`
+       if [ "$_var" ]; then
+           _val=`echo "$1" | sed -e 's/^--use-[^=]*=\(.*\)$/\1/'`
+           _v=`echo $_var | tr '[a-z]' '[A-Z]' | tr '-' '_'`
+           case X"$_val" in
+           X[Yy][Ee][Ss]|X[Tt][Rr][Uu][Ee]) eval USE_${_v}=T ;;
+           X[Nn][Oo]|X[Ff][Aa][Ll][Ss][Ee]) eval unset USE_${_v} ;;
+           *) echo "Bad value for --use-$_var ; must be yes or no"
+              exit 1 ;;
+           esac
+       else
+           echo "Bad option $1.   Use --help to show options" 1>&2
+           exit 1
+       fi
+       shift 1 ;;
+
+    X--use-*)
+        _var=`echo "$1"|sed -n 's/^--use-\([A-Za-z][-A-Za-z0-9_]*\)$/\1/p'`
+       _v=`echo $_var | tr '[a-z]' '[A-Z]' | tr '-' '_'`
+       eval USE_${_v}=T
+       shift 1;;
+
+    X--with-*=*)
+       _var=`echo "$1"| sed -n 's/^--with-\([A-Za-z][-A-Za-z0-9_]*\)=.*$/\1/p'`
+       if [ "$_var" ]; then
+           _val=`echo "$1" | sed -e 's/^--with-[^=]*=\(.*\)$/\1/'`
+           _v=`echo $_var | tr '[a-z]' '[A-Z]' | tr '-' '_'`
+           eval WITH_${_v}=\"$_val\"
+       else
+           echo "Bad option $1.   Use --help to show options" 1>&2
+           exit 1
+       fi
+       shift 1 ;;
+
+    X--with-*)
+       _var=`echo "$1" | sed -n 's/^--with-\([A-Za-z][A-Za-z0-9_-]*\)$/\1/p'`
+       if [ "$_var" ]; then
+           _v=`echo $_var | tr '[a-z]' '[A-Z]' | tr '-' '_'`
+           eval WITH_${_v}=1
+       else
+           echo "Bad option $1.   Use --help to show options" 1>&2
+           exit 1
+       fi
+       shift 1 ;;
+
+    X--help)
+       echo "$ac_standard"
+       test "$ac_help" && echo "$ac_help"
+       exit 0;;
+
+    *) if [ "$LOCAL_AC_OPTIONS" ]; then
+           eval "$LOCAL_AC_OPTIONS"
+       else
+           ac_error=T
+       fi
+       if [ "$ac_error" ]; then
+           echo "Bad option $1.   Use --help to show options" 1>&2
+           exit 1
+       fi ;;
+    esac
+done
+
+
+#
+# echo w/o newline
+#
+echononl()
+{
+    ${ac_echo:-echo} "${@}$ac_echo_nonl"
+}
+
+#
+# log something to the terminal and to a logfile.
+#
+LOG () {
+    echo "$@"
+    echo "$@" 1>&5
+}
+
+#
+# log something to the terminal without a newline, and to a logfile with
+# a newline
+#
+LOGN () {
+    echononl "$@" 1>&5
+    echo "$@"
+}
+
+#
+# log something to the terminal
+#
+TLOG () {
+    echo "$@" 1>&5
+}
+
+#
+# log something to the terminal, no newline
+#
+TLOGN () {
+    echononl "$@" 1>&5
+}
+
+
+#
+# AC_CONTINUE tells configure not to bomb if something fails, but to
+# continue blithely along
+#
+AC_CONTINUE () {
+    __fail="return"
+}
+
+#
+# Emulate gnu autoconf's AC_CHECK_HEADERS() function
+#
+AC_CHECK_HEADERS () {
+    AC_PROG_CC
+
+    echo "/* AC_CHECK_HEADERS */" > /tmp/ngc$$.c
+    for hdr in $*; do
+       echo "#include <$hdr>" >> /tmp/ngc$$.c
+    done
+    echo "main() { }" >> /tmp/ngc$$.c
+
+    LOGN "checking for header $hdr"
+
+    if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c; then
+       AC_DEFINE 'HAVE_'`echo $hdr | tr 'a-z' 'A-Z' | tr './' '_'` 1
+       TLOG " (found)"
+       rc=0
+    else
+       TLOG " (not found)"
+       rc=1
+    fi
+    rm -f /tmp/ngc$$.c /tmp/ngc$$
+    return $rc
+}
+
+
+#
+# emulate GNU autoconf's AC_CHECK_FUNCS function
+#
+AC_CHECK_FUNCS () {
+    AC_PROG_CC
+
+F=$1
+shift
+rm -f /tmp/ngc$$.c
+
+while [ "$1" ]; do
+    echo "#include <$1>" >> /tmp/ngc$$.c
+    shift
+done
+
+    cat >> /tmp/ngc$$.c << EOF
+main()
+{
+
+    $F();
+}
+EOF
+
+    LOGN "checking for the $F function"
+
+    if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $LIBS; then
+       AC_DEFINE `echo ${2:-HAVE_$F} | tr 'a-z' 'A-Z'` 1
+       TLOG " (found)"
+       rc=0
+    else
+       echo "offending command was:"
+       cat /tmp/ngc$$.c
+       echo "$AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $LIBS"
+       TLOG " (not found)"
+       rc=1
+    fi
+    rm -f /tmp/ngc$$.c /tmp/ngc$$
+    return $rc
+}
+
+
+#
+# check to see if some structure exists
+#
+# usage: AC_CHECK_STRUCT structure {include ...}
+#
+AC_CHECK_STRUCT () {
+    AC_PROG_CC
+    struct=$1
+    shift
+
+    rm -f /tmp/ngc$$.c
+
+    for include in $*; do
+       echo "#include <$include>" >> /tmp/ngc$$.c
+    done
+
+    cat >> /tmp/ngc$$.c << EOF
+main()
+{
+    struct $struct foo;
+}
+EOF
+
+    LOGN "checking for struct $struct"
+
+    if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $AC_LIBS 2>>config.log; then
+       AC_DEFINE HAVE_STRUCT_`echo ${struct} | tr 'a-z' 'A-Z'`
+       TLOG " (found)"
+       rc=0
+    else
+       TLOG " (not found)"
+       rc=1
+    fi
+    rm -f /tmp/ngc$$.c /tmp/ngc$$
+    return $rc
+}
+
+
+#
+# check to see if some structure contains a field
+#
+# usage: AC_CHECK_FIELD structure field {include ...}
+#
+AC_CHECK_FIELD () {
+    AC_PROG_CC
+
+    struct=$1
+    field=$2
+    shift 2
+
+    rm -f /tmp/ngc$$.c
+
+    for include in $*;do
+       echo "#include <$include>" >> /tmp/ngc$$.c
+    done
+
+    cat >> /tmp/ngc$$.c << EOF
+main()
+{
+    struct $struct foo;
+
+    foo.$field;
+}
+EOF
+
+    LOGN "checking that struct $struct has a $field field"
+
+    if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $AC_LIBS 2>>config.log; then
+       AC_DEFINE HAVE_`echo ${struct}_$field | tr 'a-z' 'A-Z'`
+       TLOG " (yes)"
+       rc=0
+    else
+       TLOG " (no)"
+       rc=1
+    fi
+    rm -f /tmp/ngc$$.c /tmp/ngc$$
+    return $rc
+}
+
+
+#
+# check that the C compiler works
+#
+AC_PROG_CC () {
+    test "$AC_CC" && return 0
+
+    cat > /tmp/ngc$$.c << \EOF
+#include <stdio.h>
+main()
+{
+    puts("hello, sailor");
+}
+EOF
+
+    TLOGN "checking the C compiler"
+
+    unset AC_CFLAGS AC_LDFLAGS
+
+    if [ "$CC" ] ; then
+       AC_CC="$CC"
+    elif [ "$WITH_PATH" ]; then
+       AC_CC=`acLookFor cc`
+    elif [ "`acLookFor cc`" ]; then
+       # don't specify the full path if the user is looking in their $PATH
+       # for a C compiler.
+       AC_CC=cc
+    fi
+
+    # finally check for POSIX c89
+    test "$AC_CC" || AC_CC=`acLookFor c89`
+
+    if [ ! "$AC_CC" ]; then
+       TLOG " (no C compiler found)"
+       $__fail 1
+    fi
+    echo "checking out the C compiler"
+
+    $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c
+    status=$?
+
+    TLOGN " ($AC_CC)"
+    if [ $status -eq 0 ]; then
+       TLOG " ok"
+
+       # check that the CFLAGS and LDFLAGS aren't bogus
+
+       unset AC_CFLAGS AC_LDFLAGS
+
+       if [ "$CFLAGS" ]; then
+           test "$CFLAGS" && echo "validating CFLAGS=${CFLAGS}"
+           if $AC_CC $CFLAGS -o /tmp/ngc$$.o /tmp/ngc$$.c ; then
+               AC_CFLAGS=${CFLAGS:-"-g"}
+               test "$CFLAGS" && echo "CFLAGS=\"${CFLAGS}\" are okay"
+           elif [ "$CFLAGS" ]; then
+               echo "ignoring bogus CFLAGS=\"${CFLAGS}\""
+           fi
+       else
+           AC_CFLAGS=-g
+       fi
+       if [ "$LDFLAGS" ]; then
+           test "$LDFLAGS" && echo "validating LDFLAGS=${LDFLAGS}"
+           if $AC_CC $LDFLAGS -o /tmp/ngc$$ /tmp/ngc$$.o; then
+               AC_LDFLAGS=${LDFLAGS:-"-g"}
+               test "$LDFLAGS" && TLOG "LDFLAGS=\"${LDFLAGS}\" are okay"
+           elif [ "$LDFLAGS" ]; then
+               TLOG "ignoring bogus LDFLAGS=\"${LDFLAGS}\""
+           fi
+       else
+           AC_LDFLAGS=${CFLAGS:-"-g"}
+       fi
+    else
+       AC_FAIL " does not compile code properly"
+    fi
+
+    AC_SUB 'CC' "$AC_CC"
+
+    rm -f /tmp/ngc$$ /tmp/ngc$$.c /tmp/ngc$$.o
+
+    return $status
+}
+
+
+#
+# acLookFor actually looks for a program, without setting anything.
+#
+acLookFor () {
+    path=${AC_PATH:-$ac_default_path}
+    case "X$1" in
+    X-[rx]) __mode=$1
+           shift
+           ;;
+    *)     __mode=-x
+           ;;
+    esac
+    oldifs="$IFS"
+    for program in $*; do
+       IFS=":"
+       for x in $path; do
+           if [ $__mode $x/$program -a -f $x/$program ]; then
+               echo $x/$program
+               break 2
+           fi
+       done
+    done
+    IFS="$oldifs"
+    unset __mode
+}
+
+
+#
+# check that a program exists and set its path
+#
+MF_PATH_INCLUDE () {
+    SYM=$1; shift
+
+    case X$1 in
+    X-[rx]) __mode=$1
+           shift
+           ;;
+    *)      unset __mode
+           ;;
+    esac
+
+    TLOGN "looking for $1"
+
+    DEST=`acLookFor $__mode $*`
+
+    __sym=`echo "$SYM" | tr '[a-z]' '[A-Z]'`
+    if [ "$DEST" ]; then
+       TLOG " ($DEST)"
+       echo "$1 is $DEST"
+       AC_MAK $SYM
+       AC_DEFINE PATH_$__sym \""$DEST"\"
+       AC_SUB $__sym "$DEST"
+       eval CF_$SYM=$DEST
+       return 0
+    else
+       #AC_SUB $__sym ''
+       echo "$1 is not found"
+       TLOG " (not found)"
+       return 1
+    fi
+}
+
+
+#
+# AC_INIT starts the ball rolling
+#
+# After AC_INIT, fd's 1 and 2 point to config.log
+# and fd 5 points to what used to be fd 1
+#
+AC_INIT () {
+    __config_files="config.cmd config.sub config.h config.mak config.log"
+    rm -f $__config_files
+    __cwd=`pwd`
+    exec 5>&1 1>$__cwd/config.log 2>&1
+    AC_CONFIGURE_FOR=__AC_`echo $1 | sed -e 's/\..$//' | tr 'a-z' 'A-Z' | tr ' ' '_'`_D
+
+    # check to see whether to use echo -n or echo ...\c
+    #
+    echo -n hello > $$
+    echo world >> $$
+    if grep "helloworld" $$ >/dev/null; then
+       ac_echo="echo -n"
+       echo "[echo -n] works"
+    else
+       ac_echo="echo"
+       echo 'hello\c' > $$
+       echo 'world' >> $$
+       if grep "helloworld" $$ >/dev/null; then
+           ac_echo_nonl='\c'
+           echo "[echo ...\\c] works"
+       fi
+    fi
+    rm -f $$
+
+    LOG "Configuring for [$1]"
+
+    cat > $__cwd/config.h << EOF
+/*
+ * configuration for $1${2:+" ($2)"}, generated `date`
+ * by ${LOGNAME:-`whoami`}@`hostname`
+ */
+#ifndef $AC_CONFIGURE_FOR
+#define $AC_CONFIGURE_FOR 1
+
+
+EOF
+
+    unset __share
+    if [ -d $AC_PREFIX/share/man ]; then
+       for t in 1 2 3 4 5 6 7 8 9; do
+           if [ -d $AC_PREFIX/share/man/man$t ]; then
+               __share=/share
+           elif [ -d $AC_PREFIX/share/man/cat$t ]; then
+               __share=/share
+           fi
+       done
+    else
+       __share=
+    fi
+
+    if [ -d $AC_PREFIX/libexec ]; then
+       __libexec=libexec
+    else
+       __libexec=lib
+    fi
+
+
+    AC_PREFIX=${AC_PREFIX:-/usr/local}
+    AC_EXECDIR=${AC_EXECDIR:-$AC_PREFIX/bin}
+    AC_SBINDIR=${AC_SBINDIR:-$AC_PREFIX/sbin}
+    AC_LIBDIR=${AC_LIBDIR:-$AC_PREFIX/lib}
+    AC_MANDIR=${AC_MANDIR:-$AC_PREFIX$__share/man}
+    AC_LIBEXEC=${AC_LIBEXEC:-$AC_PREFIX/$__libexec}
+    AC_CONFDIR=${AC_CONFDIR:-/etc}
+
+    AC_PATH=${WITH_PATH:-$PATH}
+    AC_PROG_CPP
+    AC_PROG_INSTALL
+
+    ac_os=`uname -s`
+    _os=`echo $ac_os | tr '[a-z]' '[A-Z]'`
+    AC_DEFINE OS_$_os  1
+    eval OS_${_os}=1
+    unset _os
+}
+
+
+#
+# AC_LIBRARY checks to see if a given library exists and contains the
+# given function.
+# usage: AC_LIBRARY function library [alternate ...]
+#
+AC_LIBRARY() {
+    SRC=$1
+    shift
+
+    __acllibs=
+    __aclhdrs=
+
+    for x in "$@"; do
+       case X"$x" in
+       X-l*) __acllibs="$__acllibs $x" ;;
+       *)    __aclhdrs="$__aclhdrs $x" ;;
+       esac
+    done
+
+    # first see if the function can be found in any of the
+    # current libraries
+    AC_QUIET AC_CHECK_FUNCS $SRC $__aclhdrs && return 0
+
+    # then search through the list of libraries
+    __libs="$LIBS"
+    for x in $__acllibs; do
+       LIBS="$__libs $x"
+       if AC_QUIET AC_CHECK_FUNCS $SRC $__aclhdrs; then
+           AC_LIBS="$AC_LIBS $x"
+           return 0
+       fi
+    done
+    return 1
+}
+
+
+#
+# AC_PROG_LEX checks to see if LEX exists, and if it's lex or flex.
+#
+AC_PROG_LEX() {
+    TLOGN "looking for lex "
+
+    DEST=`acLookFor lex`
+    if [ "$DEST" ]; then
+       AC_MAK LEX
+       AC_DEFINE PATH_LEX \"$DEST\"
+       AC_SUB 'LEX' "$DEST"
+       echo "lex is $DEST"
+    else
+       DEST=`acLookFor flex`
+       if [ "$DEST" ]; then
+           AC_MAK FLEX
+           AC_DEFINE 'LEX' \"$DEST\"
+           AC_SUB 'LEX', "$DEST"
+           echo "lex is $DEST"
+       else
+           AC_SUB LEX ''
+           echo "neither lex or flex found"
+           TLOG " (not found)"
+           return 1
+       fi
+    fi
+
+    if AC_LIBRARY yywrap -ll -lfl; then
+       TLOG "($DEST)"
+       return 0
+    fi
+    TLOG "(no lex library found)"
+    return 1
+}
+
+
+#
+# AC_PROG_YACC checks to see if YACC exists, and if it's bison or
+# not.
+#
+AC_PROG_YACC () {
+
+    TLOGN "looking for yacc "
+
+    DEST=`acLookFor yacc`
+    if [ "$DEST" ]; then
+       AC_MAK YACC
+       AC_DEFINE PATH_YACC \"$DEST\"
+       AC_SUB 'YACC' "$DEST"
+       TLOG "($DEST)"
+       echo "yacc is $DEST"
+    else
+       DEST=`acLookFor bison`
+       if [ "$DEST" ]; then
+           AC_MAK BISON
+           AC_DEFINE 'YACC' \"$DEST\"
+           AC_SUB 'YACC' "$DEST -y"
+           echo "yacc is $DEST -y"
+           TLOG "($DEST -y)"
+       else
+           AC_SUB 'YACC' ''
+           echo "neither yacc or bison found"
+           TLOG " (not found)"
+           return 1
+       fi
+    fi
+    return 0
+}
+
+
+#
+# AC_PROG_LN_S checks to see if ln exists, and, if so, if ln -s works
+#
+AC_PROG_LN_S () {
+    test "$AC_FIND_PROG" || AC_PROG_FIND
+
+    test "$AC_FIND_PROG" || return 1
+    
+    TLOGN "looking for \"ln -s\""
+    DEST=`acLookFor ln`
+
+    if [ "$DEST" ]; then
+       rm -f /tmp/b$$
+       $DEST -s /tmp/a$$ /tmp/b$$
+       if [ "`$AC_FIND_PROG /tmp/b$$ -type l -print`" ]; then
+           TLOG " ($DEST)"
+           echo "$DEST exists, and ln -s works"
+           AC_SUB 'LN_S' "$DEST -s"
+           rm -f /tmp/b$$
+       else
+           AC_SUB 'LN_S' ''
+           TLOG " ($DEST exists, but -s does not seem to work)"
+           echo "$DEST exists, but ln -s doesn't seem to work"
+           rm -f /tmp/b$$
+           return 1
+       fi
+    else
+       AC_SUB 'LN_S' ''
+       echo "ln not found"
+       TLOG " (not found)"
+       return 1
+    fi
+}
+
+
+#
+# AC_PROG_FIND looks for the find program and sets the FIND environment
+# variable
+#
+AC_PROG_FIND () {
+    if test -z "$AC_FIND_PROG"; then
+       MF_PATH_INCLUDE FIND find
+       rc=$?
+       AC_FIND_PROG=$DEST
+       return $rc
+    fi
+    return 0
+}
+
+
+#
+# AC_PROG_AWK looks for the awk program and sets the AWK environment
+# variable
+#
+AC_PROG_AWK () {
+    if test -z "$AC_AWK_PROG"; then
+       MF_PATH_INCLUDE AWK awk
+       rc=$?
+       AC_AWK_PROG=$DEST
+       return $rc
+    fi
+    return 0
+}
+
+
+#
+# AC_PROG_SED looks for the sed program and sets the SED environment
+# variable
+#
+AC_PROG_SED () {
+    if test -z "$AC_SED_PROG"; then
+       MF_PATH_INCLUDE SED sed
+       rc=$?
+       AC_SED_PROG=$DEST
+       return $rc
+    fi
+    return 0
+}
+
+
+#
+# AC_HEADER_SYS_WAIT looks for sys/wait.h
+#
+AC_HEADER_SYS_WAIT () {
+    AC_CHECK_HEADERS sys/wait.h || return 1
+}
+
+#
+# AC_TYPE_PID_T checks to see if the pid_t type exists
+#
+AC_TYPE_PID_T () {
+    cat > /tmp/pd$$.c << EOF
+#include <sys/types.h>
+main() { pid_t me; }
+EOF
+
+    LOGN "checking for pid_t"
+
+    if $AC_CC -c /tmp/pd$$.c -o /tmp/pd$$.o; then
+       TLOG " (found)"
+       rc=0
+    else
+       echo "typedef int pid_t;" >> $__cwd/config.h
+       TLOG " (not found)"
+       rc=1
+    fi
+    rm -f /tmp/pd$$.o /tmp/pd$$.c
+    return $rc
+}
+
+
+#
+# AC_C_CONST checks to see if the compiler supports the const keyword
+#
+AC_C_CONST () {
+    cat > /tmp/pd$$.c << EOF
+const char me=1;
+EOF
+    LOGN "checking for \"const\" keyword"
+
+    if $AC_CC -c /tmp/pd$$.c -o /tmp/pd$$.o; then
+       TLOG " (yes)"
+       rc=0
+    else
+       AC_DEFINE 'const' '/**/'
+       TLOG " (no)"
+       rc=1
+    fi
+    rm -f /tmp/pd$$.o /tmp/pd$$.c
+    return $rc
+}
+
+
+#
+# AC_SCALAR_TYPES checks to see if the compiler can generate 2 and 4 byte ints.
+#
+AC_SCALAR_TYPES () {
+    cat > /tmp/pd$$.c << EOF
+#include <stdio.h>
+main()
+{
+    unsigned long v_long;
+    unsigned int v_int;
+    unsigned short v_short;
+
+    if (sizeof v_long == 4)
+       puts("#define DWORD     unsigned long");
+    else if (sizeof v_int == 4)
+       puts("#define DWORD     unsigned int");
+    else
+       exit(1);
+
+    if (sizeof v_int == 2)
+       puts("#define WORD      unsigned int");
+    else if (sizeof v_short == 2)
+       puts("#define WORD      unsigned short");
+    else
+       exit(2);
+    puts("#define BYTE unsigned char");
+    exit(0);
+}
+EOF
+    rc=1
+    LOGN "defining WORD & DWORD scalar types"
+    if $AC_CC /tmp/pd$$.c -o /tmp/pd$$; then
+       if /tmp/pd$$  >> $__cwd/config.h; then
+           rc=0
+       fi
+    fi
+    case "$rc" in
+    0) TLOG "" ;;
+    *) TLOG " ** FAILED **" ;;
+    esac
+    rm -f /tmp/pd$$ /tmp/pd$$.c
+}
+
+
+#
+# AC_OUTPUT generates makefiles from makefile.in's
+#
+AC_OUTPUT () {
+    cd $__cwd
+    AC_SUB 'LIBS'    "$AC_LIBS"
+    AC_SUB 'CONFIGURE_FILES' "$__config_files"
+    AC_SUB 'GENERATED_FILES' "$*"
+    AC_SUB 'CFLAGS'  "$AC_CFLAGS"
+    AC_SUB 'FCFLAGS' "$AC_FCFLAGS"
+    AC_SUB 'CXXFLAGS' "$AC_CXXFLAGS"
+    AC_SUB 'LDFLAGS' "$AC_LDFLAGS"
+    AC_SUB 'srcdir'  "$AC_SRCDIR"
+    AC_SUB 'prefix'  "$AC_PREFIX"
+    AC_SUB 'exedir'  "$AC_EXECDIR"
+    AC_SUB 'sbindir' "$AC_SBINDIR"
+    AC_SUB 'libdir'  "$AC_LIBDIR"
+    AC_SUB 'libexec' "$AC_LIBEXEC"
+    AC_SUB 'confdir' "$AC_CONFDIR"
+    AC_SUB 'mandir'  "$AC_MANDIR"
+
+    if [ -r config.sub ]; then
+       test "$AC_SED_PROG" || AC_PROG_SED
+       test "$AC_SED_PROG" || return 1
+
+       echo                                   >> config.h
+       echo "#endif/* ${AC_CONFIGURE_FOR} */" >> config.h
+
+       rm -f config.cmd
+       Q=\'
+       cat - > config.cmd << EOF
+#! /bin/sh
+${CXX:+CXX=${Q}${CXX}${Q}} ${CXXFLAGS:+CXXFLAGS=${Q}${CXXFLAGS}${Q}} ${FC:+FC=${Q}${FC}${Q}} ${FCFLAGS:+FCFLAGS=${Q}${FCFLAGS}${Q}} ${CC:+CC=${Q}${CC}${Q}} ${CFLAGS:+CFLAGS=${Q}${CFLAGS}${Q}} $ac_progname $ac_configure_command
+EOF
+       chmod +x config.cmd
+
+       __d=$AC_SRCDIR
+       for makefile in $*;do
+           if test -r $__d/${makefile}.in; then
+               LOG "generating $makefile"
+               ./config.md `__ac_dirname ./$makefile` 2>/dev/null
+               $AC_SED_PROG -f config.sub < $__d/${makefile}.in > $makefile
+               __config_files="$__config_files $makefile"
+           else
+               LOG "WARNING: ${makefile}.in does not exist!"
+           fi
+       done
+       unset __d
+
+    else
+       echo 
+    fi
+}
+
+#
+# AC_CHECK_FLOCK checks to see if flock() exists and if the LOCK_NB argument
+# works properly.
+#
+AC_CHECK_FLOCK() {
+
+    AC_CHECK_HEADERS sys/types.h sys/file.h fcntl.h
+
+    cat << EOF > $$.c
+#include <stdio.h>
+#include <sys/file.h>
+#include <sys/types.h>
+#include <fcntl.h>
+
+main()
+{
+    int x = open("$$.c", O_RDWR, 0666);
+    int y = open("$$.c", O_RDWR, 0666);
+
+    if (flock(x, LOCK_EX) != 0)
+       exit(1);
+    if (flock(y, LOCK_EX|LOCK_NB) == 0)
+       exit(1);
+    exit(0);
+}
+EOF
+
+    LOGN "checking for flock()"
+    HAS_FLOCK=0
+    if $AC_CC -o flock $$.c ; then
+       if ./flock ; then
+           LOG " (found)"
+           HAS_FLOCK=1
+           AC_DEFINE HAS_FLOCK
+       else
+           LOG " (bad)"
+       fi
+    else
+       LOG " (no)"
+    fi
+
+    rm -f flock $$.c
+
+    case "$HAS_FLOCK" in
+    0) return 1 ;;
+    *) return 0 ;;
+    esac
+}
+
+
+#
+# AC_CHECK_RESOLVER finds out whether the berkeley resolver is
+# present on this system.
+#
+AC_CHECK_RESOLVER () {
+    AC_PROG_CC
+
+    TLOGN "checking for the Berkeley resolver library"
+
+    cat > /tmp/ngc$$.c << EOF
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/nameser.h>
+#include <resolv.h>
+
+main()
+{
+    char bfr[256];
+
+    res_init();
+    res_query("hello", C_IN, T_A, bfr, sizeof bfr);
+}
+EOF
+
+    # first see if res_init() and res_query() actually exist...
+
+    if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c; then
+       __extralib=
+    elif $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c -lresolv; then
+       __extralib=-lresolv
+       AC_LIBS="$AC_LIBS -lresolv"
+    else
+       TLOG " (not found)"
+       rm -f /tmp/ngc$$.c
+       return 1
+    fi
+
+    # if res_init() and res_query() actually exist, check to
+    # see if the HEADER structure is defined ...
+
+    cat > /tmp/ngc$$.c << EOF
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/nameser.h>
+#include <resolv.h>
+
+main()
+{
+    HEADER hhh;
+    res_init();
+}
+EOF
+
+    if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $__extralib; then
+       TLOG " (found)"
+    elif $AC_CC -DBIND_8_COMPAT -o /tmp/ngc$$ /tmp/ngc$$.c $__extralib; then
+       TLOG " (bind9 with BIND_8_COMPAT)"
+       AC_DEFINE BIND_8_COMPAT 1
+    else
+       TLOG " (broken)"
+       rm -f /tmp/ngc$$.c
+       return 1
+    fi
+    rm -f /tmp/ngc$$.c
+    return 0
+}
+
+
+#
+# AC_PROG_INSTALL finds the install program and guesses whether it's a 
+# Berkeley or GNU install program
+#
+AC_PROG_INSTALL () {
+
+    DEST=`acLookFor install`
+
+    LOGN "checking for install"
+    unset IS_BSD
+    if [ "$DEST" ]; then
+       # BSD install or GNU install?  Let's find out...
+       touch /tmp/a$$
+
+       $DEST /tmp/a$$ /tmp/b$$
+
+       if test -r /tmp/a$$; then
+           LOG " ($DEST)"
+       else
+           IS_BSD=1
+           LOG " ($DEST) bsd install"
+       fi
+       rm -f /tmp/a$$ /tmp/b$$
+    else
+       DEST=`acLookFor ginstall`
+       if [ "$DEST" ]; then
+           LOG " ($DEST)"
+       else
+           DEST="false"
+           LOG " (not found)"
+       fi
+    fi
+
+    if [ "$IS_BSD" ]; then
+       PROG_INSTALL="$DEST -c"
+    else
+       PROG_INSTALL="$DEST"
+    fi
+
+    AC_SUB 'INSTALL' "$PROG_INSTALL"
+    AC_SUB 'INSTALL_PROGRAM' "$PROG_INSTALL -s -m 755"
+    AC_SUB 'INSTALL_DATA' "$PROG_INSTALL -m 444"
+
+    # finally build a little directory installer
+    # if mkdir -p works, use that, otherwise use install -d,
+    # otherwise build a script to do it by hand.
+    # in every case, test to see if the directory exists before
+    # making it.
+
+    if mkdir -p $$a/b; then
+       # I like this method best.
+       __mkdir="mkdir -p"
+       rmdir $$a/b
+       rmdir $$a
+    elif $PROG_INSTALL -d $$a/b; then
+       __mkdir="$PROG_INSTALL -d"
+       rmdir $$a/b
+       rmdir $$a
+    fi
+
+    __config_files="$__config_files config.md"
+    AC_SUB 'INSTALL_DIR' "$__cwd/config.md"
+    echo "#! /bin/sh"                                   > $__cwd/config.md
+    echo "# script generated" `date` "by configure.sh" >> $__cwd/config.md
+    echo                                               >> $__cwd/config.md
+    if [ "$__mkdir" ]; then
+       echo "test -d \"\$1\" || $__mkdir \"\$1\""     >> $__cwd/config.md
+       echo "exit $?"                                 >> $__cwd/config.md
+    else
+       cat - >> $__cwd/config.md << \EOD
+pieces=`IFS=/; for x in $1; do echo $x; done`
+dir=
+for x in $pieces; do
+    dir="$dir$x"
+    mkdir $dir || exit 1
+    dir="$dir/"
+done
+exit 0
+EOD
+    fi
+    chmod +x $__cwd/config.md
+}
+
+#
+# acCheckCPP is a local that runs a C preprocessor with a given set of
+# compiler options
+#
+acCheckCPP () {
+       cat > /tmp/ngc$$.c << EOF
+#define FOO BAR
+
+FOO
+EOF
+
+    if $1 $2 /tmp/ngc$$.c > /tmp/ngc$$.o; then
+       if grep -v '#define' /tmp/ngc$$.o | grep -s BAR >/dev/null; then
+           echo "CPP=[$1], CPPFLAGS=[$2]"
+           AC_SUB 'CPP' "$1"
+           AC_SUB 'CPPFLAGS' "$2"
+           rm /tmp/ngc$$.c /tmp/ngc$$.o
+           return 0
+       fi
+    fi
+    rm /tmp/ngc$$.c /tmp/ngc$$.o
+    return 1
+}
+
+
+#
+# AC_PROG_CPP checks for cpp, then checks to see which CPPFLAGS are needed
+# to run it as a filter.
+#
+AC_PROG_CPP () {
+    if [ "$AC_CPP_PROG" ]; then
+       DEST=$AC_CPP_PROG
+    else
+       __ac_path="$AC_PATH"
+       AC_PATH="/lib:/usr/lib:${__ac_path:-$ac_default_path}"
+       DEST=`acLookFor cpp`
+       AC_PATH="$__ac_path"
+    fi
+
+    unset fail
+    LOGN "Looking for cpp"
+    if [ "$DEST" ]; then
+       TLOGN " ($DEST)"
+       acCheckCPP $DEST "$CPPFLAGS" || \
+                acCheckCPP $DEST -traditional-cpp -E || \
+                acCheckCPP $DEST -E || \
+                acCheckCPP $DEST -traditional-cpp -pipe || \
+                acCheckCPP $DEST -pipe || fail=1
+
+       if [ "$fail" ]; then
+           AC_FAIL " (can't run cpp as a pipeline)"
+       else
+           TLOG " ok"
+           return 0
+       fi
+    fi
+    AC_FAIL " (not found)"
+}
+
+#
+# AC_FAIL spits out an error message, then __fail's 
+AC_FAIL() {
+    LOG "$*" 
+    $__fail 1
+}
+
+#
+# AC_SUB writes a substitution into config.sub
+AC_SUB() {
+    (   echononl "s;@$1@;"
+       _subst=`echo $2 | sed -e 's/;/\\;/g'`
+       echononl "$_subst"
+       echo ';g' ) >> $__cwd/config.sub
+}
+
+#
+# AC_MAK writes a define into config.mak
+AC_MAK() {
+    echo "HAVE_$1 = 1" >> $__cwd/config.mak
+}
+
+#
+# AC_DEFINE adds a #define to config.h
+AC_DEFINE() {
+    echo "#define $1 ${2:-1}" >> $__cwd/config.h
+}
+
+#
+# AC_INCLUDE adds a #include to config.h
+AC_INCLUDE() {
+    echo "#include \"$1\"" >> $__cwd/config.h
+}
+
+#
+# AC_CONFIG adds a configuration setting to all the config files
+AC_CONFIG() {
+    AC_DEFINE "PATH_$1" \""$2"\"
+    AC_MAK "$1"
+    AC_SUB "$1" "$2"
+}
+
+#
+# AC_QUIET does something quietly
+AC_QUIET() {
+    eval $* 5>/dev/null
+}
diff --git a/configure b/configure
new file mode 100755 (executable)
index 0000000..d9626dc
--- /dev/null
+++ b/configure
@@ -0,0 +1,3 @@
+#!/bin/sh
+cd config &&
+exec ./configure "$@"
index 2e7c6bff382efdb6d4e67969cabb9fa1b1c3e785..5956f5bb54c6e3903e4ec2a6e204633b5d1210d1 100644 (file)
@@ -1,5 +1,6 @@
 #define _LARGEFILE64_SOURCE 1
 #undef NDEBUG
+#include "../../config/config.h"
 #include "bupsplit.h"
 #include <Python.h>
 #include <assert.h>
@@ -683,7 +684,7 @@ static PyObject *bup_set_linux_file_attr(PyObject *self, PyObject *args)
 }
 #endif /* def linux */
 
-
+#ifdef HAVE_UTIMENSAT
 #if defined(_ATFILE_SOURCE) \
   || _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
 #define HAVE_BUP_UTIMENSAT 1
@@ -759,7 +760,7 @@ static PyObject *bup_utimensat(PyObject *self, PyObject *args)
 
 #endif /* defined(_ATFILE_SOURCE)
           || _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L */
-
+#endif /* HAVE_UTIMENSAT */
 
 static PyObject *stat_struct_to_py(const struct stat *st)
 {
index 5563905569e5d489b2ef46ae166bf03a5de0824e..c2c83e2f0c42dd7ea28d5b41b99d5f4835030872 100644 (file)
@@ -51,9 +51,10 @@ def parse_remote(remote):
 
 
 class Client:
-    def __init__(self, remote, create=False):
+    def __init__(self, remote, create=False, compression_level=1):
         self._busy = self.conn = None
         self.sock = self.p = self.pout = self.pin = None
+        self.compression_level = compression_level
         is_reverse = os.environ.get('BUP_SERVER_REVERSE')
         if is_reverse:
             assert(not remote)
@@ -245,7 +246,8 @@ class Client:
                                  suggest_packs = self._suggest_packs,
                                  onopen = _set_busy,
                                  onclose = self._not_busy,
-                                 ensure_busy = self.ensure_busy)
+                                 ensure_busy = self.ensure_busy,
+                                 compression_level = self.compression_level)
 
     def read_ref(self, refname):
         self.check_busy()
@@ -282,7 +284,8 @@ class Client:
 class PackWriter_Remote(git.PackWriter):
     def __init__(self, conn, objcache_maker, suggest_packs,
                  onopen, onclose,
-                 ensure_busy):
+                 ensure_busy,
+                 compression_level=1):
         git.PackWriter.__init__(self, objcache_maker)
         self.file = conn
         self.filename = 'remote socket'
@@ -293,6 +296,7 @@ class PackWriter_Remote(git.PackWriter):
         self._packopen = False
         self._bwcount = 0
         self._bwtime = time.time()
+        self.compression_level = compression_level
 
     def _open(self):
         if not self._packopen:
index eacf407a57b5e68cdc65f867a968eee3bd495c7c..5edfe1c3185d6a143902aac79a2726520b1afc8f 100644 (file)
@@ -165,7 +165,7 @@ def tree_decode(buf):
         yield (int(mode, 8), name, sha)
 
 
-def _encode_packobj(type, content):
+def _encode_packobj(type, content, compression_level=1):
     szout = ''
     sz = len(content)
     szbits = (sz & 0x0f) | (_typemap[type]<<4)
@@ -177,14 +177,18 @@ def _encode_packobj(type, content):
             break
         szbits = sz & 0x7f
         sz >>= 7
-    z = zlib.compressobj(1)
+    if compression_level > 9:
+        compression_level = 9
+    elif compression_level < 0:
+        compression_level = 0
+    z = zlib.compressobj(compression_level)
     yield szout
     yield z.compress(content)
     yield z.flush()
 
 
-def _encode_looseobj(type, content):
-    z = zlib.compressobj(1)
+def _encode_looseobj(type, content, compression_level=1):
+    z = zlib.compressobj(compression_level)
     yield z.compress('%s %d\0' % (type, len(content)))
     yield z.compress(content)
     yield z.flush()
@@ -489,7 +493,7 @@ def _make_objcache():
 
 class PackWriter:
     """Writes Git objects inside a pack file."""
-    def __init__(self, objcache_maker=_make_objcache):
+    def __init__(self, objcache_maker=_make_objcache, compression_level=1):
         self.count = 0
         self.outbytes = 0
         self.filename = None
@@ -497,6 +501,7 @@ class PackWriter:
         self.idx = None
         self.objcache_maker = objcache_maker
         self.objcache = None
+        self.compression_level = compression_level
 
     def __del__(self):
         self.close()
@@ -540,7 +545,9 @@ class PackWriter:
             log('>')
         if not sha:
             sha = calc_hash(type, content)
-        size, crc = self._raw_write(_encode_packobj(type, content), sha=sha)
+        size, crc = self._raw_write(_encode_packobj(type, content,
+                                                    self.compression_level),
+                                    sha=sha)
         if self.outbytes >= max_pack_size or self.count >= max_pack_objects:
             self.breakpoint()
         return sha
@@ -836,7 +843,8 @@ def check_repo_or_die(path=None):
     except OSError, e:
         if e.errno == errno.ENOENT:
             if repodir != home_repodir:
-                log('error: %r is not a bup/git repository\n' % repo())
+                log('error: %r is not a bup repository; run "bup init"\n'
+                    % repo())
                 sys.exit(15)
             else:
                 init_repo()
index 13125afbfa8d373c7bf29f4ca88a29f4e8d372a5..d9d177cabf30931a14e074e828204c2b7ed13999 100644 (file)
@@ -1,7 +1,7 @@
 """Helper functions and classes for bup."""
 
 import sys, os, pwd, subprocess, errno, socket, select, mmap, stat, re, struct
-import heapq, operator, time
+import heapq, operator, time, platform
 from bup import _version, _helpers
 import bup._helpers as _helpers
 
@@ -203,6 +203,14 @@ def detect_fakeroot():
     return os.getenv("FAKEROOTKEY") != None
 
 
+def is_superuser():
+    if platform.system().startswith('CYGWIN'):
+        import ctypes
+        return ctypes.cdll.shell32.IsUserAnAdmin()
+    else:
+        return os.geteuid() == 0
+
+
 _username = None
 def username():
     """Get the user's login name."""
diff --git a/lib/bup/ls.py b/lib/bup/ls.py
new file mode 100644 (file)
index 0000000..fe04f8a
--- /dev/null
@@ -0,0 +1,67 @@
+"""Common code for listing files from a bup repository."""
+import stat
+from bup import options, vfs
+from helpers import *
+
+
+def node_name(text, n, show_hash):
+    """Add symbols to a node's name to differentiate file types."""
+    prefix = ''
+    if show_hash:
+        prefix += "%s " % n.hash.encode('hex')
+    if stat.S_ISDIR(n.mode):
+        return '%s%s/' % (prefix, text)
+    elif stat.S_ISLNK(n.mode):
+        return '%s%s@' % (prefix, text)
+    else:
+        return '%s%s' % (prefix, text)
+
+
+optspec = """
+%sls [-a] [path...]
+--
+s,hash   show hash for each file
+a,all    show hidden files
+"""
+
+def do_ls(args, pwd, default='.', onabort=None, spec_prefix=''):
+    """Output a listing of a file or directory in the bup repository.
+
+    When stdout is attached to a tty, the output is formatted in columns. When
+    not attached to tty (for example when the output is piped to another
+    command), one file is listed per line.
+    """
+    if onabort:
+        o = options.Options(optspec % spec_prefix, onabort=onabort)
+    else:
+        o = options.Options(optspec % spec_prefix)
+    (opt, flags, extra) = o.parse(args)
+
+    L = []
+
+    ret = 0
+    for path in (extra or [default]):
+        try:
+            n = pwd.try_resolve(path)
+
+            if stat.S_ISDIR(n.mode):
+                for sub in n:
+                    name = sub.name
+                    if opt.all or not len(name)>1 or not name.startswith('.'):
+                        if istty1:
+                            L.append(node_name(name, sub, opt.hash))
+                        else:
+                            print node_name(name, sub, opt.hash)
+            else:
+                if istty1:
+                    L.append(node_name(path, n, opt.hash))
+                else:
+                    print node_name(path, n, opt.hash)
+        except vfs.NodeError, e:
+            log('error: %s\n' % e)
+            ret = 1
+
+    if istty1:
+        sys.stdout.write(columnate(L, ''))
+
+    return ret
index aecf740a13c3507559b4bf56b638acde901ffb50..46d04b9e162d5eb73e6100cfa6a9da4b61329f92 100644 (file)
@@ -8,8 +8,8 @@ import errno, os, sys, stat, pwd, grp, struct, re
 from cStringIO import StringIO
 from bup import vint, xstat
 from bup.drecurse import recursive_dirlist
-from bup.helpers import add_error, mkdirp, log
-from bup.xstat import utime, lutime
+from bup.helpers import add_error, mkdirp, log, is_superuser
+from bup.xstat import utime, lutime, lstat
 import bup._helpers as _helpers
 
 try:
@@ -312,7 +312,7 @@ class Metadata:
                 uid = -1
                 add_error('ignoring missing owner for "%s"\n' % path)
             else:
-                if os.geteuid() != 0:
+                if not is_superuser():
                     uid = -1 # Not root; assume we can't change owner.
                 else:
                     try:
index c9a6cf52ea59a2542558c1ddbf5cb39146dfa3e3..cfbeea111fb00725090bdbb83eb83daa56aa8e14 100644 (file)
@@ -158,7 +158,10 @@ class Options:
                     self._aliases[f] = _remove_negative_k(flagl[0])
                     self._hasparms[f] = has_parm
                     self._defaults[f] = dvi
-                    if len(f) == 1:
+                    if f == '#':
+                        self._shortopts += '0123456789'
+                        flagl_nice.append('-#')
+                    elif len(f) == 1:
                         self._shortopts += f + (has_parm and ':' or '')
                         flagl_nice.append('-' + f)
                     else:
@@ -220,6 +223,11 @@ class Options:
             if k.startswith('no-'):
                 k = self._aliases[k[3:]]
                 v = 0
+            elif (self._aliases.get('#') and
+                  k in ('0','1','2','3','4','5','6','7','8','9')):
+                v = int(k)  # guaranteed to be exactly one digit
+                k = self._aliases['#']
+                opt['#'] = v
             else:
                 k = self._aliases[k]
                 if not self._hasparms[k]:
index 31ecbb9513c15a63b691ef80ab661b8d9859d53c..6e8252e78ec189766cd2ab6846935de87799cb59 100644 (file)
@@ -23,10 +23,10 @@ def test_detect_fakeroot():
 
 @wvtest
 def test_strip_path():
-    prefix = "/var/backup/daily.0/localhost"
+    prefix = "/NOT_EXISTING/var/backup/daily.0/localhost"
     empty_prefix = ""
     non_matching_prefix = "/home"
-    path = "/var/backup/daily.0/localhost/etc/"
+    path = "/NOT_EXISTING/var/backup/daily.0/localhost/etc/"
 
     WVPASSEQ(strip_path(prefix, path), '/etc')
     WVPASSEQ(strip_path(empty_prefix, path), path)
@@ -35,8 +35,11 @@ def test_strip_path():
 
 @wvtest
 def test_strip_base_path():
-    path = "/var/backup/daily.0/localhost/etc/"
-    base_paths = ["/var", "/var/backup", "/var/backup/daily.0/localhost"]
+    path = "/NOT_EXISTING/var/backup/daily.0/localhost/etc/"
+    base_paths = ["/NOT_EXISTING/var",
+                  "/NOT_EXISTING/var/backup",
+                  "/NOT_EXISTING/var/backup/daily.0/localhost"
+                 ]
     WVPASSEQ(strip_base_path(path, base_paths), '/etc')
 
 @wvtest
@@ -62,22 +65,22 @@ def test_strip_symlinked_base_path():
 
 @wvtest
 def test_graft_path():
-    middle_matching_old_path = "/user"
-    non_matching_old_path = "/usr"
-    matching_old_path = "/home"
-    matching_full_path = "/home/user"
+    middle_matching_old_path = "/NOT_EXISTING/user"
+    non_matching_old_path = "/NOT_EXISTING/usr"
+    matching_old_path = "/NOT_EXISTING/home"
+    matching_full_path = "/NOT_EXISTING/home/user"
     new_path = "/opt"
 
     all_graft_points = [(middle_matching_old_path, new_path),
                         (non_matching_old_path, new_path),
                         (matching_old_path, new_path)]
 
-    path = "/home/user/"
+    path = "/NOT_EXISTING/home/user/"
 
     WVPASSEQ(graft_path([(middle_matching_old_path, new_path)], path),
-                        "/home/user")
+                        "/NOT_EXISTING/home/user")
     WVPASSEQ(graft_path([(non_matching_old_path, new_path)], path),
-                        "/home/user")
+                        "/NOT_EXISTING/home/user")
     WVPASSEQ(graft_path([(matching_old_path, new_path)], path), "/opt/user")
     WVPASSEQ(graft_path(all_graft_points, path), "/opt/user")
     WVPASSEQ(graft_path([(matching_full_path, new_path)], path),
index 5d7f02d3bc7b340f6049d6bc7cac94902b1f34ae..48cc2f73d540d33910f50fbf9fd27c0a96c00f3a 100644 (file)
@@ -60,12 +60,14 @@ def index_negative_timestamps():
     WVPASS()
 
     # Jun 10, 1893
-    os.utime("foo", (-0x90000000, -0x90000000))
+    os.utime("foo", (-0x80000000, -0x80000000))
     e = index.BlankNewEntry("foo")
     e.from_stat(xstat.stat("foo"), time.time())
     assert len(e.packed())
     WVPASS()
 
+    unlink('foo')
+
 
 @wvtest
 def index_dirty():
index 26ecbba26d38bdd4798509c3c1f9445ef055d46e..2d227998533f2cfbed59ecb48587322b5158c9a9 100644 (file)
@@ -1,7 +1,7 @@
 import glob, grp, pwd, stat, tempfile, subprocess
 import bup.helpers as helpers
 from bup import metadata
-from bup.helpers import clear_errors, detect_fakeroot
+from bup.helpers import clear_errors, detect_fakeroot, is_superuser
 from wvtest import *
 
 
@@ -116,7 +116,7 @@ def _first_err():
 
 @wvtest
 def test_from_path_error():
-    if os.geteuid() == 0 or detect_fakeroot():
+    if is_superuser() or detect_fakeroot():
         return
     tmpdir = tempfile.mkdtemp(prefix='bup-tmetadata-')
     try:
@@ -136,7 +136,7 @@ def test_from_path_error():
 
 @wvtest
 def test_apply_to_path_restricted_access():
-    if os.geteuid() == 0 or detect_fakeroot():
+    if is_superuser() or detect_fakeroot():
         return
     tmpdir = tempfile.mkdtemp(prefix='bup-tmetadata-')
     try:
@@ -156,7 +156,7 @@ def test_apply_to_path_restricted_access():
 
 @wvtest
 def test_restore_restricted_user_group():
-    if os.geteuid() == 0 or detect_fakeroot():
+    if is_superuser() or detect_fakeroot():
         return
     tmpdir = tempfile.mkdtemp(prefix='bup-tmetadata-')
     try:
@@ -253,7 +253,7 @@ if not xattr:
 else:
     @wvtest
     def test_handling_of_incorrect_existing_linux_xattrs():
-        if os.geteuid() != 0 or detect_fakeroot():
+        if not is_superuser():
             return
         setup_testfs()
         for f in glob.glob('testfs/*'):
index d01ba512e15ac828045d8272d0592539158b53bd..7a0da0c60c32e837d4cac817071105bc6394bd63 100644 (file)
@@ -38,13 +38,14 @@ deftest3=  a default option with [3] no actual default
 deftest4=  a default option with [[square]]
 deftest5=  a default option with "correct" [[square]
 no-stupid  disable stupidity
+#,compress=  set compression level [5]
 """
 
 @wvtest
 def test_options():
     o = options.Options(optspec)
     (opt,flags,extra) = o.parse(['-tttqp', 7, '--longoption', '19',
-                                 'hanky', '--onlylong'])
+                                 'hanky', '--onlylong', '-7'])
     WVPASSEQ(flags[0], ('-t', ''))
     WVPASSEQ(flags[1], ('-t', ''))
     WVPASSEQ(flags[2], ('-t', ''))
@@ -57,5 +58,8 @@ def test_options():
     WVPASSEQ((opt.deftest1, opt.deftest2, opt.deftest3, opt.deftest4,
               opt.deftest5), (1,2,None,None,'[square'))
     WVPASSEQ((opt.stupid, opt.no_stupid), (True, False))
+    WVPASSEQ(opt['#'], 7)
+    WVPASSEQ(opt.compress, 7)
+
     (opt,flags,extra) = o.parse(['--onlylong', '-t', '--no-onlylong'])
     WVPASSEQ((opt.t, opt.q, opt.onlylong), (1, None, 0))
index 830e2cf393fe3e6e577c5bb6f024defe2b567459..032d1583718f2af15df2d8ab36974e6e75549628 100755 (executable)
@@ -80,7 +80,8 @@ force-delete "$TOP/bupmeta.tmp"
 (
     rm -rf "$TOP/bupmeta.tmp/src"
     mkdir -p "$TOP/bupmeta.tmp/src"
-    cp -a Documentation cmd lib t "$TOP/bupmeta.tmp"/src
+    #cp -a Documentation cmd lib t "$TOP/bupmeta.tmp"/src
+    cp -pPR Documentation cmd lib t "$TOP/bupmeta.tmp"/src
 ) || WVFAIL
 
 # Use the test tree to check bup meta.
@@ -112,7 +113,8 @@ if actually-root; then
         chown root:root testfs
         chmod 0700 testfs
 
-        cp -a src testfs/src
+        #cp -a src testfs/src
+        cp -pPR src testfs/src
         (cd testfs && test-src-create-extract)
 
         WVSTART 'meta - atime (as root)'
index 6f1b50e3f39e1d19c3ce849bbfd743e42e682b87..6058e44c55a260eb01daaaa1ce2d8d3c4d7aec28 100755 (executable)
--- a/t/test.sh
+++ b/t/test.sh
@@ -436,3 +436,31 @@ WVPASS true
 WVPASS bup import-rsnapshot $D/
 WVPASSEQ "$(bup ls buptest/latest/)" "a/
 c/"
+
+
+WVSTART "compression"
+D=compression0.tmp
+export BUP_DIR="$TOP/$D/.bup"
+rm -rf $D
+mkdir $D
+WVPASS bup init
+WVPASS bup index $TOP/Documentation
+WVPASS bup save -n compression -0 --strip $TOP/Documentation
+# 'ls' on NetBSD sets -A by default when running as root, so we have to undo
+# it by grepping out any dotfiles.  (Normal OSes don't auto-set -A, but this
+# is harmless there.)
+WVPASSEQ "$(bup ls compression/latest/ | sort)" \
+        "$(ls $TOP/Documentation | grep -v '^\.' | sort)"
+COMPRESSION_0_SIZE=$(du -s $D | cut -f1)
+
+D=compression9.tmp
+export BUP_DIR="$TOP/$D/.bup"
+rm -rf $D
+mkdir $D
+WVPASS bup init
+WVPASS bup index $TOP/Documentation
+WVPASS bup save -n compression -9 --strip $TOP/Documentation
+WVPASSEQ "$(bup ls compression/latest/ | sort)" "$(ls $TOP/Documentation | sort)"
+COMPRESSION_9_SIZE=$(du -s $D | cut -f1)
+
+WVPASS [ "$COMPRESSION_9_SIZE" -lt "$COMPRESSION_0_SIZE" ]