File: libpgsql.preinst.in

package info (click to toggle)
postgresql 6.3.2-15
  • links: PTS
  • area: main
  • in suites: slink
  • size: 21,136 kB
  • ctags: 15,441
  • sloc: ansic: 162,182; sh: 5,538; java: 5,143; yacc: 4,891; tcl: 4,778; sql: 4,120; makefile: 2,653; lex: 906; cpp: 839; python: 836; perl: 678; asm: 70; csh: 5; sed: 2
file content (63 lines) | stat: -rw-r--r-- 1,504 bytes parent folder | download | duplicates (2)
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
#! /bin/sh

get_old_bins() {
	# Look for existing postgresql binaries, for the previous release, and
	# copy them into a safe location, so that they will be preserved when
	# postgresql is replaced by a new release.

	if [ ! -d /usr/lib/postgresql/dumpall/$1 ]
	then
		install -d /usr/lib/postgresql/dumpall/$1
	fi
	cp /usr/lib/postgresql/lib/libpq.so.1.* /usr/lib/postgresql/dumpall/$1 &&
		( cd /usr/lib/postgresql/dumpall/$1
		  ln -sf libpq.so.1.* libpq.so.1
		  ln -sf libpq.so.1 libpq.so )
}

SHELL=/bin/sh

current=%PG_VERSION%
lastinstall=`echo $2 | cut -d\- -f1 | cut -d. -f1-2`
operation=$1

if [ -r /etc/postgresql/postgresql.env ]
then
	set -a
	. /etc/postgresql/postgresql.env
	set +a
fi

echo
if [ -d ${PGDATA:=/var/postgres/data} ]
then
    installed=`cat ${PGDATA}/PG_VERSION 2>/dev/null`
    if [ -n "${installed}" ]
    then
	if [ A"${installed}" != A${current} ]
        then
	    # This is where we should end up for an existing Debian package that
	    # conflicts with this one and for a non-Debian installation that
	    # happens to be in our standard location
    
	    if [ A"${lastinstall}" = A${installed} ]
	    then
		    get_old_bins ${installed}
	    fi
    
	fi
    fi
else
    # there was no database where we are going to put the new one,
    # but the executables of an older package might be left around
    # and might be needed to do a dump
    
    if [ -d /usr/lib/postgresql/bin -a "$1" != upgrade ]
    then
	get_old_bins unknown
    fi
fi

#DEBHELPER#

exit 0