#!/bin/sh

archmodel() {
    local arch=$(dpkg-architecture -qDEB_HOST_ARCH)
    case $arch in
	i[0-9]86)	arch=i386 ;;
	x86_64|amd64)	arch=i386 ;;
	arm*)		arch=arm ;;
	mips*)		arch=mips ;;
	s390x)		arch=s390 ;;
	parisc64)	arch=parisc ;;
	sparc64)	arch=sparc ;;
	ppc64)		arch=powerpc.generic ;;
	ppc|powerpc)	arch="powerpc.*" ;;
	m68k)		arch="m68k.*" ;;
    esac
    echo $arch
}

if [ -z "$1" ]; then
    echo "Usage: $0 DESTINATION_DIRECTORY"
    exit 1
fi

arch=$(archmodel)

for file in extra/modprobe.d/arch/$arch; do
    if [ ! -f $file -a "$(echo $file)" = "$file" ]; then
	cat <<EOM



=================================================================
There are no architecture-specific modprobe files to install
for your architecture ($arch). This is probably an error.
If so, please send an appropriate configuration to the maintainer
of this package.
=================================================================


EOM
	sleep 10
    else
	cp $file $1
    fi
done

