File: savebin.inc

package info (click to toggle)
postgresql 7.4.7-6sarge6
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 11,168 kB
  • ctags: 27
  • sloc: sh: 1,903; makefile: 337; ansic: 204; perl: 69; sed: 6; tcl: 1
file content (43 lines) | stat: -rw-r--r-- 1,072 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
# savebin.inc: provide functions to save old binaries and libraries for
# upgrading
#
# These functions assume that the variable $PKGVERSION is set and contains the
# major version number of the currently installed postgresql package (e. g.
# "7.4")

SAVEDIR="/var/lib/postgres/dumpall"

# save file $1 into $SAVEDIR/$PKGVERSION
save_file() {
    if [ -z "$PKGVERSION" ]; then
	echo "Error: savebin.inc requires the setting of \$PKGVERSION" >&2
	exit 1
    fi
    DIR="$SAVEDIR/$PKGVERSION"

    if [ -e "$1" ]; then
	[ -d "$DIR" ] || install -d "$DIR"
	F="`basename \"$1\"`"
	[ -e "$DIR/$F" ] || cp -d "$1" "$DIR"
    fi
}

# save library $1 and its recursive symlink targets into $SAVEDIR
save_lib() {
    save_file "$1"
    if [ -L "$1" ]; then
	save_lib "`readlink -f \"$1\"`"
    fi
}

# save binary and all its linked libraries into $SAVEDIR
save_bin() {
    save_file "$1"
    if ldd "$1" >/dev/null 2>/dev/null; then
	# file is a dynamically linked binary, get libs
	LIBS="`ldd \"$1\" | awk '{print $3}'`"
	for lib in $LIBS; do
	    save_lib "$lib"
	done
    fi
}