#!/bin/sh

PREREQ=""

prereqs()
{
	echo "$PREREQ"
}

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

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

if [ -f /boot/cryptfs.xml ]; then
    cp /boot/cryptfs.xml $DESTDIR/etc/
elif [ -f /etc/cryptfs.xml ] && cryptfs | grep -xq root; then
    cp /etc/cryptfs.xml $DESTDIR/etc/
else
    exit 0
fi

if [ -f /boot/cryptfs.key ]; then
    cp /boot/cryptfs.key $DESTDIR/etc/
fi

copy_exec /sbin/cryptfs /sbin
copy_modules_dir kernel/crypto
manual_add_modules dm-crypt

if [ -x /bin/loadkeys ] && [ -r /etc/console/boottime.kmap.gz ]; then
    copy_exec /bin/loadkeys /bin
    cp /etc/console/boottime.kmap.gz $DESTDIR/etc/
fi

if grep -qsE '^[ \t]*LC_ALL=.*[Uu][Tt][Ff]-?8' /etc/environment /etc/default/locale; then
    grep -hE '^[ \t]*LC_ALL=.*[Uu][Tt][Ff]-?8' /etc/environment /etc/default/locale > $DESTDIR/etc/ISUTF8
    copy_exec /bin/echo /bin
    
    if [ -x /usr/bin/kbd_mode ]; then
	copy_exec /usr/bin/kbd_mode /bin
    fi
    
    if [ -r /usr/lib/locale/locale-archive ]; then
	mkdir -p $DESTDIR/usr/lib/locale/
	cp /usr/lib/locale/locale-archive $DESTDIR/usr/lib/locale/
    fi
fi
