#!/bin/bash

# Merges per-package classmap databases into the system-wide classmap database.

gccversion=4.1

gcjdbtool=/usr/bin/gcj-dbtool-${gccversion}
classmapd=/usr/share/gcj-${gccversion}/classmap.d
classmaps=/var/lib/gcj-${gccversion}/classmap.db

# Move into a temporary file to avoid editing the existing file. The existing
# file could be mmap()ed by gij processes.
find ${classmapd} -name '*.db' -print0 | ${gcjdbtool} -0 -m ${classmaps}.tmp
if [ $? -ne 0 ]; then
    echo "error merging classmaps" >&2
    exit 1
fi

mv ${classmaps}.tmp ${classmaps}
if [ $? -ne 0 ]; then
    echo "could not replace existing classmap database" >&2
    exit 1
fi

