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

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

URL=https://github.com/woodenshoe-wi/rox-filer/archive/
PKG=rox-filer
VER=2019.02
SVER=16woodenshoe
COMP=tar.gz
DESC="Light weight gtk file manager"
DEPS=+gtk+2
CAT=Filesystem
DESKTOP=ROX-Filer-file-manager.desktop
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

patch_and_move(){
	mv rox-git $PKG
	cd $PKG
	for i in ../*.patch; do
		echo "applying $i"
		patch -p1 < $i
		[ $? -ne 0 ] && echo "failed to apply $i" #&& exit 1
	done
	for i in ../*.diff; do
		echo "applying $i"
		patch -R -p1 < $i
		[ $? -ne 0 ] && echo "failed to apply $i" #&& exit 1
	done
	cd -
}

build() {
	cp -arf ${PKG}-${PKG}-$SVER ${PKG}-$VER #stupid
	rm -rf ${PKG}-${PKG}-$SVER
	( cd ${PKG}-$VER
	./ROX-Filer/AppRun
	)
}

inst() {
	EXEC=`find ./${PKG}-$VER -type f -name 'ROX-Filer'`
	if [ "$EXEC" ];then 
		cp -arf rox-filer-template ${PKG}-install
		cp -af $EXEC ${PKG}-install/usr/local/apps/ROX-Filer/
		chmod 755 ${PKG}-install/usr/local/apps/ROX-Filer/ROX-Filer
	else
		rm -r ${PKG}-${PKG}-$SVER #clean up
		exit 1
	fi
}
	
# main
retrieve ${PKG}-${SVER}.${COMP}
extract ${PKG}-${SVER}.${COMP}
#patch_and_move
build
inst
package_std $PKG $VER $ARCH $DESKTOP "$DESC" $DEPS $CAT	$SVER
