SUMMARY="A powerful, fast and reliable backup & sync tool"
DESCRIPTION="An application that backs-up and/or synchronizes any directories \
with the power of rsync. It is simple to use, fast (transfers over only \
changes made and not all data), safe (keeps your data safe by checking all \
declared directories before proceeding in any data manipulation), reliable and \
fully customizable."
COPYRIGHT="2008-2018 Loukas Avgeriou"
LICENSE="GNU GPL v3"
REVISION="2"
HOMEPAGE="http://luckybackup.sourceforge.net"
SOURCE_URI="https://downloads.sourceforge.net/luckybackup/luckybackup-$portVersion.tar.gz"
CHECKSUM_SHA256="e801af2483cbdd62bc9af8e2ded252c51adbad81482e291042f58e21c3d4925b"
PATCHES="luckybackup-$portVersion.patchset"
ADDITIONAL_FILES="luckybackup.rdef.in"

ARCHITECTURES="all !x86_gcc2"
if [ "$targetArchitecture" = x86_gcc2 ]; then
SECONDARY_ARCHITECTURES="x86"
fi

PROVIDES="
	luckybackup$secondaryArchSuffix = $portVersion
	app:LuckyBackup = $portVersion
	"
REQUIRES="
	cmd:rsync
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5WebKit$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:librsync$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libGL$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5WebKit$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:librsync$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:qmake$secondaryArchSuffix >= 5
	"

PATCH()
{
	sed -i \
		-e "s|^\(documentation\.paff =\).*|\1 $docDir|" \
		-e "s|^\(documentation\.path =\).*|\1 $dataDir/luckybackup|" \
		-e "s|^\(translations\.path =\).*|\1 $dataDir/luckybackup|" \
		-e "s|^\(manpage\.path =\).*|\1 $manDir/man8|" \
		-e "s|^\(license\.path =\).*|\1 $dataDir/luckybackup|" \
		luckybackup.pro
}

BUILD()
{
	qmake luckybackup.pro
	make $jobArgs
}

INSTALL()
{
	make install
	install -d "$appsDir"
	install -T luckybackup "$appsDir"/LuckyBackup
	gunzip "$manDir"/man8/luckybackup.8.gz
	sed -i -e 's|~/\.luckyBackup/|~/config/settings/LuckyBackup/|' \
		"$manDir"/man8/luckybackup.8

	local APP_SIGNATURE="application/x-vnd.LuckyBackup"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"
	local LONG_INFO="$SUMMARY"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		"$portDir"/additional-files/luckybackup.rdef.in > luckybackup.rdef

	addResourcesToBinaries luckybackup.rdef "$appsDir"/LuckyBackup
	addAppDeskbarSymlink "$appsDir"/LuckyBackup
}
