#Maintainer: George Vlahavas (vlahavas~at~gmail~dot~com)

pkgname=mate-file-archiver
pkgver=20120330
pkgrel=2gv
source=("http://pub.mate-desktop.org/releases/1.2/mate-file-archiver-$pkgver.tar.xz" "engrampa.tap" "help.patch" "configdir.patch")
docs=("readme" "install" "copying" "changelog" "authors" "news" "todo" "maintainers")
options=('noautodotnew')

doinst() {
	# Update the scrollkeeper database (Remove stale pieces)
	if [ -x usr/bin/scrollkeeper-update ]; then
        	usr/bin/scrollkeeper-update > /dev/null 2>&1
	fi
}

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"mate-file-archver (an archive manager for MATE)"
"MATE File Archiver (Engrampa) is an archive manager for the MATE"
"desktop envirnment."
"With Engrampa you can:"
""
"    * Create and modify archives."
"    * View the content of an archive."
"    * View a file contained in the archive."
"    * Extract files from the archive."
)


build() {
	cd $startdir/src/$pkgname-$pkgver

	patch -p1 < $startdir/src/help.patch || exit 1
	patch -p1 < $startdir/src/configdir.patch || exit 1

	./autogen.sh --prefix=/usr --libdir=/usr/lib${LIBDIRSUFFIX} --localstatedir=/var --sysconfdir=/etc --disable-scrollkeeper --with-mateconf-source="xml::/etc/mateconf/mateconf.xml.defaults" --disable-static --build=$arch-slackware-linux
	make || return 1
	make install DESTDIR=$startdir/pkg

	# mateconf stuff
	export MATECONF_CONFIG_SOURCE="xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults"
	if [ -d $startdir/pkg/etc/mateconf/schemas ]; then
	    install -v -d -m755 $startdir/pkg/etc/mateconf/mateconf.xml.defaults
	    SCHEMAS=$startdir/pkg/etc/mateconf/schemas
	    for schema in $SCHEMAS/*.schemas; do
	        mateconftool-2 --makefile-install-rule $schema
	    done
	    # Reset / Verify correct permissions
	    ( cd $startdir/pkg/etc/mateconf ; find . -type d -exec chmod 755 {} \; )
	    ( cd $startdir/pkg/etc/mateconf ; find . -type f -exec chmod 644 {} \; )
	fi

	# thunar plugin
	mkdir -p $startdir/pkg/usr/libexec/thunar-archive-plugin
	cp $startdir/src/engrampa.tap $startdir/pkg/usr/libexec/thunar-archive-plugin/
	chmod 755 $startdir/pkg/usr/libexec/thunar-archive-plugin/engrampa.tap

	# remove unnecessary help files
	find $startdir/pkg/usr/share/mate/help/engrampa/* -maxdepth 0 -type d ! -name C -exec rm -rf {} \;
}