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 65
|
## start of included file get_old_bins.inc ##
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.
# This procedure is run by the preinst of libpgsql2, postgresql and
# postgresql-client, whichever is first to be installed.
if dpkg --compare-versions $1 lt 6.4
then
# 6.3 and before used libpq.so.1 (from libpgsql)
# Look for files from libpgsql package
if [ "`dpkg -l libpgsql | tail -1 | cut -c2`" = i ]
then
# libpgsql was installed
filelist=`grep -s libpq.so /var/lib/dpkg/info/libpgsql.list | cut -f2 -d:`
fi
else
# Look for a previous version of libpgsql2
filelist=`grep -s libpq.so /var/lib/dpkg/info/libpgsql2.list | cut -f2 -d:`
fi
if [ -z "$filelist" ]
then
filelist=`ls -l /usr/lib/libpq.so* | grep -v '^l' | awk '{print $NF}'`
fi
filelist="$filelist `grep -s postgresql/bin /var/lib/dpkg/info/postgresql*.list | grep -E 'bin/(psql|pg_dump|post)' | grep -vE 'postgresql-(startup|dump)' | cut -f2 -d:`"
if [ -n "$filelist" ]
then
# Create the directory to hold the saved binaries
if [ ! -d /usr/lib/postgresql/dumpall/$1 ]
then
install -d /usr/lib/postgresql/dumpall/$1
fi
( cd /usr/lib/postgresql/dumpall/$1 &&
for f in $filelist
do
if [ ! -f `basename $f` -a ! -L $f ]
then
cp $f .
fi
done
if [ -f postgres -a ! -f postmaster ]
then
ln postgres postmaster
fi
# make shared-library softlink
for f in `ls libpq.so.[12].[0-9]`
do
target=`echo $f | cut -f1-3 -d.`
if [ ! -f $target ]
then
ln -s $f $target
fi
done
) || echo Could not save old binaries
else
echo No old binaries found in Debian packages
fi
}
## end of included file get_old_bins.inc ##
|