### this file is sourced not run
PKGVER=4.0.4
PKGBUILD=1
PKGARCH=noarch

# source: step

TARBALL=findnrun-$PKGVER.tar.xz
MD5SUM=504294d15b0fa544dd4a436fb5131623
SRC_URL=https://github.com/step-/find-n-run/archive/refs/tags/$PKGVER.tar.gz
BUNDLE=

SLACKREQ='gtkdialog
gawk >= 4.1.0-x86_64-1
yad'
SLACKSUG='findnrun_nls mdview exiftool fzf'
SLACKDESC="findnrun: findnrun $PKGVER (GUI search utility)
findnrun:
findnrun: Findnrun is a desktop application finder.
findnrun: Plugins can search for and present custom data types.
findnrun:
findnrun:
findnrun:
findnrun:
findnrun:
findnrun: https://github.com/step-/find-n-run/
findnrun:"

### default pkg_download
### prepare
pkg_prepare() {
	if pkg_check $SRC_DIR $TARBALL $MD5SUM $SRC_URL; then
		cp $SRC_DIR/$TARBALL tmp/pkg
	else
		return 1
	fi
}

### default pkg_package
### build
pkg_build() {
	# Extract and delete scripts.
	# Process in chroot, so bad things cannot impact the host.

	mkdir -p /tmp/build && cd /tmp/build &&
	tar -xf /tmp/pkg/$TARBALL &&
	cd find-n-run-* &&

	# This patch allows installing the optional fzf package
	# from the Fatdog64 repo instead of from GitHub.
	patch --no-backup-if-mismatch -p1 -i /tmp/pkg/fd800-fossil-install-fzf.patch &&

	# Remove GitHub stuff and translations.
	rm -rd .github README.md LICENSE \
		usr/share/doc/nls/ usr/share/locale &&
	rmdir usr/share/doc &&

	# Remove old images and files outside the current help docs.
	find usr/share/findnrun/doc/images -type f \
		\( \! -name "*-${PKGVER%_RC*}-*" \
		-a \! -name "*-${PKGVER%_[a-f0-9]*}-*" \
		-a \! -name "*-2.0.0-*" \
		-a \! -name "*-3.1.0-*" \
		-a \! -name "*.pub.*" \
		\) -delete &&
	rm 'usr/share/findnrun/doc/help[en].tar.gz' &&

	# Install.
	cp -pr usr / &&
	pkg_build_slackdesc
}

# vim:ft=sh:
