--- ip4r-1.03.orig/Makefile
+++ ip4r-1.03/Makefile
@@ -5,7 +5,7 @@
 
 ifdef USE_PGXS
 PG_CPPFLAGS = -DIP4R_PGVER=$(shell echo $(VERSION) | awk -F. '{ print ($$1*1000+$$2)*1000+$$3 }')
-PGXS = $(shell pg_config --pgxs)
+PGXS ?= $(shell pg_config --pgxs)
 include $(PGXS)
 else
 subdir = contrib/ip4r
--- ip4r-1.03.orig/README.ip4r
+++ ip4r-1.03/README.ip4r
@@ -63,33 +63,10 @@
 INSTALLATION
 ============
 
-On version 8.0 or later of PostgreSQL, ip4r can be installed via the
-pgxs mechanism. Unpack the distribution and do:
+In order to use the types in a given database, the ip4r.sql script must be
+run in that database, while connected as a database superuser.  For example:
 
-make USE_PGXS=1
-make USE_PGXS=1 install
-
-(as with PostgreSQL itself, this requires GNU Make. The second command
-will usually need to be run as root.)
-
-On versions prior to 8.0, first unpack the PostgreSQL distribution
-itself, and run ./configure with the same parameters you used when
-installing PostgreSQL originally. If you installed from a binary
-package, you will have to discover what options the packager used.
-Then create a subdirectory contrib/ip4r and copy the contents of
-the ip4r distribution there, and run make install.
-
-Installing via either of the above methods creates the ip4r.so module,
-and installs an SQL script ip4r.sql in the usual place for contrib
-modules ($prefix/share/contrib by default,
-/usr/local/share/postgresql/contrib on FreeBSD, etc.). In order to use
-the types in a given database, the ip4r.sql script must be run in that
-database, while connected as a database superuser.  For example:
-
-psql -U pgsql -f /usr/local/share/postgresql/contrib/ip4r.sql mydatabase
-
-(on systems other than FreeBSD, the username is usually "postgres"
-rather than "pgsql")
+psql -U postgres -f /usr/share/postgresql/8.3/contrib/ip4r.sql mydatabase
 
 This installs the type and its support functions in the catalog of the
 specified database. If you install it in template1, then newly-created
--- ip4r-1.03.orig/debian/changelog
+++ ip4r-1.03/debian/changelog
@@ -0,0 +1,40 @@
+ip4r (1.03-2~bpo40+1) etch-backports; urgency=low
+
+  * Rebuild for etch-backports.
+
+ -- Robert S. Edmonds <edmonds@debian.org>  Thu, 15 May 2008 16:22:35 -0400
+
+ip4r (1.03-2) unstable; urgency=low
+
+  * Drop postgresql-8.2-ip4r; closes: #474285.
+
+ -- Robert S. Edmonds <edmonds@debian.org>  Sat, 05 Apr 2008 12:43:15 -0400
+
+ip4r (1.03-1) unstable; urgency=low
+
+  * New upstream release (supports PostgreSQL 8.3).
+  * Build new binary package postgresql-8.3-ip4r.
+
+ -- Robert S. Edmonds <edmonds@debian.org>  Mon, 04 Feb 2008 18:32:21 -0500
+
+ip4r (1.01-2) unstable; urgency=low
+
+  * Use /usr/lib/postgresql/8.2/bin/pg_config instead of /usr/bin/pg_config in
+    upstream Makefile; closes: #460379.
+  * Drop cdbs packaging.
+
+ -- Robert S. Edmonds <edmonds@debian.org>  Sat, 12 Jan 2008 15:49:57 -0500
+
+ip4r (1.01-1) unstable; urgency=low
+
+  * New upstream release.
+  * Build extension module for postgresql-8.2, closes: #419295.
+
+ -- Robert S. Edmonds <edmonds@debian.org>  Mon, 16 Apr 2007 15:17:48 -0400
+
+ip4r (1.0-1) unstable; urgency=low
+
+  * Initial release, closes: #381811.
+
+ -- Robert S. Edmonds <edmonds@debian.org>  Mon,  7 Aug 2006 01:01:13 -0400
+
--- ip4r-1.03.orig/debian/compat
+++ ip4r-1.03/debian/compat
@@ -0,0 +1 @@
+5
--- ip4r-1.03.orig/debian/control
+++ ip4r-1.03/debian/control
@@ -0,0 +1,38 @@
+Source: ip4r
+Section: misc
+Priority: extra
+Maintainer: Robert S. Edmonds <edmonds@debian.org>
+Build-Depends: debhelper (>= 5.0.0), postgresql-server-dev-8.3
+Standards-Version: 3.7.3
+
+Package: postgresql-8.3-ip4r
+Architecture: any
+Depends: ${shlibs:Depends}
+Recommends: postgresql-8.3
+Description: IPv4 and IPv4 range index types for PostgreSQL 8.3
+ This PostgreSQL module provides two data types, ip4 and ip4r, which can
+ contain a single IPv4 address or a range of IPv4 addresses,
+ respectively.
+ .
+ While PostgreSQL already has built-in types 'inet' and 'cidr', the
+ authors of this module found that they had a number of requirements
+ that were not addressed by the built-in type.
+ .
+ Firstly and most importantly, the built-in types have no support for
+ index lookups of the form (column >>= parameter), i.e. where you have
+ a table of IP address ranges and wish to find which ones include a
+ given IP address.  This requires an rtree or gist index to do
+ efficiently, and also requires a way to represent IP address ranges
+ that do not fall precisely on CIDR boundaries.
+ .
+ Secondly, the built-in inet/cidr are somewhat overloaded with
+ semantics, with inet combining two distinct concepts (a netblock, and
+ a specific IP within that netblock). Furthermore, they are variable
+ length types (to support IPv6) with non-trivial overheads, and the
+ authors (whose applications mainly deal in large volumes of single
+ IPv4 addresses) wanted a more lightweight representation.
+ .
+ ip4r therefore supports two distinct data types (so far):
+ .
+   ip4   - a single IPv4 address
+   ip4r  - an arbitrary range of IPv4 addresses
--- ip4r-1.03.orig/debian/copyright
+++ ip4r-1.03/debian/copyright
@@ -0,0 +1,15 @@
+This package was debianized by Robert Edmonds <edmonds@debian.org> on
+Thu, 16 Mar 2006 13:50:09 -0500.
+
+It was downloaded from http://pgfoundry.org/projects/ip4r/
+
+Copyright Holders:
+
+Andrew - Supernews <andrew@supernews.net>
+Steve Atkins <steve@blighty.com>
+
+License:
+
+This code is available under the terms of the BSD license.  On Debian
+GNU/Linux systems, the complete text of the BSD license can be found in
+/usr/share/common-licenses/BSD.
--- ip4r-1.03.orig/debian/postgresql-8.2-ip4r.dirs
+++ ip4r-1.03/debian/postgresql-8.2-ip4r.dirs
@@ -0,0 +1,2 @@
+usr/lib/postgresql/8.2/lib
+usr/share/postgresql/8.2/contrib
--- ip4r-1.03.orig/debian/postgresql-8.2-ip4r.docs
+++ ip4r-1.03/debian/postgresql-8.2-ip4r.docs
@@ -0,0 +1 @@
+README.ip4r
--- ip4r-1.03.orig/debian/postgresql-8.2-ip4r.install
+++ ip4r-1.03/debian/postgresql-8.2-ip4r.install
@@ -0,0 +1,2 @@
+ip4r.so usr/lib/postgresql/8.2/lib
+ip4r.sql usr/share/postgresql/8.2/contrib
--- ip4r-1.03.orig/debian/postgresql-8.3-ip4r.dirs
+++ ip4r-1.03/debian/postgresql-8.3-ip4r.dirs
@@ -0,0 +1,2 @@
+usr/lib/postgresql/8.3/lib
+usr/share/postgresql/8.3/contrib
--- ip4r-1.03.orig/debian/postgresql-8.3-ip4r.docs
+++ ip4r-1.03/debian/postgresql-8.3-ip4r.docs
@@ -0,0 +1 @@
+README.ip4r
--- ip4r-1.03.orig/debian/postgresql-8.3-ip4r.install
+++ ip4r-1.03/debian/postgresql-8.3-ip4r.install
@@ -0,0 +1,2 @@
+ip4r.so usr/lib/postgresql/8.3/lib
+ip4r.sql usr/share/postgresql/8.3/contrib
--- ip4r-1.03.orig/debian/rules
+++ ip4r-1.03/debian/rules
@@ -0,0 +1,45 @@
+#!/usr/bin/make -f
+
+CFLAGS = $(shell /usr/lib/postgresql/8.3/bin/pg_config --cflags)
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+	CFLAGS += -O0
+else
+	CFLAGS += -O2
+endif
+
+PGXS83 = $(shell /usr/lib/postgresql/8.3/bin/pg_config --pgxs)
+
+build:
+
+clean:
+	dh_testdir
+	dh_testroot
+	$(MAKE) clean USE_PGXS=1 PGXS="$(PGXS83)"
+	dh_clean 
+
+install: build
+	dh_testdir
+	dh_testroot
+	dh_clean -k 
+	dh_installdirs
+	$(MAKE) CFLAGS="$(CFLAGS)" USE_PGXS=1 PGXS="$(PGXS83)"
+	dh_install -ppostgresql-8.3-ip4r
+
+binary-indep: build install
+binary-arch: build install
+	dh_testdir
+	dh_testroot
+	dh_installchangelogs
+	dh_installdocs
+	dh_link
+	dh_strip
+	dh_compress
+	dh_fixperms
+	dh_installdeb
+	dh_shlibdeps
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
