summaryrefslogtreecommitdiff
path: root/debian/rebuild-gcj-db
blob: 297a00bffb9b313102539edad6ad83b1e7014dbd (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#! /bin/bash

set -e

if [ $# -gt 1 ]; then
    cat 1>&2 <<-EOF
	rebuild-gcj-db: re-build the gcj classmap database
	
	usage: $0 [install|remove]
	EOF
    exit 1
fi

mode=install
case "$1" in
    install|remove)
	mode=$1;;
esac

uname=$(uname -m)

rebuild_db()
{
    dbtool=$1; shift
    dbLocation=$1; shift
    dirs=

    for dir; do [ -d $dir ] && dirs="$dirs $dir"; done
    if [ -z "$dirs" ]; then
	# no more dirs with .db files on the system
	return 0
    fi
    mkdir -p $(dirname $dbLocation)
    if $dbtool -n $dbLocation.tmp 64; then
	:
	#case "$uname" in parisc*)
	#    echo >&2 "$dbtool succeeded unexpectedly"
	#esac
    else
	case "$uname" in
	    m68k)
	        echo >&2 "ERROR: $dbtool did fail; known problem on $uname"
		return 0;;
	    *)
		exit 2
	esac
    fi
    find $dirs -follow -name '*.db' -print0 | \
	xargs -r -0 $dbtool -m $dbLocation.tmp $dbLocation.tmp || exit 1
    mv $dbLocation.tmp $dbLocation
}


rebuild_databases()
{
    v=$1
    dbtool=gcj-dbtool-$1
    dbLocation=`$dbtool -p || true`

    if [ -n "$dbLocation" ]; then
	case "$uname" in m68k)
	    echo >&2 "$dbtool succeeded unexpectedly"
	esac
    else
	case "$uname" in
	    m68k)
	        echo >&2 "ERROR: $dbtool did fail; known problem on $uname"
		return 0;;
	    *)
		exit 2
	esac
    fi

    if [ "$mode" = remove ] && [ ! -f "$dbLocation" ]; then
	# libgcj7-0 or libgcj8 are already removed; no need
	# to rebuild anything
	return 0
    fi
    rebuild_db \
	$dbtool \
	$dbLocation \
	/usr/share/gcj/classmap.d \
	/usr/share/gcj-$v/classmap.d
}

# still different databases for each gcj-4.x

if which gcj-dbtool-4.9 >/dev/null 2>&1; then
    rebuild_databases 4.9
fi

if which gcj-dbtool-4.8 >/dev/null 2>&1; then
    rebuild_databases 4.8
fi

if which gcj-dbtool-4.7 >/dev/null 2>&1; then
    rebuild_databases 4.7
fi

if which gcj-dbtool-4.6 >/dev/null 2>&1; then
    rebuild_databases 4.6
fi

if which gcj-dbtool-4.4 >/dev/null 2>&1; then
    rebuild_databases 4.4
fi