# netmon_wce
# Builds from https://github.com/puppylinux-woof-CE/petbuilds

. ../func
. ../build.conf

URL=http://distro.ibiblio.org/puppylinux/sources/n
PKG=netmon_wce
VER=3.3
COMP=tar.bz2
DESC="Network tray monitor - supports wireless and ipv6"
DEPS=+gtk+,+wireless_tools
CAT=Network
DESKTOP=netmon_wce.desktop
ICONS=light
BUILD=
CWD=$(pwd)
[ -z "$MWD" ] && MWD=$(dirname $CWD)	
[ -z "$BUILD" ] && BUILD=$DEF_BUILD
[ -f "$DESKTOP" ] || DESKTOP=not
[ -z "$DEPS" ] && DEPS=not	

ARCH=$(uname -m)
case $ARCH in
 *64) 	LIBDIR=$LIBCONF64 ;;
 arm*)	LIBDIR=$LIBCONFarm;;
 *) 	LIBDIR=$LIBCONF32 ;;
esac

build() {
	mkdir ${PKG}-${VER}
	for f in `ls|grep -v 'petbuild$'|grep -v ${PKG}-${VER}`;do
		cp -arf $f  ${PKG}-${VER}
	done
	cd ${PKG}-${VER}
	make $MKFLG
	[ "$?" -eq 0 ] || exit
	make DESTDIR=$CWD/${PKG}-install install
	install -d -m 0755 $CWD/${PKG}-install/root/.config/autostart
	install -m 0644 $DESKTOP $CWD/${PKG}-install/root/.config/autostart
	cd -
}

package() {
	# add this recipe
	install -d -m 0755 ./${PKG}-install/usr/src/dev
	cat ${PKG}.petbuild > ./${PKG}-install/usr/src/dev/${PKG}-build-recipe
	# install custom icons
	if [ "$ICONS" = 'light' ];then
		for i in `ls Icons|grep -E '[lt]1'` ;do
			e=`echo $i|sed 's/[lt]1/[lt]/'`
			cp -af Icons/$i ./${PKG}-install/usr/share/pixmaps/netmon_wce/$e
			echo "copying $e"
		done
	fi
	# docs
	install -d -m 0755 ./${PKG}-install/usr/share/doc/netmon_wce/
	install -m 0644 README.txt ./${PKG}-install/usr/share/doc/netmon_wce/
	install -m 0644 Changelog ./${PKG}-install/usr/share/doc/netmon_wce/
	# pot file
	install -d -m 0755 ./${PKG}-install/usr/share/doc/nls/netmon_wce/
	install -m 0644 po/*.pot ./${PKG}-install/usr/share/doc/nls/netmon_wce/
	
	# split
	get_files ${PKG}-install ${PKG}-${VER}-${ARCH}_${BUILD}
	(cd ${PKG}-${VER}; $MWD/split.sh ../${PKG}-install $BUILD)
	# delete any icon cache or library cache
	find ./${PKG}-${VER}-${ARCH}_${BUILD} -type f -name '*cache' -delete
	[ -f ./pinstall.sh ] && install -m 0755 pinstall.sh ./${PKG}-${VER}-${ARCH}_${BUILD}/
	[ -f ./puninstall.sh ] && install -m 0755 puninstall.sh ./${PKG}-${VER}-${ARCH}_${BUILD}/
	for p in $(ls|grep "\-${ARCH}"|grep -v "files$") ; do
		case $p in
			*_DEV*) DESC="$PKG development"; DEPS=+${PKG} ;;
			*_DOC*) DESC="$PKG documentation"; DEPS=+${PKG} ;;
			*_NLS*) DESC="$PKG locales"; DEPS=+${PKG} ;;
		esac	
		echo "packaging $p"	
		dir2pet -x -s -w="$DESC" -d="$DEPS" -c="$CAT" -p=${p} 2>&1 >/dev/null
		rm -r $p
		mv ${p}.pet ../0pets_out
	done
	rm -r ${PKG}-install
	rm -r ${PKG}-${VER}
	mv -f *.files ../0logs
	echo "done!"
}
	
# main
#retrieve ${PKG}-${VER}.${COMP}
#extract ${PKG}-${VER}.${COMP}
build
package	
