# autologin
# Builds from https://github.com/puppylinux-woof-CE/petbuilds
# File auto generated by ./mk_petbuild.sh. Edit as necessary.

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

URL=http://example.com #dummy
PKG=autologin
VER=0.1
COMP=tar.gz
DESC="autologin for puppy"
DEPS=
CAT=BuildingBlock
DESKTOP=autologin.desktop
BUILD=
CWD=$(pwd)
[ -z "$MWD" ] && MWD=$(dirname $CWD)
[ -z "$BUILD" ] && BUILD=$DEF_BUILD
# comment these 2 below if you use a custom package() function
#[ -f "$DESKTOP" ] || DESKTOP=not
#[ -z "$DEPS" ] && DEPS=not

ARCH=$(uname -m)
case $ARCH in # set in build.conf
 *64) 	LIBDIR=$LIBCONF64 ;;
 arm*)	LIBDIR=$LIBCONFarm;;
 *) 	LIBDIR=$LIBCONF32 ;;
esac

build() {
	cd ${PKG}-${VER}
	gcc -o autologinroot autologinroot.c || exit 1
	strip --strip-unneeded autologinroot
	install -d -m 0755 ${CWD}/${PKG}-install/bin/
	install -d -m 0755 ${CWD}/${PKG}-install/usr/src/dev/
	install -m 0755 autologinroot ${CWD}/${PKG}-install/bin/autologinroot
	rm -f autologinroot
	cd -
}

package() {
	cat ${PKG}.petbuild > ${PKG}-install/usr/src/dev/${PKG}-build-recipe
	
	# split
	get_files ${PKG}-install ${PKG}-${VER}-${ARCH}_${BUILD}
	(cd ${PKG}-${VER}; $MWD/split.sh ../${PKG}-install $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
	mv -f *.files ../0logs/
	echo "done!"
}

# main
#retrieve ${PKG}-${VER}.${COMP}
#extract ${PKG}-${VER}.${COMP}
build
package
