# This file is used to build a pacman usable gtk2 package for tomboy-ng

# Requirments : sudo pacman -S base-devel fpc lazarus-gtk2 unzip
#
#		Run a pacman equiped VM (such as my Manjaro21.2-X)
#		that has Lazarus installed. It will download a copy
#		of src and kcontrols and built it all. Note that if
#		you build master (ie as a snapshot) pacman thinks of its
#		version as "master" but tomboy-ng still reports the 
# 		version according to the version file.
#
# Usage : VER=0.34 makepkg --skipinteg 
#         VER=master makepkg --skipinteg 
# 
# Install
# 	sudo pacman -U ./tomboy-ng-master-1-x86_64.pkg.tar.zst

# Maintainer tomboy-ng@bannons.id.au

# Note : buildit.bash in 0.34 and earlier will not work on non-Debian systems
# so necessary to replace with later buildit.bash.

# The only way I can find to get the sha256 for the downloaded tar/zip
# balls is to download them, run e.g.  shasum -a 256 kc-master.zip on each
# and manually add that sha to this file. I really don't see the point.
# maybe for tagged releases, certainly not for master.
# So, passing the version number on the command line will not work unless
# we skip the checksum check. And it really is pretty useless anyway.
# Deal with this when and if its every important.

pkgname=tomboy-ng
pkgver="$VER"			# Remember to set VER when calling makepkg
pkgrel=1			# inc this if releasing a re-package of same ver
pkgdesc="Manage a large or small set of notes with a range of fonts and markup."
arch=('i686' 'x86_64' 'aarchhf' 'aarch64')
url="https://github.com/tomboy-notes/tomboy-ng"
license=('MIT' 'BSD' 'GPL2' 'LGPL3')
depends=('qt6pas>=6.2.7')
# makedepends=('fpc>=3.2.2' 'lazarus-gtk2')
optdepends=('gnome-shell-extension-appindicator: May need to display Systray Icon with Gnome Desktop')
provides=('tomboy-ng')

#	we want to get the taged release version, could also target master
#        https://github.com/tomboy-notes/tomboy-ng/archive/refs/tags/v0.34.tar.gz

if [ "$pkgver" == "master" ]; then
	echo "doing if"
	source=("tb-master.zip::https://github.com/tomboy-notes/$pkgname/archive/refs/heads/master.zip"
		"kc-master.zip::https://github.com/davidbannon/KControls/archive/master.zip")
	# the first sha is skipped because it changes with every commit I make.
	sha256sums=(SKIP 97d974a11c645be3025b80ef0383c160d9869d2b8449482b8ece6fc4ffd27dc1 )
else
	echo "doing else"
	source=("https://github.com/tomboy-notes/$pkgname/archive/refs/tags/v$pkgver.tar.gz"
		"kc-master.zip::https://github.com/davidbannon/KControls/archive/master.zip")
	# Once we have a working tagged release, use shasum to get the shar.....
	# NO, this is crap, I cannot change the release on the command line without also
	# changing the sha here ?? - the whole thing is pointless.
	# sha256sums=(
	#	f9deb76984ac445711c4524f2324b4f7a692e8d2a43ddf70ae63d17fb39880b4
	#	97d974a11c645be3025b80ef0383c160d9869d2b8449482b8ece6fc4ffd27dc1 )
	sha256sums=(SKIP 97d974a11c645be3025b80ef0383c160d9869d2b8449482b8ece6fc4ffd27dc1 )
	
fi

echo "========= source ========"
echo "$source"
echo "========================="

noextract=('master.zip')    # leave kcontrols alone, I'll deal with it.

prepare() {
	cd "$pkgname-$pkgver"
	touch Qt6           # A semophore to buildit.bash we want a Qt6 version
	unzip ../kc-master.zip
	mv KControls-master kcontrols
}

build() {
	# cp ../buildit.bash tomboy-ng-master/buildit.bash
	cd "$pkgname-$pkgver"
	# ./configure --prefix=/usr
	make
}

package() {
	cd "$pkgname-$pkgver"
	make DESTDIR="$pkgdir/" install
}
