Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 bup (0.25~git2011.11.04-5) unstable; urgency=low
 .
   * Add 0.22a-1 changelog entry to this file. Remove changelog
     entry for  0.21-1 which was never uploaded.  Closes: #665650.
   * The experimental upload appears to have worked!
     Closes: #664185, #668997.
Author: Jon Dowland <jmtd@debian.org>
Bug-Debian: http://bugs.debian.org/664185
Bug-Debian: http://bugs.debian.org/665650
Bug-Debian: http://bugs.debian.org/668997

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: http://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- bup-0.25~git2011.11.04.orig/Makefile
+++ bup-0.25~git2011.11.04/Makefile
@@ -1,5 +1,5 @@
 OS:=$(shell uname | sed 's/[-_].*//')
-CFLAGS:=-Wall -O2 -Werror $(PYINCLUDE)
+CFLAGS:=-Wall -O2 $(PYINCLUDE)
 SOEXT:=.so
 
 ifeq ($(OS),CYGWIN)
@@ -23,7 +23,7 @@ BINDIR=$(DESTDIR)$(PREFIX)/bin
 LIBDIR=$(DESTDIR)$(PREFIX)/lib/bup
 install: all
 	$(INSTALL) -d $(MANDIR)/man1 $(DOCDIR) $(BINDIR) \
-		$(LIBDIR)/bup $(LIBDIR)/cmd $(LIBDIR)/tornado \
+		$(LIBDIR)/bup $(LIBDIR)/cmd \
 		$(LIBDIR)/web $(LIBDIR)/web/static
 	[ ! -e Documentation/.docs-available ] || \
 	  $(INSTALL) -m 0644 \
@@ -44,9 +44,6 @@ install: all
 		lib/bup/*$(SOEXT) \
 		$(LIBDIR)/bup
 	$(INSTALL) -m 0644 \
-		lib/tornado/*.py \
-		$(LIBDIR)/tornado
-	$(INSTALL) -m 0644 \
 		lib/web/static/* \
 		$(LIBDIR)/web/static/
 	$(INSTALL) -m 0644 \
--- bup-0.25~git2011.11.04.orig/lib/bup/_version.py.pre
+++ bup-0.25~git2011.11.04/lib/bup/_version.py.pre
@@ -1,4 +1,4 @@
 
-COMMIT='8953dc8d911844ae5c5764ac542811e95e592fe4'
-NAMES=' (origin/master, origin/HEAD, master)'
-DATE='2011-11-04 13:55:15 -0400'
+COMMIT='$Format:%H$'
+NAMES='$Format:%d$'
+DATE='$Format:%ci$'
--- bup-0.25~git2011.11.04.orig/lib/bup/_helpers.c
+++ bup-0.25~git2011.11.04/lib/bup/_helpers.c
@@ -156,59 +156,58 @@ static PyObject *firstword(PyObject *sel
 
 #define BLOOM2_HEADERLEN 16
 
-typedef struct {
-    uint32_t high;
-    unsigned char low;
-} bits40_t;
-
-static void to_bloom_address_bitmask4(const bits40_t *buf,
+static void to_bloom_address_bitmask4(const unsigned char *buf,
 	const int nbits, uint64_t *v, unsigned char *bitmask)
 {
     int bit;
+    uint32_t high;
     uint64_t raw, mask;
 
+    memcpy(&high, buf, 4);
     mask = (1<<nbits) - 1;
-    raw = (((uint64_t)ntohl(buf->high)) << 8) | buf->low;
+    raw = (((uint64_t)ntohl(high) << 8) | buf[4]);
     bit = (raw >> (37-nbits)) & 0x7;
     *v = (raw >> (40-nbits)) & mask;
     *bitmask = 1 << bit;
 }
 
-static void to_bloom_address_bitmask5(const uint32_t *buf,
+static void to_bloom_address_bitmask5(const unsigned char *buf,
 	const int nbits, uint32_t *v, unsigned char *bitmask)
 {
     int bit;
+    uint32_t high;
     uint32_t raw, mask;
 
+    memcpy(&high, buf, 4);
     mask = (1<<nbits) - 1;
-    raw = ntohl(*buf);
+    raw = ntohl(high);
     bit = (raw >> (29-nbits)) & 0x7;
     *v = (raw >> (32-nbits)) & mask;
     *bitmask = 1 << bit;
 }
 
-#define BLOOM_SET_BIT(name, address, itype, otype) \
-static void name(unsigned char *bloom, const void *buf, const int nbits)\
+#define BLOOM_SET_BIT(name, address, otype) \
+static void name(unsigned char *bloom, const unsigned char *buf, const int nbits)\
 {\
     unsigned char bitmask;\
     otype v;\
-    address((itype *)buf, nbits, &v, &bitmask);\
+    address(buf, nbits, &v, &bitmask);\
     bloom[BLOOM2_HEADERLEN+v] |= bitmask;\
 }
-BLOOM_SET_BIT(bloom_set_bit4, to_bloom_address_bitmask4, bits40_t, uint64_t)
-BLOOM_SET_BIT(bloom_set_bit5, to_bloom_address_bitmask5, uint32_t, uint32_t)
+BLOOM_SET_BIT(bloom_set_bit4, to_bloom_address_bitmask4, uint64_t)
+BLOOM_SET_BIT(bloom_set_bit5, to_bloom_address_bitmask5, uint32_t)
 
 
-#define BLOOM_GET_BIT(name, address, itype, otype) \
-static int name(const unsigned char *bloom, const void *buf, const int nbits)\
+#define BLOOM_GET_BIT(name, address, otype) \
+static int name(const unsigned char *bloom, const unsigned char *buf, const int nbits)\
 {\
     unsigned char bitmask;\
     otype v;\
-    address((itype *)buf, nbits, &v, &bitmask);\
+    address(buf, nbits, &v, &bitmask);\
     return bloom[BLOOM2_HEADERLEN+v] & bitmask;\
 }
-BLOOM_GET_BIT(bloom_get_bit4, to_bloom_address_bitmask4, bits40_t, uint64_t)
-BLOOM_GET_BIT(bloom_get_bit5, to_bloom_address_bitmask5, uint32_t, uint32_t)
+BLOOM_GET_BIT(bloom_get_bit4, to_bloom_address_bitmask4, uint64_t)
+BLOOM_GET_BIT(bloom_get_bit5, to_bloom_address_bitmask5, uint32_t)
 
 
 static PyObject *bloom_add(PyObject *self, PyObject *args)
--- bup-0.25~git2011.11.04.orig/config/configure
+++ bup-0.25~git2011.11.04/config/configure
@@ -59,7 +59,11 @@ AC_CHECK_HEADERS unistd.h
 AC_CHECK_HEADERS linux/fs.h
 AC_CHECK_HEADERS sys/ioctl.h
 
-AC_CHECK_FUNCS utimensat 
+# on GNU/kFreeBSD utimensat is defined in the GNU libc
+# but won't work
+if [ -z "$OS_GNUKFREEBSD" ]; then
+   AC_CHECK_FUNCS utimensat
+fi
 AC_CHECK_FUNCS utimes
 AC_CHECK_FUNCS lutimes
 
--- bup-0.25~git2011.11.04.orig/config/configure.inc
+++ bup-0.25~git2011.11.04/config/configure.inc
@@ -653,7 +653,7 @@ EOF
     AC_PROG_CPP
     AC_PROG_INSTALL
 
-    ac_os=`uname -s | sed 's/[-_].*//'`
+    ac_os=`uname -s | sed 's/[-_].*//' | sed 's,/,,'`
     _os=`echo $ac_os | tr '[a-z]' '[A-Z]'`
     AC_DEFINE OS_$_os	1
     eval OS_${_os}=1
--- /dev/null
+++ bup-0.25~git2011.11.04/0001-rewrite-asserts-to-be-side-effect-free.patch
@@ -0,0 +1,40 @@
+From e6e39056c3a17db2cd493d5c590f42a8c02ca772 Mon Sep 17 00:00:00 2001
+From: Jon Dowland <jmtd@debian.org>
+Date: Wed, 16 May 2012 15:41:23 +0100
+Subject: [PATCH] rewrite asserts to be side-effect free
+
+Two asserts changed program state, and so problems could occur if
+the asserts are not executed (such as when PYTHONOPTIMIZE is fiddled
+with). Move the side-effect code out of the assert and test only
+previously calculated results.
+---
+ lib/bup/git.py |    6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/lib/bup/git.py b/lib/bup/git.py
+index 5cb2829..b999a09 100644
+--- a/lib/bup/git.py
++++ b/lib/bup/git.py
+@@ -959,7 +959,8 @@ class CatPipe:
+         if not self.p or self.p.poll() != None:
+             self._restart()
+         assert(self.p)
+-        assert(self.p.poll() == None)
++        r = self.p.poll()
++        assert(r == None)
+         if self.inprogress:
+             log('_fast_get: opening %r while %r is open\n'
+                 % (id, self.inprogress))
+@@ -985,7 +986,8 @@ class CatPipe:
+             yield type
+             for blob in it:
+                 yield blob
+-            assert(self.p.stdout.readline() == '\n')
++            l = self.p.stdout.readline()
++            assert(l == '\n')
+             self.inprogress = None
+         except Exception, e:
+             it.abort()
+-- 
+1.7.10
+
--- /dev/null
+++ bup-0.25~git2011.11.04/tmppatch
@@ -0,0 +1,15 @@
+diff --git a/debian/rules b/debian/rules
+index dc55496..c5e6690 100755
+--- a/debian/rules
++++ b/debian/rules
+@@ -12,5 +12,10 @@ override_dh_auto_clean:
+ 		mv lib/bup/_oldversion.py.pre lib/bup/_version.py.pre; \
+ 	fi
+ 
++override_dh_auto_test:
++	if [ "$(dpkg-architecture -qDEB_BUILD_ARCH)" != "s390" ]; then \
++		dh_auto_test; \
++	fi
++
+ %:
+ 	dh $@
--- /dev/null
+++ bup-0.25~git2011.11.04/pythonoptimize
@@ -0,0 +1,40 @@
+From e6e39056c3a17db2cd493d5c590f42a8c02ca772 Mon Sep 17 00:00:00 2001
+From: Jon Dowland <jmtd@debian.org>
+Date: Wed, 16 May 2012 15:41:23 +0100
+Subject: [PATCH] rewrite asserts to be side-effect free
+
+Two asserts changed program state, and so problems could occur if
+the asserts are not executed (such as when PYTHONOPTIMIZE is fiddled
+with). Move the side-effect code out of the assert and test only
+previously calculated results.
+---
+ lib/bup/git.py |    6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/lib/bup/git.py b/lib/bup/git.py
+index 5cb2829..b999a09 100644
+--- a/lib/bup/git.py
++++ b/lib/bup/git.py
+@@ -959,7 +959,8 @@ class CatPipe:
+         if not self.p or self.p.poll() != None:
+             self._restart()
+         assert(self.p)
+-        assert(self.p.poll() == None)
++        r = self.p.poll()
++        assert(r == None)
+         if self.inprogress:
+             log('_fast_get: opening %r while %r is open\n'
+                 % (id, self.inprogress))
+@@ -985,7 +986,8 @@ class CatPipe:
+             yield type
+             for blob in it:
+                 yield blob
+-            assert(self.p.stdout.readline() == '\n')
++            l = self.p.stdout.readline()
++            assert(l == '\n')
+             self.inprogress = None
+         except Exception, e:
+             it.abort()
+-- 
+1.7.10
+
--- bup-0.25~git2011.11.04.orig/lib/bup/git.py
+++ bup-0.25~git2011.11.04/lib/bup/git.py
@@ -959,7 +959,8 @@ class CatPipe:
         if not self.p or self.p.poll() != None:
             self._restart()
         assert(self.p)
-        assert(self.p.poll() == None)
+        r = self.p.poll()
+        assert(r == None)
         if self.inprogress:
             log('_fast_get: opening %r while %r is open\n'
                 % (id, self.inprogress))
@@ -985,7 +986,8 @@ class CatPipe:
             yield type
             for blob in it:
                 yield blob
-            assert(self.p.stdout.readline() == '\n')
+            l = self.p.stdout.readline()
+            assert(l == '\n')
             self.inprogress = None
         except Exception, e:
             it.abort()
--- bup-0.25~git2011.11.04.orig/lib/bup/helpers.py
+++ bup-0.25~git2011.11.04/lib/bup/helpers.py
@@ -231,9 +231,13 @@ def userfullname():
     if not _userfullname:
         uid = os.getuid()
         try:
-            _userfullname = pwd.getpwuid(uid)[4].split(',')[0]
+            entry = pwd.getpwuid(uid)
+            _userfullname = entry[4].split(',')[0] or entry[0]
         except KeyError:
-            _userfullname = 'user%d' % uid
+            pass
+        finally:
+            if not _userfullname:
+              _userfullname = 'user%d' % uid
     return _userfullname
 
 
