Subject: Collected Debian patches for pagekite
Author: Sunil Mohan Adapa <sunil@medhas.org>

The pagekite package is maintained in Git rather than maintaining
patches as separate files, and separating the patches doesn't seem to
be worth the effort.  They are therefore all included in this single
Debian patch.

For full commit history and separated commits, see the packaging Git
repository.

--- pagekite-0.5.8a.orig/Makefile
+++ pagekite-0.5.8a/Makefile
@@ -88,28 +88,21 @@ rpm_el6-fc13:
 	                           --requires=python-SocksipyChain
 
 VERSION=`python setup.py --version`
-.debprep: doc/pagekite.1
-	@rm -f setup.cfg
-	@sed -e "s/@VERSION@/$(VERSION)/g" \
-		< debian/control.in >debian/control
-	@sed -e "s/@VERSION@/$(VERSION)/g" \
-		< debian/copyright.in >debian/copyright
-	@sed -e "s/@VERSION@/$(VERSION)/g" \
-	     -e "s/@DATE@/`date -R`/g" \
-		< debian/changelog.in >debian/changelog
-	@ls -1 doc/*.? >debian/pagekite.manpages
-	@ln -fs ../etc/logrotate.d/pagekite.debian debian/pagekite.logrotate
-	@ln -fs ../etc/init.d/pagekite.debian debian/init.d
+DEB_VERSION=`head -n1 debian/changelog | sed -e "s+.*(\(.*\)).*+\1+"`
+.debprep:
+	@ln -sf deb debian
+	if [ "x$(VERSION)" != "x$(DEB_VERSION)" ] ; \
+	then \
+	  dch --maintmaint --newversion $(VERSION) --urgency=low \
+              --distribution=unstable "New release." ; \
+	fi
 
-.targz: .debprep
+.targz:
 	@python setup.py sdist
 
-.deb: .targz
-	@cp -v dist/pagekite*.tar.gz \
-		../pagekite-$(VERSION)_$(VERSION).orig.tar.gz
-	@debuild -i -us -uc -b
+.deb: .debprep
+	@debuild -i -us -uc
 	@mv ../pagekite_*.deb dist/
-	@rm ../pagekite-*.orig.tar.gz
 
 .header: pagekite doc/header.txt
 	@sed -e "s/@VERSION@/$(VERSION)/g" \
@@ -151,6 +144,6 @@ clean:
 	@rm -vf sockschain *.pyc */*.pyc */*/*.pyc scripts/breeder.py .SELF
 	@rm -vf .appver pagekite-tmp.py MANIFEST setup.cfg pagekite_gtk.py
 	@rm -vrf *.egg-info .header doc/pagekite.1 build/
-	@rm -vf debian/files debian/control debian/copyright debian/changelog
-	@rm -vrf debian/pagekite* debian/python* debian/init.d
+	-debuild clean
+	@-rm debian
 
--- pagekite-0.5.8a.orig/doc/pagekite.1
+++ pagekite-0.5.8a/doc/pagekite.1
@@ -1,11 +1,11 @@
 .\" This man page is autogenerated from the pagekite built-in manual.
-.TH PAGEKITE "1" "2015-10-16" "https://pagekite.net/" "Awesome Commands"
+.TH PAGEKITE "1" "2016-02-06" "https://pagekite.net/" "Awesome Commands"
 .nh
 .ad l
 .SH NAME
 
 
-pagekite v0.5.8a \- Make localhost servers publicly visible
+pagekite \- Make localhost servers publicly visible
 
 .SH SYNOPSIS
 
--- pagekite-0.5.8a.orig/pagekite/compat.py
+++ pagekite-0.5.8a/pagekite/compat.py
@@ -50,7 +50,7 @@ try:
   import datetime
   ts_to_date = datetime.datetime.fromtimestamp
   def ts_to_iso(ts=None):
-    return datetime.datetime.fromtimestamp(ts).isoformat()
+    return datetime.datetime.utcfromtimestamp(ts).isoformat()
 except ImportError:
   ts_to_date = str
   ts_to_iso = str
--- pagekite-0.5.8a.orig/pagekite/manual.py
+++ pagekite-0.5.8a/pagekite/manual.py
@@ -2,6 +2,7 @@
 """
 The program manual!
 """
+import os
 import re
 import time
 
@@ -9,8 +10,8 @@ from common import *
 from compat import ts_to_iso
 
 MAN_NAME = ("""\
-    pagekite.py v%s - Make localhost servers publicly visible
-""" % APPVER)
+    pagekite.py - Make localhost servers publicly visible
+""")
 MAN_SYNOPSIS = ("""\
     <b>pagekite.py</b> [<a>--options</a>] [<a>service</a>] <a>kite-name</a> [<a>+flags</a>]
 """)
@@ -454,7 +455,7 @@ def MAN(pname=None):
 .TH PAGEKITE "1" "%s" "https://pagekite.net/" "Awesome Commands"
 .nh
 .ad l
-""") % ts_to_iso(time.time()).split('T')[0]
+""") % ts_to_iso(float(os.environ.get('SOURCE_DATE_EPOCH', time.time()))).split('T')[0]
   for h, section, text in MANUAL_TOC:
     man += ('.%s %s\n\n%s\n\n'
             ) % (h, h == 'SH' and section.upper() or section,
