#Packager: Dimitris Tzemos <djemos~at~slackel.gr>

pkgname=udevil
pkgver=0.4.3
pkgrel=1dj
source=("https://github.com/IgnorantGuru/udevil/raw/pkg/$pkgver/$pkgname-$pkgver.tar.xz")
docs=("AUTHORS" "COPYING" "ChangeLog" "NEWS" "README")
url='http://ignorantguru.github.com/udevil/'
options=('noautodotnew')
dotnew=('etc/udevil/udevil.conf')

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"udevil (removable devices manager)"
"udevil is a command line Linux program which mounts and unmounts"
"removable devices without a password, shows device info, and monitors"
"device changes. It can also mount ISO files, nfs://, smb://, ftp://,"
"ssh:// URLs, and tmpfs/ramfs filesystems."
"udevil is highly configurable, requires no daemon running, and depends"
"only on udev and glib. To use it, just prefix a normal mount command"
"with 'udevil'."
""
"homepage: http://ignorantguru.github.com/udevil/"
)


build() {

	cd $SRC/$pkgname-$pkgver
	
	./configure \
		--prefix=/usr \
		--libdir=/usr/lib${LIBDIRSUFFIX} \
		--localstatedir=/var \
		--sysconfdir=/etc \
		--build=$arch-slackware-linux  || return 1
		
	make -j $numjobs || return 1
	make install DESTDIR=$PKG || return 1
	
	# Specify which system groups are allowed to use the suidded udevil
	sed -i "s|^allowed_groups.*|allowed_groups = plugdev|" $PKG/etc/udevil/udevil.conf  || return 1
	chgrp plugdev $PKG/usr/bin/udevil  || return 1
	chmod u+s,go-s,o-x $PKG/usr/bin/udevil  || return 1

	# Specify which filesystems udevil is allowed to handle
	ALLOWED_FS="ext2, ext3, ext4, fat, vfat, ntfs, reiserfs, xfs, btrfs, fuse, fuseblk,"
	ALLOWED_FS=${ALLOWED_FS}" fusectl, file, cifs, nfs, curlftpfs, ftpfs, sshfs, tmpfs,"
	ALLOWED_FS=${ALLOWED_FS}" ramfs, iso9660, udf, msdos, umsdos"
	sed -i "s|^allowed_types.*|allowed_types = $ALLOWED_FS|" $PKG/etc/udevil/udevil.conf  || return 1
	sed -i '/default_options /s/, noexec//' $PKG/etc/udevil/udevil.conf  || return 1
	echo "allowed_internal_devices = /dev/*" >> $PKG/etc/udevil/udevil.conf  || return 1
	echo "allowed_internal_uuids = *" >> $PKG/etc/udevil/udevil.conf  || return 1

}

