### this file is sourced not run
# source: step

pkgname=htmldoc repo=michaelrsweet/htmldoc releasetype=official

if [ "$releasetype" != official ]; then
### INTERIM RELEASE ###
	# .9 = number of commits since the last official release
	# read it in github's release page
	PKGVER=1.9.16.9
	PKGBUILD=1
	PKGARCH=x86_64

	hash=a4b0dfe5c89f30b94720e157fa41e95d68afcde3
	hash7=${hash#???????}; hash7=${hash%$hash7}
	PKGVER=${PKGVER}_$hash7

	TARBALL=$pkgname-${PKGVER}-$hash7.tar.gz
	SRC_URL=https://github.com/$repo/archive/${hash}.tar.gz
	MD5SUM=1c993a8ea0942e9e2daa8a262a323cdd

else
### OFFICIAL RELEASE ###
	PKGVER=1.9.19
	PKGBUILD=1
	PKGARCH=x86_64

	TARBALL=$pkgname-${PKGVER}.tar.gz
	SRC_URL=https://github.com/$repo/archive/refs/tags/v$PKGVER.tar.gz
	MD5SUM=399cebc678c1fc1ef996fdf572f636a8

fi

BUNDLE=

SLACKREQ='cups fltk libgnutls libpng libjpeg-turbo zstd libp11kit libidn2 glib libpcre2'

SLACKDESC="$pkgname: $pkgname ${PKGVER} (HTML and markdown source converter)
$pkgname:
$pkgname: HTMLDOC is a program that reads HTML and Markdown source files or web
$pkgname: pages and generates corresponding EPUB, HTML, separated HTML,
$pkgname: PostScript, or PDF files with an optional table of contents.
$pkgname:
$pkgname: https://github.com/michaelrsweet/htmldoc
$pkgname:
$pkgname:
$pkgname:
$pkgname:
"

### default pkg_download
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/htmldoc-* &&

	# patches
	#(merged upstread 1.9.19) patch -Np1 -i ../pkg/add_file_method_htmldoc_pull_512.patch &&

	# replace "gedit %s; enable tooltips
	sed -i -Ee '
	s/(.*HTMLEditor.*VALUE[(]")[^"]+(".*)/\1defaulttexteditor %s\2/
	s/(.*Tooltips.*VALUE[(]).(.*)/\11\2/
	' ./htmldoc/htmldoc.h &&

	# fix .desktop categories
	sed -i -Ee 's/(.*Categories=).*/\1X-Document;/' ./desktop/htmldoc.desktop

}
### default pkg_package
### build
pkg_build() {
	cd /tmp/$pkgname* &&
	pkg_build_autoconf &&
	pkg_build_slackdesc
}

# vim:ft=sh

