blob: 19814866c2d6a23d255dd269c9f0caecf77ae2b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#! /bin/sh
# Figure out where to find pg_config. This is primarily build for
# debian and debian like systems where multiple versions of postgres may
# be installed.
# Return a simplified (2-part) version string.
#
strip_version()
{
sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\)\.[0-9][0-9]*.*/\1/'
}
# Attempt to read the postgres version by connecting to the database
# server. If that fails, use the contents of the PG_VERSION file, if it
# exists.
#
pgver()
{
if [ "x$1" != "x" ]; then
echo $1
else
if ver=`psql --no-psqlrc --tuples-only \
--command="select version()"`; then
# All was well, so record the version in PG_VERSION for later
# use by install (which is run from root and may not have access
# to psql or postgres databases.
ver=`echo ${ver} | awk '{print $2}' | strip_version`
echo $ver >PG_VERSION
echo $ver
else
if [ -f ./PG_VERSION ]; then
cat ./PG_VERSION
else
echo "Cannot establish postgres version..." 1>&2
echo "Specify PG_VERSION explicitly in the make command." 1>&2
exit 2
fi
fi
fi
}
# Maybe the correct pg_config is where it claims to be.
#
if ver=`pgver $1`; then
if cver=`pg_config --version | strip_version`; then
if [ "x${cver}" = "x${ver}" ]; then
which pg_config
exit 0
fi
fi
# Or maybe, we can figure it out from the database version
if [ -f /usr/lib/postgresql/${ver}/bin/pg_config ]; then
echo /usr/lib/postgresql/${ver}/bin/pg_config
exit 0
fi
# If we get here, we really have not much idea, nor anywhere else to
# look.
echo "Cannot find pg_config for postgres version ${ver}" 1>&2
exit 2
fi
|