#!/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

# Rebuild all the standard databases.
for base in /usr/lib*; do
   dbLocation=`/usr/bin/gcj-dbtool -p $base`
   libdir=$base/gcj
   if ! test -d $libdir; then
      # No shared libraries here.
      continue
   fi
   dirname $dbLocation | xargs mkdir -p
   /usr/bin/gcj-dbtool -n $dbLocation 64
   find $libdir -follow -name '*.db' -print0 | \
      xargs -0 /usr/bin/gcj-dbtool -m $dbLocation $dbLocation
done
