SUMMARY="Manage your disks, partitions and file systems"
DESCRIPTION="KDE Partition Manager

WARNING
KDE Partition Manager is a potentially dangerous program for your data. It \
has been tested carefully and there are currently no known bugs that could \
lead to data loss, but nevertheless there is always a chance for an error \
to ocurr and you might lose your data.

BACK UP YOUR DATA BEFORE USING THIS SOFTWARE!
This software allows you to manage your disks, partitions and file systems: \
Create, resize, delete, copy, backup and restore partitions with a large \
number of supported file systems:

ext2/3/4
Btrfs
Linux swap
Reiserfs
F2FS
NTFS
FAT
exFAT
LUKS encryption support
and more...."
HOMEPAGE="https://github.com/KDE/partitionmanager/"
COPYRIGHT="2008-2018 KDE Organisation"
LICENSE="GNU GPL v2"
REVISION="1"
srcGitRev="dfca46250e5ea5261d66e44223500cf1b94bdcb6"
SOURCE_URI="https://github.com/kde/partitionmanager/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="9d840520a5289a3f9086cd03efa0742f7b90541879ee36354ca66495834c4680"
SOURCE_DIR="partitionmanager-$srcGitRev"
ADDITIONAL_FILES="partitionmanager.rdef.in"

ARCHITECTURES="?all"
SECONDARY_ARCHITECTURES="?x86"

PROVIDES="
	partitionmanager$secondaryArchSuffix = $portVersion
	cmd:partitionmanager$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libKF5Auth$secondaryArchSuffix
	lib:libKF5Codecs$secondaryArchSuffix
	lib:libKF5Completion$secondaryArchSuffix
	lib:libKF5ConfigCore$secondaryArchSuffix
	lib:libKF5ConfigWidgets$secondaryArchSuffix
	lib:libKF5CoreAddons$secondaryArchSuffix
	lib:libKF5Crash$secondaryArchSuffix
	lib:libKF5DBusAddons$secondaryArchSuffix
	lib:libKF5I18n$secondaryArchSuffix
	lib:libKF5IconThemes$secondaryArchSuffix
	lib:libKF5JobWidgets$secondaryArchSuffix
	lib:libKF5KIOCore$secondaryArchSuffix
	lib:libKF5Parts$secondaryArchSuffix
	lib:libKF5Service$secondaryArchSuffix
	lib:libKF5Solid$secondaryArchSuffix
	lib:libKF5SonnetCore$secondaryArchSuffix
	lib:libKF5TextWidgets$secondaryArchSuffix
	lib:libKF5WidgetsAddons$secondaryArchSuffix
	lib:libKF5XmlGui$secondaryArchSuffix
	lib:libkpmcore$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	extra_cmake_modules >= 5.45
	devel:libKF5Auth$secondaryArchSuffix
	devel:libKF5Bookmarks$secondaryArchSuffix
	devel:libKF5Codecs$secondaryArchSuffix
	devel:libKF5Completion$secondaryArchSuffix
	devel:libKF5ConfigCore$secondaryArchSuffix
	devel:libKF5ConfigWidgets$secondaryArchSuffix
	devel:libKF5CoreAddons$secondaryArchSuffix
	devel:libKF5Crash$secondaryArchSuffix
	devel:libKF5DBusAddons$secondaryArchSuffix
	devel:libKF5I18n$secondaryArchSuffix
	devel:libKF5IconThemes$secondaryArchSuffix
	devel:libKF5ItemViews$secondaryArchSuffix
	devel:libKF5JobWidgets$secondaryArchSuffix
	devel:libKF5KIOCore$secondaryArchSuffix
	devel:libKF5Service$secondaryArchSuffix
	devel:libKF5Solid$secondaryArchSuffix
	devel:libKF5WidgetsAddons$secondaryArchSuffix
	devel:libKF5XmlGui$secondaryArchSuffix
	devel:libkpmcore$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake$secondaryArchSuffix
	cmd:g++$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	sed -e '/add_subdirectory(doc)/ s/^#*/#/' -i CMakeLists.txt
	mkdir -p build
	cd build
	cmake .. \
		-DCMAKE_INSTALL_PREFIX=$appsDir \
		-DSHARE_INSTALL_PREFIX=$dataDir \
		-DECM_DIR=/system/data/cmake/Modules/ECM/cmake

	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	local APP_SIGNATURE="application/x-vnd.qt5-partitionmanager"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
#	local MINOR="`echo "$portVersion" | cut -d. -f3`"
	local MINOR="0"
	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/partitionmanager.rdef.in > partitionmanager.rdef

	mv $appsDir/bin/partitionmanager $appsDir/PartitionManager
	rm -rf $appsDir/bin
	addResourcesToBinaries partitionmanager.rdef $appsDir/PartitionManager
	addAppDeskbarSymlink $appsDir/PartitionManager
}
