File: get_old_bins.inc

package info (click to toggle)
postgresql 6.5.3-27
  • links: PTS
  • area: main
  • in suites: potato
  • size: 28,360 kB
  • ctags: 20,905
  • sloc: ansic: 204,608; yacc: 10,718; sql: 9,387; sh: 9,379; java: 8,835; tcl: 7,709; makefile: 3,376; lex: 1,642; perl: 1,034; python: 959; cpp: 847; asm: 70; pascal: 42; awk: 10; sed: 8
file content (65 lines) | stat: -rw-r--r-- 1,873 bytes parent folder | download
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 ##