#! /bin/sh

umask 022
export PATH='/bin:/usr/bin:/usr/local/bin'

if [ Packages.* = 'Packages.*' ] 2>/dev/null; then
    cd $HOME/diet-pc
    [ -s ipkg.conf ] && ALTCONF='-f ipkg.conf' || ALTCONF=
    ARCHLIST=`ipkg $ALTCONF -V 0 print_architecture | cut -f2 -d' ' | \
	    tr '\n' ' '`
    for ARCH in $ARCHLIST; do
	cd $ARCH
	/bin/echo -e "Indexing $ARCH ... \c"
	[ ! -f .htaccess ] && echo 'Options Indexes' >.htaccess
	ipkg-make-index -p Packages .
	echo 'done'
	cd ..
    done
else
    [ ! -f .htaccess ] && echo 'Options Indexes' >.htaccess
    exec ipkg-make-index -p Packages .
fi
