Infrastructure at your Service

Daniel Westermann

Testing postgresql development snapshots

If you want to test some of the features that will be coming with the next postgresql release even before an official beta version is released you can use the daily development snapshot . Here is a simple makefile for downloading the snapshot, compiling the source and starting up the postgresql instance ( Attention: Makefiles work with tabs, so make sure that the lines begin with a tab instead of spaces where the lines are indented ):

PGBASEVER=9.5
PG=http://ftp.postgresql.org/pub/snapshot/dev/postgresql-snapshot.tar.bz2
PGFILE=postgresql-snapshot.tar.bz2
CURRDIR=$(shell pwd)
DATADIR=$(CURRDIR)/data

fromscratch: reset download buildpg initdb startdb

reset: stopdb
	rm -rf build
	rm -rf install
	rm -rf data
	mkdir build
	mkdir install
	mkdir data

download:
	wget ${PG}
	mv ${PGFILE} build/

buildpg:
	( cd build && tar -axf ${PGFILE} )
	( cd build/postgresql-${PGBASEVER}* && ./configure --prefix=${CURRDIR}/install )
	( cd build/postgresql-${PGBASEVER}* && make )
#	( cd build/postgresql-${PGBASEVER}* && make check )
	( cd build/postgresql-${PGBASEVER}* && make install world )
	( cd build/postgresql-${PGBASEVER}*/contrib && make install )

initdb:
	( echo "postgres" > ${CURRDIR}/pgpasswd )
	( cd install/bin && ./initdb -D ${DATADIR} --pwfile ${CURRDIR}/pgpasswd )

startdb:
	( install/bin/pg_ctl -D ${DATADIR} start) 

stopdb:
	if [ -f ${DATADIR}/postmaster.pid ]; then \
		( install/bin/pg_ctl -D ${DATADIR} stop -m fast ) \
	fi

Before building postgresql you should take care that the required operating system packages are in place. For redhat based distributions these are:

gcc openldap-devel python-devel readline-devel openssl-devel redhat-lsb bison flex perl-ExtUtils-Embed zlib-devel crypto-utils openssl-devel pam-devel libxml2-devel libxslt-devel tcl tcl-devel

Copy the Makefile to your home directory (or anywhere else) on a linux server:

[postgres2@oel7 ~]$ ls -la Makefile
-rw-r--r--. 1 postgres2 root 941 May 28 11:26 Makefile

Then just execute the make command providing the fromscratch target:

make fromscratch

Once everything was executed you can login to postgresql:

[postgres2@oel7 ~]$ install/bin/psql
psql (9.5devel)
Type "help" for help.
postgres=# select version();
                                                     version                                                     
-----------------------------------------------------------------------------------------------------------------
 PostgreSQL 9.5devel on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-9), 64-bit
(1 row)

Have fun testing …

Daniel Westermann
Daniel Westermann

Principal Consultant & Technology Leader Open Infrastructure