#Maintainer: George Vlahavas (vlahavas~at~gmail~dot~com)
#
# Also need p7zip to work properly

pkgname=unetbootin
pkgver=585
pkgrel=1rl
source=("http://downloads.sourceforge.net/unetbootin/unetbootin-source-$pkgver.tar.gz" "icons.tar.gz")
sourcetemplate=http://people.salixos.org/laprjns/$pkgname/$pkgver/
docs=("readme*" "install" "copying" "changelog" "authors" "news" "todo" "maintainers")
url=http://unetbootin.sourceforge.net/

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"unetbootin (a tool that creates bootable Live USB drives)"
"UNetbootin (Universal Netboot Installer) is a cross-platform utility"
"that can create Live USB systems and can load a variety of system"
"utilities or install various Linux distributions and other operating"
"systems without a CD."
)


build() {
	cd $startdir/src/

	qmake "DEFINES += NOSTATIC" "RESOURCES -= unetbootin.qrc"
	sed -i "s/-O2/$CFLAGS/" Makefile
	make

	mkdir -p $startdir/pkg/usr/sbin
	cp unetbootin $startdir/pkg/usr/sbin

	mkdir -p $startdir/pkg/usr/share/applications
	cp unetbootin.desktop $startdir/pkg/usr/share/applications/
	sed -i "s/Exec=\(.*\)/Exec=gksu dbus-launch --exit-with-session unetbootin/" $startdir/pkg/usr/share/applications/unetbootin.desktop
	echo "Icon=unetbootin" >> $startdir/pkg/usr/share/applications/unetbootin.desktop
	echo "NotShowIn=KDE" >> $startdir/pkg/usr/share/applications/unetbootin.desktop
	cp unetbootin.desktop $startdir/pkg/usr/share/applications/unetbootin-kde.desktop
	sed -i "s/Exec=\(.*\)/Exec=kdesu dbus-launch --exit-with-session unetbootin/" $startdir/pkg/usr/share/applications/unetbootin-kde.desktop
	echo "Icon=unetbootin" >> $startdir/pkg/usr/share/applications/unetbootin-kde.desktop
	echo "OnlyShowIn=KDE" >> $startdir/pkg/usr/share/applications/unetbootin-kde.desktop
	
	# Copy icons to the right place
 	ICONSIZES="48 32 24 22 16"
	for i in $ICONSIZES; do
		mkdir -p $startdir/pkg/usr/share/icons/hicolor/$i\x$i/apps;
 		mv $startdir/src/$pkgname-$i.png $startdir/pkg/usr/share/icons/hicolor/$i\x$i/apps/$pkgname.png;
 	done;
 	mkdir -p $startdir/pkg/usr/share/icons/hicolor/scalable/apps
 	mv $startdir/src/$pkgname.svg $startdir/pkg/usr/share/icons/hicolor/scalable/apps/
}