#!/bin/bash
# rebuild-gcj-db

if [ $# != 0 ]; then
    # we allow the old LIBDIR argument to stop existing rpms from choking.
    if [ $# != 1 -o $1 != /usr/lib ]; then
        cat 1>&2 <<EOF
rebuild-gcj-db: re-build the gcj classmap database

usage: $0
EOF
        exit 1
    fi
fi

dbLocation=`/usr/bin/gcj-dbtool -p /usr/lib`
dirname $dbLocation | xargs mkdir -p
/usr/bin/gcj-dbtool -n $dbLocation 64
locations="$dbLocation.d /usr/lib/gcj"
oldlocation=/usr/lib/gcj-4.0.0/classmap.db.d
if [ $dbLocation.d != $oldlocation -a -d $oldlocation ]; then
    locations="$locations $oldlocation"
fi
find $locations -name '*.db' -print0 | \
    xargs -0 /usr/bin/gcj-dbtool -m $dbLocation $dbLocation
