SUMMARY="The highly caffeinated Git GUI"
DESCRIPTION="git-cola is a powerful Git GUI with a slick and intuitive user interface."
HOMEPAGE="https://git-cola.github.io/"
COPYRIGHT="2007-2020 David Aguilar and contributors"
LICENSE="GNU GPL v2"
REVISION="2"
SOURCE_URI="https://github.com/git-cola/git-cola/archive/refs/tags/v$portVersion.tar.gz"
CHECKSUM_SHA256="ec1167ea9a472214bf18f5537d96e137c724f3d28a85b3642f07dba35f04b24a"
SOURCE_DIR="git-cola-$portVersion"
PATCHES="git_cola-$portVersion.patchset"
ADDITIONAL_FILES="git_cola.rdef.in"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PYTHON_VERSION="3.8"

PROVIDES="
	git_cola$secondaryArchSuffix = $portVersion
	app:Git_Cola
	app:Git_Dag
	cmd:git_cola_sequence_editor
	"
REQUIRES="
	haiku$secondaryArchSuffix
	cmd:git
	cmd:python$PYTHON_VERSION
	pyqt5_python${PYTHON_VERSION/./}
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	pyqt5_python${PYTHON_VERSION/./}
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:msgfmt
	cmd:python$PYTHON_VERSION
	cmd:sed
	"

BUILD()
{
	$portPackageLinksDir/cmd~python$PYTHON_VERSION/bin/python$PYTHON_VERSION setup.py build
}

INSTALL()
{
	$portPackageLinksDir/cmd~python$PYTHON_VERSION/bin/python$PYTHON_VERSION setup.py install \
		--prefix=$prefix \
		--no-private-libs

	mkdir -p $appsDir
	mv $prefix/bin/git-cola $appsDir/Git\ Cola
	mv $prefix/bin/git-dag $appsDir/Git\ DAG

	# compile our version and icon resources
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3 | cut -d~ -f1`"
	if [ -z "$MINOR" ]; then MINOR=0; fi

	sed \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		$portDir/additional-files/git_cola.rdef.in > $sourceDir/build/git_cola.rdef

	rc $sourceDir/build/git_cola.rdef

	# add resources to Git Cola
	settype -t application/x-vnd.Be-elfexecutable $appsDir/Git\ Cola
	resattr -o $appsDir/Git\ Cola $sourceDir/build/git_cola.rsrc
	mimeset -f $appsDir/Git\ Cola
	addAppDeskbarSymlink $appsDir/Git\ Cola

	# add resources to Git DAG
	settype -t application/x-vnd.Be-elfexecutable $appsDir/Git\ DAG
	resattr -o $appsDir/Git\ DAG $sourceDir/build/git_cola.rsrc
	mimeset -f $appsDir/Git\ DAG
	addAppDeskbarSymlink $appsDir/Git\ DAG

	# cleanup
	mkdir -p $documentationDir
	mv $prefix/share/doc/git-cola $documentationDir

	# move the icons, scripts, etc...
	mv $prefix/share/git-cola/* $dataDir/git-cola

	#TODO fix locale support
	#mv $prefix/share/locale $dataDir/locale

	rm -rf $prefix/share

}
