#! /bin/sh

BUILD=`cpp -dumpmachine`
case "$BUILD" in
x86_64-linux-gnu)
    ARCH='amd64'
    ;;
*86-linux-gnu)
    ARCH='i386'
    ;;
powerpc-linux-gnu|ppc-linux-gnu)
    ARCH='powerpc'
    ;;
arm-linux-gnueabi)
    ARCH='armel'
    ;;
*)
    ARCH=`echo $BUILD | cut -f1 -d-`
    ;;
esac

sed -i -e "s/^arch .\+ 10\$/arch __ARCH__ 10/" \
	-e "s@^src dietpc3 \(.\+\)/[^/]\+\$@src dietpc3 \1/__ARCH__@" \
	ipkg/etc/ipkg.conf

sed -i -e 's/^Architecture:.*$/Architecture: __ARCH__/' ipkg/CONTROL/control

find . -type l -print | xargs -I{} sh -c "rm -f {}"
xargs -I{} sh -c 'rm -f {}' < MANIFEST
