#! /bin/sh

PREREQ="evms"

prereqs()
{
	echo "$PREREQ"
}

case $1 in
prereqs)
	prereqs
	exit 0
	;;
esac

. /usr/share/initramfs-tools/hook-functions

if [ ! -x /sbin/evmsn ]; then
	exit 0
fi

# The main binaries
copy_exec /sbin/evms sbin/
copy_exec /sbin/evmsn sbin/

# It's useful to have somewhere the engine can log to
mkdir -p ${DESTDIR}/var/log/

# Basic terminal information needed to make ncurses work
mkdir -p ${DESTDIR}/lib/terminfo/l/
cp /lib/terminfo/l/linux ${DESTDIR}/lib/terminfo/l/
mkdir -p ${DESTDIR}/lib/terminfo/v/
cp /lib/terminfo/v/vt100 ${DESTDIR}/lib/terminfo/v/
cp /lib/terminfo/v/vt220 ${DESTDIR}/lib/terminfo/v/

#
# We want the full set of EVMS tools to work with, not just the
# reduced set we already have (due to the evms prereq).
#
EVMS_VERSION=$( dpkg -s evms | grep ^Version: | cut -d" " -f2 | cut -d- -f1 )
for x in /lib/evms/${EVMS_VERSION}/*; do
	if [ ! -f ${DESTDIR}${x} ] ; then
	    copy_exec ${x} /lib/evms/${EVMS_VERSION}
	fi
done

# We'll also need some support tools for the different filesystems.
TOOLS="mkswap badblocks mke2fs resize2fs e2fsck tune2fs"
if [ -x /sbin/reiserfsck ]; then
	TOOLS="$TOOLS reiserfsck resize_reiserfs mkreiserfs"
fi
if [ -x /sbin/jfs_fsck ]; then
	TOOLS="$TOOLS jfs_fsck jfs_mkfs"
fi
if [ -x /sbin/fsck.xfs ]; then
	TOOLS="$TOOLS fsck.xfs mkfs.xfs"
fi
for tool in $TOOLS; do
	copy_exec /sbin/$tool sbin/
done
