| 1 | === Steps for creating a "proper" Postgis 2.0 package on Debian Squeeze === |
| 2 | |
| 3 | I prefer to build in a chroot. Install debootstrap if you don't already have it. Change amd64 to i386 or whatever is necessary to suit your environment. |
| 4 | {{{ |
| 5 | mkdir chroot |
| 6 | debootstrap --arch=amd64 squeeze chroot http://ftp.debian.org/debian/ |
| 7 | sudo mount --bind /proc chroot/proc |
| 8 | sudo mount --bind /sys chroot/sys |
| 9 | sudo mount --bind /dev chroot/dev |
| 10 | sudo mount --bind /dev/pts chroot/dev/pts |
| 11 | sudo chroot chroot /bin/bash |
| 12 | }}} |
| 13 | |
| 14 | Add the backports repo for postgresql 9.1 (Optional). I for one want to use modern software, so I chose to go with Postgresql 9.1 instead of 8.4 which is what squeeze defaults to. |
| 15 | {{{ |
| 16 | cat >> /etc/apt/sources.list.d/backports.list <<EOF |
| 17 | deb http://backports.debian.org/debian-backports squeeze-backports main |
| 18 | EOF |
| 19 | |
| 20 | cat >> /etc/apt/preferences.d/postgresql.pref <<EOF |
| 21 | Package: libpq5 |
| 22 | Pin: release o=Debian Backports |
| 23 | Pin-Priority: 1000 |
| 24 | |
| 25 | Package: libpq-dev |
| 26 | Pin: release o=Debian Backports |
| 27 | Pin-Priority: 1000 |
| 28 | |
| 29 | Package: postgresql-9.1 |
| 30 | Pin: release o=Debian Backports |
| 31 | Pin-Priority: 1000 |
| 32 | |
| 33 | Package: postgresql-client-9.1 |
| 34 | Pin: release o=Debian Backports |
| 35 | Pin-Priority: 1000 |
| 36 | |
| 37 | Package: postgresql-client-common |
| 38 | Pin: release o=Debian Backports |
| 39 | Pin-Priority: 1000 |
| 40 | |
| 41 | Package: postgresql-common |
| 42 | Pin: release o=Debian Backports |
| 43 | Pin-Priority: 1000 |
| 44 | |
| 45 | Package: postgresql-contrib |
| 46 | Pin: release o=Debian Backports |
| 47 | Pin-Priority: 1000 |
| 48 | |
| 49 | Package: postgresql-contrib-9.1 |
| 50 | Pin: release o=Debian Backports |
| 51 | Pin-Priority: 1000 |
| 52 | |
| 53 | Package: postgresql-plperl-9.1 |
| 54 | Pin: release o=Debian Backports |
| 55 | Pin-Priority: 1000 |
| 56 | |
| 57 | Package: postgresql-server-dev-9.1 |
| 58 | Pin: release o=Debian Backports |
| 59 | Pin-Priority: 1000 |
| 60 | EOF |
| 61 | |
| 62 | apt-get update |
| 63 | }}} |
| 64 | |
| 65 | Install the dependencies required for building everything. Note that here I install the postgresql 9.1 files. YMMV if you use postgresql 8.4. |
| 66 | {{{ |
| 67 | sudo apt-get install build-essential postgresql-9.1 debhelper devscripts dh-make-perl autotools-dev flex bison libgeos-dev libproj-dev libssl-dev xsltproc docbook docbook-xsl default-jdk libpg-java fastjar libjts-java imagemagick libcunit1-dev dblatex libxml2-dev libgtk2.0-dev postgresql-server-dev-9.1 apt-file libclass-data-inheritable-perl alien doxygen swig ruby ruby-dev libpopt-dev libjson0-dev checkinstall proj-bin grass-dev libcurl4-dev libdap-dev libgif-dev libhdf4-alt-dev libhdf5-serial-dev libjasper-dev libjpeg-dev libltdl3-dev libmysqlclient-dev libnetcdf-dev libpng-dev libpq-dev libspatialite-dev libsqlite3-dev libxerces-c2-dev unixodbc-dev libgdal1-dev ant |
| 68 | }}} |
| 69 | |
| 70 | Create a scratch directory to perform all the tasks and cd into it |
| 71 | {{{ |
| 72 | mkdir scratch |
| 73 | cd scratch |
| 74 | }}} |
| 75 | |
| 76 | Download the two patch files from this page into this scratch directory |
| 77 | |
| 78 | Build a GEOS 3.3.3 package. I used the control files from wheezy. |
| 79 | {{{ |
| 80 | wget http://ftp.us.debian.org/debian/pool/main/g/geos/geos_3.3.3.orig.tar.gz |
| 81 | tar xvf geos_3.3.3.orig.tar.gz |
| 82 | cd geos-3.3.3 |
| 83 | wget http://ftp.us.debian.org/debian/pool/main/g/geos/geos_3.3.3-1.1.debian.tar.gz |
| 84 | tar xvf geos_3.3.3-1.1.debian.tar.gz |
| 85 | rm -f geos_3.3.3-1.1.debian.tar.gz |
| 86 | dpkg-buildpackage |
| 87 | cd .. |
| 88 | }}} |
| 89 | |
| 90 | Install the GEOS dev packages. These are required to build Postgis 2.0 |
| 91 | {{{ |
| 92 | sudo dpkg -i |
| 93 | }}} |
| 94 | |
| 95 | Build Postgis 2.0. This uses the postgis 1.5.3 control files from squeeze. The two patches are applied here to fix an issue with the Postgis (a bad URL in java/jdbc/build.xml to the maven jar that ant requires for building), and to make the control files build the package. |
| 96 | {{{ |
| 97 | wget http://postgis.org/download/postgis-2.0.1.tar.gz |
| 98 | tar xvf postgis-2.0.1.tar.gz |
| 99 | cd postgis-2.0.1 |
| 100 | patch -p0 < ../postgis_maven.patch |
| 101 | wget http://ftp.de.debian.org/debian/pool/main/p/postgis/postgis_1.5.3-2.debian.tar.gz |
| 102 | tar xvfz postgis_1.5.3-2.debian.tar.gz |
| 103 | rm -f postgis_1.5.3-2.debian.tar.gz |
| 104 | patch -p0 < ../../postgis_debian-2.0.1.patch |
| 105 | rm -rf debian/source |
| 106 | dpkg-buildpackage |
| 107 | cd .. |
| 108 | }}} |
| 109 | |
| 110 | Install the pacakges. This command line would install all packages created by this process. Obviously don't pick anything you don't really need. For example, I have no use for the GEOS ruby bindings or the Postgis java package. |
| 111 | {{{ |
| 112 | sudo dpkg -i libgeos-3.3.3_3.3.3-1.1_amd64.deb libgeos-dbg_3.3.3-1.1_amd64.deb libgeos++-dev_3.3.3-1.1_amd64.deb libgeos-ruby1.8_3.3.3-1.1_amd64.deb libgeos-c1_3.3.3-1.1_amd64.deb libgeos-dev_3.3.3-1.1_amd64.deb libgeos-doc_3.3.3-1.1_all.deb libpostgis-java_2.0.1_all.deb postgis_2.0.1_amd64.deb postgresql-9.1-postgis_2.0.1_amd64.deb |
| 113 | }}} |
| 114 | |
| 115 | Pull in deps |
| 116 | {{{ |
| 117 | sudo apt-get -f install |
| 118 | }}} |