#!/bin/sh

#NYLON_DIR=/usr/src/cross/nylon-build-stable-1.0/tmp/staging/i686-linux/bin
NYLON_DIR=/usr/src/cross/ff/trunk/openwrt/staging_dir_mipsel/usr/bin

rmbak=$(find -type f -name "*~")
test -n "$rmbak" && rm -v $rmbak

#$NYLON_DIR/ipkg-build -o root -g root skipstone $PWD/feed
#$NYLON_DIR/ipkg-build -o root -g root coreutils $PWD/feed
#$NYLON_DIR/ipkg-build -o root -g root mood-hotplug $PWD/feed
#$NYLON_DIR/ipkg-build -o root -g root mood-netbase $PWD/feed
#$NYLON_DIR/ipkg-build -o root -g root mood-weirdx $PWD/feed
#$NYLON_DIR/ipkg-build -o root -g root mood-kmod-rt73 $PWD/feed
#$NYLON_DIR/ipkg-build -o root -g root mood-nylon-modules $PWD/feed
#!disabled!$NYLON_DIR/ipkg-build -o root -g root mood-xdm-1.1.4 $PWD/feed
#$NYLON_DIR/ipkg-build -o root -g root mood-xdm-1.0.5 $PWD/feed

$NYLON_DIR/ipkg-build -o root -g root freenet $PWD/feed

out=mood-ff-web/srv/www
test -d $out || mkdir -p $out
(cd mood-ff-web-src;./template.pl -l en -x "/index.html,/intro-de.html,/intro-en.html" -o ../$out)
#chown root:root . -R
find $out -type f -printf "chmod 0644 \"%p\"\n" | sh
find $out -type d -printf "chmod 0755 \"%p\"\n" | sh
find $out -type f -name "*.rrd" -printf "chmod 0755 \"%p\"\n" | sh
find $out -type f -name "cgi-bin*" -printf "chmod 0755 \"%p\"\n" | sh
find $out -type f -name "*.awk" -printf "chmod 0755 \"%p\"\n" | sh
#chmod +x `file $(find $out -type f) | grep Bourne|sed -e 's/:.*//'`
#!disabled!$NYLON_DIR/ipkg-build -o root -g root linux-kernel-headers $PWD/feed

$NYLON_DIR/ipkg-build -o root -g root mood-ff-web $PWD/feed
$NYLON_DIR/ipkg-build -o root -g root mood-ff $PWD/feed
$NYLON_DIR/ipkg-build -o root -g root mood-ffx $PWD/feed
$NYLON_DIR/ipkg-build -o root -g root mood-nylon $PWD/feed

$NYLON_DIR/ipkg-make-index $PWD/feed>$PWD/feed/Packages
cd feed;rm -f md5sum.asc;md5sum `find -maxdepth 1 -type f`>md5sum.asc;cd -
