the Fink project is an effort to port
popular Unix programs to Mac OS X
Info4: <<
Package: postgresql90
Version: 9.0.4
Revision: 5
Description: PostgreSQL open-source database
License: BSD
Maintainer: Benjamin Reed
Depends: <<
daemonic (>= 20010902-1),
libxml2-shlibs,
libxslt-shlibs,
passwd-postgres,
readline5-shlibs,
%N-shlibs (>= %v-%r)
<<
BuildDepends: <<
bison,
fink (>= 0.30.0-1),
fink-mirrors (>= 0.28.7.1-2),
libxml2,
libxslt,
passwd-postgres,
readline5,
system-openssl-dev,
system-perl,
tcltk,
tcltk-dev
<<
Provides: postgresql-server
GCC: 4.0
Source: mirror:postgresql:source/v%v/postgresql-%v.tar.bz2
Source-MD5: 80390514d568a7af5ab61db1cda27e29
PatchScript: <<
#!/bin/sh -ex
sed -e 's|@BUILDDIR@|%b|g' -e 's|@INSTPREFIX@|%p|g' < %{PatchFile} | patch -p1
# If we have fink ExtUtils::ParseXS, it is early in PERL5LIB;
# therefore we need the xsubpp program (also part of that
# pkg). Handcoded makefiles for perl modules are bad, m'kay?
fink_XSUBPP="%p/lib/perl5/ExtUtils/xsubpp"
if [ -x $fink_XSUBPP ]; then
perl -pi -e "s,\S+xsubpp,${fink_XSUBPP},g" src/pl/plperl/GNUmakefile
fi
<<
PatchFile: %n.patch
PatchFile-MD5: 7c9ccbc8a0c66027b7bf6d0f5df6ad5a
SetCPPFLAGS: -I%p/lib/system-openssl/include -DHAVE_OPTRESET -fno-common
SetLDFLAGS: -L%p/lib/system-openssl/lib -F/System/Library/Frameworks
UseMaxBuildJobs: true
CompileScript: <<
#!/bin/sh -xe
if [[ $(sw_vers -productVersion | cut -d. -f1-2) > 10.6 ]]; then
export CC=clang
export CXX=clang++
elif [ -x /usr/bin/gcc-4.2 ]; then
export CC=gcc-4.2
export CXX=g++-4.2
fi
export PERL=/usr/bin/perl
export PYTHON=/usr/bin/python
./configure \
--prefix='%p/opt/postgresql-9.0' \
--docdir='%p/share/doc/%N' \
--mandir='${prefix}/share/man' \
--infodir='${prefix}/share/info' \
--with-libraries=%p/lib \
--with-includes=%p/include \
\
--with-perl \
--with-python \
--with-tcl \
--with-tclconfig=%p/lib \
\
--enable-thread-safety \
--with-openssl \
--with-pam \
--with-bonjour \
--with-krb5 \
--with-gssapi \
\
--with-libxml \
--with-libxslt
perl -pi -e 's,-arch x86_64,,g; s,-arch i386,,g; s,-arch ppc,,g' src/Makefile.global
make
make -C contrib
<<
InstallScript: <<
#!/bin/sh -xe
# postgresql
make -j1 install DESTDIR="%d" BE_DLLLIBS=%p/opt/postgresql-9.0/bin/postgres
make -j1 -C contrib install DESTDIR="%d" BE_DLLLIBS=%p/opt/postgresql-9.0/bin/postgres
ranlib %i/opt/postgresql-9.0/lib/*.a
install -d -m 755 %i/share/doc/%N
find contrib -name README.\* -exec cp {} %i/share/doc/%N/ \;
install -d -m 755 %i/bin
install -c -m 755 pgsql.sh %i/bin/pgsql.sh-9.0
install -d -m 755 %i/var/postgresql-9.0
echo "be sure to back up this database before any upgrades!" >> %i/var/postgresql-9.0/README
install -d -m 755 %i/var/log
ln -sf %p/var/postgresql-9.0/pgsql.log %i/var/log/pgsql-9.0.log
for file in `ls -1 %i/opt/postgresql-9.0/bin/`; do
echo "${file}" >> %i/var/postgresql-9.0/binary.list
done
cat <
#!/bin/sh
for arg in "\$@"; do
case \$arg in
-h|--h|--he|--hel|--help)
echo "usage: \$0 [-h]"
echo ""
echo " -h, --help this help"
echo ""
exit 0;
;;
*)
echo "\$0: unknown argument '\$arg'"
exit 1;
;;
esac
done
update-alternatives --remove "pgsql.sh" "%p/bin/pgsql.sh-9.0"
for tuple in %p/opt/postgresql-9.0/bin:binary.list; do
TUPLE_PATH=\`echo \$tuple | cut -d: -f1\`
TUPLE_FILE=\`echo \$tuple | cut -d: -f2\`
for file in \`cat %p/var/postgresql-9.0/\${TUPLE_FILE}\`; do
update-alternatives --remove "\${file}" "\${TUPLE_PATH}/\${file}"
done
done
END
cat <
#!/bin/sh
FORCE=0
for arg in "\$@"; do
case \$arg in
-h|--h|--he|--hel|--help)
echo "usage: \$0 [-h] [-f]"
echo ""
echo " -h, --help this help"
# echo " -f, --force force this version of PostgreSQL, even if there is a newer one"
echo ""
exit 0;
;;
# -f|--f|--fo|--for|--forc|--force)
# FORCE=1
# ;;
*)
echo "\$0: unknown argument '\$arg'"
exit 1;
;;
esac
done
update-alternatives --install "%p/bin/pgsql.sh" "pgsql.sh" "%p/bin/pgsql.sh-9.0" 90
for tuple in bin:binary.list; do
TUPLE_PATH=\`echo \$tuple | cut -d: -f1\`
TUPLE_FILE=\`echo \$tuple | cut -d: -f2\`
for file in \`cat %p/var/postgresql-9.0/\${TUPLE_FILE}\`; do
if [ -e "%p/opt/postgresql-9.0/\${TUPLE_PATH}/\${file}" ]; then
#echo update-alternatives --install "%p/\${TUPLE_PATH}/\${file}" "\${file}" "%p/opt/postgresql-9.0/\${TUPLE_PATH}/\${file}" 90
update-alternatives --install "%p/\${TUPLE_PATH}/\${file}" "\${file}" "%p/opt/postgresql-9.0/\${TUPLE_PATH}/\${file}" 90
fi
done
done
END
chmod 755 %i/var/postgresql-9.0/*.sh
perl -pi -e 's,^%d,,' %i/bin/pg_config*
<<
DocFiles: COPYRIGHT HISTORY INSTALL README
SplitOff: <<
Package: %N-dev
Description: PostgreSQL development headers and libraries
Depends: %N (>= %v-%r)
BuildDependsOnly: true
Files: <<
opt/postgresql-9.0/bin/pg_config*
opt/postgresql-9.0/include
opt/postgresql-9.0/lib/*.a
opt/postgresql-9.0/lib/libecpg_compat.dylib
opt/postgresql-9.0/lib/libecpg.dylib
opt/postgresql-9.0/lib/libpgtypes.dylib
opt/postgresql-9.0/lib/libpq.dylib
<<
PreInstScript: <<
PG_ID=`id -u postgres 2>/dev/null || true`
if [ -z "$PG_ID" ]; then
echo "Whoa there! You must have a postgres user to install this package."
echo "Please do a 'fink reinstall passwd-postgres'"
echo "and make sure you hit 'y' when it asks if you want to update your users."
exit 1
fi
<<
PostInstScript: [ -x %p/var/postgresql-9.0/update-alternatives.sh ] && %p/var/postgresql-9.0/update-alternatives.sh
PreRmScript: if [ "$1" != "upgrade" ]; then [ -x %p/var/postgresql-9.0/remove-alternatives.sh ] && %p/var/postgresql-9.0/remove-alternatives.sh; fi
<<
SplitOff2: <<
Package: %N-shlibs
Description: PostgreSQL shared libraries
Files: <<
opt/postgresql-9.0/lib/lib*.*.dylib
var/postgresql-9.0/*.sh
var/postgresql-9.0/*.list
<<
Shlibs: <<
%p/opt/postgresql-9.0/lib/libecpg.6.dylib 6.0.0 postgresql90-shlibs (>= 9.0.0-1)
%p/opt/postgresql-9.0/lib/libecpg_compat.3.dylib 3.0.0 postgresql90-shlibs (>= 9.0.0-1)
%p/opt/postgresql-9.0/lib/libpgtypes.3.dylib 3.0.0 postgresql90-shlibs (>= 9.0.0-1)
%p/opt/postgresql-9.0/lib/libpq.5.dylib 5.0.0 postgresql90-shlibs (>= 9.0.0-1)
<<
PostInstScript: <<
[ -x %p/var/postgresql-9.0/update-alternatives.sh ] && %p/var/postgresql-9.0/update-alternatives.sh
if [ -d "%p/var/postgresql-9.0/data" ]; then
if [ `%p/bin/dpkg -s postgresql90 | grep -c 9.0.0-0` -gt 0 ]; then
echo ""
echo '!!! ERROR !!!'
echo ""
echo "The PostgreSQL 9.0 on-disk format has changed since the 9.0 betas."
echo "You must remove %p/var/postgresql-9.0/data before proceeding."
echo "You should probably back up with pg_dump if there's anything important. ;)"
echo ""
exit 1
fi
fi
<<
PreRmScript: if [ "$1" != "upgrade" ]; then [ -x %p/var/postgresql-9.0/remove-alternatives.sh ] && %p/var/postgresql-9.0/remove-alternatives.sh; fi
<<
PreInstScript: <<
PG_ID=`id -u postgres 2>/dev/null || true`
if [ -z "$PG_ID" ]; then
echo "Whoa there! You must have a postgres user to install this package."
echo "Please do a 'fink reinstall passwd-postgres'"
echo "and make sure you hit 'y' when it asks if you want to update your users."
exit 1
fi
<<
PostInstScript: <<
INSTALL_PHASE="$1"
[ -x %p/var/postgresql-9.0/update-alternatives.sh ] && %p/var/postgresql-9.0/update-alternatives.sh
# remove the old "pgsql" entries from netinfo; the username was switched to
# "postgres" but the old ones hang around because of the way niload works
niutil -destroy . /users/pgsql >/dev/null 2>&1 || true
niutil -destroy . /groups/pgsql >/dev/null 2>&1 || true
die () {
echo "failed"
echo ""
echo "*** bailing because an error ocurred:"
echo ""
echo "$*"
exit 1
}
# update daemonic init script if necessary
daemonic install %N >/dev/null 2>&1 || :
# get a nice port to run on
while true; do
PGPORT=$RANDOM;
if [ "$PGPORT" -gt 10000 ] && [ "$PGPORT" -lt 20000 ]; then
break
fi
done
export PGPORT
echo "- starting PostgreSQL on port $PGPORT"
if %p/bin/pgsql.sh-9.0 start >/tmp/pgstart-9.0.log 2>&1; then
sleep 5
ERROR=0
# install the plpgsql language if possible
printf -- "- attempting to install the plpgsql language in the template1 database... "
%p/opt/postgresql-9.0/bin/createlang -U postgres -p $PGPORT plpgsql template1 >/tmp/createlang-9.0.log 2>&1 || ERROR="$?"
if [ $ERROR -eq 0 ]; then
echo "done"
elif [ $ERROR -gt 0 ] && [ $ERROR -ne 2 ]; then
echo "WARNING: an unknown error occurred inserting the plpgsql language"
else
:
fi
sleep 5
%p/bin/pgsql.sh-9.0 stop >/dev/null 2>&1 || echo "WARNING: unable to stop postgresql: run 'PGPORT=$PGPORT sudo %p/bin/pgsql.sh-9.0 stop' to try again"
else
cat <
If you wish to install it manually, run:
sudo %p/bin/pgsql.sh-9.0 start
sudo -u postgres %p/opt/postgresql-9.0/bin/createlang plpgsql template1
END
fi
<<
PreRmScript: <<
# clean up
if [ $1 != "upgrade" ]; then
[ -x %p/var/postgresql-9.0/remove-alternatives.sh ] && %p/var/postgresql-9.0/remove-alternatives.sh
daemonic remove %N >/dev/null 2>&1 || :
fi
<<
DaemonicFile: <<
<<
Homepage: http://www.postgresql.org/
DescUsage: <<
The package runs initdb on installation as the user 'postgres'.
The best way to run it is using the supplied pgsql.sh script, i.e.
'sudo pgsql.sh start'. Or, you can run
'sudo daemonic enable %N' as root to create a
StartupItem for it.
Unless you set up admin users in the database, the easiest way to
run psql commands with administrator access is to prefix them with
the command "sudo -u postgres". This will ask you your administrator
password, and then run the command as the postgres user.
For example, to create a new database, you would run:
sudo -u postgres %p/opt/postgresql-9.0/bin/createdb mydb
<<
DescPackaging: <<
IMPORTANT: The location of the data files has changed from early
revisions of this package. If you're upgrading from an earlier
revision, note that this one expects the data files to be installed
at
When run from the startup script, logs output to
<<
DescPort: <<
Rearranged a lot of the PostgreSQL build to be more "correct" on
Darwin, including making proper dylibs (instead of bundles, which
ended up creating static binaries).
<<
<<
diff -Nurd postgresql-9.0.4/pgsql.sh postgresql-9.0.4-new/pgsql.sh
--- postgresql-9.0.4/pgsql.sh 1969-12-31 19:00:00.000000000 -0500
+++ postgresql-9.0.4-new/pgsql.sh 2011-07-21 11:38:27.000000000 -0400
@@ -0,0 +1,83 @@
+#!/bin/sh
+
+die () {
+ echo "failed"
+ echo ""
+ echo "*** bailing because an error ocurred:"
+ echo ""
+ echo "$*"
+ exit 1
+}
+
+PREFIX="@INSTPREFIX@/opt/postgresql-9.0"
+DATADIR="@INSTPREFIX@/var/postgresql-9.0/data"
+LOGFILE="@INSTPREFIX@/var/postgresql-9.0/pgsql.log"
+
+export LANG=C
+unset LC_ALL
+
+export PATH="$PREFIX/bin:@INSTPREFIX@/bin:$PATH"
+
+SHMMAX=`sysctl kern.sysv.shmmax | cut -d' ' -f2-`
+SHMMNI=`sysctl kern.sysv.shmmni | cut -d' ' -f2-`
+SHMALL=`sysctl kern.sysv.shmall | cut -d' ' -f2-`
+
+if [ "$SHMMAX" -lt "8388608" ] || [ "$SHMMNI" -lt "64" ] || [ "$SHMALL" -lt "32768" ]; then
+ echo "WARNING: You probably need to set your shared memory resources higher for"
+ echo " PostgreSQL to function. For more information on raising your shared"
+ echo " memory settings, see:"
+ echo " http://wiki.finkproject.org/index.php/Shared_Memory_Regions_on_Darwin"
+ echo ""
+ echo " I am also creating a default configuration in /etc/sysctl.conf.pg"
+ echo " that contains values that will work with the default PostgreSQL "
+ echo " memory settings. To use it, rename it to /etc/sysctl.conf (if you"
+ echo " don't have one already) and reboot."
+ echo ""
+ echo " For now, I'll try setting your sysctl to something higher and then"
+ echo " running things anyways. Good luck! =)"
+ echo ""
+ sysctl -w kern.sysv.shmmax=8388608
+ sysctl -w kern.sysv.shmmin=1
+ sysctl -w kern.sysv.shmmni=64
+ sysctl -w kern.sysv.shmseg=8
+ sysctl -w kern.sysv.shmall=32768
+ echo ""
+ cat <
+kern.sysv.shmmax=8388608
+kern.sysv.shmmin=1
+kern.sysv.shmmni=64
+kern.sysv.shmseg=8
+kern.sysv.shmall=32768
+END
+fi
+
+if [ ! -d "$DATADIR" ]; then
+ printf -- "- making postgresql directories: "
+ sudo mkdir -p "$DATADIR"
+ sudo chown -R postgres "$DATADIR/.."
+ echo "ok"
+
+ printf -- "- initializing database in $DATADIR: "
+ sudo -u postgres ${PREFIX}/bin/initdb -E UNICODE -D "$DATADIR" >/tmp/pgsql-init-9.0.log 2>&1 || die "couldn't initialize database"
+ echo "ok"
+fi
+
+PG_COMMAND="sudo -u postgres env"
+if [ -n "$PGPORT" ]; then
+ PG_COMMAND="$PG_COMMAND PGPORT=$PGPORT"
+fi
+PG_COMMAND="$PG_COMMAND ${PREFIX}/bin/pg_ctl"
+
+case "$1" in
+ init)
+ ;;
+ start)
+ $PG_COMMAND -D "$DATADIR" -l "$LOGFILE" start
+ ;;
+ restart)
+ $PG_COMMAND -D "$DATADIR" -m fast restart
+ ;;
+ stop)
+ $PG_COMMAND -D "$DATADIR" -m fast stop
+ ;;
+esac
diff -Nurd postgresql-9.0.4/src/Makefile.global.in postgresql-9.0.4-new/src/Makefile.global.in
--- postgresql-9.0.4/src/Makefile.global.in 2011-04-14 23:15:53.000000000 -0400
+++ postgresql-9.0.4-new/src/Makefile.global.in 2011-07-21 11:39:12.000000000 -0400
@@ -196,7 +196,7 @@
# Compilers
-CPP = @CPP@
+CPP = $(CC) -E
CPPFLAGS = @CPPFLAGS@
ifdef PGXS
@@ -243,7 +243,7 @@
ifdef PGXS
LDFLAGS = -L$(libdir)
else
- LDFLAGS = -L$(top_builddir)/src/port
+ LDFLAGS = -L$(top_builddir)/src/port -L$(top_builddir)/src/interfaces/libpq -L$(top_builddir)/src/interfaces/ecpg/ecpglib -L$(top_builddir)/src/interfaces/ecpg/pgtypeslib -L$(top_builddir)/src/interfaces/ecpg/compatlib
endif
LDFLAGS += @LDFLAGS@
diff -Nurd postgresql-9.0.4/src/backend/utils/misc/postgresql.conf.sample postgresql-9.0.4-new/src/backend/utils/misc/postgresql.conf.sample
--- postgresql-9.0.4/src/backend/utils/misc/postgresql.conf.sample 2011-04-14 23:15:53.000000000 -0400
+++ postgresql-9.0.4-new/src/backend/utils/misc/postgresql.conf.sample 2011-07-21 11:38:27.000000000 -0400
@@ -77,7 +77,7 @@
# - Security and Authentication -
#authentication_timeout = 1min # 1s-600s
-#ssl = off # (change requires restart)
+ssl = off # (change requires restart)
#ssl_ciphers = 'ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH' # allowed SSL ciphers
# (change requires restart)
#ssl_renegotiation_limit = 512MB # amount of data between renegotiations
diff -Nurd postgresql-9.0.4/src/bin/initdb/initdb.c postgresql-9.0.4-new/src/bin/initdb/initdb.c
--- postgresql-9.0.4/src/bin/initdb/initdb.c 2011-04-14 23:15:53.000000000 -0400
+++ postgresql-9.0.4-new/src/bin/initdb/initdb.c 2011-07-21 11:38:27.000000000 -0400
@@ -114,7 +114,7 @@
/* defaults */
static int n_connections = 10;
-static int n_buffers = 50;
+static int n_buffers = 20;
/*
* Warning messages for authentication methods
diff -Nurd postgresql-9.0.4/src/interfaces/ecpg/compatlib/Makefile postgresql-9.0.4-new/src/interfaces/ecpg/compatlib/Makefile
--- postgresql-9.0.4/src/interfaces/ecpg/compatlib/Makefile 2011-04-14 23:15:53.000000000 -0400
+++ postgresql-9.0.4-new/src/interfaces/ecpg/compatlib/Makefile 2011-07-21 11:38:27.000000000 -0400
@@ -21,6 +21,7 @@
-I$(libpq_srcdir) -I$(top_srcdir)/src/include/utils $(CPPFLAGS)
override CFLAGS += $(PTHREAD_CFLAGS)
+LDFLAGS := -L../ecpglib -L../pgtypeslib $(LDFLAGS)
SHLIB_LINK = -L../ecpglib -lecpg -L../pgtypeslib -lpgtypes $(libpq) \
$(filter -lintl -lm, $(LIBS)) $(PTHREAD_LIBS)
diff -Nurd postgresql-9.0.4/src/interfaces/ecpg/ecpglib/Makefile postgresql-9.0.4-new/src/interfaces/ecpg/ecpglib/Makefile
--- postgresql-9.0.4/src/interfaces/ecpg/ecpglib/Makefile 2011-04-14 23:15:53.000000000 -0400
+++ postgresql-9.0.4-new/src/interfaces/ecpg/ecpglib/Makefile 2011-07-21 11:38:27.000000000 -0400
@@ -33,6 +33,7 @@
OBJS += thread.o
endif
+LDFLAGS := -L../pgtypeslib $(LDFLAGS)
SHLIB_LINK = -L../pgtypeslib -lpgtypes $(libpq) $(filter -lintl -lm, $(LIBS)) $(PTHREAD_LIBS)
SHLIB_EXPORTS = exports.txt
diff -Nurd postgresql-9.0.4/src/makefiles/Makefile.darwin postgresql-9.0.4-new/src/makefiles/Makefile.darwin
--- postgresql-9.0.4/src/makefiles/Makefile.darwin 2011-04-14 23:15:53.000000000 -0400
+++ postgresql-9.0.4-new/src/makefiles/Makefile.darwin 2011-07-21 11:38:27.000000000 -0400
@@ -10,4 +10,4 @@
# Rule for building a shared library from a single .o file
%.so: %.o
- $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SL) -bundle $(BE_DLLLIBS) -o $@ $<
+ $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SL) -bundle $(BE_DLLLIBS) -undefined dynamic_lookup -o $@ $<